[PATCH V2] libext2fs: reset handle after inserting new extent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 53422e8a5644e22ea3f6e0efba82a765b72e4308 moved
the new extent insertion in ext2fs_extent_set_bmap prior
to the modification of the original extent, but the
insert function left the handle pointing a the new
extent; this left us modifying the -new- extent not
the original one, and winding up with a corrupt extent
tree something like:

BLOCKS:
(0-1):588791-588792, (0):588791

We need to move back to the previous extent prior
to modification, if we inserted a new one.

V2: Use extent_goto vs. extent_get.

Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>
---

diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index 35b080e..4a4fd2c 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -1257,6 +1257,10 @@ again:
 					EXT2_EXTENT_INSERT_AFTER, &newextent);
 			if (retval)
 				goto done;
+			/* Now pointing at inserted extent; move back to prev */
+			retval = ext2fs_extent_goto(handle, logical - 1);
+			if (retval)
+				goto done;
 		}
 		extent.e_len--;
 		retval = ext2fs_extent_replace(handle, 0, &extent);

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux