Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dc7f370c authored by Miao Xie's avatar Miao Xie Committed by Josef Bacik
Browse files

Btrfs: move the R/O check out of btrfs_clean_one_deleted_snapshot()



If the fs is remounted to be R/O, it is unnecessary to call
btrfs_clean_one_deleted_snapshot(), so move the R/O check out of
this function. And besides that, it can make the check logic in the
caller more clear.

Cc: David Sterba <dsterba@suse.cz>
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
parent 05323cd1
Loading
Loading
Loading
Loading
+9 −0
Original line number Original line Diff line number Diff line
@@ -1699,6 +1699,15 @@ static int cleaner_kthread(void *arg)
		if (!mutex_trylock(&root->fs_info->cleaner_mutex))
		if (!mutex_trylock(&root->fs_info->cleaner_mutex))
			goto sleep;
			goto sleep;


		/*
		 * Avoid the problem that we change the status of the fs
		 * during the above check and trylock.
		 */
		if (need_cleaner_sleep(root)) {
			mutex_unlock(&root->fs_info->cleaner_mutex);
			goto sleep;
		}

		btrfs_run_delayed_iputs(root);
		btrfs_run_delayed_iputs(root);
		again = btrfs_clean_one_deleted_snapshot(root);
		again = btrfs_clean_one_deleted_snapshot(root);
		mutex_unlock(&root->fs_info->cleaner_mutex);
		mutex_unlock(&root->fs_info->cleaner_mutex);
+0 −5
Original line number Original line Diff line number Diff line
@@ -1885,11 +1885,6 @@ int btrfs_clean_one_deleted_snapshot(struct btrfs_root *root)
	int ret;
	int ret;
	struct btrfs_fs_info *fs_info = root->fs_info;
	struct btrfs_fs_info *fs_info = root->fs_info;


	if (fs_info->sb->s_flags & MS_RDONLY) {
		pr_debug("btrfs: cleaner called for RO fs!\n");
		return 0;
	}

	spin_lock(&fs_info->trans_lock);
	spin_lock(&fs_info->trans_lock);
	if (list_empty(&fs_info->dead_roots)) {
	if (list_empty(&fs_info->dead_roots)) {
		spin_unlock(&fs_info->trans_lock);
		spin_unlock(&fs_info->trans_lock);