[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <fe6c86050b3447758c09e1881582405f@AcuMS.aculab.com>
Date: Tue, 19 Jul 2022 14:19:08 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Christophe JAILLET' <christophe.jaillet@...adoo.fr>,
Mark Fasheh <mark@...heh.com>,
Joel Becker <jlbec@...lplan.org>,
Joseph Qi <joseph.qi@...ux.alibaba.com>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
"ocfs2-devel@....oracle.com" <ocfs2-devel@....oracle.com>
Subject: RE: [PATCH 2/3] ocfs2: Remove a useless spinlock
From: Christophe JAILLET
> Sent: 19 July 2022 14:25
>
> 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)
>
> > While map->map is protected, the result of test_bit()
> > is stale - so can't be used for much.
> >
>
> Anyway, should there be a locking issue, it is there with or without my
> patch, right?
Indeed.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists