On Thu, Nov 21, 2019 at 08:08:19PM +0200, Alex Lyakas wrote: > We are hitting the following issue: if XFS is mounted with sunit/swidth different from those > specified during mkfs, then xfs_repair reports false corruption and eventually segfaults. > > Example: > > # mkfs > mkfs.xfs -f -K -p /etc/zadara/xfs.protofile -d sunit=64,swidth=64 -l sunit=32 /dev/vda > > #mount with a different sunit/swidth: > mount -onoatime,sync,nouuid,sunit=32,swidth=32 /dev/vda /mnt/xfs > FYI, I couldn't reproduce this at first because sparse inodes is enabled by default and that introduces more strict inode alignment requirements. I'm assuming that sparse inodes is disabled in your example, but it would be more helpful if you included the exact configuration and mkfs output in such reports. > #umount > umount /mnt/xfs > ... > > Looking at the kernel code of XFS, there seems to be no need to update the superblock sunit/swidth if the mount-provided sunit/swidth are different. > The superblock values are not used during runtime. > I'm not really sure what the right answer is here. On one hand, this patch seems fundamentally reasonable to me. I find it kind of odd for mount options to override and persist configuration set in the superblock like this. OTOH, this changes a historical behavior which may (or may not) cause disruption for users. I also think it's somewhat unfortunate to change kernel mount option behavior to accommodate repair, but I think the mount option behavior being odd argument stands on its own regardless. What is your actual use case for changing the stripe unit/width at mount time like this? > With the suggested patch, xfs repair is working properly also when mount-provided sunit/swidth are different. > > However, I am not sure whether this is the proper approach. Otherwise, should we not allow specifying different sunit/swidth during mount? > ... > > Signed-off-by: Alex Lyakas <alex@xxxxxxxxxx> > --- > fs/xfs/xfs_mount.c | 18 ++++++------------ > 1 file changed, 6 insertions(+), 12 deletions(-) > > diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c > index ba5b6f3..e8263b4 100644 > --- a/fs/xfs/xfs_mount.c > +++ b/fs/xfs/xfs_mount.c > @@ -399,19 +399,13 @@ > } > > /* > - * Update superblock with new values > - * and log changes > + * If sunit/swidth specified during mount do not match > + * those in the superblock, use the mount-specified values, > + * but do not update the superblock. > + * Otherwise, xfs_repair reports false corruption. > + * Here, only verify that superblock supports data alignment. > */ > - if (xfs_sb_version_hasdalign(sbp)) { > - if (sbp->sb_unit != mp->m_dalign) { > - sbp->sb_unit = mp->m_dalign; > - mp->m_update_sb = true; > - } > - if (sbp->sb_width != mp->m_swidth) { > - sbp->sb_width = mp->m_swidth; > - mp->m_update_sb = true; > - } > - } else { > + if (!xfs_sb_version_hasdalign(sbp)) { Would this change xfs_info behavior on a filesystem mounted with different runtime fields from the superblock? I haven't tested it, but it looks like we pull the fields from the superblock. Brian > xfs_warn(mp, > "cannot change alignment: superblock does not support data alignment"); > return -EINVAL; > -- > 1.9.1 >