@@ -530,7 +530,8 @@ xfs_validate_sb_common(
530530 }
531531
532532 if (!xfs_validate_stripe_geometry (mp , XFS_FSB_TO_B (mp , sbp -> sb_unit ),
533- XFS_FSB_TO_B (mp , sbp -> sb_width ), 0 , false))
533+ XFS_FSB_TO_B (mp , sbp -> sb_width ), 0 ,
534+ xfs_buf_daddr (bp ) == XFS_SB_DADDR , false))
534535 return - EFSCORRUPTED ;
535536
536537 /*
@@ -1323,61 +1324,82 @@ xfs_sb_get_secondary(
13231324}
13241325
13251326/*
1326- * sunit, swidth, sectorsize(optional with 0) should be all in bytes,
1327- * so users won't be confused by values in error messages.
1327+ * sunit, swidth, sectorsize(optional with 0) should be all in bytes, so users
1328+ * won't be confused by values in error messages. This function returns false
1329+ * if the stripe geometry is invalid and the caller is unable to repair the
1330+ * stripe configuration later in the mount process.
13281331 */
13291332bool
13301333xfs_validate_stripe_geometry (
13311334 struct xfs_mount * mp ,
13321335 __s64 sunit ,
13331336 __s64 swidth ,
13341337 int sectorsize ,
1338+ bool may_repair ,
13351339 bool silent )
13361340{
13371341 if (swidth > INT_MAX ) {
13381342 if (!silent )
13391343 xfs_notice (mp ,
13401344"stripe width (%lld) is too large" , swidth );
1341- return false ;
1345+ goto check_override ;
13421346 }
13431347
13441348 if (sunit > swidth ) {
13451349 if (!silent )
13461350 xfs_notice (mp ,
13471351"stripe unit (%lld) is larger than the stripe width (%lld)" , sunit , swidth );
1348- return false ;
1352+ goto check_override ;
13491353 }
13501354
13511355 if (sectorsize && (int )sunit % sectorsize ) {
13521356 if (!silent )
13531357 xfs_notice (mp ,
13541358"stripe unit (%lld) must be a multiple of the sector size (%d)" ,
13551359 sunit , sectorsize );
1356- return false ;
1360+ goto check_override ;
13571361 }
13581362
13591363 if (sunit && !swidth ) {
13601364 if (!silent )
13611365 xfs_notice (mp ,
13621366"invalid stripe unit (%lld) and stripe width of 0" , sunit );
1363- return false ;
1367+ goto check_override ;
13641368 }
13651369
13661370 if (!sunit && swidth ) {
13671371 if (!silent )
13681372 xfs_notice (mp ,
13691373"invalid stripe width (%lld) and stripe unit of 0" , swidth );
1370- return false ;
1374+ goto check_override ;
13711375 }
13721376
13731377 if (sunit && (int )swidth % (int )sunit ) {
13741378 if (!silent )
13751379 xfs_notice (mp ,
13761380"stripe width (%lld) must be a multiple of the stripe unit (%lld)" ,
13771381 swidth , sunit );
1378- return false ;
1382+ goto check_override ;
13791383 }
13801384 return true;
1385+
1386+ check_override :
1387+ if (!may_repair )
1388+ return false;
1389+ /*
1390+ * During mount, mp->m_dalign will not be set unless the sunit mount
1391+ * option was set. If it was set, ignore the bad stripe alignment values
1392+ * and allow the validation and overwrite later in the mount process to
1393+ * attempt to overwrite the bad stripe alignment values with the values
1394+ * supplied by mount options.
1395+ */
1396+ if (!mp -> m_dalign )
1397+ return false;
1398+ if (!silent )
1399+ xfs_notice (mp ,
1400+ "Will try to correct with specified mount options sunit (%d) and swidth (%d)" ,
1401+ BBTOB (mp -> m_dalign ), BBTOB (mp -> m_swidth ));
1402+ return true;
13811403}
13821404
13831405/*
0 commit comments