From f0a018e555f5ad585cafd406d7911e366a6f862c Mon Sep 17 00:00:00 2001 From: Anand Jain Date: Sat, 13 Feb 2016 10:01:40 +0800 Subject: [PATCH] btrfs: optimize check for stale device Optimize check for stale device to only be checked when there is device added or changed. If there is no update to the device, there is no need to call btrfs_free_stale_device(). Signed-off-by: Anand Jain Signed-off-by: David Sterba --- fs/btrfs/volumes.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 5e49adb34b2e..20af20b0eaee 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -699,7 +699,8 @@ static noinline int device_list_add(const char *path, * if there is new btrfs on an already registered device, * then remove the stale device entry. */ - btrfs_free_stale_device(device); + if (ret > 0) + btrfs_free_stale_device(device); *fs_devices_ret = fs_devices; -- 2.39.5