Skip to content

Commit 7503b83

Browse files
committed
btrfs: move ulist allocation out of transaction in quota enable
The allocation happens with GFP_KERNEL after a transaction has been started, this can potentially cause deadlock if reclaim tries to get the memory by flushing filesystem data. The fs_info::qgroup_ulist is not used during transaction start when quotas are not enabled. The status bit BTRFS_FS_QUOTA_ENABLED is set later in btrfs_quota_enable so it's safe to move it before the transaction start. Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent aea6f02 commit 7503b83

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fs/btrfs/qgroup.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,12 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
894894
if (fs_info->quota_root)
895895
goto out;
896896

897+
fs_info->qgroup_ulist = ulist_alloc(GFP_KERNEL);
898+
if (!fs_info->qgroup_ulist) {
899+
ret = -ENOMEM;
900+
goto out;
901+
}
902+
897903
/*
898904
* 1 for quota root item
899905
* 1 for BTRFS_QGROUP_STATUS item
@@ -909,13 +915,6 @@ int btrfs_quota_enable(struct btrfs_fs_info *fs_info)
909915
goto out;
910916
}
911917

912-
fs_info->qgroup_ulist = ulist_alloc(GFP_KERNEL);
913-
if (!fs_info->qgroup_ulist) {
914-
ret = -ENOMEM;
915-
btrfs_abort_transaction(trans, ret);
916-
goto out;
917-
}
918-
919918
/*
920919
* initially create the quota tree
921920
*/

0 commit comments

Comments
 (0)