From: Liu Bo <bo.li.liu@oracle.com>
To: Nikolay Borisov <nborisov@suse.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH RFC] Btrfs: expose bad chunks in sysfs
Date: Mon, 12 Feb 2018 16:06:31 -0800 [thread overview]
Message-ID: <20180213000631.GB23045@lim.localdomain> (raw)
In-Reply-To: <7d4e2901-8330-976b-9791-13b22f75ce96@suse.com>
On Mon, Feb 12, 2018 at 07:39:02PM +0200, Nikolay Borisov wrote:
>
>
> On 12.02.2018 16:17, Liu Bo wrote:
> > On Tue, Feb 06, 2018 at 11:11:55AM +0200, Nikolay Borisov wrote:
[...]
> >>
> >> Use list_for_each_entry_safe to make it more apparent you are going to
> >> be removing from the list. The code as-is works since you are doing a
> >> break after deleting element from the list but this is somewhat subtle.
> >
> > To be honest, I don't see much difference.
> >
> > I think the _safe version is to protect us from some race when others
> > remove objects from list, and write lock is held so we're safe.
>
> No, the _safe version uses the second argument (n) as the list iterator.
> The non-safe version just uses 'pos', and in case you remove 'pos' from
> the list AND continue iterating you will deref an invalid pointer. So
> _safe is actually really necessary for correctness when you intend to
> remove an entry from a list you are iterating, irrespective of any locks
> you might have.
You're right, I know it takes an extra pointer to store the next
entry, but miss the point when deleting by itself.
Thank you for the clarification.
thanks,
-liubo
next prev parent reply other threads:[~2018-02-13 0:12 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-05 23:15 [PATCH RFC] Btrfs: expose bad chunks in sysfs Liu Bo
2018-02-06 1:28 ` Qu Wenruo
2018-02-07 22:57 ` Liu Bo
2018-02-08 2:49 ` Qu Wenruo
2018-02-06 9:11 ` Nikolay Borisov
2018-02-12 14:17 ` Liu Bo
2018-02-12 17:39 ` Nikolay Borisov
2018-02-13 0:06 ` Liu Bo [this message]
2018-02-08 9:47 ` Anand Jain
2018-02-12 14:37 ` Liu Bo
2018-02-08 18:52 ` Goffredo Baroncelli
2018-02-08 19:07 ` Liu Bo
2018-02-09 0:23 ` Qu Wenruo
2018-02-09 17:02 ` Goffredo Baroncelli
2018-02-12 15:26 ` Liu Bo
2018-02-09 4:57 ` Darrick J. Wong
2018-02-12 15:23 ` Liu Bo
2018-02-26 17:18 ` David Sterba
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=20180213000631.GB23045@lim.localdomain \
--to=bo.li.liu@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.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;
as well as URLs for NNTP newsgroup(s).