Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build error with kernel 6.9 #185

Closed
manualinux opened this issue May 13, 2024 · 6 comments
Closed

Build error with kernel 6.9 #185

manualinux opened this issue May 13, 2024 · 6 comments
Assignees

Comments

@manualinux
Copy link

When compiling the module with kernel 6.9, the following error message occurs:

drivers/block/rapiddisk/rapiddisk.c:809:54: error: too few arguments provided to function-like macro invocation
  809 |         disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
      |                                                             ^
./include/linux/blkdev.h:787:9: note: macro 'blk_alloc_disk' defined here
  787 | #define blk_alloc_disk(lim, node_id)                                    \
      |         ^
drivers/block/rapiddisk/rapiddisk.c:809:27: error: use of undeclared identifier 'blk_alloc_disk'; did you mean '__blk_alloc_disk'?
  809 |         disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
      |                                  ^~~~~~~~~~~~~~
      |                                  __blk_alloc_disk
./include/linux/blkdev.h:772:17: note: '__blk_alloc_disk' declared here
  772 | struct gendisk *__blk_alloc_disk(struct queue_limits *lim, int node,
      |                 ^
drivers/block/rapiddisk/rapiddisk.c:816:54: error: too few arguments provided to function-like macro invocation
  816 |         disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
      |                                                             ^
./include/linux/blkdev.h:787:9: note: macro 'blk_alloc_disk' defined here
  787 | #define blk_alloc_disk(lim, node_id)                                    \
      |         ^
drivers/block/rapiddisk/rapiddisk.c:816:27: error: use of undeclared identifier 'blk_alloc_disk'; did you mean '__blk_alloc_disk'?
  816 |         disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
      |                                  ^~~~~~~~~~~~~~
      |                                  __blk_alloc_disk
./include/linux/blkdev.h:772:17: note: '__blk_alloc_disk' declared here
  772 | struct gendisk *__blk_alloc_disk(struct queue_limits *lim, int node,
      |                 ^
4 errors generated.

Regards

@manualinux
Copy link
Author

Hello,

I have taken as a reference the modification of openZFS that can be found here. And I have added the following:

struct queue_limits *lim = NULL;

Modifying the following:

disk = rdsk->rdsk_disk = blk_alloc_disk(lim, NUMA_NO_NODE);

It is obvious that you will have to adapt it depending on the kernel that is used, but with these modifications the compilation can be carried out successfully. If more lines of code need to be added, I leave that up to you.

Regards.

@bberberov
Copy link
Contributor

What is the latest known compatible kernel that works with the 9.1.0 release?

I'm getting the same build errors with 6.9:

...
[   24s] /home/abuild/rpmbuild/BUILD/rapiddisk-9.1.0/obj/default/rapiddisk.c: In function ‘attach_device’:
[   24s] /home/abuild/rpmbuild/BUILD/rapiddisk-9.1.0/obj/default/rapiddisk.c:809:61: error: macro "blk_alloc_disk" requires 2 arguments, but only 1 given
[   24s]   809 |         disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
...

I'd like to try a known working build.

@anbe42
Copy link
Contributor

anbe42 commented Aug 4, 2024

While looking at this issue, I noticed that the blk_alloc_disk() call is duplicated, the second one overwriting the result from the first, probably causing some memory leak. So lets drop the duplicate one first:

--- a/module/rapiddisk.c
+++ b/module/rapiddisk.c
@@ -813,13 +813,6 @@ static int attach_device(unsigned long n
        if (!disk)
                goto out_free_queue;
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
-       disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
-#else
-       disk = rdsk->rdsk_disk = alloc_disk(1);
-#endif
-       if (!disk)
-               goto out_free_queue;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
        blk_queue_logical_block_size(disk->queue, BYTES_PER_SECTOR);
        blk_queue_physical_block_size(disk->queue, PAGE_SIZE);
 #else

@anbe42
Copy link
Contributor

anbe42 commented Aug 4, 2024

Adjust for Linux commit "block: pass a queue_limits argument to blk_alloc_disk" (torvalds/linux@74fa8f9) in v6.9-rc1:

--- a/module/rapiddisk.c
+++ b/module/rapiddisk.c
@@ -805,12 +805,18 @@ static int attach_device(unsigned long n
        blk_queue_make_request(rdsk->rdsk_queue, rdsk_make_request);
 #endif
 #endif
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+       disk = rdsk->rdsk_disk = blk_alloc_disk(NULL, NUMA_NO_NODE);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
        disk = rdsk->rdsk_disk = blk_alloc_disk(NUMA_NO_NODE);
 #else
        disk = rdsk->rdsk_disk = alloc_disk(1);
 #endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6,9,0)
+       if (IS_ERR(disk))
+#else
        if (!disk)
+#endif
                goto out_free_queue;
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0)
        blk_queue_logical_block_size(disk->queue, BYTES_PER_SECTOR);

In the failure case (IS_ERR(disk)) you could get the actual error returned by the new blk_alloc_disk() with PTR_ERR(disk).

@pkoutoupis
Copy link
Owner

pkoutoupis commented Aug 4, 2024

Can you please create a pull request for me to pull and review/merge into master?

EDIT: Oh, and THANK YOU! :-)

@pkoutoupis
Copy link
Owner

Merged #189 to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants