* [PATCH v2] Don't report uninit extents past EOF invalid
@ 2013-08-14 18:30 Eric Whitney
2013-09-09 14:53 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Eric Whitney @ 2013-08-14 18:30 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso
Commit d3f32c2db8 introduced a regression that caused e2fsck failures
in xfstests generic 013, 070, 083, 091, and 263. Uninitialized
extents created by fallocate() at the end of file with the
FALLOC_FL_KEEP_SIZE flag were identified as invalid. However,
because the file size is not increased when FALLOC_FL_KEEP_SIZE is
used, uninitialized extents can correctly contain blocks located past
the end of file.
Fix this by filtering out possible invalid extents if they are
uninitialized and extend past the block containing the end of file.
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
---
e2fsck/pass1.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index ba6025b..6344d81 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1849,6 +1849,7 @@ void e2fsck_clear_inode(e2fsck_t ctx, ext2_ino_t ino,
static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
struct process_block_struct *pb,
blk64_t start_block, blk64_t end_block,
+ blk64_t eof_block,
ext2_extent_handle_t ehandle)
{
struct ext2fs_extent extent;
@@ -1892,7 +1893,9 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
problem = PR_1_EXTENT_BAD_START_BLK;
else if (extent.e_lblk < start_block)
problem = PR_1_OUT_OF_ORDER_EXTENTS;
- else if (end_block && last_lblk > end_block)
+ else if ((end_block && last_lblk > end_block) &&
+ (!(extent.e_flags & EXT2_EXTENT_FLAGS_UNINIT &&
+ last_lblk > eof_block)))
problem = PR_1_EXTENT_END_OUT_OF_BOUNDS;
else if (is_leaf && extent.e_len == 0)
problem = PR_1_EXTENT_LENGTH_ZERO;
@@ -1968,7 +1971,7 @@ fix_problem_now:
ext2fs_extent_fix_parents(ehandle);
}
scan_extent_node(ctx, pctx, pb, extent.e_lblk,
- last_lblk, ehandle);
+ last_lblk, eof_block, ehandle);
if (pctx->errcode)
return;
pctx->errcode = ext2fs_extent_get(ehandle,
@@ -2071,6 +2074,7 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
ext2_filsys fs = ctx->fs;
ext2_ino_t ino = pctx->ino;
errcode_t retval;
+ blk64_t eof_lblk;
pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
if (pctx->errcode) {
@@ -2088,7 +2092,9 @@ static void check_blocks_extents(e2fsck_t ctx, struct problem_context *pctx,
ctx->extent_depth_count[info.max_depth]++;
}
- scan_extent_node(ctx, pctx, pb, 0, 0, ehandle);
+ eof_lblk = ((EXT2_I_SIZE(inode) + fs->blocksize - 1) >>
+ EXT2_BLOCK_SIZE_BITS(fs->super)) - 1;
+ scan_extent_node(ctx, pctx, pb, 0, 0, eof_lblk, ehandle);
if (pctx->errcode &&
fix_problem(ctx, PR_1_EXTENT_ITERATE_FAILURE, pctx)) {
pb->num_blocks = 0;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] Don't report uninit extents past EOF invalid
2013-08-14 18:30 [PATCH v2] Don't report uninit extents past EOF invalid Eric Whitney
@ 2013-09-09 14:53 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2013-09-09 14:53 UTC (permalink / raw)
To: Eric Whitney; +Cc: linux-ext4
On Wed, Aug 14, 2013 at 02:30:07PM -0400, Eric Whitney wrote:
> Commit d3f32c2db8 introduced a regression that caused e2fsck failures
> in xfstests generic 013, 070, 083, 091, and 263. Uninitialized
> extents created by fallocate() at the end of file with the
> FALLOC_FL_KEEP_SIZE flag were identified as invalid. However,
> because the file size is not increased when FALLOC_FL_KEEP_SIZE is
> used, uninitialized extents can correctly contain blocks located past
> the end of file.
>
> Fix this by filtering out possible invalid extents if they are
> uninitialized and extend past the block containing the end of file.
>
> Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Applied, thanks.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-09 14:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-14 18:30 [PATCH v2] Don't report uninit extents past EOF invalid Eric Whitney
2013-09-09 14:53 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).