diff mbox

[5/6] btrfs: make btrfs_free_stale_device() to match the path

Message ID 20180109141314.23795-6-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show

Commit Message

Anand Jain Jan. 9, 2018, 2:13 p.m. UTC
From: Anand Jain <Anand.Jain@oracle.com>

The btrfs_free_stale_device() is updated to match for the given
device path and delete it. (It searchs for only unmounted list of
devices.)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/volumes.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Josef Bacik Jan. 9, 2018, 4:22 p.m. UTC | #1
On Tue, Jan 09, 2018 at 10:13:13PM +0800, Anand Jain wrote:
> From: Anand Jain <Anand.Jain@oracle.com>
> 
> The btrfs_free_stale_device() is updated to match for the given
> device path and delete it. (It searchs for only unmounted list of
> devices.)
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Reviewed-by: Josef Bacik <jbacik@fb.com>

Thanks,

Josef
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 7646f8860096..f87d30aa0e18 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -606,7 +606,7 @@  static void pending_bios_fn(struct btrfs_work *work)
 }
 
 
-static void btrfs_free_stale_device(struct btrfs_device *cur_dev)
+static void btrfs_free_stale_device(struct btrfs_device *cur_dev, char *path)
 {
 	struct btrfs_fs_devices *fs_devs, *tmp_fs_devs;
 	struct btrfs_device *dev, *tmp_dev;
@@ -633,6 +633,8 @@  static void btrfs_free_stale_device(struct btrfs_device *cur_dev)
 			if (cur_dev)
 				not_found = strcmp(rcu_str_deref(dev->name),
 						   rcu_str_deref(cur_dev->name));
+			else if (path)
+				not_found = strcmp(rcu_str_deref(dev->name), path);
 			else
 				not_found = 0;
 			rcu_read_unlock();
@@ -776,7 +778,7 @@  static noinline int device_list_add(const char *path,
 
 		ret = 1;
 		device->fs_devices = fs_devices;
-		btrfs_free_stale_device(device);
+		btrfs_free_stale_device(device, NULL);
 	} else if (!device->name || strcmp(device->name->str, path)) {
 		/*
 		 * When FS is already mounted.