Re: [PATCH RFC 3/8] btrfs: use super write guard btrfs_run_defrag_inode()

David Sterba
2025-11-06T08:19:49Z

On Tue, Nov 04, 2025 at 01:12:32PM +0100, Christian Brauner wrote:
> Signed-off-by: Christian Brauner <brauner@kernel.org>
> ---
> fs/btrfs/defrag.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c
> index 7b277934f66f..35fb8ee164dc 100644
> --- a/fs/btrfs/defrag.c
> +++ b/fs/btrfs/defrag.c
> @@ -254,10 +254,9 @@ static int btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
> range.extent_thresh = defrag->extent_thresh;
> file_ra_state_init(ra, inode->vfs_inode.i_mapping);
>
> - sb_start_write(fs_info->sb);
> - ret = btrfs_defrag_file(inode, ra, &range, defrag->transid,
> - BTRFS_DEFRAG_BATCH);
> - sb_end_write(fs_info->sb);
> + scoped_guard(super_write, fs_info->sb)
> + ret = btrfs_defrag_file(inode, ra, &range,
> + defrag->transid, BTRFS_DEFRAG_BATCH);

Please use explicit { } around scoped_guard() in btrfs code. It makes
the scope more obvious.