public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Barry Naujok" <bnaujok@melbourne.sgi.com>
To: xfs@oss.sgi.com
Cc: xfs-dev@sgi.com
Subject: [PATCH] make sure xfs_repair doesn't restore corrupted primary superblock
Date: Wed, 21 Feb 2007 13:05:22 +1100	[thread overview]
Message-ID: <200702210200.NAA15545@larry.melbourne.sgi.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]

Phase 2 in xfs_repair fixes corrupted superblock fields, but in phase 5, the
originally read primary superblock before the phase 2 fix is written to disk
with updated counters. The patch in scan.c makes sure the mount point
superblock copy is updated if the primary superblock is modified.

Included is some fixes to libxfs when IO_DEBUG is enabled.

[-- Attachment #2: update_mp_superblock.diff --]
[-- Type: application/octet-stream, Size: 2981 bytes --]


===========================================================================
xfsprogs/libxfs/rdwr.c
===========================================================================

--- a/xfsprogs/libxfs/rdwr.c	2007-02-21 12:57:29.000000000 +1100
+++ b/xfsprogs/libxfs/rdwr.c	2007-02-21 11:55:46.529075152 +1100
@@ -305,8 +305,9 @@ libxfs_getbuf(dev_t device, xfs_daddr_t 
 
 	if (cache_node_get(libxfs_bcache, &key, (struct cache_node **)&bp)) {
 #ifdef IO_DEBUG
-		fprintf(stderr, "%s: allocated buffer, key=%llu(%llu), %p\n",
-			__FUNCTION__, BBTOB(len), LIBXFS_BBTOOFF64(blkno), blkno, buf);
+		fprintf(stderr, "%s: allocated %ubytes buffer, key=%llu(%llu), %p\n",
+			__FUNCTION__, BBTOB(len),
+			(long long)LIBXFS_BBTOOFF64(blkno), (long long)blkno, bp);
 #endif
 		libxfs_initbuf(bp, device, blkno, bytes);
 	}
@@ -354,7 +355,7 @@ libxfs_readbufr(dev_t dev, xfs_daddr_t b
 	}
 #ifdef IO_DEBUG
 	fprintf(stderr, "readbufr read %ubytes, blkno=%llu(%llu), %p\n",
-		bytes, LIBXFS_BBTOOFF64(blkno), blkno, bp);
+		bytes, (long long)LIBXFS_BBTOOFF64(blkno), (long long)blkno, bp);
 #endif
 	if (bp->b_dev == dev &&
 	    bp->b_blkno == blkno &&
@@ -403,7 +404,8 @@ libxfs_writebufr(xfs_buf_t *bp)
 	}
 #ifdef IO_DEBUG
 	fprintf(stderr, "writebufr wrote %ubytes, blkno=%llu(%llu), %p\n",
-		bp->b_bcount, LIBXFS_BBTOOFF64(bp->b_blkno), bp->b_blkno, bp);
+		bp->b_bcount, (long long)LIBXFS_BBTOOFF64(bp->b_blkno),
+		(long long)bp->b_blkno, bp);
 #endif
 	bp->b_flags |= LIBXFS_B_UPTODATE;
 	bp->b_flags &= ~(LIBXFS_B_DIRTY | LIBXFS_B_EXIT);
@@ -432,7 +434,7 @@ libxfs_iomove(xfs_buf_t *bp, uint boff, 
 	if (boff + len > bp->b_bcount) {
 		fprintf(stderr, "Badness, iomove out of range!\n"
 			"bp=(bno %llu, bytes %u) range=(boff %u, bytes %u)\n",
-			bp->b_blkno, bp->b_bcount, boff, len);
+			(long long)bp->b_blkno, bp->b_bcount, boff, len);
 		abort();
 	}
 #endif
@@ -464,7 +466,7 @@ libxfs_bcache_purge(void)
 	cache_purge(libxfs_bcache);
 }
 
-void 
+void
 libxfs_bcache_flush(void)
 {
 	cache_flush(libxfs_bcache);

===========================================================================
xfsprogs/repair/scan.c
===========================================================================

--- a/xfsprogs/repair/scan.c	2007-02-21 12:57:29.000000000 +1100
+++ b/xfsprogs/repair/scan.c	2007-02-21 12:57:26.280306519 +1100
@@ -431,7 +431,7 @@ _("out-of-order bmap key (file offset) i
 	}
 
 	/*
-	 * If we're the last node at our level, check that the last child 
+	 * If we're the last node at our level, check that the last child
 	 * block's forward sibling pointer is NULL.
 	 */
 	if (check_dups == 0 &&
@@ -1295,6 +1295,8 @@ scan_ag(
 	ASSERT(sb_dirty == 0 || (sb_dirty && !no_modify));
 
 	if (sb_dirty && !no_modify) {
+		if (agno == 0)
+			memcpy(&mp->m_sb, sb, sizeof(xfs_sb_t));
 		libxfs_xlate_sb(XFS_BUF_PTR(sbbuf), sb, -1, XFS_SB_ALL_BITS);
 		libxfs_writebuf(sbbuf, 0);
 	} else

             reply	other threads:[~2007-02-21  2:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-21  2:05 Barry Naujok [this message]
2007-02-21  4:06 ` [PATCH] make sure xfs_repair doesn't restore corrupted primary superblock Nathan Scott

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=200702210200.NAA15545@larry.melbourne.sgi.com \
    --to=bnaujok@melbourne.sgi.com \
    --cc=xfs-dev@sgi.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