diff options
Diffstat (limited to 'fs/ufs/super.c')
-rw-r--r-- | fs/ufs/super.c | 429 |
1 files changed, 240 insertions, 189 deletions
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index fe5ab2aa2899..74ef5e9bedff 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
@@ -90,95 +90,84 @@ | |||
90 | #include "swab.h" | 90 | #include "swab.h" |
91 | #include "util.h" | 91 | #include "util.h" |
92 | 92 | ||
93 | #undef UFS_SUPER_DEBUG | 93 | #ifdef CONFIG_UFS_DEBUG |
94 | #undef UFS_SUPER_DEBUG_MORE | ||
95 | |||
96 | |||
97 | #undef UFS_SUPER_DEBUG_MORE | ||
98 | #ifdef UFS_SUPER_DEBUG | ||
99 | #define UFSD(x) printk("(%s, %d), %s: ", __FILE__, __LINE__, __FUNCTION__); printk x; | ||
100 | #else | ||
101 | #define UFSD(x) | ||
102 | #endif | ||
103 | |||
104 | #ifdef UFS_SUPER_DEBUG_MORE | ||
105 | /* | 94 | /* |
106 | * Print contents of ufs_super_block, useful for debugging | 95 | * Print contents of ufs_super_block, useful for debugging |
107 | */ | 96 | */ |
108 | void ufs_print_super_stuff(struct super_block *sb, | 97 | static void ufs_print_super_stuff(struct super_block *sb, unsigned flags, |
109 | struct ufs_super_block_first * usb1, | 98 | struct ufs_super_block_first *usb1, |
110 | struct ufs_super_block_second * usb2, | 99 | struct ufs_super_block_second *usb2, |
111 | struct ufs_super_block_third * usb3) | 100 | struct ufs_super_block_third *usb3) |
112 | { | 101 | { |
113 | printk("ufs_print_super_stuff\n"); | 102 | printk("ufs_print_super_stuff\n"); |
114 | printk("size of usb: %u\n", sizeof(struct ufs_super_block)); | 103 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic)); |
115 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb3->fs_magic)); | 104 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
116 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); | 105 | printk(" fs_size: %llu\n", (unsigned long long) |
117 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); | 106 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size)); |
118 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); | 107 | printk(" fs_dsize: %llu\n", (unsigned long long) |
119 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); | 108 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize)); |
120 | printk(" cgoffset: %u\n", fs32_to_cpu(sb, usb1->fs_cgoffset)); | 109 | printk(" bsize: %u\n", |
121 | printk(" ~cgmask: 0x%x\n", ~fs32_to_cpu(sb, usb1->fs_cgmask)); | 110 | fs32_to_cpu(sb, usb1->fs_bsize)); |
122 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); | 111 | printk(" fsize: %u\n", |
123 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); | 112 | fs32_to_cpu(sb, usb1->fs_fsize)); |
124 | printk(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); | 113 | printk(" fs_volname: %s\n", usb2->fs_un.fs_u2.fs_volname); |
125 | printk(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); | 114 | printk(" fs_sblockloc: %llu\n", (unsigned long long) |
126 | printk(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); | 115 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.fs_sblockloc)); |
127 | printk(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); | 116 | printk(" cs_ndir(No of dirs): %llu\n", (unsigned long long) |
128 | printk(" fragshift: %u\n", fs32_to_cpu(sb, usb1->fs_fragshift)); | 117 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir)); |
129 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); | 118 | printk(" cs_nbfree(No of free blocks): %llu\n", |
130 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); | 119 | (unsigned long long) |
131 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); | 120 | fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)); |
132 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); | 121 | } else { |
133 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); | 122 | printk(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); |
134 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); | 123 | printk(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); |
135 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); | 124 | printk(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); |
136 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); | 125 | printk(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); |
137 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); | 126 | printk(" cgoffset: %u\n", |
138 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); | 127 | fs32_to_cpu(sb, usb1->fs_cgoffset)); |
139 | printk(" fstodb: %u\n", fs32_to_cpu(sb, usb1->fs_fsbtodb)); | 128 | printk(" ~cgmask: 0x%x\n", |
140 | printk(" contigsumsize: %d\n", fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_contigsumsize)); | 129 | ~fs32_to_cpu(sb, usb1->fs_cgmask)); |
141 | printk(" postblformat: %u\n", fs32_to_cpu(sb, usb3->fs_postblformat)); | 130 | printk(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); |
142 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); | 131 | printk(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); |
143 | 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)); |
144 | 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)); |
145 | 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)); |
146 | 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)); |
147 | printk("\n"); | 136 | printk(" fragshift: %u\n", |
148 | } | 137 | fs32_to_cpu(sb, usb1->fs_fragshift)); |
149 | 138 | printk(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); | |
150 | /* | 139 | printk(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); |
151 | * Print contents of ufs2 ufs_super_block, useful for debugging | 140 | printk(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); |
152 | */ | 141 | printk(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); |
153 | void ufs2_print_super_stuff( | 142 | printk(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); |
154 | struct super_block *sb, | 143 | printk(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); |
155 | struct ufs_super_block *usb) | 144 | printk(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); |
156 | { | 145 | printk(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); |
157 | printk("ufs_print_super_stuff\n"); | 146 | printk(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); |
158 | printk("size of usb: %u\n", sizeof(struct ufs_super_block)); | 147 | printk(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); |
159 | printk(" magic: 0x%x\n", fs32_to_cpu(sb, usb->fs_magic)); | 148 | printk(" fstodb: %u\n", |
160 | printk(" fs_size: %u\n",fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_size)); | 149 | fs32_to_cpu(sb, usb1->fs_fsbtodb)); |
161 | printk(" fs_dsize: %u\n",fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize)); | 150 | printk(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); |
162 | printk(" bsize: %u\n", fs32_to_cpu(usb, usb->fs_bsize)); | 151 | printk(" ndir %u\n", |
163 | printk(" fsize: %u\n", fs32_to_cpu(usb, usb->fs_fsize)); | 152 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); |
164 | printk(" fs_volname: %s\n", usb->fs_u11.fs_u2.fs_volname); | 153 | printk(" nifree %u\n", |
165 | printk(" fs_fsmnt: %s\n", usb->fs_u11.fs_u2.fs_fsmnt); | 154 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); |
166 | printk(" fs_sblockloc: %u\n",fs64_to_cpu(sb, | 155 | printk(" nbfree %u\n", |
167 | usb->fs_u11.fs_u2.fs_sblockloc)); | 156 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); |
168 | printk(" cs_ndir(No of dirs): %u\n",fs64_to_cpu(sb, | 157 | printk(" nffree %u\n", |
169 | usb->fs_u11.fs_u2.fs_cstotal.cs_ndir)); | 158 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); |
170 | printk(" cs_nbfree(No of free blocks): %u\n",fs64_to_cpu(sb, | 159 | } |
171 | usb->fs_u11.fs_u2.fs_cstotal.cs_nbfree)); | ||
172 | printk("\n"); | 160 | printk("\n"); |
173 | } | 161 | } |
174 | 162 | ||
175 | /* | 163 | /* |
176 | * Print contents of ufs_cylinder_group, useful for debugging | 164 | * Print contents of ufs_cylinder_group, useful for debugging |
177 | */ | 165 | */ |
178 | 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) | ||
179 | { | 168 | { |
180 | printk("\nufs_print_cylinder_stuff\n"); | 169 | printk("\nufs_print_cylinder_stuff\n"); |
181 | printk("size of ucg: %u\n", sizeof(struct ufs_cylinder_group)); | 170 | printk("size of ucg: %zu\n", sizeof(struct ufs_cylinder_group)); |
182 | printk(" magic: %x\n", fs32_to_cpu(sb, cg->cg_magic)); | 171 | printk(" magic: %x\n", fs32_to_cpu(sb, cg->cg_magic)); |
183 | printk(" time: %u\n", fs32_to_cpu(sb, cg->cg_time)); | 172 | printk(" time: %u\n", fs32_to_cpu(sb, cg->cg_time)); |
184 | printk(" cgx: %u\n", fs32_to_cpu(sb, cg->cg_cgx)); | 173 | printk(" cgx: %u\n", fs32_to_cpu(sb, cg->cg_cgx)); |
@@ -202,12 +191,18 @@ void ufs_print_cylinder_stuff(struct super_block *sb, struct ufs_cylinder_group | |||
202 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); | 191 | printk(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); |
203 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); | 192 | printk(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); |
204 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); | 193 | printk(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); |
205 | printk(" clustersumoff %u\n", fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); | 194 | printk(" clustersumoff %u\n", |
206 | 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)); |
207 | 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)); | ||
208 | printk("\n"); | 200 | printk("\n"); |
209 | } | 201 | } |
210 | #endif /* UFS_SUPER_DEBUG_MORE */ | 202 | #else |
203 | # define ufs_print_super_stuff(sb, flags, usb1, usb2, usb3) /**/ | ||
204 | # define ufs_print_cylinder_stuff(sb, cg) /**/ | ||
205 | #endif /* CONFIG_UFS_DEBUG */ | ||
211 | 206 | ||
212 | static struct super_operations ufs_super_ops; | 207 | static struct super_operations ufs_super_ops; |
213 | 208 | ||
@@ -225,7 +220,7 @@ void ufs_error (struct super_block * sb, const char * function, | |||
225 | 220 | ||
226 | if (!(sb->s_flags & MS_RDONLY)) { | 221 | if (!(sb->s_flags & MS_RDONLY)) { |
227 | usb1->fs_clean = UFS_FSBAD; | 222 | usb1->fs_clean = UFS_FSBAD; |
228 | ubh_mark_buffer_dirty(USPI_UBH); | 223 | ubh_mark_buffer_dirty(USPI_UBH(uspi)); |
229 | sb->s_dirt = 1; | 224 | sb->s_dirt = 1; |
230 | sb->s_flags |= MS_RDONLY; | 225 | sb->s_flags |= MS_RDONLY; |
231 | } | 226 | } |
@@ -257,7 +252,7 @@ void ufs_panic (struct super_block * sb, const char * function, | |||
257 | 252 | ||
258 | if (!(sb->s_flags & MS_RDONLY)) { | 253 | if (!(sb->s_flags & MS_RDONLY)) { |
259 | usb1->fs_clean = UFS_FSBAD; | 254 | usb1->fs_clean = UFS_FSBAD; |
260 | ubh_mark_buffer_dirty(USPI_UBH); | 255 | ubh_mark_buffer_dirty(USPI_UBH(uspi)); |
261 | sb->s_dirt = 1; | 256 | sb->s_dirt = 1; |
262 | } | 257 | } |
263 | va_start (args, fmt); | 258 | va_start (args, fmt); |
@@ -309,7 +304,7 @@ static int ufs_parse_options (char * options, unsigned * mount_options) | |||
309 | { | 304 | { |
310 | char * p; | 305 | char * p; |
311 | 306 | ||
312 | UFSD(("ENTER\n")) | 307 | UFSD("ENTER\n"); |
313 | 308 | ||
314 | if (!options) | 309 | if (!options) |
315 | return 1; | 310 | return 1; |
@@ -386,27 +381,57 @@ static int ufs_parse_options (char * options, unsigned * mount_options) | |||
386 | } | 381 | } |
387 | 382 | ||
388 | /* | 383 | /* |
384 | * Diffrent types of UFS hold fs_cstotal in different | ||
385 | * places, and use diffrent data structure for it. | ||
386 | * To make things simplier we just copy fs_cstotal to ufs_sb_private_info | ||
387 | */ | ||
388 | static void ufs_setup_cstotal(struct super_block *sb) | ||
389 | { | ||
390 | struct ufs_sb_info *sbi = UFS_SB(sb); | ||
391 | struct ufs_sb_private_info *uspi = sbi->s_uspi; | ||
392 | struct ufs_super_block_first *usb1; | ||
393 | struct ufs_super_block_second *usb2; | ||
394 | struct ufs_super_block_third *usb3; | ||
395 | unsigned mtype = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; | ||
396 | |||
397 | UFSD("ENTER, mtype=%u\n", mtype); | ||
398 | usb1 = ubh_get_usb_first(uspi); | ||
399 | usb2 = ubh_get_usb_second(uspi); | ||
400 | usb3 = ubh_get_usb_third(uspi); | ||
401 | |||
402 | if ((mtype == UFS_MOUNT_UFSTYPE_44BSD && | ||
403 | (usb1->fs_flags & UFS_FLAGS_UPDATED)) || | ||
404 | mtype == UFS_MOUNT_UFSTYPE_UFS2) { | ||
405 | /*we have statistic in different place, then usual*/ | ||
406 | uspi->cs_total.cs_ndir = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir); | ||
407 | uspi->cs_total.cs_nbfree = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree); | ||
408 | uspi->cs_total.cs_nifree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree); | ||
409 | uspi->cs_total.cs_nffree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree); | ||
410 | } else { | ||
411 | uspi->cs_total.cs_ndir = fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir); | ||
412 | uspi->cs_total.cs_nbfree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree); | ||
413 | uspi->cs_total.cs_nifree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree); | ||
414 | uspi->cs_total.cs_nffree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree); | ||
415 | } | ||
416 | UFSD("EXIT\n"); | ||
417 | } | ||
418 | |||
419 | /* | ||
389 | * Read on-disk structures associated with cylinder groups | 420 | * Read on-disk structures associated with cylinder groups |
390 | */ | 421 | */ |
391 | static int ufs_read_cylinder_structures (struct super_block *sb) | 422 | static int ufs_read_cylinder_structures(struct super_block *sb) |
392 | { | 423 | { |
393 | struct ufs_sb_info * sbi = UFS_SB(sb); | 424 | struct ufs_sb_info *sbi = UFS_SB(sb); |
394 | struct ufs_sb_private_info * uspi; | 425 | struct ufs_sb_private_info *uspi = sbi->s_uspi; |
395 | struct ufs_super_block *usb; | 426 | unsigned flags = sbi->s_flags; |
396 | struct ufs_buffer_head * ubh; | 427 | struct ufs_buffer_head * ubh; |
397 | unsigned char * base, * space; | 428 | unsigned char * base, * space; |
398 | unsigned size, blks, i; | 429 | unsigned size, blks, i; |
399 | unsigned flags = 0; | 430 | struct ufs_super_block_third *usb3; |
400 | |||
401 | UFSD(("ENTER\n")) | ||
402 | |||
403 | uspi = sbi->s_uspi; | ||
404 | 431 | ||
405 | usb = (struct ufs_super_block *) | 432 | UFSD("ENTER\n"); |
406 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data; | ||
407 | 433 | ||
408 | flags = UFS_SB(sb)->s_flags; | 434 | usb3 = ubh_get_usb_third(uspi); |
409 | |||
410 | /* | 435 | /* |
411 | * Read cs structures from (usually) first data block | 436 | * Read cs structures from (usually) first data block |
412 | * on the device. | 437 | * on the device. |
@@ -424,7 +449,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
424 | 449 | ||
425 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) | 450 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
426 | ubh = ubh_bread(sb, | 451 | ubh = ubh_bread(sb, |
427 | fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_csaddr) + i, size); | 452 | fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr) + i, size); |
428 | else | 453 | else |
429 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); | 454 | ubh = ubh_bread(sb, uspi->s_csaddr + i, size); |
430 | 455 | ||
@@ -451,14 +476,13 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
451 | sbi->s_cgno[i] = UFS_CGNO_EMPTY; | 476 | sbi->s_cgno[i] = UFS_CGNO_EMPTY; |
452 | } | 477 | } |
453 | for (i = 0; i < uspi->s_ncg; i++) { | 478 | for (i = 0; i < uspi->s_ncg; i++) { |
454 | UFSD(("read cg %u\n", i)) | 479 | UFSD("read cg %u\n", i); |
455 | if (!(sbi->s_ucg[i] = sb_bread(sb, ufs_cgcmin(i)))) | 480 | if (!(sbi->s_ucg[i] = sb_bread(sb, ufs_cgcmin(i)))) |
456 | goto failed; | 481 | goto failed; |
457 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) | 482 | if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) |
458 | goto failed; | 483 | goto failed; |
459 | #ifdef UFS_SUPER_DEBUG_MORE | 484 | |
460 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); | 485 | ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); |
461 | #endif | ||
462 | } | 486 | } |
463 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { | 487 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) { |
464 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) | 488 | if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_KERNEL))) |
@@ -466,7 +490,7 @@ static int ufs_read_cylinder_structures (struct super_block *sb) | |||
466 | sbi->s_cgno[i] = UFS_CGNO_EMPTY; | 490 | sbi->s_cgno[i] = UFS_CGNO_EMPTY; |
467 | } | 491 | } |
468 | sbi->s_cg_loaded = 0; | 492 | sbi->s_cg_loaded = 0; |
469 | UFSD(("EXIT\n")) | 493 | UFSD("EXIT\n"); |
470 | return 1; | 494 | return 1; |
471 | 495 | ||
472 | failed: | 496 | failed: |
@@ -479,26 +503,69 @@ failed: | |||
479 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) | 503 | for (i = 0; i < UFS_MAX_GROUP_LOADED; i++) |
480 | kfree (sbi->s_ucpi[i]); | 504 | kfree (sbi->s_ucpi[i]); |
481 | } | 505 | } |
482 | UFSD(("EXIT (FAILED)\n")) | 506 | UFSD("EXIT (FAILED)\n"); |
483 | return 0; | 507 | return 0; |
484 | } | 508 | } |
485 | 509 | ||
486 | /* | 510 | /* |
487 | * Put on-disk structures associated with cylinder groups and | 511 | * Sync our internal copy of fs_cstotal with disk |
488 | * write them back to disk | ||
489 | */ | 512 | */ |
490 | static void ufs_put_cylinder_structures (struct super_block *sb) | 513 | static void ufs_put_cstotal(struct super_block *sb) |
491 | { | 514 | { |
492 | struct ufs_sb_info * sbi = UFS_SB(sb); | 515 | unsigned mtype = UFS_SB(sb)->s_mount_opt & UFS_MOUNT_UFSTYPE; |
493 | struct ufs_sb_private_info * uspi; | 516 | struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; |
517 | struct ufs_super_block_first *usb1; | ||
518 | struct ufs_super_block_second *usb2; | ||
519 | struct ufs_super_block_third *usb3; | ||
520 | |||
521 | UFSD("ENTER\n"); | ||
522 | usb1 = ubh_get_usb_first(uspi); | ||
523 | usb2 = ubh_get_usb_second(uspi); | ||
524 | usb3 = ubh_get_usb_third(uspi); | ||
525 | |||
526 | if ((mtype == UFS_MOUNT_UFSTYPE_44BSD && | ||
527 | (usb1->fs_flags & UFS_FLAGS_UPDATED)) || | ||
528 | mtype == UFS_MOUNT_UFSTYPE_UFS2) { | ||
529 | /*we have statistic in different place, then usual*/ | ||
530 | usb2->fs_un.fs_u2.cs_ndir = | ||
531 | cpu_to_fs64(sb, uspi->cs_total.cs_ndir); | ||
532 | usb2->fs_un.fs_u2.cs_nbfree = | ||
533 | cpu_to_fs64(sb, uspi->cs_total.cs_nbfree); | ||
534 | usb3->fs_un1.fs_u2.cs_nifree = | ||
535 | cpu_to_fs64(sb, uspi->cs_total.cs_nifree); | ||
536 | usb3->fs_un1.fs_u2.cs_nffree = | ||
537 | cpu_to_fs64(sb, uspi->cs_total.cs_nffree); | ||
538 | } else { | ||
539 | usb1->fs_cstotal.cs_ndir = | ||
540 | cpu_to_fs32(sb, uspi->cs_total.cs_ndir); | ||
541 | usb1->fs_cstotal.cs_nbfree = | ||
542 | cpu_to_fs32(sb, uspi->cs_total.cs_nbfree); | ||
543 | usb1->fs_cstotal.cs_nifree = | ||
544 | cpu_to_fs32(sb, uspi->cs_total.cs_nifree); | ||
545 | usb1->fs_cstotal.cs_nffree = | ||
546 | cpu_to_fs32(sb, uspi->cs_total.cs_nffree); | ||
547 | } | ||
548 | ubh_mark_buffer_dirty(USPI_UBH(uspi)); | ||
549 | UFSD("EXIT\n"); | ||
550 | } | ||
551 | |||
552 | /** | ||
553 | * ufs_put_super_internal() - put on-disk intrenal structures | ||
554 | * @sb: pointer to super_block structure | ||
555 | * Put on-disk structures associated with cylinder groups | ||
556 | * and write them back to disk, also update cs_total on disk | ||
557 | */ | ||
558 | static void ufs_put_super_internal(struct super_block *sb) | ||
559 | { | ||
560 | struct ufs_sb_info *sbi = UFS_SB(sb); | ||
561 | struct ufs_sb_private_info *uspi = sbi->s_uspi; | ||
494 | struct ufs_buffer_head * ubh; | 562 | struct ufs_buffer_head * ubh; |
495 | unsigned char * base, * space; | 563 | unsigned char * base, * space; |
496 | unsigned blks, size, i; | 564 | unsigned blks, size, i; |
497 | |||
498 | UFSD(("ENTER\n")) | ||
499 | |||
500 | uspi = sbi->s_uspi; | ||
501 | 565 | ||
566 | |||
567 | UFSD("ENTER\n"); | ||
568 | ufs_put_cstotal(sb); | ||
502 | size = uspi->s_cssize; | 569 | size = uspi->s_cssize; |
503 | blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; | 570 | blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; |
504 | base = space = (char*) sbi->s_csp; | 571 | base = space = (char*) sbi->s_csp; |
@@ -523,7 +590,7 @@ static void ufs_put_cylinder_structures (struct super_block *sb) | |||
523 | brelse (sbi->s_ucg[i]); | 590 | brelse (sbi->s_ucg[i]); |
524 | kfree (sbi->s_ucg); | 591 | kfree (sbi->s_ucg); |
525 | kfree (base); | 592 | kfree (base); |
526 | UFSD(("EXIT\n")) | 593 | UFSD("EXIT\n"); |
527 | } | 594 | } |
528 | 595 | ||
529 | static int ufs_fill_super(struct super_block *sb, void *data, int silent) | 596 | static int ufs_fill_super(struct super_block *sb, void *data, int silent) |
@@ -533,7 +600,6 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
533 | struct ufs_super_block_first * usb1; | 600 | struct ufs_super_block_first * usb1; |
534 | struct ufs_super_block_second * usb2; | 601 | struct ufs_super_block_second * usb2; |
535 | struct ufs_super_block_third * usb3; | 602 | struct ufs_super_block_third * usb3; |
536 | struct ufs_super_block *usb; | ||
537 | struct ufs_buffer_head * ubh; | 603 | struct ufs_buffer_head * ubh; |
538 | struct inode *inode; | 604 | struct inode *inode; |
539 | unsigned block_size, super_block_size; | 605 | unsigned block_size, super_block_size; |
@@ -544,7 +610,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
544 | ubh = NULL; | 610 | ubh = NULL; |
545 | flags = 0; | 611 | flags = 0; |
546 | 612 | ||
547 | UFSD(("ENTER\n")) | 613 | UFSD("ENTER\n"); |
548 | 614 | ||
549 | sbi = kmalloc(sizeof(struct ufs_sb_info), GFP_KERNEL); | 615 | sbi = kmalloc(sizeof(struct ufs_sb_info), GFP_KERNEL); |
550 | if (!sbi) | 616 | if (!sbi) |
@@ -552,7 +618,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
552 | sb->s_fs_info = sbi; | 618 | sb->s_fs_info = sbi; |
553 | memset(sbi, 0, sizeof(struct ufs_sb_info)); | 619 | memset(sbi, 0, sizeof(struct ufs_sb_info)); |
554 | 620 | ||
555 | UFSD(("flag %u\n", (int)(sb->s_flags & MS_RDONLY))) | 621 | UFSD("flag %u\n", (int)(sb->s_flags & MS_RDONLY)); |
556 | 622 | ||
557 | #ifndef CONFIG_UFS_FS_WRITE | 623 | #ifndef CONFIG_UFS_FS_WRITE |
558 | if (!(sb->s_flags & MS_RDONLY)) { | 624 | if (!(sb->s_flags & MS_RDONLY)) { |
@@ -593,7 +659,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
593 | the rules */ | 659 | the rules */ |
594 | switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { | 660 | switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { |
595 | case UFS_MOUNT_UFSTYPE_44BSD: | 661 | case UFS_MOUNT_UFSTYPE_44BSD: |
596 | UFSD(("ufstype=44bsd\n")) | 662 | UFSD("ufstype=44bsd\n"); |
597 | uspi->s_fsize = block_size = 512; | 663 | uspi->s_fsize = block_size = 512; |
598 | uspi->s_fmask = ~(512 - 1); | 664 | uspi->s_fmask = ~(512 - 1); |
599 | uspi->s_fshift = 9; | 665 | uspi->s_fshift = 9; |
@@ -602,7 +668,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
602 | flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; | 668 | flags |= UFS_DE_44BSD | UFS_UID_44BSD | UFS_ST_44BSD | UFS_CG_44BSD; |
603 | break; | 669 | break; |
604 | case UFS_MOUNT_UFSTYPE_UFS2: | 670 | case UFS_MOUNT_UFSTYPE_UFS2: |
605 | UFSD(("ufstype=ufs2\n")); | 671 | UFSD("ufstype=ufs2\n"); |
606 | super_block_offset=SBLOCK_UFS2; | 672 | super_block_offset=SBLOCK_UFS2; |
607 | uspi->s_fsize = block_size = 512; | 673 | uspi->s_fsize = block_size = 512; |
608 | uspi->s_fmask = ~(512 - 1); | 674 | uspi->s_fmask = ~(512 - 1); |
@@ -617,7 +683,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
617 | break; | 683 | break; |
618 | 684 | ||
619 | case UFS_MOUNT_UFSTYPE_SUN: | 685 | case UFS_MOUNT_UFSTYPE_SUN: |
620 | UFSD(("ufstype=sun\n")) | 686 | UFSD("ufstype=sun\n"); |
621 | uspi->s_fsize = block_size = 1024; | 687 | uspi->s_fsize = block_size = 1024; |
622 | uspi->s_fmask = ~(1024 - 1); | 688 | uspi->s_fmask = ~(1024 - 1); |
623 | uspi->s_fshift = 10; | 689 | uspi->s_fshift = 10; |
@@ -628,7 +694,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
628 | break; | 694 | break; |
629 | 695 | ||
630 | case UFS_MOUNT_UFSTYPE_SUNx86: | 696 | case UFS_MOUNT_UFSTYPE_SUNx86: |
631 | UFSD(("ufstype=sunx86\n")) | 697 | UFSD("ufstype=sunx86\n"); |
632 | uspi->s_fsize = block_size = 1024; | 698 | uspi->s_fsize = block_size = 1024; |
633 | uspi->s_fmask = ~(1024 - 1); | 699 | uspi->s_fmask = ~(1024 - 1); |
634 | uspi->s_fshift = 10; | 700 | uspi->s_fshift = 10; |
@@ -639,7 +705,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
639 | break; | 705 | break; |
640 | 706 | ||
641 | case UFS_MOUNT_UFSTYPE_OLD: | 707 | case UFS_MOUNT_UFSTYPE_OLD: |
642 | UFSD(("ufstype=old\n")) | 708 | UFSD("ufstype=old\n"); |
643 | uspi->s_fsize = block_size = 1024; | 709 | uspi->s_fsize = block_size = 1024; |
644 | uspi->s_fmask = ~(1024 - 1); | 710 | uspi->s_fmask = ~(1024 - 1); |
645 | uspi->s_fshift = 10; | 711 | uspi->s_fshift = 10; |
@@ -654,7 +720,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
654 | break; | 720 | break; |
655 | 721 | ||
656 | case UFS_MOUNT_UFSTYPE_NEXTSTEP: | 722 | case UFS_MOUNT_UFSTYPE_NEXTSTEP: |
657 | UFSD(("ufstype=nextstep\n")) | 723 | UFSD("ufstype=nextstep\n"); |
658 | uspi->s_fsize = block_size = 1024; | 724 | uspi->s_fsize = block_size = 1024; |
659 | uspi->s_fmask = ~(1024 - 1); | 725 | uspi->s_fmask = ~(1024 - 1); |
660 | uspi->s_fshift = 10; | 726 | uspi->s_fshift = 10; |
@@ -669,7 +735,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
669 | break; | 735 | break; |
670 | 736 | ||
671 | case UFS_MOUNT_UFSTYPE_NEXTSTEP_CD: | 737 | case UFS_MOUNT_UFSTYPE_NEXTSTEP_CD: |
672 | UFSD(("ufstype=nextstep-cd\n")) | 738 | UFSD("ufstype=nextstep-cd\n"); |
673 | uspi->s_fsize = block_size = 2048; | 739 | uspi->s_fsize = block_size = 2048; |
674 | uspi->s_fmask = ~(2048 - 1); | 740 | uspi->s_fmask = ~(2048 - 1); |
675 | uspi->s_fshift = 11; | 741 | uspi->s_fshift = 11; |
@@ -684,7 +750,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
684 | break; | 750 | break; |
685 | 751 | ||
686 | case UFS_MOUNT_UFSTYPE_OPENSTEP: | 752 | case UFS_MOUNT_UFSTYPE_OPENSTEP: |
687 | UFSD(("ufstype=openstep\n")) | 753 | UFSD("ufstype=openstep\n"); |
688 | uspi->s_fsize = block_size = 1024; | 754 | uspi->s_fsize = block_size = 1024; |
689 | uspi->s_fmask = ~(1024 - 1); | 755 | uspi->s_fmask = ~(1024 - 1); |
690 | uspi->s_fshift = 10; | 756 | uspi->s_fshift = 10; |
@@ -699,7 +765,7 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent) | |||
699 | break; | 765 | break; |
700 | 766 | ||
701 | case UFS_MOUNT_UFSTYPE_HP: | 767 | case UFS_MOUNT_UFSTYPE_HP: |
702 | UFSD(("ufstype=hp\n")) | 768 | UFSD("ufstype=hp\n"); |
703 | uspi->s_fsize = block_size = 1024; | 769 | uspi->s_fsize = block_size = 1024; |
704 | uspi->s_fmask = ~(1024 - 1); | 770 | uspi->s_fmask = ~(1024 - 1); |
705 | uspi->s_fshift = 10; | 771 | uspi->s_fshift = 10; |
@@ -737,8 +803,6 @@ again: | |||
737 | usb1 = ubh_get_usb_first(uspi); | 803 | usb1 = ubh_get_usb_first(uspi); |
738 | usb2 = ubh_get_usb_second(uspi); | 804 | usb2 = ubh_get_usb_second(uspi); |
739 | usb3 = ubh_get_usb_third(uspi); | 805 | usb3 = ubh_get_usb_third(uspi); |
740 | usb = (struct ufs_super_block *) | ||
741 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; | ||
742 | 806 | ||
743 | /* | 807 | /* |
744 | * Check ufs magic number | 808 | * Check ufs magic number |
@@ -820,16 +884,12 @@ magic_found: | |||
820 | ubh = NULL; | 884 | ubh = NULL; |
821 | block_size = uspi->s_fsize; | 885 | block_size = uspi->s_fsize; |
822 | super_block_size = uspi->s_sbsize; | 886 | super_block_size = uspi->s_sbsize; |
823 | UFSD(("another value of block_size or super_block_size %u, %u\n", block_size, super_block_size)) | 887 | UFSD("another value of block_size or super_block_size %u, %u\n", block_size, super_block_size); |
824 | goto again; | 888 | goto again; |
825 | } | 889 | } |
826 | 890 | ||
827 | #ifdef UFS_SUPER_DEBUG_MORE | 891 | |
828 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) | 892 | ufs_print_super_stuff(sb, flags, usb1, usb2, usb3); |
829 | ufs2_print_super_stuff(sb,usb); | ||
830 | else | ||
831 | ufs_print_super_stuff(sb, usb1, usb2, usb3); | ||
832 | #endif | ||
833 | 893 | ||
834 | /* | 894 | /* |
835 | * Check, if file system was correctly unmounted. | 895 | * Check, if file system was correctly unmounted. |
@@ -842,13 +902,13 @@ magic_found: | |||
842 | (ufs_get_fs_state(sb, usb1, usb3) == (UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time))))) { | 902 | (ufs_get_fs_state(sb, usb1, usb3) == (UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time))))) { |
843 | switch(usb1->fs_clean) { | 903 | switch(usb1->fs_clean) { |
844 | case UFS_FSCLEAN: | 904 | case UFS_FSCLEAN: |
845 | UFSD(("fs is clean\n")) | 905 | UFSD("fs is clean\n"); |
846 | break; | 906 | break; |
847 | case UFS_FSSTABLE: | 907 | case UFS_FSSTABLE: |
848 | UFSD(("fs is stable\n")) | 908 | UFSD("fs is stable\n"); |
849 | break; | 909 | break; |
850 | case UFS_FSOSF1: | 910 | case UFS_FSOSF1: |
851 | UFSD(("fs is DEC OSF/1\n")) | 911 | UFSD("fs is DEC OSF/1\n"); |
852 | break; | 912 | break; |
853 | case UFS_FSACTIVE: | 913 | case UFS_FSACTIVE: |
854 | printk("ufs_read_super: fs is active\n"); | 914 | printk("ufs_read_super: fs is active\n"); |
@@ -863,8 +923,7 @@ magic_found: | |||
863 | sb->s_flags |= MS_RDONLY; | 923 | sb->s_flags |= MS_RDONLY; |
864 | break; | 924 | break; |
865 | } | 925 | } |
866 | } | 926 | } else { |
867 | else { | ||
868 | printk("ufs_read_super: fs needs fsck\n"); | 927 | printk("ufs_read_super: fs needs fsck\n"); |
869 | sb->s_flags |= MS_RDONLY; | 928 | sb->s_flags |= MS_RDONLY; |
870 | } | 929 | } |
@@ -884,10 +943,9 @@ magic_found: | |||
884 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); | 943 | uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); |
885 | 944 | ||
886 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 945 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
887 | uspi->s_u2_size = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_size); | 946 | uspi->s_u2_size = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size); |
888 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize); | 947 | uspi->s_u2_dsize = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
889 | } | 948 | } else { |
890 | else { | ||
891 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); | 949 | uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); |
892 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); | 950 | uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); |
893 | } | 951 | } |
@@ -901,8 +959,8 @@ magic_found: | |||
901 | uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask); | 959 | uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask); |
902 | uspi->s_bshift = fs32_to_cpu(sb, usb1->fs_bshift); | 960 | uspi->s_bshift = fs32_to_cpu(sb, usb1->fs_bshift); |
903 | uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift); | 961 | uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift); |
904 | UFSD(("uspi->s_bshift = %d,uspi->s_fshift = %d", uspi->s_bshift, | 962 | UFSD("uspi->s_bshift = %d,uspi->s_fshift = %d", uspi->s_bshift, |
905 | uspi->s_fshift)); | 963 | uspi->s_fshift); |
906 | uspi->s_fpbshift = fs32_to_cpu(sb, usb1->fs_fragshift); | 964 | uspi->s_fpbshift = fs32_to_cpu(sb, usb1->fs_fragshift); |
907 | uspi->s_fsbtodb = fs32_to_cpu(sb, usb1->fs_fsbtodb); | 965 | uspi->s_fsbtodb = fs32_to_cpu(sb, usb1->fs_fsbtodb); |
908 | /* s_sbsize already set */ | 966 | /* s_sbsize already set */ |
@@ -922,8 +980,8 @@ magic_found: | |||
922 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); | 980 | uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); |
923 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); | 981 | uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); |
924 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); | 982 | uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); |
925 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_cpc); | 983 | uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_un.fs_u1.fs_cpc); |
926 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_contigsumsize); | 984 | uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_contigsumsize); |
927 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); | 985 | uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); |
928 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); | 986 | uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); |
929 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); | 987 | uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); |
@@ -935,12 +993,11 @@ magic_found: | |||
935 | * Compute another frequently used values | 993 | * Compute another frequently used values |
936 | */ | 994 | */ |
937 | uspi->s_fpbmask = uspi->s_fpb - 1; | 995 | uspi->s_fpbmask = uspi->s_fpb - 1; |
938 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 996 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) |
939 | uspi->s_apbshift = uspi->s_bshift - 3; | 997 | uspi->s_apbshift = uspi->s_bshift - 3; |
940 | } | 998 | else |
941 | else { | ||
942 | uspi->s_apbshift = uspi->s_bshift - 2; | 999 | uspi->s_apbshift = uspi->s_bshift - 2; |
943 | } | 1000 | |
944 | uspi->s_2apbshift = uspi->s_apbshift * 2; | 1001 | uspi->s_2apbshift = uspi->s_apbshift * 2; |
945 | uspi->s_3apbshift = uspi->s_apbshift * 3; | 1002 | uspi->s_3apbshift = uspi->s_apbshift * 3; |
946 | uspi->s_apb = 1 << uspi->s_apbshift; | 1003 | uspi->s_apb = 1 << uspi->s_apbshift; |
@@ -956,7 +1013,7 @@ magic_found: | |||
956 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == | 1013 | if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == |
957 | UFS_MOUNT_UFSTYPE_44BSD) | 1014 | UFS_MOUNT_UFSTYPE_44BSD) |
958 | uspi->s_maxsymlinklen = | 1015 | uspi->s_maxsymlinklen = |
959 | fs32_to_cpu(sb, usb3->fs_u2.fs_44.fs_maxsymlinklen); | 1016 | fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); |
960 | 1017 | ||
961 | sbi->s_flags = flags; | 1018 | sbi->s_flags = flags; |
962 | 1019 | ||
@@ -967,7 +1024,7 @@ magic_found: | |||
967 | if (!sb->s_root) | 1024 | if (!sb->s_root) |
968 | goto dalloc_failed; | 1025 | goto dalloc_failed; |
969 | 1026 | ||
970 | 1027 | ufs_setup_cstotal(sb); | |
971 | /* | 1028 | /* |
972 | * Read cylinder group structures | 1029 | * Read cylinder group structures |
973 | */ | 1030 | */ |
@@ -975,7 +1032,7 @@ magic_found: | |||
975 | if (!ufs_read_cylinder_structures(sb)) | 1032 | if (!ufs_read_cylinder_structures(sb)) |
976 | goto failed; | 1033 | goto failed; |
977 | 1034 | ||
978 | UFSD(("EXIT\n")) | 1035 | UFSD("EXIT\n"); |
979 | return 0; | 1036 | return 0; |
980 | 1037 | ||
981 | dalloc_failed: | 1038 | dalloc_failed: |
@@ -986,15 +1043,16 @@ failed: | |||
986 | kfree (uspi); | 1043 | kfree (uspi); |
987 | kfree(sbi); | 1044 | kfree(sbi); |
988 | sb->s_fs_info = NULL; | 1045 | sb->s_fs_info = NULL; |
989 | UFSD(("EXIT (FAILED)\n")) | 1046 | UFSD("EXIT (FAILED)\n"); |
990 | return -EINVAL; | 1047 | return -EINVAL; |
991 | 1048 | ||
992 | failed_nomem: | 1049 | failed_nomem: |
993 | UFSD(("EXIT (NOMEM)\n")) | 1050 | UFSD("EXIT (NOMEM)\n"); |
994 | return -ENOMEM; | 1051 | return -ENOMEM; |
995 | } | 1052 | } |
996 | 1053 | ||
997 | static void ufs_write_super (struct super_block *sb) { | 1054 | static void ufs_write_super(struct super_block *sb) |
1055 | { | ||
998 | struct ufs_sb_private_info * uspi; | 1056 | struct ufs_sb_private_info * uspi; |
999 | struct ufs_super_block_first * usb1; | 1057 | struct ufs_super_block_first * usb1; |
1000 | struct ufs_super_block_third * usb3; | 1058 | struct ufs_super_block_third * usb3; |
@@ -1002,7 +1060,7 @@ static void ufs_write_super (struct super_block *sb) { | |||
1002 | 1060 | ||
1003 | lock_kernel(); | 1061 | lock_kernel(); |
1004 | 1062 | ||
1005 | UFSD(("ENTER\n")) | 1063 | UFSD("ENTER\n"); |
1006 | flags = UFS_SB(sb)->s_flags; | 1064 | flags = UFS_SB(sb)->s_flags; |
1007 | uspi = UFS_SB(sb)->s_uspi; | 1065 | uspi = UFS_SB(sb)->s_uspi; |
1008 | usb1 = ubh_get_usb_first(uspi); | 1066 | usb1 = ubh_get_usb_first(uspi); |
@@ -1014,26 +1072,27 @@ static void ufs_write_super (struct super_block *sb) { | |||
1014 | || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) | 1072 | || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
1015 | ufs_set_fs_state(sb, usb1, usb3, | 1073 | ufs_set_fs_state(sb, usb1, usb3, |
1016 | UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); | 1074 | UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); |
1017 | ubh_mark_buffer_dirty (USPI_UBH); | 1075 | ufs_put_cstotal(sb); |
1018 | } | 1076 | } |
1019 | sb->s_dirt = 0; | 1077 | sb->s_dirt = 0; |
1020 | UFSD(("EXIT\n")) | 1078 | UFSD("EXIT\n"); |
1021 | unlock_kernel(); | 1079 | unlock_kernel(); |
1022 | } | 1080 | } |
1023 | 1081 | ||
1024 | static void ufs_put_super (struct super_block *sb) | 1082 | static void ufs_put_super(struct super_block *sb) |
1025 | { | 1083 | { |
1026 | struct ufs_sb_info * sbi = UFS_SB(sb); | 1084 | struct ufs_sb_info * sbi = UFS_SB(sb); |
1027 | 1085 | ||
1028 | UFSD(("ENTER\n")) | 1086 | UFSD("ENTER\n"); |
1029 | 1087 | ||
1030 | if (!(sb->s_flags & MS_RDONLY)) | 1088 | if (!(sb->s_flags & MS_RDONLY)) |
1031 | ufs_put_cylinder_structures (sb); | 1089 | ufs_put_super_internal(sb); |
1032 | 1090 | ||
1033 | ubh_brelse_uspi (sbi->s_uspi); | 1091 | ubh_brelse_uspi (sbi->s_uspi); |
1034 | kfree (sbi->s_uspi); | 1092 | kfree (sbi->s_uspi); |
1035 | kfree (sbi); | 1093 | kfree (sbi); |
1036 | sb->s_fs_info = NULL; | 1094 | sb->s_fs_info = NULL; |
1095 | UFSD("EXIT\n"); | ||
1037 | return; | 1096 | return; |
1038 | } | 1097 | } |
1039 | 1098 | ||
@@ -1062,8 +1121,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1062 | return -EINVAL; | 1121 | return -EINVAL; |
1063 | if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) { | 1122 | if (!(new_mount_opt & UFS_MOUNT_UFSTYPE)) { |
1064 | new_mount_opt |= ufstype; | 1123 | new_mount_opt |= ufstype; |
1065 | } | 1124 | } else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { |
1066 | else if ((new_mount_opt & UFS_MOUNT_UFSTYPE) != ufstype) { | ||
1067 | printk("ufstype can't be changed during remount\n"); | 1125 | printk("ufstype can't be changed during remount\n"); |
1068 | return -EINVAL; | 1126 | return -EINVAL; |
1069 | } | 1127 | } |
@@ -1077,20 +1135,19 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1077 | * fs was mouted as rw, remounting ro | 1135 | * fs was mouted as rw, remounting ro |
1078 | */ | 1136 | */ |
1079 | if (*mount_flags & MS_RDONLY) { | 1137 | if (*mount_flags & MS_RDONLY) { |
1080 | ufs_put_cylinder_structures(sb); | 1138 | ufs_put_super_internal(sb); |
1081 | usb1->fs_time = cpu_to_fs32(sb, get_seconds()); | 1139 | usb1->fs_time = cpu_to_fs32(sb, get_seconds()); |
1082 | if ((flags & UFS_ST_MASK) == UFS_ST_SUN | 1140 | if ((flags & UFS_ST_MASK) == UFS_ST_SUN |
1083 | || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) | 1141 | || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) |
1084 | ufs_set_fs_state(sb, usb1, usb3, | 1142 | ufs_set_fs_state(sb, usb1, usb3, |
1085 | UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); | 1143 | UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); |
1086 | ubh_mark_buffer_dirty (USPI_UBH); | 1144 | ubh_mark_buffer_dirty (USPI_UBH(uspi)); |
1087 | sb->s_dirt = 0; | 1145 | sb->s_dirt = 0; |
1088 | sb->s_flags |= MS_RDONLY; | 1146 | sb->s_flags |= MS_RDONLY; |
1089 | } | 1147 | } else { |
1090 | /* | 1148 | /* |
1091 | * fs was mounted as ro, remounting rw | 1149 | * fs was mounted as ro, remounting rw |
1092 | */ | 1150 | */ |
1093 | else { | ||
1094 | #ifndef CONFIG_UFS_FS_WRITE | 1151 | #ifndef CONFIG_UFS_FS_WRITE |
1095 | printk("ufs was compiled with read-only support, " | 1152 | printk("ufs was compiled with read-only support, " |
1096 | "can't be mounted as read-write\n"); | 1153 | "can't be mounted as read-write\n"); |
@@ -1102,7 +1159,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1102 | printk("this ufstype is read-only supported\n"); | 1159 | printk("this ufstype is read-only supported\n"); |
1103 | return -EINVAL; | 1160 | return -EINVAL; |
1104 | } | 1161 | } |
1105 | if (!ufs_read_cylinder_structures (sb)) { | 1162 | if (!ufs_read_cylinder_structures(sb)) { |
1106 | printk("failed during remounting\n"); | 1163 | printk("failed during remounting\n"); |
1107 | return -EPERM; | 1164 | return -EPERM; |
1108 | } | 1165 | } |
@@ -1113,37 +1170,31 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data) | |||
1113 | return 0; | 1170 | return 0; |
1114 | } | 1171 | } |
1115 | 1172 | ||
1116 | static int ufs_statfs (struct dentry *dentry, struct kstatfs *buf) | 1173 | static int ufs_statfs(struct dentry *dentry, struct kstatfs *buf) |
1117 | { | 1174 | { |
1118 | struct super_block *sb = dentry->d_sb; | 1175 | struct super_block *sb = dentry->d_sb; |
1119 | struct ufs_sb_private_info * uspi; | 1176 | struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi; |
1120 | struct ufs_super_block_first * usb1; | 1177 | unsigned flags = UFS_SB(sb)->s_flags; |
1121 | struct ufs_super_block * usb; | 1178 | struct ufs_super_block_first *usb1; |
1122 | unsigned flags = 0; | 1179 | struct ufs_super_block_second *usb2; |
1180 | struct ufs_super_block_third *usb3; | ||
1123 | 1181 | ||
1124 | lock_kernel(); | 1182 | lock_kernel(); |
1125 | 1183 | ||
1126 | uspi = UFS_SB(sb)->s_uspi; | 1184 | usb1 = ubh_get_usb_first(uspi); |
1127 | usb1 = ubh_get_usb_first (uspi); | 1185 | usb2 = ubh_get_usb_second(uspi); |
1128 | usb = (struct ufs_super_block *) | 1186 | usb3 = ubh_get_usb_third(uspi); |
1129 | ((struct ufs_buffer_head *)uspi)->bh[0]->b_data ; | ||
1130 | 1187 | ||
1131 | flags = UFS_SB(sb)->s_flags; | ||
1132 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { | 1188 | if ((flags & UFS_TYPE_MASK) == UFS_TYPE_UFS2) { |
1133 | buf->f_type = UFS2_MAGIC; | 1189 | buf->f_type = UFS2_MAGIC; |
1134 | buf->f_blocks = fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_dsize); | 1190 | buf->f_blocks = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); |
1135 | buf->f_bfree = ufs_blkstofrags(fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_cstotal.cs_nbfree)) + | 1191 | } else { |
1136 | fs64_to_cpu(sb, usb->fs_u11.fs_u2.fs_cstotal.cs_nffree); | ||
1137 | buf->f_ffree = fs64_to_cpu(sb, | ||
1138 | usb->fs_u11.fs_u2.fs_cstotal.cs_nifree); | ||
1139 | } | ||
1140 | else { | ||
1141 | buf->f_type = UFS_MAGIC; | 1192 | buf->f_type = UFS_MAGIC; |
1142 | buf->f_blocks = uspi->s_dsize; | 1193 | buf->f_blocks = uspi->s_dsize; |
1143 | buf->f_bfree = ufs_blkstofrags(fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)) + | ||
1144 | fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree); | ||
1145 | buf->f_ffree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree); | ||
1146 | } | 1194 | } |
1195 | buf->f_bfree = ufs_blkstofrags(uspi->cs_total.cs_nbfree) + | ||
1196 | uspi->cs_total.cs_nffree; | ||
1197 | buf->f_ffree = uspi->cs_total.cs_nifree; | ||
1147 | buf->f_bsize = sb->s_blocksize; | 1198 | buf->f_bsize = sb->s_blocksize; |
1148 | buf->f_bavail = (buf->f_bfree > (((long)buf->f_blocks / 100) * uspi->s_minfree)) | 1199 | buf->f_bavail = (buf->f_bfree > (((long)buf->f_blocks / 100) * uspi->s_minfree)) |
1149 | ? (buf->f_bfree - (((long)buf->f_blocks / 100) * uspi->s_minfree)) : 0; | 1200 | ? (buf->f_bfree - (((long)buf->f_blocks / 100) * uspi->s_minfree)) : 0; |