Btrfs: make the snap/subv deletion end more early when the fs is R/O
authorMiao Xie <miaox@cn.fujitsu.com>
Tue, 14 May 2013 10:20:43 +0000 (10:20 +0000)
committerJosef Bacik <jbacik@fusionio.com>
Fri, 14 Jun 2013 15:29:36 +0000 (11:29 -0400)
The snapshot/subvolume deletion might spend lots of time, it would make
the remount task wait for a long time. This patch improve this problem,
we will break the deletion if the fs is remounted to be R/O. It will make
the users happy.

Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/extent-tree.c

index d354de31b81b15cca6c86e55e6179d4280db38eb..d9ff585aadba851052220cba837e705181af96a6 100644 (file)
@@ -3318,6 +3318,18 @@ static inline int btrfs_fs_closing(struct btrfs_fs_info *fs_info)
        smp_mb();
        return fs_info->closing;
 }
+
+/*
+ * If we remount the fs to be R/O or umount the fs, the cleaner needn't do
+ * anything except sleeping. This function is used to check the status of
+ * the fs.
+ */
+static inline int btrfs_need_cleaner_sleep(struct btrfs_root *root)
+{
+       return (root->fs_info->sb->s_flags & MS_RDONLY ||
+               btrfs_fs_closing(root->fs_info));
+}
+
 static inline void free_fs_info(struct btrfs_fs_info *fs_info)
 {
        kfree(fs_info->balance_ctl);
index 5b9b4eb36e5d8ee44165cd492a58ae9d0b22724e..8dbd908a3a9770d76ce69eb2b571db1d517a49a8 100644 (file)
@@ -1673,17 +1673,6 @@ static void end_workqueue_fn(struct btrfs_work *work)
        bio_endio(bio, error);
 }
 
-/*
- * If we remount the fs to be R/O or umount the fs, the cleaner needn't do
- * anything except sleeping. This function is used to check the status of
- * the fs.
- */
-static inline int need_cleaner_sleep(struct btrfs_root *root)
-{
-       return (root->fs_info->sb->s_flags & MS_RDONLY ||
-               btrfs_fs_closing(root->fs_info));
-}
-
 static int cleaner_kthread(void *arg)
 {
        struct btrfs_root *root = arg;
@@ -1693,7 +1682,7 @@ static int cleaner_kthread(void *arg)
                again = 0;
 
                /* Make the cleaner go to sleep early. */
-               if (need_cleaner_sleep(root))
+               if (btrfs_need_cleaner_sleep(root))
                        goto sleep;
 
                if (!mutex_trylock(&root->fs_info->cleaner_mutex))
@@ -1703,7 +1692,7 @@ static int cleaner_kthread(void *arg)
                 * Avoid the problem that we change the status of the fs
                 * during the above check and trylock.
                 */
-               if (need_cleaner_sleep(root)) {
+               if (btrfs_need_cleaner_sleep(root)) {
                        mutex_unlock(&root->fs_info->cleaner_mutex);
                        goto sleep;
                }
index df472ab1b5acca7b411b05bcc414913bcebcc244..b55b5fb0eb29de067ca8b3c5a9a9a6928402e537 100644 (file)
@@ -7384,7 +7384,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
        wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
 
        while (1) {
-               if (!for_reloc && btrfs_fs_closing(root->fs_info)) {
+               if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
                        pr_debug("btrfs: drop snapshot early exit\n");
                        err = -EAGAIN;
                        goto out_end_trans;