aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/dev-replace.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2017-03-28 08:44:21 -0400
committerDavid Sterba <dsterba@suse.com>2017-04-18 08:07:25 -0400
commit171938e528079deced3226a17dcab12121312a64 (patch)
treed49869102dade6b05e5736b0df6fd48301e43bb7 /fs/btrfs/dev-replace.c
parent48a89bc4f2ceab87bc858a8eb189636b09c846a7 (diff)
btrfs: track exclusive filesystem operation in flags
There are several operations, usually started from ioctls, that cannot run concurrently. The status is tracked in mutually_exclusive_operation_running as an atomic_t. We can easily track the status as one of the per-filesystem flag bits with same synchronization guarantees. The conversion replaces: * atomic_xchg(..., 1) -> test_and_set_bit(FLAG, ...) * atomic_set(..., 0) -> clear_bit(FLAG, ...) Reviewed-by: Anand Jain <anand.jain@oracle.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/dev-replace.c')
-rw-r--r--fs/btrfs/dev-replace.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/dev-replace.c b/fs/btrfs/dev-replace.c
index e653921f05d9..de7b2c897fe0 100644
--- a/fs/btrfs/dev-replace.c
+++ b/fs/btrfs/dev-replace.c
@@ -784,8 +784,7 @@ int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
784 } 784 }
785 btrfs_dev_replace_unlock(dev_replace, 1); 785 btrfs_dev_replace_unlock(dev_replace, 1);
786 786
787 WARN_ON(atomic_xchg( 787 WARN_ON(test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags));
788 &fs_info->mutually_exclusive_operation_running, 1));
789 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl"); 788 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl");
790 return PTR_ERR_OR_ZERO(task); 789 return PTR_ERR_OR_ZERO(task);
791} 790}
@@ -814,7 +813,7 @@ static int btrfs_dev_replace_kthread(void *data)
814 (unsigned int)progress); 813 (unsigned int)progress);
815 } 814 }
816 btrfs_dev_replace_continue_on_mount(fs_info); 815 btrfs_dev_replace_continue_on_mount(fs_info);
817 atomic_set(&fs_info->mutually_exclusive_operation_running, 0); 816 clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags);
818 817
819 return 0; 818 return 0;
820} 819}