* Questions about qgroup_lock and qgroup_ioctl_lock in enable/disable quota
@ 2022-03-03 8:28 Sidong Yang
0 siblings, 0 replies; only message in thread
From: Sidong Yang @ 2022-03-03 8:28 UTC (permalink / raw)
To: linux-btrfs
Hi.
As a newbie, I have some questions about qgroup_ioctl_lock and
qgroup_lock in enable/disable quota.
I'm reading btrfs_quota_enable() in qgroup.c, I'm confused about
qgroup_ioctl_lock. It seems that in the begining of the function, it
checkes fs_info->quota_root with qgroup_ioctl_lock locked. And I feel
like that fs_info->qgroup_ioctl_lock protects fs_info->quota_root. After
that it releases qgroup_ioctl_lock and starts transaction in line 1005.
I understand that there was problem about deadlock between
qgroup_ioctl_lock and the vfs freeze semaphores. And it also lock
qgroup_ioctl_locki again. Just after that, There is code checkes
fs_info->quota_root like below.
lock qgroup_ioctl_lock => check fs_info->quota_root => unlock
qgroup_ioctl_lock => unlock qgroup_ioctl_lock => start transaction =>
check fs_info->quota_root
I think there is no need to double checks. Is it right?
And the end of the function, It seems that the code as below.
unlock qgroup_ioctl_lock => commit transaction => lock qgroup_ioctl_lock
=> lock qgroup_lock => set fs_info->quota_root => unlock qgroup_lock =>
unlock qgroup_ioctl_lock
For the beginning of the function, there was no qgroup_lock for check
fs_info->quota_root. It should be protected?
I think the typical pattern below works and it's simple for the function.
start transaction => lock qgroup_ioctl_lock => unlock qgroup_ioctl_lock
=> commit transaction
Will there be any problems with this implementation?
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-03-03 8:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-03 8:28 Questions about qgroup_lock and qgroup_ioctl_lock in enable/disable quota Sidong Yang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox