From: Sidong Yang <realwakka@gmail.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: A question for kernel code in btrfs_run_qgroups()
Date: Tue, 1 Feb 2022 04:05:58 +0000 [thread overview]
Message-ID: <20220201040558.GA25465@realwakka> (raw)
In-Reply-To: <f5d1c08b-b843-6d5d-341d-c19890872e04@gmx.com>
On Tue, Feb 01, 2022 at 08:21:22AM +0800, Qu Wenruo wrote:
Hi Qu,
Thanks for answering
>
>
> On 2022/1/31 23:40, Sidong Yang wrote:
> > Hi, I'm reading btrfs code for contributing.
> > I have a question about code in btrfs_run_qgroups().
> >
> > It seems that it updates dirty qgroups modified in transaction.
>
> Yep.
>
> > And it iterates dirty qgroups with locking and unlocking qgroup_lock for
> > protecting dirty_qgroups list. According to code, It locks before enter
> > the loop and pick a entry and unlock. At the end of loop, It locks again
> > for next loop. And after loop, it set some flags and unlock.
> >
> > I wonder that it should be locked with setting STATUS_FLAG_ON? if not,
> > is there unnecessary locking in last loop?
>
> From a quick look, it indeed looks like we don't need to hole
> qgroup_lock to modify qgroup_flags.
> In fact, just lines below, we update qgroup_flags without any lock for
> INCONSISTENT bit.
Apparently it is, but I don't know surely that it really don't need to
hold lock while modifying qgroup_flags.
It has FLAG_ON that it indicates that quota turned on. I think it should
be modified carefully. Or it can be protected by other locks like
qgroup_lock or ioctl_lock?
>
>
> Unfortunately we indeed have inconsistent locking for qgroups_flags.
I agree. there is a lot of codes that modify qgroup_flags without lock
or with lock.
>
> So it's completely possible that we may not need to do modify the
> qgroup_flags under qgroup_lock.
>
> In fact there are tons of call sites that we don't hold locks for
> qgroups_flags update.
>
> So if you're interested in contributing to btrfs, starting from sorting
> the qgroup_lock usage would be a excellent start.
Yeah, I really interested in this. but I don't know good way to handle
this problem. is it really good way to remove the code holding lock
while modifying flags?
Thanks,
Sidong
>
> Thanks,
> Qu
next prev parent reply other threads:[~2022-02-01 4:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-31 15:40 A question for kernel code in btrfs_run_qgroups() Sidong Yang
2022-02-01 0:21 ` Qu Wenruo
2022-02-01 4:05 ` Sidong Yang [this message]
2022-02-01 7:31 ` Qu Wenruo
2022-02-01 9:24 ` Sidong Yang
2022-02-01 11:35 ` Qu Wenruo
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=20220201040558.GA25465@realwakka \
--to=realwakka@gmail.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
/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