Whamcloud - gitweb
libext2fs: fix parents when modifying extents 51/17151/4
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 15 Mar 2014 15:36:34 +0000 (11:36 -0400)
committerAndreas Dilger <andreas.dilger@intel.com>
Wed, 9 Dec 2015 19:49:29 +0000 (19:49 +0000)
commit447dfab1d0029829f3c4909fc174c172a2f9857a
tree64617946445d742771bda78236116158490ebfa3
parent709edd7febe7831c01c406cc1552b7c288502a8b
libext2fs: fix parents when modifying extents

In ext2fs_extent_set_bmap() and ext2fs_punch_extent(), fix the parents
when altering either end of an extent so that the parent nodes reflect
the added mapping.

There's a slight complication to using fix_parents: if there are two
mappings to an lblk in the tree, the value of handle->path->curr can
point to either extent afterwards), which is documented in a comment.

Some additional color commentary from Darrick:

  In the _set_bmap() case, I noticed that the "remapping last block
  in extent" case would produce symptoms if we are trying to remap a
  block from "extent" to "next_extent", and the two extents are
  pointed to by different index nodes.  _extent_replace(...,
  next_extent) updates e_lblk in the leaf extent, but because there's
  no _extent_fix_parents() call, the index nodes never get updated.

  In the _punch_extent() case, we conclude that we need to split an
  extent into two pieces since we're punching out the middle.  If the
  extent is the last extent in the block, the second extent will be
  inserted into a new leaf node block.  Without _fix_parents(), the
  index node doesn't seem to get updated.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Change-Id: I0fb7af2f6e88c84ef2e4656e2116a4721d57fd45
Reviewed-on: http://review.whamcloud.com/17151
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lib/ext2fs/extent.c
lib/ext2fs/punch.c