aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ufs/super.c
diff options
context:
space:
mode:
authorEvgeniy <dushistov@mail.ru>2006-01-14 03:42:06 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-14 13:27:32 -0500
commit7b4ee73e28052e53aac2fef1c91029666d8b2d70 (patch)
treea82714e4b9c2e1157695872b66bf180dc12b27a2 /fs/ufs/super.c
parent59af70385fb125f819d953801b6c45629836e916 (diff)
[PATCH] ufs cleanup
Here is update of ufs cleanup patch, brought on by the recently fixed ubh_get_usb_second() bug that made some ugly code rather painfully obvious. It also includes - fix compilation warnings which appears if debug mode turn on - remove unnecessary duplication of code to support UFS2 I tested it on ufs1 and ufs2 file-systems. Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ufs/super.c')
-rw-r--r--fs/ufs/super.c57
1 files changed, 27 insertions, 30 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index e9a42c711a9..d4aacee593f 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -221,7 +221,7 @@ void ufs_error (struct super_block * sb, const char * function,
221 va_list args; 221 va_list args;
222 222
223 uspi = UFS_SB(sb)->s_uspi; 223 uspi = UFS_SB(sb)->s_uspi;
224 usb1 = ubh_get_usb_first(USPI_UBH); 224 usb1 = ubh_get_usb_first(uspi);
225 225
226 if (!(sb->s_flags & MS_RDONLY)) { 226 if (!(sb->s_flags & MS_RDONLY)) {
227 usb1->fs_clean = UFS_FSBAD; 227 usb1->fs_clean = UFS_FSBAD;
@@ -253,7 +253,7 @@ void ufs_panic (struct super_block * sb, const char * function,
253 va_list args; 253 va_list args;
254 254
255 uspi = UFS_SB(sb)->s_uspi; 255 uspi = UFS_SB(sb)->s_uspi;
256 usb1 = ubh_get_usb_first(USPI_UBH); 256 usb1 = ubh_get_usb_first(uspi);
257 257
258 if (!(sb->s_flags & MS_RDONLY)) { 258 if (!(sb->s_flags & MS_RDONLY)) {
259 usb1->fs_clean = UFS_FSBAD; 259 usb1->fs_clean = UFS_FSBAD;
@@ -420,21 +420,18 @@ static int ufs_read_cylinder_structures (struct super_block *sb) {
420 if (i + uspi->s_fpb > blks) 420 if (i + uspi->s_fpb > blks)
421 size = (blks - i) * uspi->s_fsize; 421 size = (blks - i) * uspi->s_fsize;
422 422
423 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { 423 if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2)
424 ubh = ubh_bread(sb, 424 ubh = ubh_bread(sb,
425 fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size); 425 fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size);
426 if (!ubh) 426 else
427 goto failed;
428 ubh_ubhcpymem (space, ubh, size);
429 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space;
430 }
431 else {
432 ubh = ubh_bread(sb, uspi->s_csaddr + i, size); 427 ubh = ubh_bread(sb, uspi->s_csaddr + i, size);
433 if (!ubh) 428
434 goto failed; 429 if (!ubh)
435 ubh_ubhcpymem(space, ubh, size); 430 goto failed;
436 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space; 431
437 } 432 ubh_ubhcpymem (space, ubh, size);
433 sbi->s_csp[ufs_fragstoblks(i)]=(struct ufs_csum *)space;
434
438 space += size; 435 space += size;
439 ubh_brelse (ubh); 436 ubh_brelse (ubh);
440 ubh = NULL; 437 ubh = NULL;
@@ -539,6 +536,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
539 struct inode *inode; 536 struct inode *inode;
540 unsigned block_size, super_block_size; 537 unsigned block_size, super_block_size;
541 unsigned flags; 538 unsigned flags;
539 unsigned super_block_offset;
542 540
543 uspi = NULL; 541 uspi = NULL;
544 ubh = NULL; 542 ubh = NULL;
@@ -586,10 +584,11 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
586 if (!uspi) 584 if (!uspi)
587 goto failed; 585 goto failed;
588 586
587 super_block_offset=UFS_SBLOCK;
588
589 /* Keep 2Gig file limit. Some UFS variants need to override 589 /* Keep 2Gig file limit. Some UFS variants need to override
590 this but as I don't know which I'll let those in the know loosen 590 this but as I don't know which I'll let those in the know loosen
591 the rules */ 591 the rules */
592
593 switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { 592 switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) {
594 case UFS_MOUNT_UFSTYPE_44BSD: 593 case UFS_MOUNT_UFSTYPE_44BSD:
595 UFSD(("ufstype=44bsd\n")) 594 UFSD(("ufstype=44bsd\n"))
@@ -601,7 +600,8 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
601 flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; 600 flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD;
602 break; 601 break;
603 case UFS_MOUNT_UFSTYPE_UFS2: 602 case UFS_MOUNT_UFSTYPE_UFS2:
604 UFSD(("ufstype=ufs2\n")) 603 UFSD(("ufstype=ufs2\n"));
604 super_block_offset=SBLOCK_UFS2;
605 uspi->s_fsize = block_size = 512; 605 uspi->s_fsize = block_size = 512;
606 uspi->s_fmask = ~(512 - 1); 606 uspi->s_fmask = ~(512 - 1);
607 uspi->s_fshift = 9; 607 uspi->s_fshift = 9;
@@ -725,19 +725,16 @@ again:
725 /* 725 /*
726 * read ufs super block from device 726 * read ufs super block from device
727 */ 727 */
728 if ( (flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { 728
729 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + SBLOCK_UFS2/block_size, super_block_size); 729 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + super_block_offset/block_size, super_block_size);
730 } 730
731 else {
732 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + UFS_SBLOCK/block_size, super_block_size);
733 }
734 if (!ubh) 731 if (!ubh)
735 goto failed; 732 goto failed;
736 733
737 734
738 usb1 = ubh_get_usb_first(USPI_UBH); 735 usb1 = ubh_get_usb_first(uspi);
739 usb2 = ubh_get_usb_second(USPI_UBH); 736 usb2 = ubh_get_usb_second(uspi);
740 usb3 = ubh_get_usb_third(USPI_UBH); 737 usb3 = ubh_get_usb_third(uspi);
741 usb = (struct ufs_super_block *) 738 usb = (struct ufs_super_block *)
742 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; 739 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ;
743 740
@@ -1006,8 +1003,8 @@ static void ufs_write_super (struct super_block *sb) {
1006 UFSD(("ENTER\n")) 1003 UFSD(("ENTER\n"))
1007 flags = UFS_SB(sb)->s_flags; 1004 flags = UFS_SB(sb)->s_flags;
1008 uspi = UFS_SB(sb)->s_uspi; 1005 uspi = UFS_SB(sb)->s_uspi;
1009 usb1 = ubh_get_usb_first(USPI_UBH); 1006 usb1 = ubh_get_usb_first(uspi);
1010 usb3 = ubh_get_usb_third(USPI_UBH); 1007 usb3 = ubh_get_usb_third(uspi);
1011 1008
1012 if (!(sb->s_flags & MS_RDONLY)) { 1009 if (!(sb->s_flags & MS_RDONLY)) {
1013 usb1->fs_time = cpu_to_fs32(sb, get_seconds()); 1010 usb1->fs_time = cpu_to_fs32(sb, get_seconds());
@@ -1049,8 +1046,8 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1049 1046
1050 uspi = UFS_SB(sb)->s_uspi; 1047 uspi = UFS_SB(sb)->s_uspi;
1051 flags = UFS_SB(sb)->s_flags; 1048 flags = UFS_SB(sb)->s_flags;
1052 usb1 = ubh_get_usb_first(USPI_UBH); 1049 usb1 = ubh_get_usb_first(uspi);
1053 usb3 = ubh_get_usb_third(USPI_UBH); 1050 usb3 = ubh_get_usb_third(uspi);
1054 1051
1055 /* 1052 /*
1056 * Allow the "check" option to be passed as a remount option. 1053 * Allow the "check" option to be passed as a remount option.
@@ -1124,7 +1121,7 @@ static int ufs_statfs (struct super_block *sb, struct kstatfs *buf)
1124 lock_kernel(); 1121 lock_kernel();
1125 1122
1126 uspi = UFS_SB(sb)->s_uspi; 1123 uspi = UFS_SB(sb)->s_uspi;
1127 usb1 = ubh_get_usb_first (USPI_UBH); 1124 usb1 = ubh_get_usb_first (uspi);
1128 usb = (struct ufs_super_block *) 1125 usb = (struct ufs_super_block *)
1129 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; 1126 ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ;
1130 1127