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

Daniel Vacek
2025-11-05T16:38:14Z

On Tue, 4 Nov 2025 at 13:14, Christian Brauner <brauner@kernel.org> 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);

We accept lines with up to ~100 characters in btrfs code.

--nX

> iput(&inode->vfs_inode);
>
> if (ret < 0)
>
> --
> 2.47.3
>
>