From: Eric Sandeen <sandeen@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 08/13] xfs_repair: remove last-entry hack in process_sf_dir2
Date: Tue, 17 Mar 2015 15:33:10 -0500 [thread overview]
Message-ID: <1426624395-8258-9-git-send-email-sandeen@redhat.com> (raw)
In-Reply-To: <1426624395-8258-1-git-send-email-sandeen@redhat.com>
process_sf_dir2() tries to special-case the last entry in
a short form dir, and salvage it if the name length is wrong
by using the dir size as a clue to what the length should be.
However, this doesn't actually work; there is either a 32-bit
or 64-bit inode after the name, and with dirv3 there's a file
type in there as well. Extending the name length to the dir
size means it overlaps these fields, which often have a 0 in
the top bits, and then namecheck() fails the result and junks
it anyway:
> entry #1 is zero length in shortform dir 67, resetting to 29
> entry contains illegal character in shortform dir 67
> junking entry "bbbbbbbbbbbbbbbbbbbbbbbb" in directory inode 67
And depending on the corruption, the current code will set
a new negative namelen if it turns out that the name itself
starts beyond dir size; it can't be shortened enough.
So, we could fix this up, and choose a new namelen such that
the xfs_dir2_ino8_t and/or xfs_dir2_ino8_t and/or file type
still fits at the end, but we really seem to be reaching the
point of diminishing returns. The chances that nothing but
the name length is wrong, and that the remaining few
bytes at the end of the dir size are actually correct, seems
awfully small.
Therefore just remove this special case, which I think is
of questionable value.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
---
repair/dir2.c | 47 ++++++++++++-----------------------------------
1 files changed, 12 insertions(+), 35 deletions(-)
diff --git a/repair/dir2.c b/repair/dir2.c
index 5512e41..b1816f4 100644
--- a/repair/dir2.c
+++ b/repair/dir2.c
@@ -874,43 +874,20 @@ _("entry \"%*.*s\" in shortform directory %" PRIu64 " references %s inode %" PRI
}
if (bad_sfnamelen) {
+ do_warn(
+_("entry #%d %s in shortform dir %" PRIu64),
+ i, junkreason, ino);
+ if (!no_modify)
+ do_warn(_(", junking %d entries\n"),
+ num_entries - i);
+ else
+ do_warn(_(", would junk %d entries\n"),
+ num_entries - i);
/*
- * if we're really lucky, this is the last entry in
- * case we can use the dir size to set the namelen
- * value. otherwise, forget it because we're not going
- * to be able to find the next entry.
+ * don't process the rest of the directory,
+ * break out of processing loop
*/
- if (i == num_entries - 1) {
- namelen = ino_dir_size -
- ((__psint_t) &sfep->name[0] -
- (__psint_t) sfp);
- if (!no_modify) {
- do_warn(
-_("entry #%d %s in shortform dir %" PRIu64 ", resetting to %d\n"),
- i, junkreason, ino, namelen);
- sfep->namelen = namelen;
- *dino_dirty = 1;
- } else {
- do_warn(
-_("entry #%d %s in shortform dir %" PRIu64 ", would set to %d\n"),
- i, junkreason, ino, namelen);
- }
- } else {
- do_warn(
-_("entry #%d %s in shortform dir %" PRIu64),
- i, junkreason, ino);
- if (!no_modify)
- do_warn(_(", junking %d entries\n"),
- num_entries - i);
- else
- do_warn(_(", would junk %d entries\n"),
- num_entries - i);
- /*
- * don't process the rest of the directory,
- * break out of processing looop
- */
- break;
- }
+ break;
}
/*
--
1.7.1
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2015-03-17 20:33 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-17 20:33 [PATCH 00/13] xfsprogs: roll-up of previously sent patches Eric Sandeen
2015-03-17 20:33 ` [PATCH 01/13] xfs_db: Allow writes of corrupted data by optionally skipping write verifiers Eric Sandeen
2015-03-19 15:07 ` Brian Foster
2015-03-23 20:00 ` [PATCH 01/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 02/13] xfs_db: fix inode CRC validity state, and warn on read if invalid Eric Sandeen
2015-03-19 15:07 ` Brian Foster
2015-03-21 2:26 ` Eric Sandeen
2015-03-21 14:18 ` Brian Foster
2015-03-23 20:11 ` [PATCH 02/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 03/13] xfs_db: add crc manipulation commands Eric Sandeen
2015-03-19 15:07 ` Brian Foster
2015-03-21 2:30 ` Eric Sandeen
2015-03-21 14:18 ` Brian Foster
2015-03-23 20:01 ` [PATCH 03/13 DROP] " Eric Sandeen
2015-03-17 20:33 ` [PATCH 04/13] xfs_db: nlink fields are valid for di_version == 3, too Eric Sandeen
2015-03-17 20:33 ` [PATCH 05/13] xfs_repair: dirty inode in process_sf_dir2 if we change namelen Eric Sandeen
2015-03-17 20:33 ` [PATCH 06/13] xfs_repair: remove impossible tests in process_sf_dir2 Eric Sandeen
2015-03-17 20:33 ` [PATCH 07/13] xfs_repair: collapse 2 cases " Eric Sandeen
2015-03-17 20:33 ` Eric Sandeen [this message]
2015-03-17 20:33 ` [PATCH 09/13] libxfs: remove ASSERT on ftype read from disk Eric Sandeen
2015-03-19 16:46 ` Brian Foster
2015-03-19 17:27 ` Eric Sandeen
2015-03-23 20:13 ` PATCH 09/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 10/13] xfs_repair: clear need_root_dotdot if we rebuild the root dir Eric Sandeen
2015-03-17 20:33 ` [PATCH 11/13] xfs_repair: set *parent if process_dir2_data() fixes root inode Eric Sandeen
2015-03-17 20:33 ` [PATCH 12/13] xfs_repair: don't clear . or .. in process_dir2_data Eric Sandeen
2015-03-19 16:47 ` Brian Foster
2015-03-19 17:29 ` Eric Sandeen
2015-03-19 17:54 ` Brian Foster
2015-03-19 17:59 ` Eric Sandeen
2015-03-19 18:07 ` Brian Foster
2015-03-23 20:17 ` [PATCH 12/13 V2] " Eric Sandeen
2015-03-24 12:07 ` Brian Foster
2015-03-17 20:33 ` [PATCH 13/13] xfs_repair: validate & fix inode CRCs Eric Sandeen
2015-03-19 16:47 ` Brian Foster
2015-03-23 20:19 ` [PATCH 13/13 V2] " Eric Sandeen
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=1426624395-8258-9-git-send-email-sandeen@redhat.com \
--to=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/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