aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2017-06-14 15:17:32 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2017-06-14 15:17:32 -0400
commit96ecff14225ad40a29f4d5cfa6bd9266c8e1e89a (patch)
treec63c2417417cd40c65236f35d697aff0ada5ec1b /fs
parent67a70017fa0a152657bc7e337e69bb9c9f5549bf (diff)
ufs: fix logics in "ufs: make fsck -f happy"
Storing stats _only_ at new locations is wrong for UFS1; old locations should always be kept updated. The check for "has been converted to use of new locations" is also wrong - it should be "->fs_maxbsize is equal to ->fs_bsize". Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs')
-rw-r--r--fs/ufs/super.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index d9aa2627c9df..eca838a8b43e 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -480,7 +480,7 @@ static void ufs_setup_cstotal(struct super_block *sb)
480 usb3 = ubh_get_usb_third(uspi); 480 usb3 = ubh_get_usb_third(uspi);
481 481
482 if ((mtype == UFS_MOUNT_UFSTYPE_44BSD && 482 if ((mtype == UFS_MOUNT_UFSTYPE_44BSD &&
483 (usb1->fs_flags & UFS_FLAGS_UPDATED)) || 483 (usb2->fs_un.fs_u2.fs_maxbsize == usb1->fs_bsize)) ||
484 mtype == UFS_MOUNT_UFSTYPE_UFS2) { 484 mtype == UFS_MOUNT_UFSTYPE_UFS2) {
485 /*we have statistic in different place, then usual*/ 485 /*we have statistic in different place, then usual*/
486 uspi->cs_total.cs_ndir = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir); 486 uspi->cs_total.cs_ndir = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir);
@@ -596,9 +596,7 @@ static void ufs_put_cstotal(struct super_block *sb)
596 usb2 = ubh_get_usb_second(uspi); 596 usb2 = ubh_get_usb_second(uspi);
597 usb3 = ubh_get_usb_third(uspi); 597 usb3 = ubh_get_usb_third(uspi);
598 598
599 if ((mtype == UFS_MOUNT_UFSTYPE_44BSD && 599 if (mtype == UFS_MOUNT_UFSTYPE_UFS2) {
600 (usb1->fs_flags & UFS_FLAGS_UPDATED)) ||
601 mtype == UFS_MOUNT_UFSTYPE_UFS2) {
602 /*we have statistic in different place, then usual*/ 600 /*we have statistic in different place, then usual*/
603 usb2->fs_un.fs_u2.cs_ndir = 601 usb2->fs_un.fs_u2.cs_ndir =
604 cpu_to_fs64(sb, uspi->cs_total.cs_ndir); 602 cpu_to_fs64(sb, uspi->cs_total.cs_ndir);
@@ -608,16 +606,26 @@ static void ufs_put_cstotal(struct super_block *sb)
608 cpu_to_fs64(sb, uspi->cs_total.cs_nifree); 606 cpu_to_fs64(sb, uspi->cs_total.cs_nifree);
609 usb3->fs_un1.fs_u2.cs_nffree = 607 usb3->fs_un1.fs_u2.cs_nffree =
610 cpu_to_fs64(sb, uspi->cs_total.cs_nffree); 608 cpu_to_fs64(sb, uspi->cs_total.cs_nffree);
611 } else { 609 goto out;
612 usb1->fs_cstotal.cs_ndir =
613 cpu_to_fs32(sb, uspi->cs_total.cs_ndir);
614 usb1->fs_cstotal.cs_nbfree =
615 cpu_to_fs32(sb, uspi->cs_total.cs_nbfree);
616 usb1->fs_cstotal.cs_nifree =
617 cpu_to_fs32(sb, uspi->cs_total.cs_nifree);
618 usb1->fs_cstotal.cs_nffree =
619 cpu_to_fs32(sb, uspi->cs_total.cs_nffree);
620 } 610 }
611
612 if (mtype == UFS_MOUNT_UFSTYPE_44BSD &&
613 (usb2->fs_un.fs_u2.fs_maxbsize == usb1->fs_bsize)) {
614 /* store stats in both old and new places */
615 usb2->fs_un.fs_u2.cs_ndir =
616 cpu_to_fs64(sb, uspi->cs_total.cs_ndir);
617 usb2->fs_un.fs_u2.cs_nbfree =
618 cpu_to_fs64(sb, uspi->cs_total.cs_nbfree);
619 usb3->fs_un1.fs_u2.cs_nifree =
620 cpu_to_fs64(sb, uspi->cs_total.cs_nifree);
621 usb3->fs_un1.fs_u2.cs_nffree =
622 cpu_to_fs64(sb, uspi->cs_total.cs_nffree);
623 }
624 usb1->fs_cstotal.cs_ndir = cpu_to_fs32(sb, uspi->cs_total.cs_ndir);
625 usb1->fs_cstotal.cs_nbfree = cpu_to_fs32(sb, uspi->cs_total.cs_nbfree);
626 usb1->fs_cstotal.cs_nifree = cpu_to_fs32(sb, uspi->cs_total.cs_nifree);
627 usb1->fs_cstotal.cs_nffree = cpu_to_fs32(sb, uspi->cs_total.cs_nffree);
628out:
621 ubh_mark_buffer_dirty(USPI_UBH(uspi)); 629 ubh_mark_buffer_dirty(USPI_UBH(uspi));
622 ufs_print_super_stuff(sb, usb1, usb2, usb3); 630 ufs_print_super_stuff(sb, usb1, usb2, usb3);
623 UFSD("EXIT\n"); 631 UFSD("EXIT\n");
@@ -997,6 +1005,13 @@ again:
997 flags |= UFS_ST_SUN; 1005 flags |= UFS_ST_SUN;
998 } 1006 }
999 1007
1008 if ((flags & UFS_ST_MASK) == UFS_ST_44BSD &&
1009 uspi->s_postblformat == UFS_42POSTBLFMT) {
1010 if (!silent)
1011 pr_err("this is not a 44bsd filesystem");
1012 goto failed;
1013 }
1014
1000 /* 1015 /*
1001 * Check ufs magic number 1016 * Check ufs magic number
1002 */ 1017 */