Skip to contentSkip to conversation

libext2fs: fix parents when modifying extents

PATCH Applied Andreas Dilger 3 participants 9 messages Nov 14, 2015 – Nov 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 libext2fs: fix parents when modifying extents

From: Darrick J. Wong <[email protected]>

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.

Change-Id I0fb7af2f6e88c84ef2e4656e2116a4721d57fd45
---
 lib/ext2fs/extent.c |   30 ++++++++++++++++++++++++------
 lib/ext2fs/punch.c  |   14 ++++++++++----
 2 files changed, 34 insertions(+), 10 deletions(-)
lib/ext2fs/extent.c +24 -6
index c12bc93..d3d5445 100644
@@ -734,7 +734,14 @@ errcode_t ext2fs_extent_goto(ext2_extent_handle_t handle,
  * and so on.
  *
  * Safe to call for any position in node; if not at the first entry,
- * will  simply return.
+ * it will simply return.
+ *
+ * Note a subtlety of this function -- if there happen to be two extents
+ * mapping the same lblk and someone calls fix_parents on the second of the two
+ * extents, the position of the extent handle after the call will be the second
+ * extent if nothing happened, or the first extent if something did.  A caller
+ * in this situation must use ext2fs_extent_goto() after calling this function.
+ * Or simply don't map the same lblk with two extents, ever.
  */
 errcode_t ext2fs_extent_fix_parents(ext2_extent_handle_t handle)
 {
@@ -1424,17 +1431,25 @@ errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle,
 							       &next_extent);
 				if (retval)
 					goto done;
-				retval = ext2fs_extent_fix_parents(handle);
-				if (retval)
-					goto done;
 			} else
 				retval = ext2fs_extent_insert(handle,
 				      EXT2_EXTENT_INSERT_AFTER, &newextent);
 			if (retval)
 				goto done;
-			/* Now pointing at inserted extent; move back to prev */
+			retval = ext2fs_extent_fix_parents(handle);
+			if (retval)
+				goto done;
+			/*
+			 * Now pointing at inserted extent; move back to prev.
+			 *
+			 * We cannot use EXT2_EXTENT_PREV to go back; note the
+			 * subtlety in the comment for fix_parents().
+			 */
+			retval = ext2fs_extent_goto(handle, logical);
+			if (retval)
+				goto done;
 			retval = ext2fs_extent_get(handle,
-						   EXT2_EXTENT_PREV_LEAF,
+						   EXT2_EXTENT_CURRENT,
 						   &extent);
 			if (retval)
 				goto done;
@@ -1467,6 +1482,9 @@ errcode_t ext2fs_extent_set_bmap(ext2_extent_handle_t handle,
 							      0, &newextent);
 			if (retval)
 				goto done;
+			retval = ext2fs_extent_fix_parents(handle);
+			if (retval)
+				goto done;
 			retval = ext2fs_extent_get(handle,
 						   EXT2_EXTENT_NEXT_LEAF,
 						   &extent);
lib/ext2fs/punch.c +10 -4
index a3d020e..2a2cf10 100644
@@ -343,10 +343,16 @@ static errcode_t ext2fs_punch_extent(ext2_filsys fs, ext2_ino_t ino,
 					EXT2_EXTENT_INSERT_AFTER, &newex);
 			if (retval)
 				goto errout;
-			/* Now pointing at inserted extent; so go back */
-			retval = ext2fs_extent_get(handle,
-						   EXT2_EXTENT_PREV_LEAF,
-						   &newex);
+			retval = ext2fs_extent_fix_parents(handle);
+			if (retval)
+				goto errout;
+			/*
+			 * Now pointing at inserted extent; so go back.
+			 *
+			 * We cannot use EXT2_EXTENT_PREV to go back; note the
+			 * subtlety in the comment for fix_parents().
+			 */
+			retval = ext2fs_extent_goto(handle, extent.e_lblk);
 			if (retval)
 				goto errout;
 		} 
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH 2/4 LU-7368 e2fsck: skip quota update when interrupted

There is a bug in how e2fsck handles being interrupted by CTRL-C. If CTRL-C is pressed to kill e2fsck rather than e.g. kill -9, then the interrupt handler sets E2F_FLAG_CANCEL in the context but doesn't actually kill the process. Instead, e2fsck_pass1() checks this flag before processing the next inode.

If a filesystem is running in fix mode (e2fsck -fy) is interrupted, and the quota feature is enabled, then the quota file will still be written to disk even though the inode scan was not complete and the quota information is totally inaccurate. Even worse, if the Pass 1 inode and block scan was not finished, then the in-memory block bitmaps (which are used for block allocation during e2fsck) are also invalid, so any blocks allocated to the quota files may corrupt other files if those blocks were actually used.

e2fsck 1.42.13.wc3 (28-Aug-2015)
Pass 1: Checking inodes, blocks, and sizes
^C[QUOTA WARNING] Usage inconsistent for ID 0:

      actual (6455296, 168) != expected (8568832, 231)
  [QUOTA WARNING] Usage inconsistent for ID 695:
      actual (614932320256, 63981) != expected (2102405386240, 176432)

Update quota info for quota type 0? yes

[QUOTA WARNING] Usage inconsistent for ID 0:

      actual (6455296, 168) != expected (8568832, 231)
  [QUOTA WARNING] Usage inconsistent for ID 538:
      actual (614932320256, 63981) != expected (2102405386240, 176432)

Update quota info for quota type 1? yes

myth-OST0001: e2fsck canceled.
myth-OST0001: ***** FILE SYSTEM WAS MODIFIED *****

There may be a desire to flush out modified inodes and such that have been repaired, so that restarting an interrupted e2fsck will make progress, but the quota file update is plain wrong unless at least pass1 has finished, and the journal recreation is also dangerous if the block bitmaps have not been fully updated.

---
 e2fsck/e2fsck.c |    2 --
 e2fsck/e2fsck.h |    4 ++--
 e2fsck/pass1.c  |    4 +++-
 e2fsck/pass2.c  |   10 +++++-----
 e2fsck/unix.c   |   18 ++++++++++--------
 5 files changed, 20 insertions(+), 18 deletions(-)
e2fsck/e2fsck.c +0 -2
index 0ec1540..2002dc0 100644
@@ -203,8 +203,6 @@ static pass_t e2fsck_passes[] = {
 	e2fsck_pass1, e2fsck_pass2, e2fsck_pass3, e2fsck_pass4,
 	e2fsck_pass5, 0 };
 
-#define E2F_FLAG_RUN_RETURN	(E2F_FLAG_SIGNAL_MASK|E2F_FLAG_RESTART)
-
 int e2fsck_run(e2fsck_t ctx)
 {
 	int	i;
e2fsck/e2fsck.h +2 -2
index f904026..810030e 100644
@@ -173,10 +173,10 @@ struct resource_track {
  */
 #define E2F_FLAG_ABORT		0x0001 /* Abort signaled */
 #define E2F_FLAG_CANCEL		0x0002 /* Cancel signaled */
-#define E2F_FLAG_SIGNAL_MASK	0x0003
+#define E2F_FLAG_SIGNAL_MASK	(E2F_FLAG_ABORT | E2F_FLAG_CANCEL)
 #define E2F_FLAG_RESTART	0x0004 /* Restart signaled */
+#define E2F_FLAG_RUN_RETURN	(E2F_FLAG_SIGNAL_MASK | E2F_FLAG_RESTART)
 #define E2F_FLAG_RESTART_LATER	0x0008 /* Restart after all iterations done */
-
 #define E2F_FLAG_SETJMP_OK	0x0010 /* Setjmp valid for abort */
 
 #define E2F_FLAG_PROG_BAR	0x0020 /* Progress bar on screen */
e2fsck/pass1.c +3 -1
index 50a8b99..1c2b8fd 100644
@@ -766,7 +766,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 							  inode, inode_size);
 		ehandler_operation(old_op);
 		if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-			return;
+			goto endit;
 		if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) {
 			if (!ctx->inode_bb_map)
 				alloc_bb_map(ctx);
@@ -1276,6 +1276,8 @@ endit:
 
 	if ((ctx->flags & E2F_FLAG_SIGNAL_MASK) == 0)
 		print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
+	else
+		ctx->invalid_bitmaps++;
 }
 
 /*
e2fsck/pass2.c +5 -5
index 2b7bff4..822eee4 100644
@@ -148,14 +148,14 @@ void e2fsck_pass2(e2fsck_t ctx)
 
 	cd.pctx.errcode = ext2fs_dblist_iterate2(fs->dblist, check_dir_block,
 						 &cd);
-	if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
-		return;
-
 	if (ctx->flags & E2F_FLAG_RESTART_LATER) {
 		ctx->flags |= E2F_FLAG_RESTART;
-		return;
+		ctx->flags &= ~E2F_FLAG_RESTART_LATER;
 	}
 
+	if (ctx->flags & E2F_FLAG_RUN_RETURN)
+		return;
+
 	if (cd.pctx.errcode) {
 		fix_problem(ctx, PR_2_DBLIST_ITERATE, &cd.pctx);
 		ctx->flags |= E2F_FLAG_ABORT;
@@ -739,7 +739,7 @@ static int check_dir_block(ext2_filsys fs,
 	buf = cd->buf;
 	ctx = cd->ctx;
 
-	if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
+	if (ctx->flags & E2F_FLAG_RUN_RETURN)
 		return DIRENT_ABORT;
 
 	if (ctx->progress && (ctx->progress)(ctx, 2, cd->count++, cd->max))
e2fsck/unix.c +10 -8
index 66debcd..6d87f50 100644
@@ -1667,8 +1667,15 @@ print_unsupp_features:
 	}
 no_journal:
 
-	if (ctx->qctx) {
+	if (run_result & E2F_FLAG_ABORT) {
+		fatal_error(ctx, _("aborted"));
+	} else if (run_result & E2F_FLAG_CANCEL) {
+		log_out(ctx, _("%s: e2fsck canceled.\n"), ctx->device_name ?
+			ctx->device_name : ctx->filesystem_name);
+		exit_value |= FSCK_CANCELED;
+	} else if (ctx->qctx && !ctx->invalid_bitmaps) {
 		int i, needs_writeout;
+
 		for (i = 0; i < MAXQUOTAS; i++) {
 			if (qtype != -1 && qtype != i)
 				continue;
@@ -1695,18 +1702,13 @@ no_journal:
 		ext2fs_close_free(&fs);
 		goto restart;
 	}
-	if (run_result & E2F_FLAG_ABORT)
-		fatal_error(ctx, _("aborted"));
 
 #ifdef MTRACE
 	mtrace_print("Cleanup");
 #endif
 	was_changed = ext2fs_test_changed(fs);
-	if (run_result & E2F_FLAG_CANCEL) {
-		log_out(ctx, _("%s: e2fsck canceled.\n"), ctx->device_name ?
-			ctx->device_name : ctx->filesystem_name);
-		exit_value |= FSCK_CANCELED;
-	} else if (!(ctx->options & E2F_OPT_READONLY)) {
+	if (!(ctx->flags & E2F_FLAG_RUN_RETURN) &&
+	    !(ctx->options & E2F_OPT_READONLY)) {
 		if (ext2fs_test_valid(fs)) {
 			if (!(sb->s_state & EXT2_VALID_FS))
 				exit_value |= FSCK_NONDESTRUCT;
Signature · 1 line
1.7.3.4
#2 lore raw

Re: [PATCH 2/4] LU-7368 e2fsck: skip quota update when interrupted

Quoted 5 lines · Andreas Dilger

There is a bug in how e2fsck handles being interrupted by CTRL-C. If CTRL-C is pressed to kill e2fsck rather than e.g. kill -9, then the interrupt handler sets E2F_FLAG_CANCEL in the context but doesn't actually kill the process. Instead, e2fsck_pass1() checks this flag before processing the next inode.

Sigh, please remove the "LU-7368" label from the summary line, as that is for internal tracking and I thought I'd done that for the patches before sending them out.

If desired, this patch can be linked back to our bug tracker to get a full discussion of the bug as below:

Lustre-change: http://review.whamcloud.com/17150
Lustre-bug-id: https://jira.hpdd.intel.com/browse/LU-7368

For "libext2fs: fix block-mapped file punch" it would be:
Lustre-change: http://review.whamcloud.com/17152
Lustre-bug-id: https://jira.hpdd.intel.com/browse/LU-7381

and for "e2fsck: fix e2fsck -fD directory truncation" it is:
Lustre-change: http://review.whamcloud.com/17153
Lustre-bug-id: https://jira.hpdd.intel.com/browse/LU-7381

Cheers, Andreas

Quoted 170 lines

If a filesystem is running in fix mode (e2fsck -fy) is interrupted, and the quota feature is enabled, then the quota file will still be written to disk even though the inode scan was not complete and the quota information is totally inaccurate. Even worse, if the Pass 1 inode and block scan was not finished, then the in-memory block bitmaps (which are used for block allocation during e2fsck) are also invalid, so any blocks allocated to the quota files may corrupt other files if those blocks were actually used.

e2fsck 1.42.13.wc3 (28-Aug-2015)
Pass 1: Checking inodes, blocks, and sizes
^C[QUOTA WARNING] Usage inconsistent for ID 0:

     actual (6455296, 168) != expected (8568832, 231)
 [QUOTA WARNING] Usage inconsistent for ID 695:
     actual (614932320256, 63981) != expected (2102405386240, 176432)

Update quota info for quota type 0? yes

[QUOTA WARNING] Usage inconsistent for ID 0:

     actual (6455296, 168) != expected (8568832, 231)
 [QUOTA WARNING] Usage inconsistent for ID 538:
     actual (614932320256, 63981) != expected (2102405386240, 176432)

Update quota info for quota type 1? yes

myth-OST0001: e2fsck canceled.
myth-OST0001: ***** FILE SYSTEM WAS MODIFIED *****

There may be a desire to flush out modified inodes and such that have been repaired, so that restarting an interrupted e2fsck will make progress, but the quota file update is plain wrong unless at least pass1 has finished, and the journal recreation is also dangerous if the block bitmaps have not been fully updated.

---

e2fsck/e2fsck.c |    2 --
e2fsck/e2fsck.h |    4 ++--
e2fsck/pass1.c  |    4 +++-
e2fsck/pass2.c  |   10 +++++-----
e2fsck/unix.c   |   18 ++++++++++--------
5 files changed, 20 insertions(+), 18 deletions(-)
e2fsck/e2fsck.c +0 -2
index 0ec1540..2002dc0 100644
@@ -203,8 +203,6 @@ static pass_t e2fsck_passes[] = {
 	e2fsck_pass1, e2fsck_pass2, e2fsck_pass3, e2fsck_pass4,
 	e2fsck_pass5, 0 };
 
-#define E2F_FLAG_RUN_RETURN	(E2F_FLAG_SIGNAL_MASK|E2F_FLAG_RESTART)
-
 int e2fsck_run(e2fsck_t ctx)
 {
 	int	i;
e2fsck/e2fsck.h +2 -2
index f904026..810030e 100644
@@ -173,10 +173,10 @@ struct resource_track {
 */
 #define E2F_FLAG_ABORT		0x0001 /* Abort signaled */
 #define E2F_FLAG_CANCEL		0x0002 /* Cancel signaled */
-#define E2F_FLAG_SIGNAL_MASK	0x0003
+#define E2F_FLAG_SIGNAL_MASK	(E2F_FLAG_ABORT | E2F_FLAG_CANCEL)
 #define E2F_FLAG_RESTART	0x0004 /* Restart signaled */
+#define E2F_FLAG_RUN_RETURN	(E2F_FLAG_SIGNAL_MASK | E2F_FLAG_RESTART)
 #define E2F_FLAG_RESTART_LATER	0x0008 /* Restart after all iterations done */
-
 #define E2F_FLAG_SETJMP_OK	0x0010 /* Setjmp valid for abort */
 
 #define E2F_FLAG_PROG_BAR	0x0020 /* Progress bar on screen */
e2fsck/pass1.c +3 -1
index 50a8b99..1c2b8fd 100644
@@ -766,7 +766,7 @@ void e2fsck_pass1(e2fsck_t ctx)
 							  inode, inode_size);
 		ehandler_operation(old_op);
 		if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-			return;
+			goto endit;
 		if (pctx.errcode == EXT2_ET_BAD_BLOCK_IN_INODE_TABLE) {
 			if (!ctx->inode_bb_map)
 				alloc_bb_map(ctx);
@@ -1276,6 +1276,8 @@ endit:
 
 	if ((ctx->flags & E2F_FLAG_SIGNAL_MASK) == 0)
 		print_resource_track(ctx, _("Pass 1"), &rtrack, ctx->fs->io);
+	else
+		ctx->invalid_bitmaps++;
 }
 
 /*
e2fsck/pass2.c +5 -5
index 2b7bff4..822eee4 100644
@@ -148,14 +148,14 @@ void e2fsck_pass2(e2fsck_t ctx)
 
 	cd.pctx.errcode = ext2fs_dblist_iterate2(fs->dblist, check_dir_block,
 						 &cd);
-	if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
-		return;
-
 	if (ctx->flags & E2F_FLAG_RESTART_LATER) {
 		ctx->flags |= E2F_FLAG_RESTART;
-		return;
+		ctx->flags &= ~E2F_FLAG_RESTART_LATER;
 	}
 
+	if (ctx->flags & E2F_FLAG_RUN_RETURN)
+		return;
+
 	if (cd.pctx.errcode) {
 		fix_problem(ctx, PR_2_DBLIST_ITERATE, &cd.pctx);
 		ctx->flags |= E2F_FLAG_ABORT;
@@ -739,7 +739,7 @@ static int check_dir_block(ext2_filsys fs,
 	buf = cd->buf;
 	ctx = cd->ctx;
 
-	if (ctx->flags & E2F_FLAG_SIGNAL_MASK || ctx->flags & E2F_FLAG_RESTART)
+	if (ctx->flags & E2F_FLAG_RUN_RETURN)
 		return DIRENT_ABORT;
 
 	if (ctx->progress && (ctx->progress)(ctx, 2, cd->count++, cd->max))
e2fsck/unix.c +0 -0
index 66debcd..6d87f50 100644
@@ -1667,8 +1667,15 @@ print_unsupp_features:
 	}

no_journal:

e2fsck/unix.c +7 -1
-	if (ctx->qctx) {
+	if (run_result & E2F_FLAG_ABORT) {
+		fatal_error(ctx, _("aborted"));
+	} else if (run_result & E2F_FLAG_CANCEL) {
+		log_out(ctx, _("%s: e2fsck canceled.\n"), ctx->device_name ?
+			ctx->device_name : ctx->filesystem_name);
+		exit_value |= FSCK_CANCELED;
+	} else if (ctx->qctx && !ctx->invalid_bitmaps) {
		int i, needs_writeout;
+
		for (i = 0; i < MAXQUOTAS; i++) {
			if (qtype != -1 && qtype != i)
				continue;
e2fsck/unix.c +2 -8
@@ -1695,18 +1702,13 @@ no_journal:
 		ext2fs_close_free(&fs);
 		goto restart;
 	}
-	if (run_result & E2F_FLAG_ABORT)
-		fatal_error(ctx, _("aborted"));
 
 #ifdef MTRACE
 	mtrace_print("Cleanup");
 #endif
 	was_changed = ext2fs_test_changed(fs);
-	if (run_result & E2F_FLAG_CANCEL) {
-		log_out(ctx, _("%s: e2fsck canceled.\n"), ctx->device_name ?
-			ctx->device_name : ctx->filesystem_name);
-		exit_value |= FSCK_CANCELED;
-	} else if (!(ctx->options & E2F_OPT_READONLY)) {
+	if (!(ctx->flags & E2F_FLAG_RUN_RETURN) &&
+	    !(ctx->options & E2F_OPT_READONLY)) {
 		if (ext2fs_test_valid(fs)) {
 			if (!(sb->s_state & EXT2_VALID_FS))
 				exit_value |= FSCK_NONDESTRUCT;
--

1.7.3.4

Quoted 4 lines

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

Cheers, Andreas

#4 lore raw

PATCH 3/4 libext2fs: fix block-mapped file punch

In reply to Andreas Dilger

If ext2fs_punch() is called with "end = ~0U" (which is natural from a programming POV) it tries to compute "count" based on "start" and "end", but doesn't quite get it right.

Fix ext2fs_punch() if "end" is anywhere beyond the 2^32 block limit so that the 32-bit calculations don't overflow. Pass "count=~0" in this case, and also handle that explicitly in ext2_punch_ind(). Since ext2_punch_ind() is itself a public function, so it makes sense to fix this in both places.

---
 lib/ext2fs/punch.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
lib/ext2fs/punch.c +13 -5
index 2a2cf10..0c954c1 100644
@@ -119,6 +119,9 @@ static errcode_t ext2fs_punch_ind(ext2_filsys fs, struct ext2_inode *inode,
 	}
 
 	addr_per_block = (blk_t) fs->blocksize >> 2;
+	/* make sure that count + start doesn't overflow a 32-bit value */
+	if (count == ~0U)
+		count = ~0U - start;
 
 	for (level = 0; level < 4; level++, max *= (blk64_t)addr_per_block) {
 #ifdef PUNCH_DEBUG
@@ -458,14 +461,19 @@ errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
 
 		if (start > ~0U)
 			return 0;
-		if (end > ~0U)
-			end = ~0U;
-		count = ((end - start + 1) < ~0U) ? (end - start + 1) : ~0U;
-		retval = ext2fs_punch_ind(fs, inode, block_buf, 
-					  (blk_t) start, count);
+		if (end >= ~0U || end - start + 1 >= ~0U)
+			count = ~0U;
+		else
+			count = end - start + 1;
+		retval = ext2fs_punch_ind(fs, inode, block_buf,
+					  (blk_t)start, count);
 	}
 	if (retval)
 		return retval;
 
+#ifdef PUNCH_DEBUG
+	printf("%u: write inode size now %u blocks %u\n",
+		ino, inode->i_size, inode->i_blocks);
+#endif
 	return ext2fs_write_inode(fs, ino, inode);
 }
Signature · 1 line
1.7.3.4
#5 lore raw

Re: [PATCH 3/4] libext2fs: fix block-mapped file punch

Quoted 3 lines · Andreas Dilger

If ext2fs_punch() is called with "end = ~0U" (which is natural from a programming POV) it tries to compute "count" based on "start" and "end", but doesn't quite get it right.

You should make clear that this only applies in the case where we are punching on an indirect block mapped file. I read this and alarm bells started going off since end is a blk64_t, and we can't do this for extent-mapped files.

Quoted 4 lines

Pass "count=~0"
in this case, and also handle that explicitly in ext2_punch_ind(). Since ext2_punch_ind() is itself a public function, so it makes sense to fix this in both places.

Um, ext2fs_punch()_ind is *not* a public function.

- Ted

#6 lore raw

Re: [PATCH 3/4] libext2fs: fix block-mapped file punch

In reply to Andreas Dilger
Quoted 3 lines · Andreas Dilger

If ext2fs_punch() is called with "end = ~0U" (which is natural from a programming POV) it tries to compute "count" based on "start" and "end", but doesn't quite get it right.

I don't object to ext2fs_punch handling 32-bit overflows correctly if it is being called on an indirect mapped file (where the logical block numbers are limited to 2**32). But it would be good if the patch description actually said that. Also, arguably this is still a bug in the caller, which should use ~0ULL to mean the end of the file.

Quoted 5 lines

Fix ext2fs_punch() if "end" is anywhere beyond the 2^32 block limit so that the 32-bit calculations don't overflow. Pass "count=~0" in this case, and also handle that explicitly in ext2_punch_ind(). Since ext2_punch_ind() is itself a public function, so it makes sense to fix this in both places.

Um, ext2_punch_ind() is a static function....

Review static errcode_t ext2fs_punch_ind(ext2_filsys fs, struct ext2_inode *inode,

Quoted 1 line
(quoted diff) +0 -0
@@ -119,6 +119,9 @@ static errcode_t ext2fs_punch_ind(ext2_filsys fs, struct ext2_inode *inode,

Cheers,

- Ted

#7 lore raw

PATCH 4/4 e2fsck: fix e2fsck -fD directory truncation

In reply to Andreas Dilger

When an extent-mapped directory is compacted by "e2fsck -fD" and frees enough leaf blocks that it loses an extent tree index block, the old e2fsck_rehash_dir->ext2fs_block_iterate3->write_dir_block() code would not free the extent block, which would result in the extent tree becoming corrupted when it is written out.

Pass 1: Checking inodes, blocks, and sizes
Inode 17825800, end of extent exceeds allowed value
(logical block 710, physical block 570459684, len 1019)

This results in loss of a whole index block of directory leaf blocks and thousands of files in lost+found.

Fix e2fsck_rehash_dir() to call ext2fs_punch() to free the blocks at the end of the directory instead of trying to handle this itself while writing out the directory. That properly handles all of the cases of updating the extent tree as well as accounting for blocks that are released (both leaf blocks and index blocks).

Add a test case for compacting the directory to be smaller than the index block that originally caused the corruption.

---
 e2fsck/rehash.c               |   73 ++++++++++++++++++++++------------------
 tests/f_extent_htree/expect.1 |   29 ++++++++++++++++
 tests/f_extent_htree/expect.2 |    7 ++++
 tests/f_extent_htree/image.gz |  Bin 0 -> 10101 bytes
 tests/f_extent_htree/name     |    1 +
 tests/f_extent_htree/script   |   69 ++++++++++++++++++++++++++++++++++++++
 tests/f_h_badnode/expect.1    |    2 +-
 tests/f_h_badnode/expect.2    |    2 +-
 8 files changed, 148 insertions(+), 35 deletions(-)
 create mode 100644 tests/f_extent_htree/expect.1
 create mode 100644 tests/f_extent_htree/expect.2
 create mode 100644 tests/f_extent_htree/image.gz
 create mode 100644 tests/f_extent_htree/name
 create mode 100644 tests/f_extent_htree/script
e2fsck/rehash.c +40 -33
index 8ff4883..e72ae55 100644
@@ -52,10 +52,13 @@
 #include "e2fsck.h"
 #include "problem.h"
 
+#undef REHASH_DEBUG
+
 struct fill_dir_struct {
 	char *buf;
 	struct ext2_inode *inode;
 	errcode_t err;
+	ext2_ino_t ino;
 	e2fsck_t ctx;
 	struct hash_entry *harray;
 	int max_array, num_array;
@@ -625,8 +628,8 @@ static errcode_t calculate_tree(ext2_filsys fs,
 struct write_dir_struct {
 	struct out_dir *outdir;
 	errcode_t	err;
+	ext2_ino_t	ino;
 	e2fsck_t	ctx;
-	blk64_t		cleared;
 };
 
 /*
@@ -643,28 +646,35 @@ static int write_dir_block(ext2_filsys fs,
 	blk64_t	blk;
 	char	*dir;
 
-	if (*block_nr == 0)
+#ifdef REHASH_DEBUG
+	printf("%u: write_dir_block %lld:%lld", wd->ino, blockcnt, *block_nr);
+#endif
+	if (*block_nr == 0) {
+#ifdef REHASH_DEBUG
+		printf(" - skip\n");
+#endif
 		return 0;
+	}
+	/* Don't free blocks at the end of the directory, they will be
+	 * truncated by the caller. */
 	if (blockcnt >= wd->outdir->num) {
-		e2fsck_read_bitmaps(wd->ctx);
-		blk = *block_nr;
-		/*
-		 * In theory, we only release blocks from the end of the
-		 * directory file, so it's fine to clobber a whole cluster at
-		 * once.
-		 */
-		if (blk % EXT2FS_CLUSTER_RATIO(fs) == 0) {
-			ext2fs_block_alloc_stats2(fs, blk, -1);
-			wd->cleared++;
-		}
-		*block_nr = 0;
-		return BLOCK_CHANGED;
+#ifdef REHASH_DEBUG
+		printf(" - not freed\n");
+#endif
+		return 0;
 	}
-	if (blockcnt < 0)
+	if (blockcnt < 0) {
+#ifdef REHASH_DEBUG
+		printf(" - skip\n");
+#endif
 		return 0;
+	}
 
 	dir = wd->outdir->buf + (blockcnt * fs->blocksize);
 	wd->err = ext2fs_write_dir_block3(fs, *block_nr, dir, 0);
+#ifdef REHASH_DEBUG
+	printf(" - write (%d)\n", wd->err);
+#endif
 	if (wd->err)
 		return BLOCK_ABORT;
 	return 0;
@@ -684,10 +694,10 @@ static errcode_t write_directory(e2fsck_t ctx, ext2_filsys fs,
 
 	wd.outdir = outdir;
 	wd.err = 0;
+	wd.ino = ino;
 	wd.ctx = ctx;
-	wd.cleared = 0;
 
-	retval = ext2fs_block_iterate3(fs, ino, 0, 0,
+	retval = ext2fs_block_iterate3(fs, ino, 0, NULL,
 				       write_dir_block, &wd);
 	if (retval)
 		return retval;
@@ -699,14 +709,18 @@ static errcode_t write_directory(e2fsck_t ctx, ext2_filsys fs,
 		inode.i_flags &= ~EXT2_INDEX_FL;
 	else
 		inode.i_flags |= EXT2_INDEX_FL;
-	retval = ext2fs_inode_size_set(fs, &inode,
-				       outdir->num * fs->blocksize);
+#ifdef REHASH_DEBUG
+	printf("%u: set inode size to %u blocks = %u bytes\n",
+	       ino, outdir->num, outdir->num * fs->blocksize);
+#endif
+	retval = ext2fs_inode_size_set(fs, &inode, (ext2_off64_t)outdir->num *
+						   fs->blocksize);
 	if (retval)
 		return retval;
-	ext2fs_iblk_sub_blocks(fs, &inode, wd.cleared);
-	e2fsck_write_inode(ctx, ino, &inode, "rehash_dir");
 
-	return 0;
+	/* ext2fs_punch() also calls ext2fs_write_inode() */
+	retval = ext2fs_punch(fs, ino, &inode, NULL, outdir->num, ~0ULL);
+	return retval;
 }
 
 errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
@@ -715,32 +729,25 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)
 	errcode_t		retval;
 	struct ext2_inode 	inode;
 	char			*dir_buf = 0;
-	struct fill_dir_struct	fd;
-	struct out_dir		outdir;
+	struct fill_dir_struct	fd = { NULL };
+	struct out_dir		outdir = { 0 };
 
-	outdir.max = outdir.num = 0;
-	outdir.buf = 0;
-	outdir.hashes = 0;
 	e2fsck_read_inode(ctx, ino, &inode, "rehash_dir");
 
 	retval = ENOMEM;
-	fd.harray = 0;
 	dir_buf = malloc(inode.i_size);
 	if (!dir_buf)
 		goto errout;
 
 	fd.max_array = inode.i_size / 32;
-	fd.num_array = 0;
 	fd.harray = malloc(fd.max_array * sizeof(struct hash_entry));
 	if (!fd.harray)
 		goto errout;
 
+	fd.ino = ino;
 	fd.ctx = ctx;
 	fd.buf = dir_buf;
 	fd.inode = &inode;
-	fd.err = 0;
-	fd.dir_size = 0;
-	fd.compress = 0;
 	if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) ||
 	    (inode.i_size / fs->blocksize) < 2)
 		fd.compress = 1;
tests/f_extent_htree/expect.1 new file +29 -0
new file mode 100644
index 0000000..223ca69
@@ -0,0 +1,29 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+
+         352 inodes used (41.12%, out of 856)
+           0 non-contiguous files (0.0%)
+           1 non-contiguous directory (0.3%)
+             # of inodes with ind/dind/tind blocks: 0/0/0
+             Extent depth histogram: 342/1
+         586 blocks used (68.94%, out of 850)
+           0 bad blocks
+           0 large files
+
+         340 regular files
+           3 directories
+           0 character device files
+           0 block device files
+           0 fifos
+           0 links
+           0 symbolic links (0 fast symbolic links)
+           0 sockets
+------------
+         343 files
+Exit status is 1
tests/f_extent_htree/expect.2 new file +7 -0
new file mode 100644
index 0000000..860b491
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 352/856 files (0.3% non-contiguous), 586/850 blocks
+Exit status is 0
tests/f_extent_htree/image.gz new file binary +0 -0
new file mode 100644
index 0000000000000000000000000000000000000000..284207efb12a04136c9f26c33f2197fed97cbd99
GIT binary patch
tests/f_extent_htree/name new file +1 -0
new file mode 100644
index 0000000..fc3812d
@@ -0,0 +1 @@
+htree extent compression
tests/f_extent_htree/script new file +69 -0

69 lines not on this page · raw message

tests/f_h_badnode/expect.1 +1 -1
index ce2adb3..95b1cee 100644
@@ -14,5 +14,5 @@ Pass 4: Checking reference counts
 Pass 5: Checking group summary information
 
 test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
-test_filesys: 47730/100192 files (0.0% non-contiguous), 13551/31745 blocks
+test_filesys: 47730/100192 files (0.0% non-contiguous), 13550/31745 blocks
 Exit status is 1
tests/f_h_badnode/expect.2 +1 -1
index b9dadb7..65985d1 100644
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
-test_filesys: 47730/100192 files (0.0% non-contiguous), 13551/31745 blocks
+test_filesys: 47730/100192 files (0.0% non-contiguous), 13550/31745 blocks
 Exit status is 0
Signature · 1 line
1.7.3.4
#8 lore raw

Re: [PATCH 4/4] e2fsck: fix e2fsck -fD directory truncation

Quoted 10 lines · Andreas Dilger

When an extent-mapped directory is compacted by "e2fsck -fD" and frees enough leaf blocks that it loses an extent tree index block, the old e2fsck_rehash_dir->ext2fs_block_iterate3->write_dir_block() code would not free the extent block, which would result in the extent tree becoming corrupted when it is written out.

Pass 1: Checking inodes, blocks, and sizes Inode 17825800, end of extent exceeds allowed value

           (logical block 710, physical block 570459684, len 1019)
Quoted 8 lines

This results in loss of a whole index block of directory leaf blocks and thousands of files in lost+found.

Fix e2fsck_rehash_dir() to call ext2fs_punch() to free the blocks at the end of the directory instead of trying to handle this itself while writing out the directory. That properly handles all of the cases of updating the extent tree as well as accounting for blocks that are released (both leaf blocks and index blocks).

There were a couple of bugs in the ext2fs_punch() code that also had to be fixed (see previous patches).

One patch is from Darrick on master, so you may prefer to just cherry-pick it directly. I didn't actually hit the problem it was fixing in my tests, but it seemed plausible and looked useful for the maint branch.

The second one fixes some existing bugs in the punch code for indirect block filesystems, which I hit in a few other tests (f_dir_optimize, f_dup_de, and others that are optimizing directories).

Quoted 2 lines

Add a test case for compacting the directory to be smaller than the index block that originally caused the corruption.

The test case for this patch was created using the supplied script, but depends on "mke2fs -d $root_dir" working, which doesn't exist on the maint branch. For maint I've included the resulting image.gz file (only about 10KB compressed) and a stub script file that just runs "e2fsck -fvyD" against it.

For merge into master, the test f_extent_htree script should be edited to remove the leading stub, and can generate the test filesystem itself (which also tests the "mke2fs -d" functionality and takes less space, but takes a couple more seconds to run).

Cheers, Andreas

Quoted 502 lines

---
e2fsck/rehash.c | 73
++++++++++++++++++++++------------------

tests/f_extent_htree/expect.1 |   29 ++++++++++++++++
tests/f_extent_htree/expect.2 |    7 ++++
tests/f_extent_htree/image.gz |  Bin 0 -> 10101 bytes
tests/f_extent_htree/name     |    1 +
tests/f_extent_htree/script   |   69
++++++++++++++++++++++++++++++++++++++
tests/f_h_badnode/expect.1    |    2 +-
tests/f_h_badnode/expect.2    |    2 +-
8 files changed, 148 insertions(+), 35 deletions(-)

create mode 100644 tests/f_extent_htree/expect.1
create mode 100644 tests/f_extent_htree/expect.2
create mode 100644 tests/f_extent_htree/image.gz
create mode 100644 tests/f_extent_htree/name
create mode 100644 tests/f_extent_htree/script

e2fsck/rehash.c +28 -18
index 8ff4883..e72ae55 100644
@@ -52,10 +52,13 @@
 #include "e2fsck.h"
 #include "problem.h"
 
+#undef REHASH_DEBUG
+
 struct fill_dir_struct {
 	char *buf;
 	struct ext2_inode *inode;
 	errcode_t err;
+	ext2_ino_t ino;
 	e2fsck_t ctx;
 	struct hash_entry *harray;
 	int max_array, num_array;
@@ -625,8 +628,8 @@ static errcode_t calculate_tree(ext2_filsys fs,
 struct write_dir_struct {
 	struct out_dir *outdir;
 	errcode_t	err;
+	ext2_ino_t	ino;
 	e2fsck_t	ctx;
-	blk64_t		cleared;
 };
 
 /*
@@ -643,28 +646,35 @@ static int write_dir_block(ext2_filsys fs,
 	blk64_t	blk;
 	char	*dir;
 
-	if (*block_nr == 0)
+#ifdef REHASH_DEBUG
+	printf("%u: write_dir_block %lld:%lld", wd->ino, blockcnt, *block_nr);
+#endif
+	if (*block_nr == 0) {
+#ifdef REHASH_DEBUG
+		printf(" - skip\n");
+#endif
 		return 0;
+	}
+	/* Don't free blocks at the end of the directory, they will be
+	 * truncated by the caller. */
 	if (blockcnt >= wd->outdir->num) {
-		e2fsck_read_bitmaps(wd->ctx);
-		blk = *block_nr;
-		/*
-		 * In theory, we only release blocks from the end of the
-		 * directory file, so it's fine to clobber a whole cluster at
-		 * once.
-		 */
-		if (blk % EXT2FS_CLUSTER_RATIO(fs) == 0) {
-			ext2fs_block_alloc_stats2(fs, blk, -1);
-			wd->cleared++;
-		}
-		*block_nr = 0;
-		return BLOCK_CHANGED;
+#ifdef REHASH_DEBUG
+		printf(" - not freed\n");
+#endif
+		return 0;
 	}
-	if (blockcnt < 0)
+	if (blockcnt < 0) {
+#ifdef REHASH_DEBUG
+		printf(" - skip\n");
+#endif
 		return 0;
+	}
 
 	dir = wd->outdir->buf + (blockcnt * fs->blocksize);
 	wd->err = ext2fs_write_dir_block3(fs, *block_nr, dir, 0);
+#ifdef REHASH_DEBUG
+	printf(" - write (%d)\n", wd->err);
+#endif
 	if (wd->err)
 		return BLOCK_ABORT;
 	return 0;
@@ -684,10 +694,10 @@ static errcode_t write_directory(e2fsck_t ctx,
 ext2_filsys fs,
 
 	wd.outdir = outdir;
 	wd.err = 0;
+	wd.ino = ino;
 	wd.ctx = ctx;
-	wd.cleared = 0;
 
-	retval = ext2fs_block_iterate3(fs, ino, 0, 0,
+	retval = ext2fs_block_iterate3(fs, ino, 0, NULL,
 				       write_dir_block, &wd);
 	if (retval)
		return retval;
e2fsck/rehash.c +9 -5
@@ -699,14 +709,18 @@ static errcode_t write_directory(e2fsck_t ctx,
 ext2_filsys fs,
 		inode.i_flags &= ~EXT2_INDEX_FL;
 	else
 		inode.i_flags |= EXT2_INDEX_FL;
-	retval = ext2fs_inode_size_set(fs, &inode,
-				       outdir->num * fs->blocksize);
+#ifdef REHASH_DEBUG
+	printf("%u: set inode size to %u blocks = %u bytes\n",
+	       ino, outdir->num, outdir->num * fs->blocksize);
+#endif
+	retval = ext2fs_inode_size_set(fs, &inode, (ext2_off64_t)outdir->num *
+						   fs->blocksize);
 	if (retval)
 		return retval;
-	ext2fs_iblk_sub_blocks(fs, &inode, wd.cleared);
-	e2fsck_write_inode(ctx, ino, &inode, "rehash_dir");
 
-	return 0;
+	/* ext2fs_punch() also calls ext2fs_write_inode() */
+	retval = ext2fs_punch(fs, ino, &inode, NULL, outdir->num, ~0ULL);
+	return retval;
 }
 

errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino)

e2fsck/rehash.c +3 -10
@@ -715,32 +729,25 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx,
 ext2_ino_t ino)
 	errcode_t		retval;
 	struct ext2_inode 	inode;
 	char			*dir_buf = 0;
-	struct fill_dir_struct	fd;
-	struct out_dir		outdir;
+	struct fill_dir_struct	fd = { NULL };
+	struct out_dir		outdir = { 0 };
 
-	outdir.max = outdir.num = 0;
-	outdir.buf = 0;
-	outdir.hashes = 0;
 	e2fsck_read_inode(ctx, ino, &inode, "rehash_dir");
 
 	retval = ENOMEM;
-	fd.harray = 0;
 	dir_buf = malloc(inode.i_size);
 	if (!dir_buf)
 		goto errout;
 
 	fd.max_array = inode.i_size / 32;
-	fd.num_array = 0;
 	fd.harray = malloc(fd.max_array * sizeof(struct hash_entry));
 	if (!fd.harray)
 		goto errout;
 
+	fd.ino = ino;
 	fd.ctx = ctx;
 	fd.buf = dir_buf;
 	fd.inode = &inode;
-	fd.err = 0;
-	fd.dir_size = 0;
-	fd.compress = 0;
 	if (!(fs->super->s_feature_compat & EXT2_FEATURE_COMPAT_DIR_INDEX) ||
 	    (inode.i_size / fs->blocksize) < 2)
		fd.compress = 1;
tests/f_extent_htree/expect.1 new file +29 -0
new file mode 100644
index 0000000..223ca69
@@ -0,0 +1,29 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 3A: Optimizing directories
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+
+test_filesys: ***** FILE SYSTEM WAS MODIFIED *****
+
+         352 inodes used (41.12%, out of 856)
+           0 non-contiguous files (0.0%)
+           1 non-contiguous directory (0.3%)
+             # of inodes with ind/dind/tind blocks: 0/0/0
+             Extent depth histogram: 342/1
+         586 blocks used (68.94%, out of 850)
+           0 bad blocks
+           0 large files
+
+         340 regular files
+           3 directories
+           0 character device files
+           0 block device files
+           0 fifos
+           0 links
+           0 symbolic links (0 fast symbolic links)
+           0 sockets
+------------
+         343 files
+Exit status is 1
tests/f_extent_htree/expect.2 new file +7 -0
new file mode 100644
index 0000000..860b491
@@ -0,0 +1,7 @@
+Pass 1: Checking inodes, blocks, and sizes
+Pass 2: Checking directory structure
+Pass 3: Checking directory connectivity
+Pass 4: Checking reference counts
+Pass 5: Checking group summary information
+test_filesys: 352/856 files (0.3% non-contiguous), 586/850 blocks
+Exit status is 0
tests/f_extent_htree/image.gz new file +0 -0
new file mode 100644
index 

0000000000000000000000000000000000000000..284207efb12a04136c9f26c33f2197fe d97cbd99
GIT binary patch
literal 10101 zcmbVRcR&-_*G2ugao1I>sGtd=t_{Tk0vd=2tZkLGA{HVFBBEd@5)3f9xS~Le*ib34 zV<jtyNC{&jumXvQ5CuY%paBCJLx4%0_dQra{P*(@Gs&BI^WMGZoO|wrk}zb*MN`+! z0|x~h@bUMXvv6-%h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jDJPQS{EWV&Oa{3RqHFZgJ?cq*i)T96XKmLw; S1hD`^CoQ(LFj+Co<o^JlLF&8!

literal 0
HcmV?d00001

tests/f_extent_htree/name new file +1 -0
new file mode 100644
index 0000000..fc3812d
@@ -0,0 +1 @@
+htree extent compression
tests/f_extent_htree/script new file +7 -0
new file mode 100644
index 0000000..60854c6
@@ -0,0 +1,69 @@
+#!/bin/bash
+
+FSCK_OPT="-fyvD"
+. $cmd_dir/run_e2fsck
+
+exit $?
+# This script depends on "mke2fs -d", which is only in master and not

maint,

tests/f_extent_htree/script new file +22 -0
+# to populate the file directory tree poorly (namely that there are no
+# contiguous blocks in the directory leaf and the extent tree is large).
+
+# Once the "mke2fs -d" option is available on the "maint" branch, the
+# above few lines should be deleted, along with the "image.gz" file.
+
+TMPDIR=${TMPDIR:-"/tmp"}
+OUT=$test_name.log
+
+FSCK_OPT="-fyvD"
+SKIP_GUNZIP="true"
+
+NAMELEN=250
+SRC=$TMPDIR/$test_name.tmp
+SUB=subdir
+BASE=$SRC/$SUB/$(yes | tr -d '\n' | dd bs=$NAMELEN count=1 2> /dev/null)
+TMPFILE=${TMPFILE:-"$TMPDIR/image"}
+BSIZE=1024
+
+> $OUT
+mkdir -p $SRC/$SUB
+# calculate the number of files needed to create the directory extent

tree

tests/f_extent_htree/script new file +13 -0
+# deep enough to exceed the in-inode index and spill into an index block.
+#
+# dirents per block * extents per block * (index blocks > i_blocks)
+NUM=$(((BSIZE / (NAMELEN + 8)) * (BSIZE / 12) * 2))
+# Create source files. Unfortunately hard links will be copied as links,
+# and blocks with only NULs will be turned into holes.
+if [ ! -f $BASE.1 ]; then
+	for N in $(seq $NUM); do
+		echo "foo" > $BASE.$N
+	done >> $OUT
+fi
+
+# make filesystem with enough inodes and blocks to hold all the test

files
+> $TMPFILE

tests/f_extent_htree/script new file +2 -0
+NUM=$((NUM * 5 / 3))
+echo "mke2fs -b $BSIZE -O dir_index,extent -d$SRC -N$NUM $TMPFILE $NUM"
Quoted 1 line
Quoted 1 line

$OUT

+$MKE2FS -b $BSIZE -O dir_index,extent -d$SRC -N$NUM $TMPFILE $NUM >> $OUT 2>&1

tests/f_extent_htree/script new file +4 -0
+rm -r $SRC
+
+# Run e2fsck to convert dir to htree before deleting the files, as mke2fs
+# doesn't do this.  Run second e2fsck to verify there is no corruption

yet.

tests/f_extent_htree/script new file +10 -0
+(
+	EXP1=$test_dir/expect.pre.1
+	EXP2=$test_dir/expect.pre.2
+	OUT1=$test_name.pre.1.log
+	OUT2=$test_name.pre.2.log
+	DESCRIPTION="$(cat $test_dir/name) setup"
+	. $cmd_dir/run_e2fsck
+)
+
+# generate a list of filenames for debugfs to delete, one from each leaf

block

tests/f_extent_htree/script new file +9 -0
+DELETE_LIST=$TMPDIR/delete.$$
+$DEBUGFS -c -R "htree subdir" $TMPFILE 2>> $OUT |
+	grep -A2 "Reading directory block" |
+	awk '/yyyyy/ { print "rm '$SUB'/"$4 }' > $DELETE_LIST
+$DEBUGFS -w -f $DELETE_LIST $TMPFILE >> $OUT 2>&1
+rm $DELETE_LIST
+cp $TMPFILE $TMPFILE.sav
+
+. $cmd_dir/run_e2fsck
tests/f_h_badnode/expect.1 +0 -0
index ce2adb3..95b1cee 100644
@@ -14,5 +14,5 @@ Pass 4: Checking reference counts

Pass 5: Checking group summary information

test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** -test_filesys: 47730/100192 files (0.0% non-contiguous), 13551/31745 blocks
+test_filesys: 47730/100192 files (0.0% non-contiguous), 13550/31745 blocks
Exit status is 1

tests/f_h_badnode/expect.2 +0 -0
index b9dadb7..65985d1 100644
@@ -3,5 +3,5 @@ Pass 2: Checking directory structure
Quoted 12 lines

Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
-test_filesys: 47730/100192 files (0.0% non-contiguous), 13551/31745 blocks
+test_filesys: 47730/100192 files (0.0% non-contiguous), 13550/31745 blocks
Exit status is 0

Signature · 1 line
1.7.3.4

Cheers, Andreas

Signature · 4 lines
Andreas Dilger

Lustre Principal Architect
Intel High Performance Data Division