@@ -535,43 +535,6 @@ btrfs_get_bdev_and_sb(const char *device_path, fmode_t flags, void *holder,
return ret;
}
-/*
- * Check if the device in the 'path' matches with the device in the given
- * struct btrfs_device '*device'.
- * Returns:
- * 0 If it is the same device.
- * 1 If it is not the same device.
- * -errno For error.
- */
-static int device_matched(struct btrfs_device *device, dev_t dev_new)
-{
- char *device_name;
- dev_t dev_old;
- int ret;
-
- device_name = kzalloc(BTRFS_PATH_NAME_MAX, GFP_KERNEL);
- if (!device_name)
- return -ENOMEM;
-
- rcu_read_lock();
- ret = sprintf(device_name, "%s", rcu_str_deref(device->name));
- rcu_read_unlock();
- if (!ret) {
- kfree(device_name);
- return -EINVAL;
- }
-
- ret = lookup_bdev(device_name, &dev_old);
- kfree(device_name);
- if (ret)
- return ret;
-
- if (dev_old == dev_new)
- return 0;
-
- return 1;
-}
-
/*
* Search and remove all stale (devices which are not mounted) devices.
* When both inputs are NULL, it will search and release all stale devices.
@@ -602,9 +565,7 @@ static int btrfs_free_stale_devices(dev_t devt,
&fs_devices->devices, dev_list) {
if (skip_device && skip_device == device)
continue;
- if (devt && !device->name)
- continue;
- if (devt && device_matched(device, devt) != 0)
+ if (devt && device->devt != devt)
continue;
if (fs_devices->opened) {
/* for an already deleted device return 0 */
Commit 6531891b2bcb ("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> --- v3: - fs/btrfs/volumes.c | 41 +---------------------------------------- 1 file changed, 1 insertion(+), 40 deletions(-)