public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes
Date: Thu,  5 Feb 2015 16:50:22 -0500	[thread overview]
Message-ID: <1423173023-54866-2-git-send-email-bfoster@redhat.com> (raw)
In-Reply-To: <1423173023-54866-1-git-send-email-bfoster@redhat.com>

xfs_repair validates the superblock inode alignment field against
several possible valid values. On v5 superblocks, the inode alignment
can be scaled up based on the inode size in relation to the minimum
inode size.

If the block size is larger than the default cluster size (consider
large page size arches such as ppc64), the initial alignment value
calculates to zero. If the inode size is large enough such that
sb_inoalignmt is not zero, sb_validate_ino_align() scales the align
value by the factor of inode size increase. If align is zero, however,
we multiply by zero, the subsequent check incorrectly fails and the
overall superblock verification fails as well. To reproduce, format an
fs as follows on ppc64 and run xfs_repair:

	mkfs.xfs -f -m crc=1 -b size=64k -i size=2k <dev>

Fix the scaled alignment calculation by scaling the default cluster size
appropriately to avoid a multiplication by zero.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 repair/sb.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/repair/sb.c b/repair/sb.c
index ad27756..2805fbd 100644
--- a/repair/sb.c
+++ b/repair/sb.c
@@ -196,7 +196,8 @@ sb_validate_ino_align(struct xfs_sb *sb)
 	if (!xfs_sb_version_hascrc(sb))
 		return false;
 
-	align *= sb->sb_inodesize / XFS_DINODE_MIN_SIZE;
+	align = (XFS_INODE_BIG_CLUSTER_SIZE *
+		 sb->sb_inodesize / XFS_DINODE_MIN_SIZE) >> sb->sb_blocklog;
 	if (align == sb->sb_inoalignmt)
 		return true;
 
-- 
1.8.3.1

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  reply	other threads:[~2015-02-05 21:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-05 21:50 [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues Brian Foster
2015-02-05 21:50 ` Brian Foster [this message]
2015-02-05 21:50 ` [PATCH 2/2] repair: check ino alignment value to avoid mod by zero Brian Foster
2015-02-05 23:37 ` [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues Dave Chinner

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=1423173023-54866-2-git-send-email-bfoster@redhat.com \
    --to=bfoster@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