diff options
author | Anand Jain <anand.jain@oracle.com> | 2022-01-12 08:06:02 +0300 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2022-03-14 15:13:47 +0300 |
commit | 330a5bf4551784f2f0baef27f2c78550e40fc8a0 (patch) | |
tree | 78844d6fc9354aa3372e69ced58b18df0b653cdc /fs | |
parent | 4889bc05a96e039b055bbd11438c40bf956f057b (diff) | |
download | linux-330a5bf4551784f2f0baef27f2c78550e40fc8a0.tar.xz |
btrfs: use dev_t to match device in device_matched
Commit "btrfs: add device major-minor info in the struct btrfs_device"
saved the device major-minor number in the struct btrfs_device upon
discovering it.
So no need to lookup_bdev() again just match, which means
device_matched() can go away.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/volumes.c | 41 |
1 files changed, 1 insertions, 40 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ebe655eb8b4d..1e1120ed9f8c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -534,45 +534,6 @@ error: return ret; } -/* - * Check if the device in the path matches the device in the given struct device. - * - * Returns: - * true If it is the same device. - * false If it is not the same device or on error. - */ -static bool device_matched(const struct btrfs_device *device, dev_t dev_new) -{ - char *device_name; - dev_t dev_old; - int ret; - - /* - * If we are looking for a device with the matching dev_t, then skip - * device without a name (a missing device). - */ - if (!device->name) - return false; - - device_name = kzalloc(BTRFS_PATH_NAME_MAX, GFP_KERNEL); - if (!device_name) - return false; - - rcu_read_lock(); - scnprintf(device_name, BTRFS_PATH_NAME_MAX, "%s", rcu_str_deref(device->name)); - rcu_read_unlock(); - - ret = lookup_bdev(device_name, &dev_old); - kfree(device_name); - if (ret) - return false; - - if (dev_old == dev_new) - return true; - - return false; -} - /** * Search and remove all stale devices (which are not mounted). * When both inputs are NULL, it will search and release all stale devices. @@ -604,7 +565,7 @@ static int btrfs_free_stale_devices(dev_t devt, struct btrfs_device *skip_device &fs_devices->devices, dev_list) { if (skip_device && skip_device == device) continue; - if (devt && !device_matched(device, devt)) + if (devt && devt != device->devt) continue; if (fs_devices->opened) { /* for an already deleted device return 0 */ |