Skip to contentSkip to conversation

xfsprogs: fixes for 3.2.1

PATCH In review Dave Chinner 2 participants 18 messages Jul 4, 2014 – Jul 7, 2014

lore
Share & tools
lore
#0 lore raw

cover xfsprogs: fixes for 3.2.1

Hi folks,

This is the current list of patches I have outstanding for xfsprogs. Several of these are critical for a 3.2.1 release as they result in xfs_repair failing to repair filesystems correctly.

These have been tested on several complex filesytems that broke reapir in the 3.2.0 release, as well as all the usual xfstests testing.

Comments welcome.

-Dave.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

PATCH 1/6 repair: support more than 25 ACLs

From: Dave Chinner <[email protected]>

v5 superblock supports many more than 25 ACLs on an inode, but xfs_repair still thinks that the maximum is 25. This slipped through becase the reapir code does not share any of the kernel side ACL code in libxfs, and instead has all it's own internal ACL definitions.

Fix the repair code to support more than 25 ACLs and update the ACL definitions to match the kernel definitions. In doing so, this tickles a off-by-one bug on remote attribute maximum sizes that is already fixed in the kernel code. So in addition to fixing the repair code, this patch pulls in parts of the following kernel commits:

bba719b5 xfs: fix off-by-one error in xfs_attr3_rmt_verify 0a8aa193 xfs: increase number of ACL entries for V5 superblocks

---
 libxfs/xfs_attr_remote.c |  2 +-
 repair/attr_repair.c     | 73 ++++++++++++++++++++++++++++++------------------
 repair/attr_repair.h     | 46 +++++++++++++++++++++---------
 3 files changed, 80 insertions(+), 41 deletions(-)
libxfs/xfs_attr_remote.c +1 -1
index 5cf5c73..08b983b 100644
@@ -85,7 +85,7 @@ xfs_attr3_rmt_verify(
 	if (be32_to_cpu(rmt->rm_bytes) > fsbsize - sizeof(*rmt))
 		return false;
 	if (be32_to_cpu(rmt->rm_offset) +
-				be32_to_cpu(rmt->rm_bytes) >= XATTR_SIZE_MAX)
+				be32_to_cpu(rmt->rm_bytes) > XATTR_SIZE_MAX)
 		return false;
 	if (rmt->rm_owner == 0)
 		return false;
repair/attr_repair.c +46 -27

185 lines not on this page · raw message

repair/attr_repair.h +33 -13

62 lines not on this page · raw message

Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#3 lore raw

PATCH 2/6 xfs_db: write command broken on 64 bit values

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

convert_args() has problesm with 64 bit fields because it tries to shift them by 64 bits. The result of doing so is undefined by the C standard, and so results in the unexpected behaviour of the result being being the original value unchanged rather than 0. Hence you can't write 64 bit fields because the code thinks that all values other than 0 are out of range.

---
 db/write.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
db/write.c +1 -1
index ca8bd0f..0157a44 100644
@@ -565,7 +565,7 @@ convert_arg(
 		return NULL;
 
 	/* Does the value fit into the range of the destination bitfield? */
-	if ((val >> bit_length) > 0)
+	if (bit_length < 64 && (val >> bit_length) > 0)
 		return NULL;
 	/*
 	 * If the length of the field is not a multiple of a byte, push
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH 2/6] xfs_db: write command broken on 64 bit values

Quoted 10 lines · Dave Chinner

From: Dave Chinner <[email protected]>

convert_args() has problesm with 64 bit fields because it tries to shift them by 64 bits. The result of doing so is undefined by the C standard, and so results in the unexpected behaviour of the result being being the original value unchanged rather than 0. Hence you can't write 64 bit fields because the code thinks that all values other than 0 are out of range.

Looks good,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw

PATCH 3/6 repair: handle directory block corruption in phase 6

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

This should only occur in no-modify mode, but when we fail to find the last extent in a directory btree due to corruption we need to trash the directory if it's the first data block we find the error on. That is because there is nothing to recover from the directory, and if we try to scan it xfs_reapir segv's because nothing has been read from disk.

Also catch a memory allocation failure in this code, too.

---
 repair/phase6.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
repair/phase6.c +17 -2
index 9b10f16..47ecad4 100644
@@ -2179,7 +2179,7 @@ longform_dir2_entry_check(xfs_mount_t	*mp,
 	freetab = malloc(FREETAB_SIZE(ip->i_d.di_size / mp->m_dirblksize));
 	if (!freetab) {
 		do_error(
-		_("malloc failed in longform_dir2_entry_check (%" PRId64 " bytes)\n"),
+_("malloc failed in longform_dir2_entry_check (%" PRId64 " bytes)\n"),
 			FREETAB_SIZE(ip->i_d.di_size / mp->m_dirblksize));
 		exit(1);
 	}
@@ -2191,6 +2191,11 @@ longform_dir2_entry_check(xfs_mount_t	*mp,
 	}
 	num_bps = freetab->naents;
 	bplist = calloc(num_bps, sizeof(struct xfs_buf*));
+	if (!bplist)
+		do_error(
+_("calloc failed in longform_dir2_entry_check (%zu bytes)\n"),
+			num_bps * sizeof(struct xfs_buf*));
+
 	/* is this a block, leaf, or node directory? */
 	libxfs_dir2_isblock(NULL, ip, &isblock);
 	libxfs_dir2_isleaf(NULL, ip, &isleaf);
@@ -2203,8 +2208,18 @@ longform_dir2_entry_check(xfs_mount_t	*mp,
 		int			 error;
 
 		next_da_bno = da_bno + mp->m_dirblkfsbs - 1;
-		if (bmap_next_offset(NULL, ip, &next_da_bno, XFS_DATA_FORK))
+		if (bmap_next_offset(NULL, ip, &next_da_bno, XFS_DATA_FORK)) {
+			/*
+			 * if this is the first block, there isn't anything we
+			 * can recover so we just trash it.
+			 */
+			 if (da_bno == 0) {
+				fixit++;
+				goto out_fix;
+			}
 			break;
+		}
+
 		db = xfs_dir2_da_to_db(mp, da_bno);
 		if (db >= num_bps) {
 			/* more data blocks than expected */
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 3/6
#6 lore raw

Re: [PATCH 3/6] repair: handle directory block corruption in phase 6

repair/phase6.c longform_dir2_entry_check(xfs_mount_t *mp, · line 2182

Quoted 6 lines
repair/phase6.c +1 -1
@@ -2179,7 +2179,7 @@ longform_dir2_entry_check(xfs_mount_t	*mp,
 	freetab = malloc(FREETAB_SIZE(ip->i_d.di_size / mp->m_dirblksize));
 	if (!freetab) {
 		do_error(
-		_("malloc failed in longform_dir2_entry_check (%" PRId64 " bytes)\n"),
+_("malloc failed in longform_dir2_entry_check (%" PRId64 " bytes)\n"),

Use __func__ to make this both more readable and future proof (same for the other error message).

Otherwise looks good,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw

PATCH 4/6 libxfs: reused invalidated buffers leak state and data

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

When rebuilding a bad directory, repair first truncates away all the blocks in the directory, good or bad. This removes blocks from the bmap btree, and when those blocks are freed the bmap btree code invalidates them. This marks the buffers LIBXFS_B_STALE so that we don't try to write stale data from that buffer at a later time.

However, when rebuilding the directory, blocks may get reallocated and we reuse the underlying buffers. This has two problems.

The first is that if the buffer was previously detected as having a verifier error (i.e. an error that is leading to the block being freed and the buffer being invalidated) then the error might still be held in b_error. Hence the libxfs code needs to ensure that b_error does not leak from one buffer usage context to another after invalidation.

The second problem is that when new data is written into a buffer, it no longer has stale contents. Hence when we write the buffer, we need to clear the LIBXFS_B_STALE flag to ensure that the new data gets written.

---
 libxfs/rdwr.c | 8 ++++++++
 1 file changed, 8 insertions(+)
libxfs/rdwr.c +8 -0
index 981f2ba..c81c82f 100644
@@ -632,6 +632,12 @@ libxfs_putbuf(xfs_buf_t *bp)
 			pthread_mutex_unlock(&bp->b_lock);
 		}
 	}
+	/*
+	 * ensure that any errors on this use of the buffer don't carry
+	 * over to the next user.
+	 */
+	bp->b_error = 0;
+
 	cache_node_put(libxfs_bcache, (struct cache_node *)bp);
 }
 
@@ -928,6 +934,7 @@ libxfs_writebuf_int(xfs_buf_t *bp, int flags)
 	 * subsequent reads after this write from seeing stale errors.
 	 */
 	bp->b_error = 0;
+	bp->b_flags &= ~LIBXFS_B_STALE;
 	bp->b_flags |= (LIBXFS_B_DIRTY | flags);
 	return 0;
 }
@@ -946,6 +953,7 @@ libxfs_writebuf(xfs_buf_t *bp, int flags)
 	 * subsequent reads after this write from seeing stale errors.
 	 */
 	bp->b_error = 0;
+	bp->b_flags &= ~LIBXFS_B_STALE;
 	bp->b_flags |= (LIBXFS_B_DIRTY | flags);
 	libxfs_putbuf(bp);
 	return 0;
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#8 lore raw

Re: [PATCH 4/6] libxfs: reused invalidated buffers leak state and data

libxfs/rdwr.c libxfs_putbuf(xfs_buf_t *bp) · line 641

Quoted 11 lines · Dave Chinner
libxfs/rdwr.c +6 -0
@@ -632,6 +632,12 @@ libxfs_putbuf(xfs_buf_t *bp)
 			pthread_mutex_unlock(&bp->b_lock);
 		}
 	}
+	/*
+	 * ensure that any errors on this use of the buffer don't carry
+	 * over to the next user.
+	 */
+	bp->b_error = 0;
+
 	cache_node_put(libxfs_bcache, (struct cache_node *)bp);

This seems a bit fishy to me. For one I'm pretty sure it needs to be done before unlocking b_lock, second it's different behavior from the kernel where we explicitly clear it in the caller for the rare case we want to reuse a buffer that had an error (xfs_buf_iodone_callbacks seems to be the only one). Any reason to do this differently in userspace?

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#9 lore raw

Re: [PATCH 4/6] libxfs: reused invalidated buffers leak state and data

Quoted 15 lines · Christoph Hellwig

libxfs/rdwr.c libxfs_putbuf(xfs_buf_t *bp) · line 641

Quoted 11 lines · Dave Chinner
libxfs/rdwr.c +6 -0
@@ -632,6 +632,12 @@ libxfs_putbuf(xfs_buf_t *bp)
 			pthread_mutex_unlock(&bp->b_lock);
 		}
 	}
+	/*
+	 * ensure that any errors on this use of the buffer don't carry
+	 * over to the next user.
+	 */
+	bp->b_error = 0;
+
 	cache_node_put(libxfs_bcache, (struct cache_node *)bp);

This seems a bit fishy to me. For one I'm pretty sure it needs to be done before unlocking b_lock,

Fair enough.

Quoted 5 lines

second it's different behavior from the
kernel where we explicitly clear it in the caller for the rare case we want to reuse a buffer that had an error (xfs_buf_iodone_callbacks seems to be the only one). Any reason to do this differently in userspace?

The userspace code that uses the buffer cache is much less constrained than the kernel code. The userspace code is pretty nasty in places, especially when it comes to buffer error handling.

We can't clear errors or zero buffer contents in libxfs_getbuf-* like we do in the kernel, because those functions are used by the libxfs_readbuf_* functions and hence need to leave the buffers unchanged on cache hits. This is actually the only way to gather a write error from a libxfs_writebuf() call - you need to get the buffer again so you can check bp->b_error field - assuming that the buffer is still in the cache when you check, that is.

This is very different to the kernel code which idoes not release buffers on a write so we can wait on IO and check errors. The kernel buffer cache also guarantees a buffer of a known initial state from xfs_buf_get() even on a cache hit.

Hence the userspace buffer cache is behaving quite differently to the kernel buffer cache and as a result it's leaking errors from reads, invalidations and writes through xfs_da_get_buf/libxfs_getbuf. Current no userspace outside libxfs code clears bp->b_error - very little code even checks it - so th elibxfs code is tripping on stale errors left by the usrspace code. libxfs_writebuf() already zeros bp->b_error to prevent propagation of stale errors into future reads, so this patch is really just closing the hole in the other buffer release path that the code usually takes.

Doing a full audit and addition of error handling of all the userspace code is a little beyond my resources right now. The only thing I can really do quickly about the problem is clear the error when we've finished with the buffer.

I'm open to other ways of fixing this, but right now we've got to fix xfs_repair because it's currently breaking filesystems worse than before xfs_repair was run...

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#10 lore raw

Re: [PATCH 4/6] libxfs: reused invalidated buffers leak state and data

Quoted 3 lines · Dave Chinner

I'm open to other ways of fixing this, but right now we've got to fix xfs_repair because it's currently breaking filesystems worse than before xfs_repair was run...

Ok, so clearly mark this as difference from kernel code in a long comment explaining the situation similar to wrote you above. It's pretty obvious that the buffer cache in userspace will eventually need a major overhaul sooner or later. I wonder how feasible porting the kernel one would be..

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#11 lore raw

Re: [PATCH 4/6] libxfs: reused invalidated buffers leak state and data

Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Dave Chinner

I'm open to other ways of fixing this, but right now we've got to fix xfs_repair because it's currently breaking filesystems worse than before xfs_repair was run...

Ok, so clearly mark this as difference from kernel code in a long comment explaining the situation similar to wrote you above.

Will do.

Quoted 4 lines

It's
pretty obvious that the buffer cache in userspace will eventually need a major overhaul sooner or later. I wonder how feasible porting the kernel one would be..

It's not so much the porting that's the issue - it's cleaning up all the applications that use it that is the headache. And, realistically, I don't think there's much of the kernel code that can be used - we have to rewrite all the allocation, freeing, locking and IO parts of it, so we'd pretty much be re-implementing most of it, anyway....

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#12 lore raw

Re: [PATCH 4/6] libxfs: reused invalidated buffers leak state and data

Quoted 10 lines · Dave Chinner
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Dave Chinner

I'm open to other ways of fixing this, but right now we've got to fix xfs_repair because it's currently breaking filesystems worse than before xfs_repair was run...

Ok, so clearly mark this as difference from kernel code in a long comment explaining the situation similar to wrote you above.

Will do.

Ok, I added this to the top of the libxfs/rdwr.c file:

/*
* Important design/architecture note:
*
* The userspace code that uses the buffer cache is much less constrained than
* the kernel code. The userspace code is pretty nasty in places, especially
* when it comes to buffer error handling. Very little of the userspace code
* outside libxfs clears bp->b_error - very little code even checks it - so the
* libxfs code is tripping on stale errors left by the userspace code. *
* We can't clear errors or zero buffer contents in libxfs_getbuf-* like we do
* in the kernel, because those functions are used by the libxfs_readbuf_*
* functions and hence need to leave the buffers unchanged on cache hits. This
* is actually the only way to gather a write error from a libxfs_writebuf()
* call - you need to get the buffer again so you can check bp->b_error field -
* assuming that the buffer is still in the cache when you check, that is. *
* This is very different to the kernel code which does not release buffers on a
* write so we can wait on IO and check errors. The kernel buffer cache also
* guarantees a buffer of a known initial state from xfs_buf_get() even on a
* cache hit.
*
* IOWs, userspace is behaving quite differently to the kernel and as a result
* it leaks errors from reads, invalidations and writes through
* libxfs_getbuf/libxfs_readbuf.
*
* The result of this is that until the userspace code outside libxfs is cleaned
* up, functions that release buffers from userspace control (i.e
* libxfs_writebuf/libxfs_putbuf) need to zero bp->b_error to prevent
* propagation of stale errors into future buffer operations.
*/

Is that sufficient for the moment?

-Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#14 lore raw

PATCH 5/6 repair: fix quota inode handling in secondary superblocks

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

Changes to support separate project quota inodes changed the way quota inodes got written to the superblock. The current code is tailored for the needs to the kernel, where the inodes should only be written if certain falgs are set saying a quota type is enabled.

Unfortunately, when recovering a corrupt secondary superblock, we need to unconditionally write the quota inode fields after we unconditionally zero the quota flags field. The result of this bug is that the bad quota inode fields cannot be cleared and hence always are reported by bad by repair in subsequent runs.

Fix this by directly clearing the quota inodes in the superblock buffers so that we do need to set special flags to get xfs_sb_to_disk() to do the right thing as setting flags leave bad flag values in the superblock instead of bad inode numbers....

Also, when clearing the inode numbers, write them as NULLFSINO rather than 0 as this is what the kernel will write them as if quota is turned off.

---
 include/libxfs.h  |  1 +
 libxfs/rdwr.c     |  4 ++--
 repair/agheader.c | 44 +++++++++++++++++++++++++++++---------------
 repair/sb.c       |  2 ++
 repair/scan.c     |  1 +
 5 files changed, 35 insertions(+), 17 deletions(-)
include/libxfs.h +1 -0
index 7203d79..45a924f 100644
@@ -759,6 +759,7 @@ bool xfs_dinode_verify(struct xfs_mount *mp, xfs_ino_t ino,
 /* xfs_sb.h */
 #define libxfs_mod_sb			xfs_mod_sb
 #define libxfs_sb_from_disk		xfs_sb_from_disk
+#define libxfs_sb_quota_from_disk	xfs_sb_quota_from_disk
 #define libxfs_sb_to_disk		xfs_sb_to_disk
 
 /* xfs_symlink.h */
libxfs/rdwr.c +2 -2
index c81c82f..e681f2a 100644
@@ -913,10 +913,10 @@ libxfs_writebufr(xfs_buf_t *bp)
 	}
 
 #ifdef IO_DEBUG
-	printf("%lx: %s: wrote %u bytes, blkno=%llu(%llu), %p\n",
+	printf("%lx: %s: wrote %u bytes, blkno=%llu(%llu), %p, error %d\n",
 			pthread_self(), __FUNCTION__, bp->b_bcount,
 			(long long)LIBXFS_BBTOOFF64(bp->b_bn),
-			(long long)bp->b_bn, bp);
+			(long long)bp->b_bn, bp, error);
 #endif
 	if (!error) {
 		bp->b_flags |= LIBXFS_B_UPTODATE;
repair/agheader.c +29 -15

72 lines not on this page · raw message

repair/sb.c +2 -0
index 5e0b0f2..bc421cc 100644
@@ -138,6 +138,7 @@ find_secondary_sb(xfs_sb_t *rsb)
 		for (i = 0; !done && i < bsize; i += BBSIZE)  {
 			c_bufsb = (char *)sb + i;
 			libxfs_sb_from_disk(&bufsb, (xfs_dsb_t *)c_bufsb);
+			libxfs_sb_quota_from_disk(&bufsb);
 
 			if (verify_sb(c_bufsb, &bufsb, 0) != XR_OK)
 				continue;
@@ -538,6 +539,7 @@ get_sb(xfs_sb_t *sbp, xfs_off_t off, int size, xfs_agnumber_t agno)
 		do_error("%s\n", strerror(error));
 	}
 	libxfs_sb_from_disk(sbp, buf);
+	libxfs_sb_quota_from_disk(sbp);
 
 	rval = verify_sb((char *)buf, sbp, agno == 0);
 	free(buf);
repair/scan.c +1 -0
index 1b64d8b..f29ff8d 100644
@@ -1496,6 +1496,7 @@ scan_ag(
 		goto out_free_sb;
 	}
 	libxfs_sb_from_disk(sb, XFS_BUF_TO_SBP(sbbuf));
+	libxfs_sb_quota_from_disk(sb);
 
 	agfbuf = libxfs_readbuf(mp->m_dev,
 			XFS_AG_DADDR(mp, agno, XFS_AGF_DADDR(mp)),
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 5/6
#15 lore raw

Re: [PATCH 5/6] repair: fix quota inode handling in secondary superblocks

Quoted 18 lines · Dave Chinner

From: Dave Chinner <[email protected]>

Changes to support separate project quota inodes changed the way quota inodes got written to the superblock. The current code is tailored for the needs to the kernel, where the inodes should only be written if certain falgs are set saying a quota type is enabled.

Unfortunately, when recovering a corrupt secondary superblock, we need to unconditionally write the quota inode fields after we unconditionally zero the quota flags field. The result of this bug is that the bad quota inode fields cannot be cleared and hence always are reported by bad by repair in subsequent runs.

Fix this by directly clearing the quota inodes in the superblock buffers so that we do need to set special flags to get xfs_sb_to_disk() to do the right thing as setting flags leave bad flag values in the superblock instead of bad inode numbers....

Quoted 5 lines

Also, when clearing the inode numbers, write them as NULLFSINO rather than 0 as this is what the kernel will write them as if quota is turned off.

Looks good,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#16 lore raw

PATCH 6/6 repair: get rid of BADFSINO

In reply to Dave Chinner

From: Dave Chinner <[email protected]>

When we find a bad dirent, we "clear" the inode the inode number by writing BADFSINO to the inode number in the entry:

#define BADFSINO ((xfs_ino_t)0xfeffffffffffffffULL)

We then capture this bad inode number later in the same function either in the same pass or in a later phase and junk the entry. When we junk the entry, we write a "/" over the first character of the dirent name, which is then detected up later by the directory rebuild and ignored.

The issue with this is that the directory buffer can be written to disk between the dirent being marked with BADFSINO and the directory rebuild processing in phase 6, resulting in the directory block verifier firing this error:

Invalid inode number 0xfeffffffffffffff
xfs_dir_ino_validate: XFS_ERROR_REPORT
Metadata corruption detected at block 0x11fbb698/0x1000
libxfs_writebufr: write verifer failed on bno 0x11fbb698/0x1000

And so will not write the *corrupt block* to disk. The result is that we don't repair a corruption in the directory block correctly and subsequent repair runs continue to find problems with the directory.

We really don't need both BADFSINO *and* overwriting the dirent name with "/" to mark an entry as junked. They both mean exactly the same thing, so get rid of BADFSINO and only use the name junking to mark dirents as bad. This prevents the directory data block verifier from triggering on bad inode numbers, and so the later reread of the block will find the junked entries correctly.

---
 repair/dir2.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)
repair/dir2.c +7 -14
index 14c1435..f32bba7 100644
@@ -28,13 +28,6 @@
 #include "progress.h"
 
 /*
- * Tag bad directory entries with this.
- * We can't tag them with -1 since that will look like a
- * data_unused_t instead of a data_entry_t.
- */
-#define	BADFSINO	((xfs_ino_t)0xfeffffffffffffffULL)
-
-/*
  * Known bad inode list.  These are seen when the leaf and node
  * block linkages are incorrect.
  */
@@ -1314,7 +1307,7 @@ process_dir2_data(
 		 * Conditions must either set clearino to zero or set
 		 * clearreason why it's being cleared.
 		 */
-		if (!ino_discovery && ent_ino == BADFSINO) {
+		if (!ino_discovery && dep->name[0] == '/') {
 			/*
 			 * Don't do a damned thing.  We already found this
 			 * (or did it ourselves) during phase 3.
@@ -1401,8 +1394,7 @@ _("entry at block %u offset %" PRIdPTR " in directory inode %" PRIu64
 				do_warn(
 _("\tclearing inode number in entry at offset %" PRIdPTR "...\n"),
 					(intptr_t)ptr - (intptr_t)d);
-				dep->inumber = cpu_to_be64(BADFSINO);
-				ent_ino = BADFSINO;
+				dep->name[0] = '/';
 				*dirty = 1;
 			} else {
 				do_warn(
@@ -1415,7 +1407,7 @@ _("\twould clear inode number in entry at offset %" PRIdPTR "...\n"),
 		 * discovery is turned on).  Otherwise, we'd complain a lot
 		 * during phase 4.
 		 */
-		junkit = ent_ino == BADFSINO;
+		junkit = dep->name[0] == '/';
 		nm_illegal = namecheck((char *)dep->name, dep->namelen);
 		if (ino_discovery && nm_illegal) {
 			do_warn(
@@ -1424,14 +1416,15 @@ _("entry at block %u offset %" PRIdPTR " in directory inode %" PRIu64 " has ille
 				dep->namelen, dep->namelen, dep->name);
 			junkit = 1;
 		}
+
 		/*
-		 * Now we can mark entries with BADFSINO's bad.
+		 * Ensure we write back bad entries for later processing
 		 */
-		if (!no_modify && ent_ino == BADFSINO) {
-			dep->name[0] = '/';
+		if (!no_modify && dep->name[0] == '/') {
 			*dirty = 1;
 			junkit = 0;
 		}
+
 		/*
 		 * Special .. entry processing.
 		 */
Signature · 6 lines
2.0.0

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs