]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
btrfs: qgroup: set a more sane default value for subtree drop threshold
authorQu Wenruo <wqu@suse.com>
Tue, 10 Sep 2024 05:51:04 +0000 (15:21 +0930)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Nov 2024 01:02:39 +0000 (02:02 +0100)
commit 5f9062a48db260fd6b53d86ecfb4d5dc59266316 upstream.

Since commit 011b46c30476 ("btrfs: skip subtree scan if it's too high to
avoid low stall in btrfs_commit_transaction()"), btrfs qgroup can
automatically skip large subtree scan at the cost of marking qgroup
inconsistent.

It's designed to address the final performance problem of snapshot drop
with qgroup enabled, but to be safe the default value is
BTRFS_MAX_LEVEL, requiring a user space daemon to set a different value
to make it work.

I'd say it's not a good idea to rely on user space tool to set this
default value, especially when some operations (snapshot dropping) can
be triggered immediately after mount, leaving a very small window to
that that sysfs interface.

So instead of disabling this new feature by default, enable it with a
low threshold (3), so that large subvolume tree drop at mount time won't
cause huge qgroup workload.

CC: stable@vger.kernel.org # 6.1
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/disk-io.c
fs/btrfs/qgroup.c
fs/btrfs/qgroup.h

index 216b3b412aa0e1a92480e004a6fd7c19676f3411..64bead01354c9b57290f897efc9b00a20f15bf9d 100644 (file)
@@ -1960,7 +1960,7 @@ static void btrfs_init_qgroup(struct btrfs_fs_info *fs_info)
        fs_info->qgroup_seq = 1;
        fs_info->qgroup_ulist = NULL;
        fs_info->qgroup_rescan_running = false;
-       fs_info->qgroup_drop_subtree_thres = BTRFS_MAX_LEVEL;
+       fs_info->qgroup_drop_subtree_thres = BTRFS_QGROUP_DROP_SUBTREE_THRES_DEFAULT;
        mutex_init(&fs_info->qgroup_rescan_lock);
 }
 
index feb8f9f2f3582ded5c41600e3947af56ebeade3f..427e8887a510569e3652daa82aa5283de96ed61a 100644 (file)
@@ -1407,7 +1407,7 @@ int btrfs_quota_disable(struct btrfs_fs_info *fs_info)
        fs_info->quota_root = NULL;
        fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_ON;
        fs_info->qgroup_flags &= ~BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE;
-       fs_info->qgroup_drop_subtree_thres = BTRFS_MAX_LEVEL;
+       fs_info->qgroup_drop_subtree_thres = BTRFS_QGROUP_DROP_SUBTREE_THRES_DEFAULT;
        spin_unlock(&fs_info->qgroup_lock);
 
        btrfs_free_qgroup_config(fs_info);
index deb479d176a96cc403462882d973d13bd1640fc2..1ef566cf1c2a691c3da62e71ade6a63317605ec8 100644 (file)
@@ -121,6 +121,8 @@ struct btrfs_inode;
 #define BTRFS_QGROUP_RUNTIME_FLAG_CANCEL_RESCAN                (1ULL << 63)
 #define BTRFS_QGROUP_RUNTIME_FLAG_NO_ACCOUNTING                (1ULL << 62)
 
+#define BTRFS_QGROUP_DROP_SUBTREE_THRES_DEFAULT                (3)
+
 /*
  * Record a dirty extent, and info qgroup to update quota on it
  */