From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 1/5] e2fsck: detect holes in extent-mapped directories
Date: Sun, 29 Nov 2009 15:33:25 -0500 [thread overview]
Message-ID: <1259526809-23697-1-git-send-email-tytso@mit.edu> (raw)
Directories are not allowed to be sparse; the code for scanning
extent-mapped directories was not calling ext2fs_add_dir_block() for
missing directory blocks, so we weren't catching this form of file
system corruption. Fix this.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
e2fsck/pass1.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index d2021dd..a241c23 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -1725,6 +1725,16 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
}
pb->fragmented = 1;
}
+ while (is_dir && ++pb->last_db_block < extent.e_lblk) {
+ pctx->errcode = ext2fs_add_dir_block(ctx->fs->dblist,
+ pb->ino, 0,
+ pb->last_db_block);
+ if (pctx->errcode) {
+ pctx->blk = 0;
+ pctx->num = pb->last_db_block;
+ goto failed_add_dir_block;
+ }
+ }
for (blk = extent.e_pblk, blockcnt = extent.e_lblk, i = 0;
i < extent.e_len;
blk++, blockcnt++, i++) {
@@ -1735,6 +1745,7 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
if (pctx->errcode) {
pctx->blk = blk;
pctx->num = blockcnt;
+ failed_add_dir_block:
fix_problem(ctx, PR_1_ADD_DBLOCK, pctx);
/* Should never get here */
ctx->flags |= E2F_FLAG_ABORT;
@@ -1742,6 +1753,8 @@ static void scan_extent_node(e2fsck_t ctx, struct problem_context *pctx,
}
}
}
+ if (is_dir && extent.e_len > 0)
+ pb->last_db_block = blockcnt - 1;
pb->num_blocks += extent.e_len;
pb->previous_block = extent.e_pblk + extent.e_len - 1;
start_block = extent.e_lblk + extent.e_len - 1;
--
1.6.5.216.g5288a.dirty
next reply other threads:[~2009-11-29 20:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-29 20:33 Theodore Ts'o [this message]
2009-11-29 20:33 ` [PATCH 2/5] libext2fs: Fix SET_BMAP bugs in ext2fs_bmap() and ext2fs_bmap2() Theodore Ts'o
2009-11-29 20:33 ` [PATCH 3/5] e2fsck: Fix block allocation for holes in extent-mapped directories Theodore Ts'o
2009-11-29 20:33 ` [PATCH 4/5] e2fsck: Don't rehash directories which can fit in a single directory block Theodore Ts'o
2009-11-29 20:33 ` [PATCH 5/5] e2fsck: Try to update on-disk bitmap in e2fsck_get_alloc_block() callback Theodore Ts'o
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1259526809-23697-1-git-send-email-tytso@mit.edu \
--to=tytso@mit.edu \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).