diff mbox series

[v5,02/10] btrfs: cleanup all orphan inodes on ro->rw remount

Message ID 56e0a8c18483c395d20fc6c69a42740d19742eb1.1603828718.git.boris@bur.io (mailing list archive)
State New, archived
Headers show
Series None | expand

Commit Message

Boris Burkov Oct. 27, 2020, 9:07 p.m. UTC
When we mount a rw file system, we clean the orphan inodes in the
filesystem trees, and also on the tree_root and fs_root. However, when
we remount a ro file system rw, we only clean the former. Move the calls
to btrfs_orphan_cleanup() on tree_root and fs_root to the shared rw
mount routine to effectively add them on ro->rw remount.

Signed-off-by: Boris Burkov <boris@bur.io>
---
 fs/btrfs/disk-io.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Josef Bacik Oct. 28, 2020, 1:52 p.m. UTC | #1
On 10/27/20 5:07 PM, Boris Burkov wrote:
> When we mount a rw file system, we clean the orphan inodes in the
> filesystem trees, and also on the tree_root and fs_root. However, when
> we remount a ro file system rw, we only clean the former. Move the calls
> to btrfs_orphan_cleanup() on tree_root and fs_root to the shared rw
> mount routine to effectively add them on ro->rw remount.
> 
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
>   fs/btrfs/disk-io.c | 17 ++++++++---------
>   1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index bff7a3a7be18..95b9cc5db397 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -2826,6 +2826,14 @@ int btrfs_mount_rw(struct btrfs_fs_info *fs_info)
>   	if (ret)
>   		goto out;
>   
> +	down_read(&fs_info->cleanup_work_sem);
> +	if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||
> +	    (ret = btrfs_orphan_cleanup(fs_info->tree_root))) {
> +		up_read(&fs_info->cleanup_work_sem);
> +		goto out;
> +	}
> +	up_read(&fs_info->cleanup_work_sem);

This triggers

ERROR:ASSIGN_IN_IF: do not use assignment in if condition
#10: FILE: fs/btrfs/disk-io.c:2910:
+       if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||

total: 1 errors, 0 warnings, 29 lines checked

I'm not sure I agree with this check, Dave what's your opinion?  Thanks,

Josef
diff mbox series

Patch

diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index bff7a3a7be18..95b9cc5db397 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2826,6 +2826,14 @@  int btrfs_mount_rw(struct btrfs_fs_info *fs_info)
 	if (ret)
 		goto out;
 
+	down_read(&fs_info->cleanup_work_sem);
+	if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||
+	    (ret = btrfs_orphan_cleanup(fs_info->tree_root))) {
+		up_read(&fs_info->cleanup_work_sem);
+		goto out;
+	}
+	up_read(&fs_info->cleanup_work_sem);
+
 	mutex_lock(&fs_info->cleaner_mutex);
 	ret = btrfs_recover_relocation(fs_info->tree_root);
 	mutex_unlock(&fs_info->cleaner_mutex);
@@ -3308,15 +3316,6 @@  int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
 		}
 	}
 
-	down_read(&fs_info->cleanup_work_sem);
-	if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||
-	    (ret = btrfs_orphan_cleanup(fs_info->tree_root))) {
-		up_read(&fs_info->cleanup_work_sem);
-		close_ctree(fs_info);
-		return ret;
-	}
-	up_read(&fs_info->cleanup_work_sem);
-
 	btrfs_discard_resume(fs_info);
 	ret = btrfs_mount_rw(fs_info);
 	if (ret) {