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 <rkitover@gmail.com>
Reviewed-by: Coleman Kane <ckane@colemankane.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #11387
Closes #11390
This commit is contained in:
Brian Behlendorf
2020-12-22 10:26:45 -08:00
parent c347fac586
commit b7281c88bc
3 changed files with 74 additions and 30 deletions
+4 -9
View File
@@ -66,19 +66,14 @@ typedef struct zv_request {
* Given a path, return TRUE if path is a ZVOL.
*/
static boolean_t
zvol_is_zvol_impl(const char *device)
zvol_is_zvol_impl(const char *path)
{
struct block_device *bdev;
unsigned int major;
dev_t dev = 0;
bdev = vdev_lookup_bdev(device);
if (IS_ERR(bdev))
if (vdev_lookup_bdev(path, &dev) != 0)
return (B_FALSE);
major = MAJOR(bdev->bd_dev);
bdput(bdev);
if (major == zvol_major)
if (MAJOR(dev) == zvol_major)
return (B_TRUE);
return (B_FALSE);