diff options
author | Evgeniy Dushistov <dushistov@mail.ru> | 2006-06-25 08:47:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-25 13:01:04 -0400 |
commit | 647b7e87b56f594daf648f44abfbeeb5eb6a9457 (patch) | |
tree | 2a81679a2a9f7ee0a0ad984fbae4d43be050fd51 /fs | |
parent | f391475812ba39afa322c835217ffe936f5e754a (diff) |
[PATCH] ufs: one way to access super block
Super block of UFS usually has size >512, because of fragment size may be 512,
this cause some problems.
Currently, there are two methods to work with ufs super block:
1) split structure which describes ufs super blocks into structures with
size <=512
2) use one structure which describes ufs super block, and hope that array
of "buffer_head" which holds "super block", has such construction:
bh[n]->b_data + bh[n]->b_size == bh[n + 1]->b_data
The second variant may cause some problems in the future, and usage of two
variants cause unnecessary code duplication.
This patch remove the second variant. Also patch contains some CodingStyle
fixes.
Signed-off-by: Evgeniy Dushistov <dushistov@mail.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ufs/super.c | 217 | ||||
-rw-r--r-- | fs/ufs/util.h | 52 |
2 files changed, 121 insertions, 148 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index c8339e566380..3aadbd3167a6 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -94,82 +94,77 @@ | |||
94 | /* | 94 | /* |
95 | * Print contents of ufs_super_block, useful for debugging | 95 | * Print contents of ufs_super_block, useful for debugging |
96 | */ | 96 | */ |
97 | void ufs_print_super_stuff(struct super_block *sb, | 97 | static void ufs_print_super_stuff(struct super_block *sb, unsigned flags, |
98 | struct ufs_super_block_first * usb1, | 98 | struct ufs_super_block_first *usb1, |
99 | struct ufs_super_block_second * usb2, | 99 | struct ufs_super_block_second *usb2, |
100 | struct ufs_super_block_third * usb3) | 100 | struct ufs_super_block_third *usb3) |
101 | { | 101 | { |
102 | printk("ufs_print_super_stuff\n"); | 102 | printk("ufs_print_super_stuff\n"); |
103 | printk("size of usb: %zu\n", sizeof(struct ufs_super_block)); | 103 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic)); |
104 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic)); | 104 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
105 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); | 105 | printk(" fs_size: %llu\n", (unsigned long long) |
106 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); | 106 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size)); |
107 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); | 107 | printk(" fs_dsize: %llu\n", (unsigned long long) |
108 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); | 108 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize)); |
109 | printk(" cgoffset: %u\n", fs32_to_cpu(sb, usb1->fs_cgoffset)); | 109 | printk(" bsize: %u\n", |
110 | printk(" ~cgmask: 0x%x\n", ~fs32_to_cpu(sb, usb1->fs_cgmask)); | 110 | fs32_to_cpu(sb, usb1->fs_bsize)); |
111 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); | 111 | printk(" fsize: %u\n", |
112 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); | 112 | fs32_to_cpu(sb, usb1->fs_fsize)); |
113 | printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); | 113 | printk(" fs_volname: %s\n", usb2->fs_un.fs_u2.fs_volname); |
114 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); | 114 | printk(" fs_sblockloc: %llu\n", (unsigned long long) |
115 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); | 115 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.fs_sblockloc)); |
116 | printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); | 116 | printk(" cs_ndir(No of dirs): %llu\n", (unsigned long long) |
117 | printk(" fragshift: %u\n", fs32_to_cpu(sb, usb1->fs_fragshift)); | 117 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir)); |
118 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); | 118 | printk(" cs_nbfree(No of free blocks): %llu\n", |
119 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); | 119 | (unsigned long long) |
120 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); | 120 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)); |
121 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); | 121 | } else { |
122 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); | 122 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); |
123 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); | 123 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); |
124 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); | 124 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); |
125 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); | 125 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); |
126 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); | 126 | printk(" cgoffset: %u\n", |
127 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); | 127 | fs32_to_cpu(sb, usb1->fs_cgoffset)); |
128 | printk(" fstodb: %u\n", fs32_to_cpu(sb, usb1->fs_fsbtodb)); | 128 | printk(" ~cgmask: 0x%x\n", |
129 | printk(" contigsumsize: %d\n", fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_contigsumsize)); | 129 | ~fs32_to_cpu(sb, usb1->fs_cgmask)); |
130 | printk(" postblformat: %u\n", fs32_to_cpu(sb, usb3->fs_postblformat)); | 130 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); |
131 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); | 131 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); |
132 | printk(" ndir %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); | 132 | printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); |
133 | printk(" nifree %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); | 133 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); |
134 | printk(" nbfree %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); | 134 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); |
135 | printk(" nffree %u\n", fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); | 135 | printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); |
136 | printk("\n"); | 136 | printk(" fragshift: %u\n", |
137 | } | 137 | fs32_to_cpu(sb, usb1->fs_fragshift)); |
138 | 138 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); | |
139 | /* | 139 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); |
140 | * Print contents of ufs2 ufs_super_block, useful for debugging | 140 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); |
141 | */ | 141 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); |
142 | void ufs2_print_super_stuff( | 142 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); |
143 | struct super_block *sb, | 143 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); |
144 | struct ufs_super_block *usb) | 144 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); |
145 | { | 145 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); |
146 | printk("ufs_print_super_stuff\n"); | 146 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); |
147 | printk("size of usb: %zu\n", sizeof(struct ufs_super_block)); | 147 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); |
148 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb->fs_magic)); | 148 | printk(" fstodb: %u\n", |
149 | printk(" fs_size: %llu\n", | 149 | fs32_to_cpu(sb, usb1->fs_fsbtodb)); |
150 | (unsigned long long)fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_size)); | 150 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); |
151 | printk(" fs_dsize: %llu\n", | 151 | printk(" ndir %u\n", |
152 | (unsigned long long)fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize)); | 152 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); |
153 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb->fs_bsize)); | 153 | printk(" nifree %u\n", |
154 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb->fs_fsize)); | 154 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); |
155 | printk(" fs_volname: %s\n", usb->fs_u11.fs_u2.fs_volname); | 155 | printk(" nbfree %u\n", |
156 | printk(" fs_fsmnt: %s\n", usb->fs_u11.fs_u2.fs_fsmnt); | 156 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); |
157 | printk(" fs_sblockloc: %llu\n", | 157 | printk(" nffree %u\n", |
158 | (unsigned long long)fs64_to_cpu(sb, | 158 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); |
159 | usb->fs_u11.fs_u2.fs_sblockloc)); | 159 | } |
160 | printk(" cs_ndir(No of dirs): %llu\n", | ||
161 | (unsigned long long)fs64_to_cpu(sb, | ||
162 | usb->fs_u11.fs_u2.fs_cstotal.cs_ndir)); | ||
163 | printk(" cs_nbfree(No of free blocks): %llu\n", | ||
164 | (unsigned long long)fs64_to_cpu(sb, | ||
165 | usb->fs_u11.fs_u2.fs_cstotal.cs_nbfree)); | ||
166 | printk("\n"); | 160 | printk("\n"); |
167 | } | 161 | } |
168 | 162 | ||
169 | /* | 163 | /* |
170 | * Print contents of ufs_cylinder_group, useful for debugging | 164 | * Print contents of ufs_cylinder_group, useful for debugging |
171 | */ | 165 | */ |
172 | void ufs_print_cylinder_stuff(struct super_block *sb, struct ufs_cylinder_group *cg) | 166 | static void ufs_print_cylinder_stuff(struct super_block *sb, |
167 | struct ufs_cylinder_group *cg) | ||
173 | { | 168 | { |
174 | printk("\nufs_print_cylinder_stuff\n"); | 169 | printk("\nufs_print_cylinder_stuff\n"); |
175 | printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group)); | 170 | printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group)); |
@@ -196,11 +191,17 @@ void ufs_print_cylinder_stuff(struct super_block *sb, struct ufs_cylinder_group | |||
196 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); | 191 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); |
197 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); | 192 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); |
198 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); | 193 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); |
199 | printk(" clustersumoff %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); | 194 | printk(" clustersumoff %u\n", |
200 | printk(" clusteroff %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clusteroff)); | 195 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); |
201 | printk(" nclusterblks %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_nclusterblks)); | 196 | printk(" clusteroff %u\n", |
197 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clusteroff)); | ||
198 | printk(" nclusterblks %u\n", | ||
199 | fs32_to_cpu(sb, cg->cg_u.cg_44.cg_nclusterblks)); | ||
202 | printk("\n"); | 200 | printk("\n"); |
203 | } | 201 | } |
202 | #else | ||
203 | # define ufs_print_super_stuff(sb, flags, usb1, usb2, usb3) /**/ | ||
204 | # define ufs_print_cylinder_stuff(sb, cg) /**/ | ||
204 | #endif /* CONFIG_UFS_DEBUG */ | 205 | #endif /* CONFIG_UFS_DEBUG */ |
205 | 206 | ||
206 | static struct super_operations ufs_super_ops; | 207 | static struct super_operations ufs_super_ops; |
@@ -384,9 +385,9 @@ static int ufs_parse_options (char * options, unsigned * mount_options) | |||
384 | */ | 385 | */ |
385 | static int ufs_read_cylinder_structures (struct super_block *sb) | 386 | static int ufs_read_cylinder_structures (struct super_block *sb) |
386 | { | 387 | { |
387 | struct ufs_sb_info * sbi = UFS_SB(sb); | 388 | struct ufs_sb_info *sbi = UFS_SB(sb); |
388 | struct ufs_sb_private_info * uspi; | 389 | struct ufs_sb_private_info *uspi = sbi->s_uspi; |
389 | struct ufs_super_block *usb; | 390 | struct ufs_super_block_third *usb3; |
390 | struct ufs_buffer_head * ubh; | 391 | struct ufs_buffer_head * ubh; |
391 | unsigned char * base, * space; | 392 | unsigned char * base, * space; |
392 | unsigned size, blks, i; | 393 | unsigned size, blks, i; |
@@ -394,10 +395,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
394 | 395 | ||
395 | UFSD("ENTER\n"); | 396 | UFSD("ENTER\n"); |
396 | 397 | ||
397 | uspi = sbi->s_uspi; | 398 | usb3 = ubh_get_usb_third(uspi); |
398 | |||
399 | usb = (struct ufs_super_block *) | ||
400 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data; | ||
401 | 399 | ||
402 | flags = UFS_SB(sb)->s_flags; | 400 | flags = UFS_SB(sb)->s_flags; |
403 | 401 | ||
@@ -418,7 +416,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
418 | 416 | ||
419 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) | 417 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
420 | ubh = ubh_bread(sb, | 418 | ubh = ubh_bread(sb, |
421 | fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size); | 419 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr) + i, size); |
422 | else | 420 | else |
423 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); | 421 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); |
424 | 422 | ||
@@ -450,9 +448,8 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
450 | goto failed; | 448 | goto failed; |
451 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) | 449 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) |
452 | goto failed; | 450 | goto failed; |
453 | #ifdef CONFIG_UFS_DEBUG | 451 | |
454 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); | 452 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); |
455 | #endif | ||
456 | } | 453 | } |
457 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { | 454 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { |
458 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) | 455 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) |
@@ -818,12 +815,8 @@ magic_found: | |||
818 | goto again; | 815 | goto again; |
819 | } | 816 | } |
820 | 817 | ||
821 | #ifdef CONFIG_UFS_DEBUG | 818 | |
822 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) | 819 | ufs_print_super_stuff(sb, flags, usb1, usb2, usb3); |
823 | ufs2_print_super_stuff(sb,usb); | ||
824 | else | ||
825 | ufs_print_super_stuff(sb, usb1, usb2, usb3); | ||
826 | #endif | ||
827 | 820 | ||
828 | /* | 821 | /* |
829 | * Check, if file system was correctly unmounted. | 822 | * Check, if file system was correctly unmounted. |
@@ -878,10 +871,9 @@ magic_found: | |||
878 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); | 871 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); |
879 | 872 | ||
880 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 873 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
881 | uspi->s_u2_size = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_size); | 874 | uspi->s_u2_size = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size); |
882 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize); | 875 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
883 | } | 876 | } else { |
884 | else { | ||
885 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); | 877 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); |
886 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); | 878 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); |
887 | } | 879 | } |
@@ -916,8 +908,8 @@ magic_found: | |||
916 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); | 908 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); |
917 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); | 909 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); |
918 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); | 910 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); |
919 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_cpc); | 911 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_un.fs_u1.fs_cpc); |
920 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_contigsumsize); | 912 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_contigsumsize); |
921 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); | 913 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); |
922 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); | 914 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); |
923 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); | 915 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); |
@@ -949,7 +941,7 @@ magic_found: | |||
949 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == | 941 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == |
950 | UFS_MOUNT_UFSTYPE_44BSD) | 942 | UFS_MOUNT_UFSTYPE_44BSD) |
951 | uspi->s_maxsymlinklen = | 943 | uspi->s_maxsymlinklen = |
952 | fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_maxsymlinklen); | 944 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
953 | 945 | ||
954 | sbi->s_flags = flags; | 946 | sbi->s_flags = flags; |
955 | 947 | ||
@@ -987,7 +979,8 @@ failed_nomem: | |||
987 | return -ENOMEM; | 979 | return -ENOMEM; |
988 | } | 980 | } |
989 | 981 | ||
990 | static void ufs_write_super (struct super_block *sb) { | 982 | static void ufs_write_super(struct super_block *sb) |
983 | { | ||
991 | struct ufs_sb_private_info * uspi; | 984 | struct ufs_sb_private_info * uspi; |
992 | struct ufs_super_block_first * usb1; | 985 | struct ufs_super_block_first * usb1; |
993 | struct ufs_super_block_third * usb3; | 986 | struct ufs_super_block_third * usb3; |
@@ -1027,7 +1020,7 @@ static void ufs_put_super(struct super_block *sb) | |||
1027 | kfree (sbi->s_uspi); | 1020 | kfree (sbi->s_uspi); |
1028 | kfree (sbi); | 1021 | kfree (sbi); |
1029 | sb->s_fs_info = NULL; | 1022 | sb->s_fs_info = NULL; |
1030 | UFSD("EXIT\n"); | 1023 | UFSD("EXIT\n"); |
1031 | return; | 1024 | return; |
1032 | } | 1025 | } |
1033 | 1026 | ||
@@ -1107,31 +1100,29 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1107 | return 0; | 1100 | return 0; |
1108 | } | 1101 | } |
1109 | 1102 | ||
1110 | static int ufs_statfs (struct dentry *dentry, struct kstatfs *buf) | 1103 | static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf) |
1111 | { | 1104 | { |
1112 | struct super_block *sb = dentry->d_sb; | 1105 | struct super_block *sb = dentry->d_sb; |
1113 | struct ufs_sb_private_info * uspi; | 1106 | struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi; |
1114 | struct ufs_super_block_first * usb1; | 1107 | unsigned flags = UFS_SB(sb)->s_flags; |
1115 | struct ufs_super_block * usb; | 1108 | struct ufs_super_block_first *usb1; |
1116 | unsigned flags = 0; | 1109 | struct ufs_super_block_second *usb2; |
1110 | struct ufs_super_block_third *usb3; | ||
1117 | 1111 | ||
1118 | lock_kernel(); | 1112 | lock_kernel(); |
1119 | 1113 | ||
1120 | uspi = UFS_SB(sb)->s_uspi; | 1114 | usb1 = ubh_get_usb_first(uspi); |
1121 | usb1 = ubh_get_usb_first (uspi); | 1115 | usb2 = ubh_get_usb_second(uspi); |
1122 | usb = (struct ufs_super_block *) | 1116 | usb3 = ubh_get_usb_third(uspi); |
1123 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; | ||
1124 | 1117 | ||
1125 | flags = UFS_SB(sb)->s_flags; | ||
1126 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 1118 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
1127 | buf->f_type = UFS2_MAGIC; | 1119 | buf->f_type = UFS2_MAGIC; |
1128 | buf->f_blocks = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize); | 1120 | buf->f_blocks = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
1129 | buf->f_bfree = ufs_blkstofrags(fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_cstotal.cs_nbfree)) + | 1121 | buf->f_bfree = ufs_blkstofrags( |
1130 | fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_cstotal.cs_nffree); | 1122 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)) + |
1131 | buf->f_ffree = fs64_to_cpu(sb, | 1123 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree); |
1132 | usb->fs_u11.fs_u2.fs_cstotal.cs_nifree); | 1124 | buf->f_ffree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree); |
1133 | } | 1125 | } else { |
1134 | else { | ||
1135 | buf->f_type = UFS_MAGIC; | 1126 | buf->f_type = UFS_MAGIC; |
1136 | buf->f_blocks = uspi->s_dsize; | 1127 | buf->f_blocks = uspi->s_dsize; |
1137 | buf->f_bfree = ufs_blkstofrags(fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)) + | 1128 | buf->f_bfree = ufs_blkstofrags(fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)) + |
diff --git a/fs/ufs/util.h b/fs/ufs/util.h index e95d1c46461f..eacd5e37b8e6 100644 --- a/fs/ufs/util.h +++ b/fs/ufs/util.h | |||
@@ -39,12 +39,12 @@ ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
39 | { | 39 | { |
40 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 40 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
41 | case UFS_ST_SUN: | 41 | case UFS_ST_SUN: |
42 | return fs32_to_cpu(sb, usb3->fs_u2.fs_sun.fs_state); | 42 | return fs32_to_cpu(sb, usb3->fs_un2.fs_sun.fs_state); |
43 | case UFS_ST_SUNx86: | 43 | case UFS_ST_SUNx86: |
44 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); | 44 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state); |
45 | case UFS_ST_44BSD: | 45 | case UFS_ST_44BSD: |
46 | default: | 46 | default: |
47 | return fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_state); | 47 | return fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_state); |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
@@ -54,13 +54,13 @@ ufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
54 | { | 54 | { |
55 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 55 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
56 | case UFS_ST_SUN: | 56 | case UFS_ST_SUN: |
57 | usb3->fs_u2.fs_sun.fs_state = cpu_to_fs32(sb, value); | 57 | usb3->fs_un2.fs_sun.fs_state = cpu_to_fs32(sb, value); |
58 | break; | 58 | break; |
59 | case UFS_ST_SUNx86: | 59 | case UFS_ST_SUNx86: |
60 | usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); | 60 | usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value); |
61 | break; | 61 | break; |
62 | case UFS_ST_44BSD: | 62 | case UFS_ST_44BSD: |
63 | usb3->fs_u2.fs_44.fs_state = cpu_to_fs32(sb, value); | 63 | usb3->fs_un2.fs_44.fs_state = cpu_to_fs32(sb, value); |
64 | break; | 64 | break; |
65 | } | 65 | } |
66 | } | 66 | } |
@@ -70,7 +70,7 @@ ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1, | |||
70 | struct ufs_super_block_third *usb3) | 70 | struct ufs_super_block_third *usb3) |
71 | { | 71 | { |
72 | if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) | 72 | if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
73 | return fs32_to_cpu(sb, usb3->fs_u2.fs_sunx86.fs_npsect); | 73 | return fs32_to_cpu(sb, usb3->fs_un2.fs_sunx86.fs_npsect); |
74 | else | 74 | else |
75 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); | 75 | return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect); |
76 | } | 76 | } |
@@ -82,16 +82,16 @@ ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3) | |||
82 | 82 | ||
83 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 83 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
84 | case UFS_ST_SUN: | 84 | case UFS_ST_SUN: |
85 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qbmask[0]; | 85 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qbmask[0]; |
86 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qbmask[1]; | 86 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qbmask[1]; |
87 | break; | 87 | break; |
88 | case UFS_ST_SUNx86: | 88 | case UFS_ST_SUNx86: |
89 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qbmask[0]; | 89 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qbmask[0]; |
90 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qbmask[1]; | 90 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qbmask[1]; |
91 | break; | 91 | break; |
92 | case UFS_ST_44BSD: | 92 | case UFS_ST_44BSD: |
93 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qbmask[0]; | 93 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qbmask[0]; |
94 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qbmask[1]; | 94 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qbmask[1]; |
95 | break; | 95 | break; |
96 | } | 96 | } |
97 | 97 | ||
@@ -105,16 +105,16 @@ ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3) | |||
105 | 105 | ||
106 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { | 106 | switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) { |
107 | case UFS_ST_SUN: | 107 | case UFS_ST_SUN: |
108 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qfmask[0]; | 108 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qfmask[0]; |
109 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qfmask[1]; | 109 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qfmask[1]; |
110 | break; | 110 | break; |
111 | case UFS_ST_SUNx86: | 111 | case UFS_ST_SUNx86: |
112 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qfmask[0]; | 112 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qfmask[0]; |
113 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qfmask[1]; | 113 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qfmask[1]; |
114 | break; | 114 | break; |
115 | case UFS_ST_44BSD: | 115 | case UFS_ST_44BSD: |
116 | ((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qfmask[0]; | 116 | ((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qfmask[0]; |
117 | ((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qfmask[1]; | 117 | ((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qfmask[1]; |
118 | break; | 118 | break; |
119 | } | 119 | } |
120 | 120 | ||
@@ -302,24 +302,6 @@ static inline void *get_usb_offset(struct ufs_sb_private_info *uspi, | |||
302 | #define ubh_blkmap(ubh,begin,bit) \ | 302 | #define ubh_blkmap(ubh,begin,bit) \ |
303 | ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) | 303 | ((*ubh_get_addr(ubh, (begin) + ((bit) >> 3)) >> ((bit) & 7)) & (0xff >> (UFS_MAXFRAG - uspi->s_fpb))) |
304 | 304 | ||
305 | |||
306 | /* | ||
307 | * Macros for access to superblock array structures | ||
308 | */ | ||
309 | #define ubh_postbl(ubh,cylno,i) \ | ||
310 | ((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \ | ||
311 | ? (*(__s16*)(ubh_get_addr(ubh, \ | ||
312 | (unsigned)(&((struct ufs_super_block *)0)->fs_opostbl) \ | ||
313 | + (((cylno) * 16 + (i)) << 1) ) )) \ | ||
314 | : (*(__s16*)(ubh_get_addr(ubh, \ | ||
315 | uspi->s_postbloff + (((cylno) * uspi->s_nrpos + (i)) << 1) )))) | ||
316 | |||
317 | #define ubh_rotbl(ubh,i) \ | ||
318 | ((uspi->s_postblformat != UFS_DYNAMICPOSTBLFMT) \ | ||
319 | ? (*(__u8*)(ubh_get_addr(ubh, \ | ||
320 | (unsigned)(&((struct ufs_super_block *)0)->fs_space) + (i)))) \ | ||
321 | : (*(__u8*)(ubh_get_addr(ubh, uspi->s_rotbloff + (i))))) | ||
322 | |||
323 | /* | 305 | /* |
324 | * Determine the number of available frags given a | 306 | * Determine the number of available frags given a |
325 | * percentage to hold in reserve. | 307 | * percentage to hold in reserve. |