From: Joseph Qi <joseph.qi@linux.alibaba.com>
To: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
David Laight <David.Laight@ACULAB.COM>,
Mark Fasheh <mark@fasheh.com>, Joel Becker <jlbec@evilplan.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"kernel-janitors@vger.kernel.org"
<kernel-janitors@vger.kernel.org>,
"ocfs2-devel@oss.oracle.com" <ocfs2-devel@oss.oracle.com>
Subject: Re: [PATCH 2/3] ocfs2: Remove a useless spinlock
Date: Wed, 20 Jul 2022 09:59:47 +0800 [thread overview]
Message-ID: <07c924de-78bf-c993-ce73-635af71f4edd@linux.alibaba.com> (raw)
In-Reply-To: <29c3fbdd-7695-46c5-bb75-fe358c574ab3@wanadoo.fr>
On 7/19/22 9:25 PM, Christophe JAILLET wrote:
> Le 19/07/2022 à 12:24, David Laight a écrit :
>> From: Christophe JAILLET
>>> Sent: 19 July 2022 11:02
>>>
>>> 'node_map_lock' is a spinlock only used to protect calls to set_bit(),
>>> clear_bit() and test_bit().
>>>
>>> {set|clear}_bit() are already atomic and don't need this extra spinlock.
>>> test_bit() only reads the bitmap for a given bit.
>>>
>>> Remove this useless spinlock.
>>
>> It looks to me like the calling code is racy
>> unless there is another lock in the callers.
>
> The call chains are:
> ocfs2_recover_orphans()
> ocfs2_mark_recovering_orphan_dir()
> spin_lock(&osb->osb_lock); <-- osb_lock spinlock
> ocfs2_node_map_set_bit() <-- uses node_map_lock
> ...
> spin_unlock(&osb->osb_lock);
> ...
> ocfs2_clear_recovering_orphan_dir()
> ocfs2_node_map_clear_bit() <-- uses node_map_lock
> osb_lock is NOT taken
>
>
> ocfs2_check_orphan_recovery_state()
> spin_lock(&osb->osb_lock); <-- osb_lock spinlock
> ...
> ocfs2_node_map_test_bit() <-- uses node_map_lock
> ...
> spin_unlock(&osb->osb_lock);
>
>
> So the code looks already protected by the 'osb_lock' spinlock, but I don't know this code and ocfs2_mark_recovering_orphan_dir() looks tricky to me. (so some other eyes are much welcome)
osb_lock is to protect osb filed such as 'osb_orphan_wipes', while
node_map_lock is to protect the node map 'osb_recovering_orphan_dirs'
specifically.
Thanks,
Joseph
next prev parent reply other threads:[~2022-07-20 1:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-19 10:01 [PATCH 1/3] ocfs2: Remove some useless functions Christophe JAILLET
2022-07-19 10:01 ` [PATCH 2/3] ocfs2: Remove a useless spinlock Christophe JAILLET
2022-07-19 10:24 ` David Laight
2022-07-19 13:25 ` Christophe JAILLET
2022-07-19 14:19 ` David Laight
2022-07-20 1:59 ` Joseph Qi [this message]
2022-07-20 8:26 ` Marion & Christophe JAILLET
2022-07-20 9:48 ` Joseph Qi
2022-07-20 13:32 ` Christophe JAILLET
2022-07-21 1:53 ` Joseph Qi
2022-07-19 10:05 ` [PATCH 3/3] ocfs2: use the bitmap API to simplify code Christophe JAILLET
2022-07-20 2:06 ` Joseph Qi
2022-07-20 2:03 ` [PATCH 1/3] ocfs2: Remove some useless functions Joseph Qi
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=07c924de-78bf-c993-ce73-635af71f4edd@linux.alibaba.com \
--to=joseph.qi@linux.alibaba.com \
--cc=David.Laight@ACULAB.COM \
--cc=christophe.jaillet@wanadoo.fr \
--cc=jlbec@evilplan.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark@fasheh.com \
--cc=ocfs2-devel@oss.oracle.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
all inboxes | Powered by JetHome®