Message ID | a1d2ce906be6a35c652b8792074cdb48b6d3c9ac.1737462738.git.fdmanana@suse.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | btrfs: avoid start new transaction when cleaning qgroup during subvolume drop | expand |
在 2025/1/21 23:03, fdmanana@kernel.org 写道: > From: Filipe Manana <fdmanana@suse.com> > > At btrfs_qgroup_cleanup_dropped_subvolume() all we want to commit the > current transaction in order to have all the qgroup rfer/excl numbers up > to date. However we are using btrfs_start_transaction(), which joins the > current transaction if there is one that is not yet committing, but also > starts a new one if there is none or if the current one is already > committing (its state is >= TRANS_STATE_COMMIT_START). This later case > results in unnecessary IO, wasting time and a pointless rotation of the > backup roots in the super block. > > So instead of using btrfs_start_transaction() followed by a > btrfs_commit_transaction(), use btrfs_commit_current_transaction() which > achieves our purpose and avoids starting and committing new transactions. > > Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/qgroup.c | 6 +----- > 1 file changed, 1 insertion(+), 5 deletions(-) > > diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c > index aaf16019d829..f9d3766c809b 100644 > --- a/fs/btrfs/qgroup.c > +++ b/fs/btrfs/qgroup.c > @@ -1880,11 +1880,7 @@ int btrfs_qgroup_cleanup_dropped_subvolume(struct btrfs_fs_info *fs_info, u64 su > * Commit current transaction to make sure all the rfer/excl numbers > * get updated. > */ > - trans = btrfs_start_transaction(fs_info->quota_root, 0); > - if (IS_ERR(trans)) > - return PTR_ERR(trans); > - > - ret = btrfs_commit_transaction(trans); > + ret = btrfs_commit_current_transaction(fs_info->quota_root); > if (ret < 0) > return ret; >
diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c index aaf16019d829..f9d3766c809b 100644 --- a/fs/btrfs/qgroup.c +++ b/fs/btrfs/qgroup.c @@ -1880,11 +1880,7 @@ int btrfs_qgroup_cleanup_dropped_subvolume(struct btrfs_fs_info *fs_info, u64 su * Commit current transaction to make sure all the rfer/excl numbers * get updated. */ - trans = btrfs_start_transaction(fs_info->quota_root, 0); - if (IS_ERR(trans)) - return PTR_ERR(trans); - - ret = btrfs_commit_transaction(trans); + ret = btrfs_commit_current_transaction(fs_info->quota_root); if (ret < 0) return ret;