public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Sidong Yang <realwakka@gmail.com>
To: linux-btrfs@vger.kernel.org
Subject: Questions about qgroup_lock and qgroup_ioctl_lock in enable/disable quota
Date: Thu, 3 Mar 2022 08:28:21 +0000	[thread overview]
Message-ID: <20220303082821.GA1243@realwakka> (raw)

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?

                 reply	other threads:[~2022-03-03  8:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220303082821.GA1243@realwakka \
    --to=realwakka@gmail.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox