Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/little/linux/fs/btrfs/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -4247,7 +4247,9 @@ static long btrfs_ioctl_qgroup_assign(struct file *file, void __user *arg)
}

/* update qgroup status and info */
mutex_lock(&fs_info->qgroup_ioctl_lock);
err = btrfs_run_qgroups(trans);
mutex_unlock(&fs_info->qgroup_ioctl_lock);
if (err < 0)
btrfs_handle_fs_error(fs_info, err,
"failed to update qgroup status and info");
Expand Down
11 changes: 10 additions & 1 deletion src/little/linux/fs/btrfs/qgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2699,13 +2699,22 @@ int btrfs_qgroup_account_extents(struct btrfs_trans_handle *trans)
}

/*
* called from commit_transaction. Writes all changed qgroups to disk.
* Writes all changed qgroups to disk.
* Called by the transaction commit path and the qgroup assign ioctl.
*/
int btrfs_run_qgroups(struct btrfs_trans_handle *trans)
{
struct btrfs_fs_info *fs_info = trans->fs_info;
int ret = 0;

/*
* In case we are called from the qgroup assign ioctl, assert that we
* are holding the qgroup_ioctl_lock, otherwise we can race with a quota
* disable operation (ioctl) and access a freed quota root.
*/
if (trans->transaction->state != TRANS_STATE_COMMIT_DOING)
lockdep_assert_held(&fs_info->qgroup_ioctl_lock);

if (!fs_info->quota_root)
return ret;

Expand Down