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 <dste...@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 majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to