]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - repair/sb.c
repair: handle sparse inode alignment
[thirdparty/xfsprogs-dev.git] / repair / sb.c
index 03be5e851aa6cd8ee5abcfa66e4d7f5776c1efd0..a291b3e88574d39e293169985f860bd6adff2e5d 100644 (file)
@@ -170,12 +170,13 @@ find_secondary_sb(xfs_sb_t *rsb)
 }
 
 /*
- * Calculate what inode alignment field ought to be
- * based on internal superblock info and determine if it is valid.
+ * Calculate what the inode alignment field ought to be based on internal
+ * superblock info and determine if it is valid.
  *
- * For v5 superblocks, the inode alignment will either match that of the
- * standard XFS_INODE_BIG_CLUSTER_SIZE, or it will be scaled based on the inode
- * size. Either value is valid in this case.
+ * For standard v5 superblocks, the inode alignment must either match
+ * XFS_INODE_BIG_CLUSTER_SIZE or a multiple based on the inode size. For v5
+ * superblocks with sparse inode chunks enabled, inode alignment must match the
+ * inode chunk size.
  *
  * Return true if the alignment is valid, false otherwise.
  */
@@ -201,6 +202,20 @@ sb_validate_ino_align(struct xfs_sb *sb)
        if (align == sb->sb_inoalignmt)
                return true;
 
+       /*
+        * Sparse inodes requires inoalignmt to match full inode chunk size and
+        * spino_align to match the scaled alignment (as calculated above).
+        */
+       if (xfs_sb_version_hassparseinodes(sb)) {
+               if (align != sb->sb_spino_align)
+                       return false;
+
+               align = (sb->sb_inodesize * XFS_INODES_PER_CHUNK)
+                       >> sb->sb_blocklog;
+               if (align == sb->sb_inoalignmt)
+                       return true;
+       }
+
        return false;
 }