From: Liu Bo <bo.li.liu@oracle.com>
To: dsterba@suse.cz
Cc: linux-btrfs@vger.kernel.org, Chris Mason <clm@fb.com>
Subject: Re: [PATCH] Btrfs: memset to avoid stale content in btree leaf
Date: Mon, 26 Sep 2016 11:07:35 -0700 [thread overview]
Message-ID: <20160926180735.GA23858@localhost.localdomain> (raw)
In-Reply-To: <20160926165444.GD16983@twin.jikos.cz>
On Mon, Sep 26, 2016 at 06:54:44PM +0200, David Sterba wrote:
> On Fri, Sep 23, 2016 at 01:44:44PM -0700, Liu Bo wrote:
> > @@ -3732,15 +3734,21 @@ static noinline_for_stack int write_one_eb(struct extent_buffer *eb,
> > if (btrfs_header_owner(eb) == BTRFS_TREE_LOG_OBJECTID)
> > bio_flags = EXTENT_BIO_TREE_LOG;
> >
> > - /* set btree node beyond nritems with 0 to avoid stale content */
> > + /* set btree blocks beyond nritems with 0 to avoid stale content. */
> > + nritems = btrfs_header_nritems(eb);
> > if (btrfs_header_level(eb) > 0) {
> > - u32 nritems;
> > - unsigned long end;
> > -
> > - nritems = btrfs_header_nritems(eb);
> > end = btrfs_node_key_ptr_offset(nritems);
> >
> > memset_extent_buffer(eb, 0, end, eb->len - end);
> > + } else {
> > + /*
> > + * leaf:
> > + * header 0 1 2 .. N ... data_N .. data_2 data_1 data_0
> > + */
> > + start = btrfs_item_nr_offset(nritems);
>
> So, AFAICS this also works for empty root nodes (nritems == 0). It's
> hidden in leaf_data_end that actually looks at nritems and decides.
>
> Reviewed-by: David Sterba <dsterba@suse.com>
Yeah, you're right, case (nritems == 0) has already been taken care in this patch.
Thanks a lot for reviewing it.
Thanks,
-liubo
>
> > + end = btrfs_leaf_data(eb) +
> > + leaf_data_end(fs_info->tree_root, eb);
> > + memset_extent_buffer(eb, 0, start, end - start);
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2016-09-26 18:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 20:44 [PATCH] Btrfs: memset to avoid stale content in btree leaf Liu Bo
2016-09-26 16:54 ` David Sterba
2016-09-26 18:07 ` Liu Bo [this message]
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=20160926180735.GA23858@localhost.localdomain \
--to=bo.li.liu@oracle.com \
--cc=clm@fb.com \
--cc=dsterba@suse.cz \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.