Commit babbf170c781f24095336c82ebf18ad272ddb773

Authored by Miao Xie
Committed by Josef Bacik
1 parent dc7f370c05

Btrfs: make the snap/subv deletion end more early when the fs is R/O

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>

Showing 3 changed files with 15 additions and 14 deletions Side-by-side Diff

... ... @@ -3318,6 +3318,18 @@
3318 3318 smp_mb();
3319 3319 return fs_info->closing;
3320 3320 }
  3321 +
  3322 +/*
  3323 + * If we remount the fs to be R/O or umount the fs, the cleaner needn't do
  3324 + * anything except sleeping. This function is used to check the status of
  3325 + * the fs.
  3326 + */
  3327 +static inline int btrfs_need_cleaner_sleep(struct btrfs_root *root)
  3328 +{
  3329 + return (root->fs_info->sb->s_flags & MS_RDONLY ||
  3330 + btrfs_fs_closing(root->fs_info));
  3331 +}
  3332 +
3321 3333 static inline void free_fs_info(struct btrfs_fs_info *fs_info)
3322 3334 {
3323 3335 kfree(fs_info->balance_ctl);
... ... @@ -1673,17 +1673,6 @@
1673 1673 bio_endio(bio, error);
1674 1674 }
1675 1675  
1676   -/*
1677   - * If we remount the fs to be R/O or umount the fs, the cleaner needn't do
1678   - * anything except sleeping. This function is used to check the status of
1679   - * the fs.
1680   - */
1681   -static inline int need_cleaner_sleep(struct btrfs_root *root)
1682   -{
1683   - return (root->fs_info->sb->s_flags & MS_RDONLY ||
1684   - btrfs_fs_closing(root->fs_info));
1685   -}
1686   -
1687 1676 static int cleaner_kthread(void *arg)
1688 1677 {
1689 1678 struct btrfs_root *root = arg;
... ... @@ -1693,7 +1682,7 @@
1693 1682 again = 0;
1694 1683  
1695 1684 /* Make the cleaner go to sleep early. */
1696   - if (need_cleaner_sleep(root))
  1685 + if (btrfs_need_cleaner_sleep(root))
1697 1686 goto sleep;
1698 1687  
1699 1688 if (!mutex_trylock(&root->fs_info->cleaner_mutex))
... ... @@ -1703,7 +1692,7 @@
1703 1692 * Avoid the problem that we change the status of the fs
1704 1693 * during the above check and trylock.
1705 1694 */
1706   - if (need_cleaner_sleep(root)) {
  1695 + if (btrfs_need_cleaner_sleep(root)) {
1707 1696 mutex_unlock(&root->fs_info->cleaner_mutex);
1708 1697 goto sleep;
1709 1698 }
fs/btrfs/extent-tree.c
... ... @@ -7384,7 +7384,7 @@
7384 7384 wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(root);
7385 7385  
7386 7386 while (1) {
7387   - if (!for_reloc && btrfs_fs_closing(root->fs_info)) {
  7387 + if (!for_reloc && btrfs_need_cleaner_sleep(root)) {
7388 7388 pr_debug("btrfs: drop snapshot early exit\n");
7389 7389 err = -EAGAIN;
7390 7390 goto out_end_trans;