build fails with newer kernels

4 views
Skip to first unread message

Milan P. Stanić

unread,
Oct 5, 2022, 7:47:46 AM10/5/22
to linux...@googlegroups.com
[ Please add me in Cc reply, I'm not subscribed to group ]

Hi,

I'm building linux-apfs-rw with latest kernels (5.19 and 6.0) on Alpine
Linux and noticed bug in submit_bh function parameters.

-----------------------------------------------------------------------
make -C /lib/modules/6.0.0-rc6-0-asahi/build M=/work/linux-apfs-rw
make[1]: Entering directory
'/work/aports-local/linux-asahi/src/linux-asahi-6.0-rc6-1'
CC [M] /work/linux-apfs-rw/btree.o
CC [M] /work/linux-apfs-rw/compress.o
CC [M] /work/linux-apfs-rw/dir.o
CC [M] /work/linux-apfs-rw/extents.o
CC [M] /work/linux-apfs-rw/file.o
CC [M] /work/linux-apfs-rw/inode.o
/work/linux-apfs-rw/inode.c: In function 'apfs_write_begin':
/work/linux-apfs-rw/inode.c:478:33: error: too many arguments to
function 'submit_bh'
478 | submit_bh(REQ_OP_READ, 0, bh);
| ^~~~~~~~~
In file included from /work/linux-apfs-rw/inode.c:7:
./include/linux/buffer_head.h:243:5: note: declared here
243 | int submit_bh(blk_opf_t, struct buffer_head *);
| ^~~~~~~~~
make[2]: *** [scripts/Makefile.build:249: /work/linux-apfs-rw/inode.o]
Error 1
make[1]: *** [Makefile:1854: /work/linux-apfs-rw] Error 2
make[1]: Leaving directory
'/work/aports-local/linux-asahi/src/linux-asahi-6.0-rc6-1'
make: *** [Makefile:16: default] Error 2
-----------------------------------------------------------------------

I found that submit_bh is changed in kernel with commit id
1420c4a549bf28ffddbed827d61fb3d4d2132ddb

I created patch (attached to this mail) which fixes build.

--
Kind regards

0001-fix-submit_bh-parameters.patch

Ernesto A. Fernández

unread,
Oct 5, 2022, 1:58:07 PM10/5/22
to Milan P. Stanić, linux...@googlegroups.com
Hi,

On Wed, Oct 05, 2022 at 01:47:38PM +0200, Milan P. Stanić wrote:
> I'm building linux-apfs-rw with latest kernels (5.19 and 6.0) on Alpine
> Linux and noticed bug in submit_bh function parameters.

Thanks for the report. I'll have to add some version checks for these
calls. To be clear, the problem is only for 6.0 right? Not for 5.19?

Ernesto

Ernesto A. Fernández

unread,
Oct 5, 2022, 4:35:14 PM10/5/22
to Milan P. Stanić, linux...@googlegroups.com
Hi again,

When you can let me know if this patch fixes your problem.

-- >8 --

Milan P. Stanić reports via email that the submit_bh() api has changed
in Linux 6.0, and the driver no longer builds. Implement a simple macro
wrapper called apfs_submit_bh() to fix this without littering the code
with version checks.

Signed-off-by: Ernesto A. Fernández <ern...@corellium.com>
---
apfs.h | 7 +++++++
inode.c | 2 +-
transaction.c | 2 +-
xattr.c | 2 +-
4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/apfs.h b/apfs.h
index 566cd78..b2bb117 100644
--- a/apfs.h
+++ b/apfs.h
@@ -30,6 +30,13 @@ static inline bool sb_rdonly(const struct super_block *sb) { return sb->s_flags
#define lockdep_assert_held_write(l) ((void)(l))
#endif

+/* Compatibility wrapper around submit_bh() */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
+#define apfs_submit_bh(op, op_flags, bh) submit_bh(op, op_flags, bh)
+#else
+#define apfs_submit_bh(op, op_flags, bh) submit_bh(op | op_flags, bh)
+#endif
+
#define APFS_IOC_SET_DFLT_PFK _IOW('@', 0x80, struct apfs_wrapped_crypto_state)
#define APFS_IOC_SET_DIR_CLASS _IOW('@', 0x81, u32)
#define APFS_IOC_SET_PFK _IOW('@', 0x82, struct apfs_wrapped_crypto_state)
diff --git a/inode.c b/inode.c
index ce21b5e..2211288 100644
--- a/inode.c
+++ b/inode.c
@@ -475,7 +475,7 @@ static int apfs_write_begin(struct file *file, struct address_space *mapping,
get_bh(bh);
lock_buffer(bh);
bh->b_end_io = end_buffer_read_sync;
- submit_bh(REQ_OP_READ, 0, bh);
+ apfs_submit_bh(REQ_OP_READ, 0, bh);
wait_on_buffer(bh);
if (!buffer_uptodate(bh)) {
err = -EIO;
diff --git a/transaction.c b/transaction.c
index 54fb029..e00e96d 100644
--- a/transaction.c
+++ b/transaction.c
@@ -602,7 +602,7 @@ static int apfs_transaction_commit_nx(struct super_block *sb)
clear_buffer_dirty(bh);
lock_buffer(bh);
bh->b_end_io = apfs_end_buffer_write_sync;
- submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
+ apfs_submit_bh(REQ_OP_WRITE, REQ_SYNC, bh);
}
err = apfs_checkpoint_end(sb);
if (err)
diff --git a/xattr.c b/xattr.c
index 4e2dac6..e15e85b 100644
--- a/xattr.c
+++ b/xattr.c
@@ -155,7 +155,7 @@ static int apfs_xattr_extents_read(struct inode *parent,
get_bh(bh);
lock_buffer(bh);
bh->b_end_io = end_buffer_read_sync;
- submit_bh(REQ_OP_READ, 0, bh);
+ apfs_submit_bh(REQ_OP_READ, 0, bh);
}
}
for (i = 0; i < blkcnt; i++) {
--
2.34.1

Milan P. Stanić

unread,
Oct 6, 2022, 7:03:20 AM10/6/22
to Ernesto A. Fernández, linux...@googlegroups.com
Tested again on 5.19 kernel and it builds fine (without any patch).

For some reason I thought that build also failed on 5.19 but I can't
reproduce fail now.
Sorry for confusion.

--
Kind regards

>
> Ernesto

Milan P. Stanić

unread,
Oct 6, 2022, 7:06:36 AM10/6/22
to Ernesto A. Fernández, linux...@googlegroups.com
On Wed, 2022-10-05 at 17:35, Ernesto A. Fernández wrote:
> Hi again,
>
> When you can let me know if this patch fixes your problem.

It build fine with patch on kernel 6.0 and 5.19.
Also mount works but I tested only read-only mode (don't want to take
risk of destroying filesystem).

Thank you for the better patch than one I posted.

--
Kind regards

Ernesto A. Fernández

unread,
Oct 6, 2022, 5:21:07 PM10/6/22
to Milan P. Stanić, linux...@googlegroups.com
Hi,
No problem, I just wanted to check because some distros do backport api
changes from later kernels, and it's always a pain to deal with that.
Thanks again for the report.
Reply all
Reply to author
Forward
0 new messages