From 669de459a7685b59b5c65d29e13ca9c7c2a9a481 Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Fri, 8 Nov 2024 18:55:14 -0500 Subject: [PATCH] bdev_open_by_path is now removed as well. Additional blkdev/bdev changes now cause this call to be removed as well resulting in us having to use yet another API to do the same for el9_5. The changes are a little more subtle as now the bdev_mount() call passes a custom bd_holder_ops that we must match or else throw a WARN_ON, so we switch to using sbi as our holder arg instead. Make sure to bdev_fput and not fput, since we don't want to have our private data cleanup deferred, failing xfstests generic/604. Signed-off-by: Auke Kok --- kmod/src/Makefile.kernelcompat | 9 +++++++++ kmod/src/super.c | 28 ++++++++++++++++++++++++++++ kmod/src/super.h | 3 +++ 3 files changed, 40 insertions(+) diff --git a/kmod/src/Makefile.kernelcompat b/kmod/src/Makefile.kernelcompat index 5f21c6be..403a2f66 100644 --- a/kmod/src/Makefile.kernelcompat +++ b/kmod/src/Makefile.kernelcompat @@ -422,3 +422,12 @@ endif ifneq (,$(shell grep 'struct backing_dev_info.*backing_dev_info;' include/linux/sched.h)) ccflags-y += -DKC_CURRENT_BACKING_DEV_INFO endif + +# +# v6.8-rc1-4-gf3a608827d1f +# +# adds bdev_file_open_by_path() and later in v6.8-rc1-30-ge97d06a46526 removes bdev_open_by_path() +# which requires us to use the file method from now on. +ifneq (,$(shell grep 'struct file.*bdev_file_open_by_path.const char.*path' include/linux/blkdev.h)) +ccflags-y += -DKC_BDEV_FILE_OPEN_BY_PATH +endif diff --git a/kmod/src/super.c b/kmod/src/super.c index b9428ca3..16ab2343 100644 --- a/kmod/src/super.c +++ b/kmod/src/super.c @@ -160,11 +160,17 @@ static void scoutfs_metadev_close(struct super_block *sb) * from kill_sb->put_super. */ lockdep_off(); + +#ifdef KC_BDEV_FILE_OPEN_BY_PATH + bdev_fput(sbi->meta_bdev_file); +#else #ifdef KC_BLKDEV_PUT_HOLDER_ARG blkdev_put(sbi->meta_bdev, sb); #else blkdev_put(sbi->meta_bdev, SCOUTFS_META_BDEV_MODE); #endif +#endif + lockdep_on(); sbi->meta_bdev = NULL; } @@ -481,7 +487,11 @@ out: static int scoutfs_fill_super(struct super_block *sb, void *data, int silent) { struct scoutfs_mount_options opts; +#ifdef KC_BDEV_FILE_OPEN_BY_PATH + struct file *meta_bdev_file; +#else struct block_device *meta_bdev; +#endif struct scoutfs_sb_info *sbi; struct inode *inode; int ret; @@ -527,6 +537,22 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent) goto out; } +#ifdef KC_BDEV_FILE_OPEN_BY_PATH + /* + * pass sbi as holder, since dev_mount already passes sb, which triggers a + * WARN_ON because dev_mount also passes non-NULL hops. By passing sbi + * here we just get a simple error in our test cases. + */ + meta_bdev_file = bdev_file_open_by_path(opts.metadev_path, SCOUTFS_META_BDEV_MODE, sbi, NULL); + if (IS_ERR(meta_bdev_file)) { + scoutfs_err(sb, "could not open metadev: error %ld", + PTR_ERR(meta_bdev_file)); + ret = PTR_ERR(meta_bdev_file); + goto out; + } + sbi->meta_bdev_file = meta_bdev_file; + sbi->meta_bdev = file_bdev(meta_bdev_file); +#else #ifdef KC_BLKDEV_PUT_HOLDER_ARG meta_bdev = blkdev_get_by_path(opts.metadev_path, SCOUTFS_META_BDEV_MODE, sb, NULL); #else @@ -539,6 +565,8 @@ static int scoutfs_fill_super(struct super_block *sb, void *data, int silent) goto out; } sbi->meta_bdev = meta_bdev; +#endif + ret = set_blocksize(sbi->meta_bdev, SCOUTFS_BLOCK_SM_SIZE); if (ret != 0) { scoutfs_err(sb, "failed to set metadev blocksize, returned %d", diff --git a/kmod/src/super.h b/kmod/src/super.h index 45ec8450..3bb10ddb 100644 --- a/kmod/src/super.h +++ b/kmod/src/super.h @@ -42,6 +42,9 @@ struct scoutfs_sb_info { u64 fmt_vers; struct block_device *meta_bdev; +#ifdef KC_BDEV_FILE_OPEN_BY_PATH + struct file *meta_bdev_file; +#endif spinlock_t next_ino_lock;