Lines Matching +full:usb3 +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-only
16 * Laboratoire MASI - Institut Blaise Pascal
25 * Big-endian to little-endian byte-swapping/bitmaps by
35 * Adrian Rodriguez (adrian@franklins-tower.rutgers.edu)
48 * Francois-Rene Rideau <fare@tunes.org>
50 * 4.4BSD (FreeBSD) support added on February 1st 1998 by
52 * on code by Martin von Loewis <martin@mira.isdn.cs.tu-berlin.de>.
84 #include <linux/backing-dev.h>
101 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; in ufs_nfs_get_inode()
104 if (ino < UFS_ROOTINO || ino > (u64)uspi->s_ncg * uspi->s_ipg) in ufs_nfs_get_inode()
105 return ERR_PTR(-ESTALE); in ufs_nfs_get_inode()
110 if (generation && inode->i_generation != generation) { in ufs_nfs_get_inode()
112 return ERR_PTR(-ESTALE); in ufs_nfs_get_inode()
135 return ERR_PTR(-ENOENT); in ufs_get_parent()
136 return d_obtain_alias(ufs_iget(child->d_sb, ino)); in ufs_get_parent()
152 struct ufs_super_block_third *usb3) in ufs_print_super_stuff() argument
154 u32 magic = fs32_to_cpu(sb, usb3->fs_magic); in ufs_print_super_stuff()
158 if (fs32_to_cpu(sb, usb3->fs_magic) == UFS2_MAGIC) { in ufs_print_super_stuff()
160 fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size)); in ufs_print_super_stuff()
162 fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize)); in ufs_print_super_stuff()
164 fs32_to_cpu(sb, usb1->fs_bsize)); in ufs_print_super_stuff()
166 fs32_to_cpu(sb, usb1->fs_fsize)); in ufs_print_super_stuff()
167 pr_debug(" fs_volname: %s\n", usb2->fs_un.fs_u2.fs_volname); in ufs_print_super_stuff()
169 fs64_to_cpu(sb, usb2->fs_un.fs_u2.fs_sblockloc)); in ufs_print_super_stuff()
171 fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir)); in ufs_print_super_stuff()
174 fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree)); in ufs_print_super_stuff()
177 fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree)); in ufs_print_super_stuff()
180 fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree)); in ufs_print_super_stuff()
182 fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen)); in ufs_print_super_stuff()
184 pr_debug(" sblkno: %u\n", fs32_to_cpu(sb, usb1->fs_sblkno)); in ufs_print_super_stuff()
185 pr_debug(" cblkno: %u\n", fs32_to_cpu(sb, usb1->fs_cblkno)); in ufs_print_super_stuff()
186 pr_debug(" iblkno: %u\n", fs32_to_cpu(sb, usb1->fs_iblkno)); in ufs_print_super_stuff()
187 pr_debug(" dblkno: %u\n", fs32_to_cpu(sb, usb1->fs_dblkno)); in ufs_print_super_stuff()
189 fs32_to_cpu(sb, usb1->fs_cgoffset)); in ufs_print_super_stuff()
191 ~fs32_to_cpu(sb, usb1->fs_cgmask)); in ufs_print_super_stuff()
192 pr_debug(" size: %u\n", fs32_to_cpu(sb, usb1->fs_size)); in ufs_print_super_stuff()
193 pr_debug(" dsize: %u\n", fs32_to_cpu(sb, usb1->fs_dsize)); in ufs_print_super_stuff()
194 pr_debug(" ncg: %u\n", fs32_to_cpu(sb, usb1->fs_ncg)); in ufs_print_super_stuff()
195 pr_debug(" bsize: %u\n", fs32_to_cpu(sb, usb1->fs_bsize)); in ufs_print_super_stuff()
196 pr_debug(" fsize: %u\n", fs32_to_cpu(sb, usb1->fs_fsize)); in ufs_print_super_stuff()
197 pr_debug(" frag: %u\n", fs32_to_cpu(sb, usb1->fs_frag)); in ufs_print_super_stuff()
199 fs32_to_cpu(sb, usb1->fs_fragshift)); in ufs_print_super_stuff()
200 pr_debug(" ~fmask: %u\n", ~fs32_to_cpu(sb, usb1->fs_fmask)); in ufs_print_super_stuff()
201 pr_debug(" fshift: %u\n", fs32_to_cpu(sb, usb1->fs_fshift)); in ufs_print_super_stuff()
202 pr_debug(" sbsize: %u\n", fs32_to_cpu(sb, usb1->fs_sbsize)); in ufs_print_super_stuff()
203 pr_debug(" spc: %u\n", fs32_to_cpu(sb, usb1->fs_spc)); in ufs_print_super_stuff()
204 pr_debug(" cpg: %u\n", fs32_to_cpu(sb, usb1->fs_cpg)); in ufs_print_super_stuff()
205 pr_debug(" ipg: %u\n", fs32_to_cpu(sb, usb1->fs_ipg)); in ufs_print_super_stuff()
206 pr_debug(" fpg: %u\n", fs32_to_cpu(sb, usb1->fs_fpg)); in ufs_print_super_stuff()
207 pr_debug(" csaddr: %u\n", fs32_to_cpu(sb, usb1->fs_csaddr)); in ufs_print_super_stuff()
208 pr_debug(" cssize: %u\n", fs32_to_cpu(sb, usb1->fs_cssize)); in ufs_print_super_stuff()
209 pr_debug(" cgsize: %u\n", fs32_to_cpu(sb, usb1->fs_cgsize)); in ufs_print_super_stuff()
211 fs32_to_cpu(sb, usb1->fs_fsbtodb)); in ufs_print_super_stuff()
212 pr_debug(" nrpos: %u\n", fs32_to_cpu(sb, usb3->fs_nrpos)); in ufs_print_super_stuff()
214 fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir)); in ufs_print_super_stuff()
216 fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree)); in ufs_print_super_stuff()
218 fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree)); in ufs_print_super_stuff()
220 fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree)); in ufs_print_super_stuff()
233 pr_debug(" magic: %x\n", fs32_to_cpu(sb, cg->cg_magic)); in ufs_print_cylinder_stuff()
234 pr_debug(" time: %u\n", fs32_to_cpu(sb, cg->cg_time)); in ufs_print_cylinder_stuff()
235 pr_debug(" cgx: %u\n", fs32_to_cpu(sb, cg->cg_cgx)); in ufs_print_cylinder_stuff()
236 pr_debug(" ncyl: %u\n", fs16_to_cpu(sb, cg->cg_ncyl)); in ufs_print_cylinder_stuff()
237 pr_debug(" niblk: %u\n", fs16_to_cpu(sb, cg->cg_niblk)); in ufs_print_cylinder_stuff()
238 pr_debug(" ndblk: %u\n", fs32_to_cpu(sb, cg->cg_ndblk)); in ufs_print_cylinder_stuff()
239 pr_debug(" cs_ndir: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_ndir)); in ufs_print_cylinder_stuff()
240 pr_debug(" cs_nbfree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nbfree)); in ufs_print_cylinder_stuff()
241 pr_debug(" cs_nifree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nifree)); in ufs_print_cylinder_stuff()
242 pr_debug(" cs_nffree: %u\n", fs32_to_cpu(sb, cg->cg_cs.cs_nffree)); in ufs_print_cylinder_stuff()
243 pr_debug(" rotor: %u\n", fs32_to_cpu(sb, cg->cg_rotor)); in ufs_print_cylinder_stuff()
244 pr_debug(" frotor: %u\n", fs32_to_cpu(sb, cg->cg_frotor)); in ufs_print_cylinder_stuff()
245 pr_debug(" irotor: %u\n", fs32_to_cpu(sb, cg->cg_irotor)); in ufs_print_cylinder_stuff()
247 fs32_to_cpu(sb, cg->cg_frsum[0]), fs32_to_cpu(sb, cg->cg_frsum[1]), in ufs_print_cylinder_stuff()
248 fs32_to_cpu(sb, cg->cg_frsum[2]), fs32_to_cpu(sb, cg->cg_frsum[3]), in ufs_print_cylinder_stuff()
249 fs32_to_cpu(sb, cg->cg_frsum[4]), fs32_to_cpu(sb, cg->cg_frsum[5]), in ufs_print_cylinder_stuff()
250 fs32_to_cpu(sb, cg->cg_frsum[6]), fs32_to_cpu(sb, cg->cg_frsum[7])); in ufs_print_cylinder_stuff()
251 pr_debug(" btotoff: %u\n", fs32_to_cpu(sb, cg->cg_btotoff)); in ufs_print_cylinder_stuff()
252 pr_debug(" boff: %u\n", fs32_to_cpu(sb, cg->cg_boff)); in ufs_print_cylinder_stuff()
253 pr_debug(" iuseoff: %u\n", fs32_to_cpu(sb, cg->cg_iusedoff)); in ufs_print_cylinder_stuff()
254 pr_debug(" freeoff: %u\n", fs32_to_cpu(sb, cg->cg_freeoff)); in ufs_print_cylinder_stuff()
255 pr_debug(" nextfreeoff: %u\n", fs32_to_cpu(sb, cg->cg_nextfreeoff)); in ufs_print_cylinder_stuff()
257 fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clustersumoff)); in ufs_print_cylinder_stuff()
259 fs32_to_cpu(sb, cg->cg_u.cg_44.cg_clusteroff)); in ufs_print_cylinder_stuff()
261 fs32_to_cpu(sb, cg->cg_u.cg_44.cg_nclusterblks)); in ufs_print_cylinder_stuff()
265 # define ufs_print_super_stuff(sb, usb1, usb2, usb3) /**/ argument
279 uspi = UFS_SB(sb)->s_uspi; in ufs_error()
283 usb1->fs_clean = UFS_FSBAD; in ufs_error()
286 sb->s_flags |= SB_RDONLY; in ufs_error()
291 switch (UFS_SB(sb)->s_mount_opt & UFS_MOUNT_ONERROR) { in ufs_error()
294 sb->s_id, function, &vaf); in ufs_error()
300 sb->s_id, function, &vaf); in ufs_error()
313 uspi = UFS_SB(sb)->s_uspi; in ufs_panic()
317 usb1->fs_clean = UFS_FSBAD; in ufs_panic()
324 sb->s_flags |= SB_RDONLY; in ufs_panic()
326 sb->s_id, function, &vaf); in ufs_panic()
340 sb->s_id, function, &vaf); in ufs_warning()
371 {Opt_type_nextstepcd, "ufstype=nextstep-cd"},
389 return 1; in ufs_parse_options()
461 return 1; in ufs_parse_options()
472 struct ufs_sb_private_info *uspi = sbi->s_uspi; in ufs_setup_cstotal()
475 struct ufs_super_block_third *usb3; in ufs_setup_cstotal() local
476 unsigned mtype = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; in ufs_setup_cstotal()
481 usb3 = ubh_get_usb_third(uspi); in ufs_setup_cstotal()
484 (usb2->fs_un.fs_u2.fs_maxbsize == usb1->fs_bsize)) || in ufs_setup_cstotal()
487 uspi->cs_total.cs_ndir = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_ndir); in ufs_setup_cstotal()
488 uspi->cs_total.cs_nbfree = fs64_to_cpu(sb, usb2->fs_un.fs_u2.cs_nbfree); in ufs_setup_cstotal()
489 uspi->cs_total.cs_nifree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nifree); in ufs_setup_cstotal()
490 uspi->cs_total.cs_nffree = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.cs_nffree); in ufs_setup_cstotal()
492 uspi->cs_total.cs_ndir = fs32_to_cpu(sb, usb1->fs_cstotal.cs_ndir); in ufs_setup_cstotal()
493 uspi->cs_total.cs_nbfree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nbfree); in ufs_setup_cstotal()
494 uspi->cs_total.cs_nifree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nifree); in ufs_setup_cstotal()
495 uspi->cs_total.cs_nffree = fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree); in ufs_setup_cstotal()
501 * Read on-disk structures associated with cylinder groups
506 struct ufs_sb_private_info *uspi = sbi->s_uspi; in ufs_read_cylinder_structures()
517 size = uspi->s_cssize; in ufs_read_cylinder_structures()
518 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; in ufs_read_cylinder_structures()
522 sbi->s_csp = (struct ufs_csum *)space; in ufs_read_cylinder_structures()
523 for (i = 0; i < blks; i += uspi->s_fpb) { in ufs_read_cylinder_structures()
524 size = uspi->s_bsize; in ufs_read_cylinder_structures()
525 if (i + uspi->s_fpb > blks) in ufs_read_cylinder_structures()
526 size = (blks - i) * uspi->s_fsize; in ufs_read_cylinder_structures()
528 ubh = ubh_bread(sb, uspi->s_csaddr + i, size); in ufs_read_cylinder_structures()
544 sbi->s_ucg = kmalloc_array(uspi->s_ncg, sizeof(struct buffer_head *), in ufs_read_cylinder_structures()
546 if (!sbi->s_ucg) in ufs_read_cylinder_structures()
548 for (i = 0; i < uspi->s_ncg; i++) in ufs_read_cylinder_structures()
549 sbi->s_ucg[i] = NULL; in ufs_read_cylinder_structures()
551 sbi->s_ucpi[i] = NULL; in ufs_read_cylinder_structures()
552 sbi->s_cgno[i] = UFS_CGNO_EMPTY; in ufs_read_cylinder_structures()
554 for (i = 0; i < uspi->s_ncg; i++) { in ufs_read_cylinder_structures()
556 if (!(sbi->s_ucg[i] = sb_bread(sb, ufs_cgcmin(i)))) in ufs_read_cylinder_structures()
558 if (!ufs_cg_chkmagic (sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data)) in ufs_read_cylinder_structures()
561 ufs_print_cylinder_stuff(sb, (struct ufs_cylinder_group *) sbi->s_ucg[i]->b_data); in ufs_read_cylinder_structures()
564 if (!(sbi->s_ucpi[i] = kmalloc (sizeof(struct ufs_cg_private_info), GFP_NOFS))) in ufs_read_cylinder_structures()
566 sbi->s_cgno[i] = UFS_CGNO_EMPTY; in ufs_read_cylinder_structures()
568 sbi->s_cg_loaded = 0; in ufs_read_cylinder_structures()
570 return 1; in ufs_read_cylinder_structures()
574 if (sbi->s_ucg) { in ufs_read_cylinder_structures()
575 for (i = 0; i < uspi->s_ncg; i++) in ufs_read_cylinder_structures()
576 if (sbi->s_ucg[i]) in ufs_read_cylinder_structures()
577 brelse (sbi->s_ucg[i]); in ufs_read_cylinder_structures()
578 kfree (sbi->s_ucg); in ufs_read_cylinder_structures()
580 kfree (sbi->s_ucpi[i]); in ufs_read_cylinder_structures()
591 unsigned mtype = UFS_SB(sb)->s_mount_opt & UFS_MOUNT_UFSTYPE; in ufs_put_cstotal()
592 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; in ufs_put_cstotal()
595 struct ufs_super_block_third *usb3; in ufs_put_cstotal() local
600 usb3 = ubh_get_usb_third(uspi); in ufs_put_cstotal()
604 usb2->fs_un.fs_u2.cs_ndir = in ufs_put_cstotal()
605 cpu_to_fs64(sb, uspi->cs_total.cs_ndir); in ufs_put_cstotal()
606 usb2->fs_un.fs_u2.cs_nbfree = in ufs_put_cstotal()
607 cpu_to_fs64(sb, uspi->cs_total.cs_nbfree); in ufs_put_cstotal()
608 usb3->fs_un1.fs_u2.cs_nifree = in ufs_put_cstotal()
609 cpu_to_fs64(sb, uspi->cs_total.cs_nifree); in ufs_put_cstotal()
610 usb3->fs_un1.fs_u2.cs_nffree = in ufs_put_cstotal()
611 cpu_to_fs64(sb, uspi->cs_total.cs_nffree); in ufs_put_cstotal()
616 (usb2->fs_un.fs_u2.fs_maxbsize == usb1->fs_bsize)) { in ufs_put_cstotal()
618 usb2->fs_un.fs_u2.cs_ndir = in ufs_put_cstotal()
619 cpu_to_fs64(sb, uspi->cs_total.cs_ndir); in ufs_put_cstotal()
620 usb2->fs_un.fs_u2.cs_nbfree = in ufs_put_cstotal()
621 cpu_to_fs64(sb, uspi->cs_total.cs_nbfree); in ufs_put_cstotal()
622 usb3->fs_un1.fs_u2.cs_nifree = in ufs_put_cstotal()
623 cpu_to_fs64(sb, uspi->cs_total.cs_nifree); in ufs_put_cstotal()
624 usb3->fs_un1.fs_u2.cs_nffree = in ufs_put_cstotal()
625 cpu_to_fs64(sb, uspi->cs_total.cs_nffree); in ufs_put_cstotal()
627 usb1->fs_cstotal.cs_ndir = cpu_to_fs32(sb, uspi->cs_total.cs_ndir); in ufs_put_cstotal()
628 usb1->fs_cstotal.cs_nbfree = cpu_to_fs32(sb, uspi->cs_total.cs_nbfree); in ufs_put_cstotal()
629 usb1->fs_cstotal.cs_nifree = cpu_to_fs32(sb, uspi->cs_total.cs_nifree); in ufs_put_cstotal()
630 usb1->fs_cstotal.cs_nffree = cpu_to_fs32(sb, uspi->cs_total.cs_nffree); in ufs_put_cstotal()
633 ufs_print_super_stuff(sb, usb1, usb2, usb3); in ufs_put_cstotal()
638 * ufs_put_super_internal() - put on-disk intrenal structures
640 * Put on-disk structures associated with cylinder groups
646 struct ufs_sb_private_info *uspi = sbi->s_uspi; in ufs_put_super_internal()
655 size = uspi->s_cssize; in ufs_put_super_internal()
656 blks = (size + uspi->s_fsize - 1) >> uspi->s_fshift; in ufs_put_super_internal()
657 base = space = (char*) sbi->s_csp; in ufs_put_super_internal()
658 for (i = 0; i < blks; i += uspi->s_fpb) { in ufs_put_super_internal()
659 size = uspi->s_bsize; in ufs_put_super_internal()
660 if (i + uspi->s_fpb > blks) in ufs_put_super_internal()
661 size = (blks - i) * uspi->s_fsize; in ufs_put_super_internal()
663 ubh = ubh_bread(sb, uspi->s_csaddr + i, size); in ufs_put_super_internal()
667 ubh_mark_buffer_uptodate (ubh, 1); in ufs_put_super_internal()
671 for (i = 0; i < sbi->s_cg_loaded; i++) { in ufs_put_super_internal()
673 kfree (sbi->s_ucpi[i]); in ufs_put_super_internal()
676 kfree (sbi->s_ucpi[i]); in ufs_put_super_internal()
677 for (i = 0; i < uspi->s_ncg; i++) in ufs_put_super_internal()
678 brelse (sbi->s_ucg[i]); in ufs_put_super_internal()
679 kfree (sbi->s_ucg); in ufs_put_super_internal()
689 struct ufs_super_block_third * usb3; in ufs_sync_fs() local
692 mutex_lock(&UFS_SB(sb)->s_lock); in ufs_sync_fs()
696 flags = UFS_SB(sb)->s_flags; in ufs_sync_fs()
697 uspi = UFS_SB(sb)->s_uspi; in ufs_sync_fs()
699 usb3 = ubh_get_usb_third(uspi); in ufs_sync_fs()
701 usb1->fs_time = ufs_get_seconds(sb); in ufs_sync_fs()
705 ufs_set_fs_state(sb, usb1, usb3, in ufs_sync_fs()
706 UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); in ufs_sync_fs()
710 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_sync_fs()
721 spin_lock(&sbi->work_lock); in delayed_sync_fs()
722 sbi->work_queued = 0; in delayed_sync_fs()
723 spin_unlock(&sbi->work_lock); in delayed_sync_fs()
725 ufs_sync_fs(sbi->sb, 1); in delayed_sync_fs()
733 spin_lock(&sbi->work_lock); in ufs_mark_sb_dirty()
734 if (!sbi->work_queued) { in ufs_mark_sb_dirty()
736 queue_delayed_work(system_long_wq, &sbi->sync_work, delay); in ufs_mark_sb_dirty()
737 sbi->work_queued = 1; in ufs_mark_sb_dirty()
739 spin_unlock(&sbi->work_lock); in ufs_mark_sb_dirty()
750 cancel_delayed_work_sync(&sbi->sync_work); in ufs_put_super()
752 ubh_brelse_uspi (sbi->s_uspi); in ufs_put_super()
753 kfree (sbi->s_uspi); in ufs_put_super()
755 sb->s_fs_info = NULL; in ufs_put_super()
762 struct ufs_sb_private_info *uspi = UFS_SB(sb)->s_uspi; in ufs_max_bytes()
763 int bits = uspi->s_apbshift; in ufs_max_bytes()
769 res = UFS_NDADDR + (1LL << bits) + (1LL << (2*bits)) + in ufs_max_bytes()
770 (1LL << (3*bits)); in ufs_max_bytes()
772 if (res >= (MAX_LFS_FILESIZE >> uspi->s_bshift)) in ufs_max_bytes()
774 return res << uspi->s_bshift; in ufs_max_bytes()
783 struct ufs_super_block_third * usb3; in ufs_fill_super() local
790 int ret = -EINVAL; in ufs_fill_super()
800 pr_err("ufs was compiled with read-only support, can't be mounted as read-write\n"); in ufs_fill_super()
801 return -EROFS; in ufs_fill_super()
808 sb->s_fs_info = sbi; in ufs_fill_super()
809 sbi->sb = sb; in ufs_fill_super()
813 mutex_init(&sbi->s_lock); in ufs_fill_super()
814 spin_lock_init(&sbi->work_lock); in ufs_fill_super()
815 INIT_DELAYED_WORK(&sbi->sync_work, delayed_sync_fs); in ufs_fill_super()
820 sbi->s_mount_opt = 0; in ufs_fill_super()
821 ufs_set_opt (sbi->s_mount_opt, ONERROR_LOCK); in ufs_fill_super()
822 if (!ufs_parse_options ((char *) data, &sbi->s_mount_opt)) { in ufs_fill_super()
826 if (!(sbi->s_mount_opt & UFS_MOUNT_UFSTYPE)) { in ufs_fill_super()
829 "mount -t ufs -o ufstype=" in ufs_fill_super()
830 "sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...\n\n" in ufs_fill_super()
833 ufs_set_opt (sbi->s_mount_opt, UFSTYPE_OLD); in ufs_fill_super()
837 sbi->s_uspi = uspi; in ufs_fill_super()
840 uspi->s_dirblksize = UFS_SECTOR_SIZE; in ufs_fill_super()
843 sb->s_maxbytes = MAX_LFS_FILESIZE; in ufs_fill_super()
845 sb->s_time_gran = NSEC_PER_SEC; in ufs_fill_super()
846 sb->s_time_min = S32_MIN; in ufs_fill_super()
847 sb->s_time_max = S32_MAX; in ufs_fill_super()
849 switch (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) { in ufs_fill_super()
852 uspi->s_fsize = block_size = 512; in ufs_fill_super()
853 uspi->s_fmask = ~(512 - 1); in ufs_fill_super()
854 uspi->s_fshift = 9; in ufs_fill_super()
855 uspi->s_sbsize = super_block_size = 1536; in ufs_fill_super()
856 uspi->s_sbbase = 0; in ufs_fill_super()
862 uspi->s_fsize = block_size = 512; in ufs_fill_super()
863 uspi->s_fmask = ~(512 - 1); in ufs_fill_super()
864 uspi->s_fshift = 9; in ufs_fill_super()
865 uspi->s_sbsize = super_block_size = 1536; in ufs_fill_super()
866 uspi->s_sbbase = 0; in ufs_fill_super()
867 sb->s_time_gran = 1; in ufs_fill_super()
868 sb->s_time_min = S64_MIN; in ufs_fill_super()
869 sb->s_time_max = S64_MAX; in ufs_fill_super()
875 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
876 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
877 uspi->s_fshift = 10; in ufs_fill_super()
878 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
879 uspi->s_sbbase = 0; in ufs_fill_super()
880 uspi->s_maxsymlinklen = 0; /* Not supported on disk */ in ufs_fill_super()
886 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
887 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
888 uspi->s_fshift = 10; in ufs_fill_super()
889 uspi->s_sbsize = 2048; in ufs_fill_super()
891 uspi->s_sbbase = 0; in ufs_fill_super()
892 uspi->s_maxsymlinklen = 0; /* Not supported on disk */ in ufs_fill_super()
898 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
899 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
900 uspi->s_fshift = 10; in ufs_fill_super()
901 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
902 uspi->s_sbbase = 0; in ufs_fill_super()
903 uspi->s_maxsymlinklen = 0; /* Not supported on disk */ in ufs_fill_super()
909 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
910 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
911 uspi->s_fshift = 10; in ufs_fill_super()
912 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
913 uspi->s_sbbase = 0; in ufs_fill_super()
917 pr_info("ufstype=old is supported read-only\n"); in ufs_fill_super()
918 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
924 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
925 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
926 uspi->s_fshift = 10; in ufs_fill_super()
927 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
928 uspi->s_sbbase = 0; in ufs_fill_super()
929 uspi->s_dirblksize = 1024; in ufs_fill_super()
933 pr_info("ufstype=nextstep is supported read-only\n"); in ufs_fill_super()
934 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
939 UFSD("ufstype=nextstep-cd\n"); in ufs_fill_super()
940 uspi->s_fsize = block_size = 2048; in ufs_fill_super()
941 uspi->s_fmask = ~(2048 - 1); in ufs_fill_super()
942 uspi->s_fshift = 11; in ufs_fill_super()
943 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
944 uspi->s_sbbase = 0; in ufs_fill_super()
945 uspi->s_dirblksize = 1024; in ufs_fill_super()
949 pr_info("ufstype=nextstep-cd is supported read-only\n"); in ufs_fill_super()
950 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
956 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
957 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
958 uspi->s_fshift = 10; in ufs_fill_super()
959 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
960 uspi->s_sbbase = 0; in ufs_fill_super()
961 uspi->s_dirblksize = 1024; in ufs_fill_super()
965 pr_info("ufstype=openstep is supported read-only\n"); in ufs_fill_super()
966 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
972 uspi->s_fsize = block_size = 1024; in ufs_fill_super()
973 uspi->s_fmask = ~(1024 - 1); in ufs_fill_super()
974 uspi->s_fshift = 10; in ufs_fill_super()
975 uspi->s_sbsize = super_block_size = 2048; in ufs_fill_super()
976 uspi->s_sbbase = 0; in ufs_fill_super()
980 pr_info("ufstype=hp is supported read-only\n"); in ufs_fill_super()
981 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
1000 ubh = ubh_bread_uspi(uspi, sb, uspi->s_sbbase + super_block_offset/block_size, super_block_size); in ufs_fill_super()
1007 usb3 = ubh_get_usb_third(uspi); in ufs_fill_super()
1010 uspi->s_postblformat = fs32_to_cpu(sb, usb3->fs_postblformat); in ufs_fill_super()
1012 (uspi->s_postblformat != UFS_42POSTBLFMT)) { in ufs_fill_super()
1018 uspi->s_postblformat == UFS_42POSTBLFMT) { in ufs_fill_super()
1027 sbi->s_bytesex = BYTESEX_LE; in ufs_fill_super()
1028 switch ((uspi->fs_magic = fs32_to_cpu(sb, usb3->fs_magic))) { in ufs_fill_super()
1037 sbi->s_bytesex = BYTESEX_BE; in ufs_fill_super()
1038 switch ((uspi->fs_magic = fs32_to_cpu(sb, usb3->fs_magic))) { in ufs_fill_super()
1048 if ((((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_NEXTSTEP) in ufs_fill_super()
1049 || ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_NEXTSTEP_CD) in ufs_fill_super()
1050 || ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_OPENSTEP)) in ufs_fill_super()
1051 && uspi->s_sbbase < 256) { in ufs_fill_super()
1054 uspi->s_sbbase += 8; in ufs_fill_super()
1065 uspi->s_bsize = fs32_to_cpu(sb, usb1->fs_bsize); in ufs_fill_super()
1066 uspi->s_fsize = fs32_to_cpu(sb, usb1->fs_fsize); in ufs_fill_super()
1067 uspi->s_sbsize = fs32_to_cpu(sb, usb1->fs_sbsize); in ufs_fill_super()
1068 uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask); in ufs_fill_super()
1069 uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift); in ufs_fill_super()
1071 if (!is_power_of_2(uspi->s_fsize)) { in ufs_fill_super()
1073 __func__, uspi->s_fsize); in ufs_fill_super()
1076 if (uspi->s_fsize < 512) { in ufs_fill_super()
1078 __func__, uspi->s_fsize); in ufs_fill_super()
1081 if (uspi->s_fsize > 4096) { in ufs_fill_super()
1083 __func__, uspi->s_fsize); in ufs_fill_super()
1086 if (!is_power_of_2(uspi->s_bsize)) { in ufs_fill_super()
1088 __func__, uspi->s_bsize); in ufs_fill_super()
1091 if (uspi->s_bsize < 4096) { in ufs_fill_super()
1093 __func__, uspi->s_bsize); in ufs_fill_super()
1096 if (uspi->s_bsize / uspi->s_fsize > 8) { in ufs_fill_super()
1098 __func__, uspi->s_bsize / uspi->s_fsize); in ufs_fill_super()
1101 if (uspi->s_fsize != block_size || uspi->s_sbsize != super_block_size) { in ufs_fill_super()
1104 block_size = uspi->s_fsize; in ufs_fill_super()
1105 super_block_size = uspi->s_sbsize; in ufs_fill_super()
1110 sbi->s_flags = flags;/*after that line some functions use s_flags*/ in ufs_fill_super()
1111 ufs_print_super_stuff(sb, usb1, usb2, usb3); in ufs_fill_super()
1122 (ufs_get_fs_state(sb, usb1, usb3) == (UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time))))) { in ufs_fill_super()
1123 switch(usb1->fs_clean) { in ufs_fill_super()
1134 UFSD("fs is DEC OSF/1\n"); in ufs_fill_super()
1138 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
1142 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
1146 __func__, usb1->fs_clean); in ufs_fill_super()
1147 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
1152 sb->s_flags |= SB_RDONLY; in ufs_fill_super()
1158 sb->s_op = &ufs_super_ops; in ufs_fill_super()
1159 sb->s_export_op = &ufs_export_ops; in ufs_fill_super()
1161 sb->s_magic = fs32_to_cpu(sb, usb3->fs_magic); in ufs_fill_super()
1163 uspi->s_sblkno = fs32_to_cpu(sb, usb1->fs_sblkno); in ufs_fill_super()
1164 uspi->s_cblkno = fs32_to_cpu(sb, usb1->fs_cblkno); in ufs_fill_super()
1165 uspi->s_iblkno = fs32_to_cpu(sb, usb1->fs_iblkno); in ufs_fill_super()
1166 uspi->s_dblkno = fs32_to_cpu(sb, usb1->fs_dblkno); in ufs_fill_super()
1167 uspi->s_cgoffset = fs32_to_cpu(sb, usb1->fs_cgoffset); in ufs_fill_super()
1168 uspi->s_cgmask = fs32_to_cpu(sb, usb1->fs_cgmask); in ufs_fill_super()
1171 uspi->s_size = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_size); in ufs_fill_super()
1172 uspi->s_dsize = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_dsize); in ufs_fill_super()
1174 uspi->s_size = fs32_to_cpu(sb, usb1->fs_size); in ufs_fill_super()
1175 uspi->s_dsize = fs32_to_cpu(sb, usb1->fs_dsize); in ufs_fill_super()
1178 uspi->s_ncg = fs32_to_cpu(sb, usb1->fs_ncg); in ufs_fill_super()
1181 uspi->s_fpb = fs32_to_cpu(sb, usb1->fs_frag); in ufs_fill_super()
1182 uspi->s_minfree = fs32_to_cpu(sb, usb1->fs_minfree); in ufs_fill_super()
1183 uspi->s_bmask = fs32_to_cpu(sb, usb1->fs_bmask); in ufs_fill_super()
1184 uspi->s_fmask = fs32_to_cpu(sb, usb1->fs_fmask); in ufs_fill_super()
1185 uspi->s_bshift = fs32_to_cpu(sb, usb1->fs_bshift); in ufs_fill_super()
1186 uspi->s_fshift = fs32_to_cpu(sb, usb1->fs_fshift); in ufs_fill_super()
1187 UFSD("uspi->s_bshift = %d,uspi->s_fshift = %d", uspi->s_bshift, in ufs_fill_super()
1188 uspi->s_fshift); in ufs_fill_super()
1189 uspi->s_fpbshift = fs32_to_cpu(sb, usb1->fs_fragshift); in ufs_fill_super()
1190 uspi->s_fsbtodb = fs32_to_cpu(sb, usb1->fs_fsbtodb); in ufs_fill_super()
1192 uspi->s_csmask = fs32_to_cpu(sb, usb1->fs_csmask); in ufs_fill_super()
1193 uspi->s_csshift = fs32_to_cpu(sb, usb1->fs_csshift); in ufs_fill_super()
1194 uspi->s_nindir = fs32_to_cpu(sb, usb1->fs_nindir); in ufs_fill_super()
1195 uspi->s_inopb = fs32_to_cpu(sb, usb1->fs_inopb); in ufs_fill_super()
1196 uspi->s_nspf = fs32_to_cpu(sb, usb1->fs_nspf); in ufs_fill_super()
1197 uspi->s_npsect = ufs_get_fs_npsect(sb, usb1, usb3); in ufs_fill_super()
1198 uspi->s_interleave = fs32_to_cpu(sb, usb1->fs_interleave); in ufs_fill_super()
1199 uspi->s_trackskew = fs32_to_cpu(sb, usb1->fs_trackskew); in ufs_fill_super()
1201 if (uspi->fs_magic == UFS2_MAGIC) in ufs_fill_super()
1202 uspi->s_csaddr = fs64_to_cpu(sb, usb3->fs_un1.fs_u2.fs_csaddr); in ufs_fill_super()
1204 uspi->s_csaddr = fs32_to_cpu(sb, usb1->fs_csaddr); in ufs_fill_super()
1206 uspi->s_cssize = fs32_to_cpu(sb, usb1->fs_cssize); in ufs_fill_super()
1207 uspi->s_cgsize = fs32_to_cpu(sb, usb1->fs_cgsize); in ufs_fill_super()
1208 uspi->s_ntrak = fs32_to_cpu(sb, usb1->fs_ntrak); in ufs_fill_super()
1209 uspi->s_nsect = fs32_to_cpu(sb, usb1->fs_nsect); in ufs_fill_super()
1210 uspi->s_spc = fs32_to_cpu(sb, usb1->fs_spc); in ufs_fill_super()
1211 uspi->s_ipg = fs32_to_cpu(sb, usb1->fs_ipg); in ufs_fill_super()
1212 uspi->s_fpg = fs32_to_cpu(sb, usb1->fs_fpg); in ufs_fill_super()
1213 uspi->s_cpc = fs32_to_cpu(sb, usb2->fs_un.fs_u1.fs_cpc); in ufs_fill_super()
1214 uspi->s_contigsumsize = fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_contigsumsize); in ufs_fill_super()
1215 uspi->s_qbmask = ufs_get_fs_qbmask(sb, usb3); in ufs_fill_super()
1216 uspi->s_qfmask = ufs_get_fs_qfmask(sb, usb3); in ufs_fill_super()
1217 uspi->s_nrpos = fs32_to_cpu(sb, usb3->fs_nrpos); in ufs_fill_super()
1218 uspi->s_postbloff = fs32_to_cpu(sb, usb3->fs_postbloff); in ufs_fill_super()
1219 uspi->s_rotbloff = fs32_to_cpu(sb, usb3->fs_rotbloff); in ufs_fill_super()
1221 uspi->s_root_blocks = mul_u64_u32_div(uspi->s_dsize, in ufs_fill_super()
1222 uspi->s_minfree, 100); in ufs_fill_super()
1223 if (uspi->s_minfree <= 5) { in ufs_fill_super()
1224 uspi->s_time_to_space = ~0ULL; in ufs_fill_super()
1225 uspi->s_space_to_time = 0; in ufs_fill_super()
1226 usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTSPACE); in ufs_fill_super()
1228 uspi->s_time_to_space = (uspi->s_root_blocks / 2) + 1; in ufs_fill_super()
1229 uspi->s_space_to_time = mul_u64_u32_div(uspi->s_dsize, in ufs_fill_super()
1230 uspi->s_minfree - 2, 100) - 1; in ufs_fill_super()
1236 uspi->s_fpbmask = uspi->s_fpb - 1; in ufs_fill_super()
1238 uspi->s_apbshift = uspi->s_bshift - 3; in ufs_fill_super()
1240 uspi->s_apbshift = uspi->s_bshift - 2; in ufs_fill_super()
1242 uspi->s_2apbshift = uspi->s_apbshift * 2; in ufs_fill_super()
1243 uspi->s_3apbshift = uspi->s_apbshift * 3; in ufs_fill_super()
1244 uspi->s_apb = 1 << uspi->s_apbshift; in ufs_fill_super()
1245 uspi->s_2apb = 1 << uspi->s_2apbshift; in ufs_fill_super()
1246 uspi->s_3apb = 1 << uspi->s_3apbshift; in ufs_fill_super()
1247 uspi->s_apbmask = uspi->s_apb - 1; in ufs_fill_super()
1248 uspi->s_nspfshift = uspi->s_fshift - UFS_SECTOR_BITS; in ufs_fill_super()
1249 uspi->s_nspb = uspi->s_nspf << uspi->s_fpbshift; in ufs_fill_super()
1250 uspi->s_inopf = uspi->s_inopb >> uspi->s_fpbshift; in ufs_fill_super()
1251 uspi->s_bpf = uspi->s_fsize << 3; in ufs_fill_super()
1252 uspi->s_bpfshift = uspi->s_fshift + 3; in ufs_fill_super()
1253 uspi->s_bpfmask = uspi->s_bpf - 1; in ufs_fill_super()
1254 if ((sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_44BSD || in ufs_fill_super()
1255 (sbi->s_mount_opt & UFS_MOUNT_UFSTYPE) == UFS_MOUNT_UFSTYPE_UFS2) in ufs_fill_super()
1256 uspi->s_maxsymlinklen = in ufs_fill_super()
1257 fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_maxsymlinklen); in ufs_fill_super()
1259 if (uspi->fs_magic == UFS2_MAGIC) in ufs_fill_super()
1263 if (uspi->s_maxsymlinklen > maxsymlen) { in ufs_fill_super()
1265 "fast symlink size (%u)\n", uspi->s_maxsymlinklen); in ufs_fill_super()
1266 uspi->s_maxsymlinklen = maxsymlen; in ufs_fill_super()
1268 sb->s_maxbytes = ufs_max_bytes(sb); in ufs_fill_super()
1269 sb->s_max_links = UFS_LINK_MAX; in ufs_fill_super()
1276 sb->s_root = d_make_root(inode); in ufs_fill_super()
1277 if (!sb->s_root) { in ufs_fill_super()
1278 ret = -ENOMEM; in ufs_fill_super()
1298 sb->s_fs_info = NULL; in ufs_fill_super()
1304 return -ENOMEM; in ufs_fill_super()
1311 struct ufs_super_block_third * usb3; in ufs_remount() local
1316 mutex_lock(&UFS_SB(sb)->s_lock); in ufs_remount()
1317 uspi = UFS_SB(sb)->s_uspi; in ufs_remount()
1318 flags = UFS_SB(sb)->s_flags; in ufs_remount()
1320 usb3 = ubh_get_usb_third(uspi); in ufs_remount()
1326 ufstype = UFS_SB(sb)->s_mount_opt & UFS_MOUNT_UFSTYPE; in ufs_remount()
1330 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1331 return -EINVAL; in ufs_remount()
1337 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1338 return -EINVAL; in ufs_remount()
1342 UFS_SB(sb)->s_mount_opt = new_mount_opt; in ufs_remount()
1343 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1352 usb1->fs_time = ufs_get_seconds(sb); in ufs_remount()
1356 ufs_set_fs_state(sb, usb1, usb3, in ufs_remount()
1357 UFS_FSOK - fs32_to_cpu(sb, usb1->fs_time)); in ufs_remount()
1359 sb->s_flags |= SB_RDONLY; in ufs_remount()
1365 pr_err("ufs was compiled with read-only support, can't be mounted as read-write\n"); in ufs_remount()
1366 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1367 return -EINVAL; in ufs_remount()
1374 pr_err("this ufstype is read-only supported\n"); in ufs_remount()
1375 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1376 return -EINVAL; in ufs_remount()
1380 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1381 return -EPERM; in ufs_remount()
1383 sb->s_flags &= ~SB_RDONLY; in ufs_remount()
1386 UFS_SB(sb)->s_mount_opt = new_mount_opt; in ufs_remount()
1387 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_remount()
1393 struct ufs_sb_info *sbi = UFS_SB(root->d_sb); in ufs_show_options()
1394 unsigned mval = sbi->s_mount_opt & UFS_MOUNT_UFSTYPE; in ufs_show_options()
1397 while (tp->token != Opt_onerror_panic && tp->token != mval) in ufs_show_options()
1399 BUG_ON(tp->token == Opt_onerror_panic); in ufs_show_options()
1400 seq_printf(seq, ",%s", tp->pattern); in ufs_show_options()
1402 mval = sbi->s_mount_opt & UFS_MOUNT_ONERROR; in ufs_show_options()
1403 while (tp->token != Opt_err && tp->token != mval) in ufs_show_options()
1405 BUG_ON(tp->token == Opt_err); in ufs_show_options()
1406 seq_printf(seq, ",%s", tp->pattern); in ufs_show_options()
1413 struct super_block *sb = dentry->d_sb; in ufs_statfs()
1414 struct ufs_sb_private_info *uspi= UFS_SB(sb)->s_uspi; in ufs_statfs()
1415 unsigned flags = UFS_SB(sb)->s_flags; in ufs_statfs()
1416 u64 id = huge_encode_dev(sb->s_bdev->bd_dev); in ufs_statfs()
1418 mutex_lock(&UFS_SB(sb)->s_lock); in ufs_statfs()
1421 buf->f_type = UFS2_MAGIC; in ufs_statfs()
1423 buf->f_type = UFS_MAGIC; in ufs_statfs()
1425 buf->f_blocks = uspi->s_dsize; in ufs_statfs()
1426 buf->f_bfree = ufs_freefrags(uspi); in ufs_statfs()
1427 buf->f_ffree = uspi->cs_total.cs_nifree; in ufs_statfs()
1428 buf->f_bsize = sb->s_blocksize; in ufs_statfs()
1429 buf->f_bavail = (buf->f_bfree > uspi->s_root_blocks) in ufs_statfs()
1430 ? (buf->f_bfree - uspi->s_root_blocks) : 0; in ufs_statfs()
1431 buf->f_files = uspi->s_ncg * uspi->s_ipg; in ufs_statfs()
1432 buf->f_namelen = UFS_MAXNAMLEN; in ufs_statfs()
1433 buf->f_fsid = u64_to_fsid(id); in ufs_statfs()
1435 mutex_unlock(&UFS_SB(sb)->s_lock); in ufs_statfs()
1450 inode_set_iversion(&ei->vfs_inode, 1); in ufs_alloc_inode()
1451 seqlock_init(&ei->meta_lock); in ufs_alloc_inode()
1452 mutex_init(&ei->truncate_mutex); in ufs_alloc_inode()
1453 return &ei->vfs_inode; in ufs_alloc_inode()
1465 inode_init_once(&ei->vfs_inode); in init_once()
1479 return -ENOMEM; in init_inodecache()