All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues
@ 2015-02-05 21:50 Brian Foster
  2015-02-05 21:50 ` [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes Brian Foster
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Brian Foster @ 2015-02-05 21:50 UTC (permalink / raw)
  To: xfs

Hi all,

This is just a couple fixes for issues I came across while playing with
larger block and inode sizes on a ppc64 box...

Brian

Brian Foster (2):
  repair: fix v5 sb ino alignment calculation for large blocksizes
  repair: check ino alignment value to avoid mod by zero

 repair/sb.c   | 3 ++-
 repair/scan.c | 6 ++++--
 2 files changed, 6 insertions(+), 3 deletions(-)

-- 
1.8.3.1

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes
  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
  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
  2 siblings, 0 replies; 4+ messages in thread
From: Brian Foster @ 2015-02-05 21:50 UTC (permalink / raw)
  To: xfs

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] repair: check ino alignment value to avoid mod by zero
  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 ` [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes Brian Foster
@ 2015-02-05 21:50 ` Brian Foster
  2015-02-05 23:37 ` [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues Dave Chinner
  2 siblings, 0 replies; 4+ messages in thread
From: Brian Foster @ 2015-02-05 21:50 UTC (permalink / raw)
  To: xfs

xfs_repair checks inode records for valid alignment according to the
alignment specified in the superblock. It currently performs the
alignment check whenever fs_aligned_inodes is set, which is determined
based on whether the fs supports the field.

Support for the field does not guarantee its value is non-zero, however.
For example, a large block size fs on a large page size arch (e.g.,
ppc64):

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

... can lead to incorrect badly aligned inode record messages from
xfs_repair and other problems.

Update the inobt and finobt checks to verify that alignment is a
non-zero value before attempting to use it to divide (mod) by zero.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 repair/scan.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/repair/scan.c b/repair/scan.c
index 142d8d7..ce8d7f5 100644
--- a/repair/scan.c
+++ b/repair/scan.c
@@ -770,7 +770,8 @@ scan_single_ino_chunk(
 	    (inodes_per_block <= XFS_INODES_PER_CHUNK && off !=  0) ||
 	    (inodes_per_block > XFS_INODES_PER_CHUNK &&
 	     off % XFS_INODES_PER_CHUNK != 0) ||
-	    (fs_aligned_inodes && agbno % fs_ino_alignment != 0))  {
+	    (fs_aligned_inodes && fs_ino_alignment &&
+	     agbno % fs_ino_alignment != 0))  {
 		do_warn(
 	_("badly aligned inode rec (starting inode = %" PRIu64 ")\n"),
 			lino);
@@ -929,7 +930,8 @@ scan_single_finobt_chunk(
 	    (inodes_per_block <= XFS_INODES_PER_CHUNK && off !=  0) ||
 	    (inodes_per_block > XFS_INODES_PER_CHUNK &&
 	     off % XFS_INODES_PER_CHUNK != 0) ||
-	    (fs_aligned_inodes && agbno % fs_ino_alignment != 0)) {
+	    (fs_aligned_inodes && fs_ino_alignment &&
+	     agbno % fs_ino_alignment != 0)) {
 		do_warn(
 	_("badly aligned finobt inode rec (starting inode = %" PRIu64 ")\n"),
 			lino);
-- 
1.8.3.1

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] xfsprogs/repair: fix a couple large block size alignment issues
  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 ` [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes Brian Foster
  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 ` Dave Chinner
  2 siblings, 0 replies; 4+ messages in thread
From: Dave Chinner @ 2015-02-05 23:37 UTC (permalink / raw)
  To: Brian Foster; +Cc: xfs

On Thu, Feb 05, 2015 at 04:50:21PM -0500, Brian Foster wrote:
> Hi all,
> 
> This is just a couple fixes for issues I came across while playing with
> larger block and inode sizes on a ppc64 box...

Yup, fixes look sane. I'll test and pull them in.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-05 23:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/2] repair: fix v5 sb ino alignment calculation for large blocksizes Brian Foster
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.