diff options
author | Brian Behlendorf <[email protected]> | 2020-12-22 10:26:45 -0800 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-12-27 16:20:08 -0800 |
commit | b7281c88bcbba0525e8b55607145956320d103f0 (patch) | |
tree | 981a8babaef6cf441860442bf7baf04c425a890c /include | |
parent | c347fac5861e9ed736441644a97b5fa5b446998d (diff) |
Linux 5.11 compat: lookup_bdev()
The lookup_bdev() function has been updated to require a dev_t
be passed as the second argument. This is actually pretty nice
since the major number stored in the dev_t was the only part we
were interested in. This allows to us avoid handling the bdev
entirely. The vdev_lookup_bdev() wrapper was updated to emulate
the behavior of the new lookup_bdev() for all supported kernels.
Reviewed-by: Rafael Kitover <[email protected]>
Reviewed-by: Coleman Kane <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Closes #11387
Closes #11390
Diffstat (limited to 'include')
-rw-r--r-- | include/os/linux/kernel/linux/blkdev_compat.h | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/include/os/linux/kernel/linux/blkdev_compat.h b/include/os/linux/kernel/linux/blkdev_compat.h index 220344c81..4d84900be 100644 --- a/include/os/linux/kernel/linux/blkdev_compat.h +++ b/include/os/linux/kernel/linux/blkdev_compat.h @@ -318,16 +318,38 @@ zfs_check_media_change(struct block_device *bdev) * * 4.4.0-6.21 API change for Ubuntu * lookup_bdev() gained a second argument, FMODE_*, to check inode permissions. + * + * 5.11 API change + * Changed to take a dev_t argument which is set on success and return a + * non-zero error code on failure. */ -#ifdef HAVE_1ARG_LOOKUP_BDEV -#define vdev_lookup_bdev(path) lookup_bdev(path) -#else -#ifdef HAVE_2ARGS_LOOKUP_BDEV -#define vdev_lookup_bdev(path) lookup_bdev(path, 0) +static inline int +vdev_lookup_bdev(const char *path, dev_t *dev) +{ +#if defined(HAVE_DEVT_LOOKUP_BDEV) + return (lookup_bdev(path, dev)); +#elif defined(HAVE_1ARG_LOOKUP_BDEV) + struct block_device *bdev = lookup_bdev(path); + if (IS_ERR(bdev)) + return (PTR_ERR(bdev)); + + *dev = bdev->bd_dev; + bdput(bdev); + + return (0); +#elif defined(HAVE_MODE_LOOKUP_BDEV) + struct block_device *bdev = lookup_bdev(path, FMODE_READ); + if (IS_ERR(bdev)) + return (PTR_ERR(bdev)); + + *dev = bdev->bd_dev; + bdput(bdev); + + return (0); #else #error "Unsupported kernel" -#endif /* HAVE_2ARGS_LOOKUP_BDEV */ -#endif /* HAVE_1ARG_LOOKUP_BDEV */ +#endif +} /* * Kernels without bio_set_op_attrs use bi_rw for the bio flags. |