Lines Matching +full:rcu +full:- +full:endian +full:- +full:offset
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Laboratoire MASI - Institut Blaise Pascal
16 * Big-endian to little-endian byte-swapping/bitmaps by
55 struct ext2_super_block *es = sbi->s_es; in ext2_error()
58 spin_lock(&sbi->s_lock); in ext2_error()
59 sbi->s_mount_state |= EXT2_ERROR_FS; in ext2_error()
60 es->s_state |= cpu_to_le16(EXT2_ERROR_FS); in ext2_error()
61 spin_unlock(&sbi->s_lock); in ext2_error()
70 printk(KERN_CRIT "EXT2-fs (%s): error: %s: %pV\n", in ext2_error()
71 sb->s_id, function, &vaf); in ext2_error()
76 panic("EXT2-fs: panic from previous error\n"); in ext2_error()
79 "error: remounting filesystem read-only"); in ext2_error()
80 sb->s_flags |= SB_RDONLY; in ext2_error()
95 printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf); in ext2_msg()
101 * This must be called with sbi->s_lock held.
105 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_update_dynamic_rev()
107 if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV) in ext2_update_dynamic_rev()
115 es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO); in ext2_update_dynamic_rev()
116 es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE); in ext2_update_dynamic_rev()
117 es->s_rev_level = cpu_to_le32(EXT2_DYNAMIC_REV); in ext2_update_dynamic_rev()
118 /* leave es->s_feature_*compat flags alone */ in ext2_update_dynamic_rev()
119 /* es->s_uuid will be set by e2fsck if empty */ in ext2_update_dynamic_rev()
152 ext2_xattr_destroy_cache(sbi->s_ea_block_cache); in ext2_put_super()
153 sbi->s_ea_block_cache = NULL; in ext2_put_super()
156 struct ext2_super_block *es = sbi->s_es; in ext2_put_super()
158 spin_lock(&sbi->s_lock); in ext2_put_super()
159 es->s_state = cpu_to_le16(sbi->s_mount_state); in ext2_put_super()
160 spin_unlock(&sbi->s_lock); in ext2_put_super()
163 db_count = sbi->s_gdb_count; in ext2_put_super()
165 brelse(sbi->s_group_desc[i]); in ext2_put_super()
166 kfree(sbi->s_group_desc); in ext2_put_super()
167 kfree(sbi->s_debts); in ext2_put_super()
168 percpu_counter_destroy(&sbi->s_freeblocks_counter); in ext2_put_super()
169 percpu_counter_destroy(&sbi->s_freeinodes_counter); in ext2_put_super()
170 percpu_counter_destroy(&sbi->s_dirs_counter); in ext2_put_super()
171 brelse (sbi->s_sbh); in ext2_put_super()
172 sb->s_fs_info = NULL; in ext2_put_super()
173 kfree(sbi->s_blockgroup_lock); in ext2_put_super()
174 fs_put_dax(sbi->s_daxdev); in ext2_put_super()
186 ei->i_block_alloc_info = NULL; in ext2_alloc_inode()
187 inode_set_iversion(&ei->vfs_inode, 1); in ext2_alloc_inode()
189 memset(&ei->i_dquot, 0, sizeof(ei->i_dquot)); in ext2_alloc_inode()
192 return &ei->vfs_inode; in ext2_alloc_inode()
204 rwlock_init(&ei->i_meta_lock); in init_once()
206 init_rwsem(&ei->xattr_sem); in init_once()
208 mutex_init(&ei->truncate_mutex); in init_once()
210 init_rwsem(&ei->dax_sem); in init_once()
212 inode_init_once(&ei->vfs_inode); in init_once()
225 return -ENOMEM; in init_inodecache()
232 * Make sure all delayed rcu free inodes are flushed before we in destroy_inodecache()
241 struct super_block *sb = root->d_sb; in ext2_show_options()
243 struct ext2_super_block *es = sbi->s_es; in ext2_show_options()
246 spin_lock(&sbi->s_lock); in ext2_show_options()
247 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); in ext2_show_options()
249 if (sbi->s_sb_block != 1) in ext2_show_options()
250 seq_printf(seq, ",sb=%lu", sbi->s_sb_block); in ext2_show_options()
257 if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) || in ext2_show_options()
258 le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) { in ext2_show_options()
260 from_kuid_munged(&init_user_ns, sbi->s_resuid)); in ext2_show_options()
262 if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) || in ext2_show_options()
263 le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) { in ext2_show_options()
265 from_kgid_munged(&init_user_ns, sbi->s_resgid)); in ext2_show_options()
268 int def_errors = le16_to_cpu(es->s_errors); in ext2_show_options()
272 seq_puts(seq, ",errors=remount-ro"); in ext2_show_options()
320 spin_unlock(&sbi->s_lock); in ext2_show_options()
331 return EXT2_I(inode)->i_dquot; in ext2_get_dquots()
371 return ERR_PTR(-ESTALE); in ext2_nfs_get_inode()
372 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count)) in ext2_nfs_get_inode()
373 return ERR_PTR(-ESTALE); in ext2_nfs_get_inode()
383 if (generation && inode->i_generation != generation) { in ext2_nfs_get_inode()
386 return ERR_PTR(-ESTALE); in ext2_nfs_get_inode()
421 printk("EXT2-fs: Invalid sb specification: %s\n", in get_sb_block()
452 {Opt_err_ro, "errors=remount-ro"},
493 clear_opt (opts->s_mount_opt, MINIX_DF); in parse_options()
496 set_opt (opts->s_mount_opt, MINIX_DF); in parse_options()
499 set_opt (opts->s_mount_opt, GRPID); in parse_options()
502 clear_opt (opts->s_mount_opt, GRPID); in parse_options()
513 opts->s_resuid = uid; in parse_options()
523 opts->s_resgid = gid; in parse_options()
530 clear_opt (opts->s_mount_opt, ERRORS_CONT); in parse_options()
531 clear_opt (opts->s_mount_opt, ERRORS_RO); in parse_options()
532 set_opt (opts->s_mount_opt, ERRORS_PANIC); in parse_options()
535 clear_opt (opts->s_mount_opt, ERRORS_CONT); in parse_options()
536 clear_opt (opts->s_mount_opt, ERRORS_PANIC); in parse_options()
537 set_opt (opts->s_mount_opt, ERRORS_RO); in parse_options()
540 clear_opt (opts->s_mount_opt, ERRORS_RO); in parse_options()
541 clear_opt (opts->s_mount_opt, ERRORS_PANIC); in parse_options()
542 set_opt (opts->s_mount_opt, ERRORS_CONT); in parse_options()
545 set_opt (opts->s_mount_opt, NO_UID32); in parse_options()
548 set_opt (opts->s_mount_opt, DEBUG); in parse_options()
551 set_opt (opts->s_mount_opt, OLDALLOC); in parse_options()
554 clear_opt (opts->s_mount_opt, OLDALLOC); in parse_options()
557 set_opt (opts->s_mount_opt, NOBH); in parse_options()
561 set_opt (opts->s_mount_opt, XATTR_USER); in parse_options()
564 clear_opt (opts->s_mount_opt, XATTR_USER); in parse_options()
575 set_opt(opts->s_mount_opt, POSIX_ACL); in parse_options()
578 clear_opt(opts->s_mount_opt, POSIX_ACL); in parse_options()
589 set_opt(opts->s_mount_opt, XIP); in parse_options()
595 set_opt(opts->s_mount_opt, DAX); in parse_options()
604 set_opt(opts->s_mount_opt, USRQUOTA); in parse_options()
608 set_opt(opts->s_mount_opt, GRPQUOTA); in parse_options()
620 set_opt(opts->s_mount_opt, RESERVATION); in parse_options()
624 clear_opt(opts->s_mount_opt, RESERVATION); in parse_options()
643 if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { in ext2_setup_super()
646 "forcing read-only mode"); in ext2_setup_super()
651 if (!(sbi->s_mount_state & EXT2_VALID_FS)) in ext2_setup_super()
655 else if ((sbi->s_mount_state & EXT2_ERROR_FS)) in ext2_setup_super()
659 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && in ext2_setup_super()
660 le16_to_cpu(es->s_mnt_count) >= in ext2_setup_super()
661 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) in ext2_setup_super()
665 else if (le32_to_cpu(es->s_checkinterval) && in ext2_setup_super()
666 (le32_to_cpu(es->s_lastcheck) + in ext2_setup_super()
667 le32_to_cpu(es->s_checkinterval) <= in ext2_setup_super()
672 if (!le16_to_cpu(es->s_max_mnt_count)) in ext2_setup_super()
673 es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); in ext2_setup_super()
674 le16_add_cpu(&es->s_mnt_count, 1); in ext2_setup_super()
678 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, in ext2_setup_super()
679 sbi->s_frag_size, in ext2_setup_super()
680 sbi->s_groups_count, in ext2_setup_super()
683 sbi->s_mount_opt); in ext2_setup_super()
694 for (i = 0; i < sbi->s_groups_count; i++) { in ext2_check_descriptors()
699 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || in ext2_check_descriptors()
700 le32_to_cpu(gdp->bg_block_bitmap) > last_block) in ext2_check_descriptors()
705 i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); in ext2_check_descriptors()
708 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block || in ext2_check_descriptors()
709 le32_to_cpu(gdp->bg_inode_bitmap) > last_block) in ext2_check_descriptors()
714 i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); in ext2_check_descriptors()
717 if (le32_to_cpu(gdp->bg_inode_table) < first_block || in ext2_check_descriptors()
718 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 > in ext2_check_descriptors()
724 i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); in ext2_check_descriptors()
732 * Maximal file size. There is a direct, and {,double-,triple-}indirect
733 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
741 unsigned int ppb = 1 << (bits-2); in ext2_max_size()
746 * does not exceed 2^32 -1 in ext2_max_size()
750 upper_limit = (1LL << 32) - 1; in ext2_max_size()
753 upper_limit >>= (bits - 9); in ext2_max_size()
756 res += 1LL << (bits-2); in ext2_max_size()
757 res += 1LL << (2*(bits-2)); in ext2_max_size()
758 res += 1LL << (3*(bits-2)); in ext2_max_size()
769 upper_limit -= EXT2_NDIR_BLOCKS; in ext2_max_size()
772 upper_limit -= ppb; in ext2_max_size()
776 res -= meta_blocks; in ext2_max_size()
780 upper_limit -= ppb * ppb; in ext2_max_size()
784 res -= meta_blocks; in ext2_max_size()
800 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); in descriptor_loc()
805 bg = sbi->s_desc_per_block * nr; in descriptor_loc()
812 struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev); in ext2_fill_super()
820 unsigned long offset = 0; in ext2_fill_super() local
822 long ret = -ENOMEM; in ext2_fill_super()
834 sbi->s_blockgroup_lock = in ext2_fill_super()
836 if (!sbi->s_blockgroup_lock) { in ext2_fill_super()
840 sb->s_fs_info = sbi; in ext2_fill_super()
841 sbi->s_sb_block = sb_block; in ext2_fill_super()
842 sbi->s_daxdev = dax_dev; in ext2_fill_super()
844 spin_lock_init(&sbi->s_lock); in ext2_fill_super()
845 ret = -EINVAL; in ext2_fill_super()
862 * calculate the offset. in ext2_fill_super()
866 offset = (sb_block*BLOCK_SIZE) % blocksize; in ext2_fill_super()
877 * some ext2 macro-instructions depend on its value in ext2_fill_super()
879 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); in ext2_fill_super()
880 sbi->s_es = es; in ext2_fill_super()
881 sb->s_magic = le16_to_cpu(es->s_magic); in ext2_fill_super()
883 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
888 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); in ext2_fill_super()
904 if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC) in ext2_fill_super()
906 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE) in ext2_fill_super()
911 opts.s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid)); in ext2_fill_super()
912 opts.s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid)); in ext2_fill_super()
919 sbi->s_mount_opt = opts.s_mount_opt; in ext2_fill_super()
920 sbi->s_resuid = opts.s_resuid; in ext2_fill_super()
921 sbi->s_resgid = opts.s_resgid; in ext2_fill_super()
923 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext2_fill_super()
925 sb->s_iflags |= SB_I_CGROUPWB; in ext2_fill_super()
927 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && in ext2_fill_super()
953 blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); in ext2_fill_super()
956 if (!bdev_dax_supported(sb->s_bdev, blocksize)) { in ext2_fill_super()
959 clear_opt(sbi->s_mount_opt, DAX); in ext2_fill_super()
963 /* If the blocksize doesn't match, re-read the thing.. */ in ext2_fill_super()
964 if (sb->s_blocksize != blocksize) { in ext2_fill_super()
974 offset = (sb_block*BLOCK_SIZE) % blocksize; in ext2_fill_super()
981 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); in ext2_fill_super()
982 sbi->s_es = es; in ext2_fill_super()
983 if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) { in ext2_fill_super()
989 sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); in ext2_fill_super()
990 sb->s_max_links = EXT2_LINK_MAX; in ext2_fill_super()
991 sb->s_time_min = S32_MIN; in ext2_fill_super()
992 sb->s_time_max = S32_MAX; in ext2_fill_super()
994 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) { in ext2_fill_super()
995 sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE; in ext2_fill_super()
996 sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO; in ext2_fill_super()
998 sbi->s_inode_size = le16_to_cpu(es->s_inode_size); in ext2_fill_super()
999 sbi->s_first_ino = le32_to_cpu(es->s_first_ino); in ext2_fill_super()
1000 if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) || in ext2_fill_super()
1001 !is_power_of_2(sbi->s_inode_size) || in ext2_fill_super()
1002 (sbi->s_inode_size > blocksize)) { in ext2_fill_super()
1005 sbi->s_inode_size); in ext2_fill_super()
1010 sbi->s_frag_size = EXT2_MIN_FRAG_SIZE << in ext2_fill_super()
1011 le32_to_cpu(es->s_log_frag_size); in ext2_fill_super()
1012 if (sbi->s_frag_size == 0) in ext2_fill_super()
1014 sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size; in ext2_fill_super()
1016 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); in ext2_fill_super()
1017 sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group); in ext2_fill_super()
1018 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); in ext2_fill_super()
1020 sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); in ext2_fill_super()
1021 if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0) in ext2_fill_super()
1023 sbi->s_itb_per_group = sbi->s_inodes_per_group / in ext2_fill_super()
1024 sbi->s_inodes_per_block; in ext2_fill_super()
1025 sbi->s_desc_per_block = sb->s_blocksize / in ext2_fill_super()
1027 sbi->s_sbh = bh; in ext2_fill_super()
1028 sbi->s_mount_state = le16_to_cpu(es->s_state); in ext2_fill_super()
1029 sbi->s_addr_per_block_bits = in ext2_fill_super()
1031 sbi->s_desc_per_block_bits = in ext2_fill_super()
1034 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
1037 if (sb->s_blocksize != bh->b_size) { in ext2_fill_super()
1043 if (sb->s_blocksize != sbi->s_frag_size) { in ext2_fill_super()
1047 sbi->s_frag_size, sb->s_blocksize); in ext2_fill_super()
1051 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1054 sbi->s_blocks_per_group); in ext2_fill_super()
1057 if (sbi->s_frags_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1060 sbi->s_frags_per_group); in ext2_fill_super()
1063 if (sbi->s_inodes_per_group < sbi->s_inodes_per_block || in ext2_fill_super()
1064 sbi->s_inodes_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1067 sbi->s_inodes_per_group); in ext2_fill_super()
1073 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - in ext2_fill_super()
1074 le32_to_cpu(es->s_first_data_block) - 1) in ext2_fill_super()
1076 if ((u64)sbi->s_groups_count * sbi->s_inodes_per_group != in ext2_fill_super()
1077 le32_to_cpu(es->s_inodes_count)) { in ext2_fill_super()
1079 le32_to_cpu(es->s_inodes_count), in ext2_fill_super()
1080 (u64)sbi->s_groups_count * sbi->s_inodes_per_group); in ext2_fill_super()
1083 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / in ext2_fill_super()
1085 sbi->s_group_desc = kmalloc_array (db_count, in ext2_fill_super()
1088 if (sbi->s_group_desc == NULL) { in ext2_fill_super()
1089 ret = -ENOMEM; in ext2_fill_super()
1093 bgl_lock_init(sbi->s_blockgroup_lock); in ext2_fill_super()
1094 sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); in ext2_fill_super()
1095 if (!sbi->s_debts) { in ext2_fill_super()
1096 ret = -ENOMEM; in ext2_fill_super()
1102 sbi->s_group_desc[i] = sb_bread(sb, block); in ext2_fill_super()
1103 if (!sbi->s_group_desc[i]) { in ext2_fill_super()
1105 brelse (sbi->s_group_desc[j]); in ext2_fill_super()
1115 sbi->s_gdb_count = db_count; in ext2_fill_super()
1116 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); in ext2_fill_super()
1117 spin_lock_init(&sbi->s_next_gen_lock); in ext2_fill_super()
1120 spin_lock_init(&sbi->s_rsv_window_lock); in ext2_fill_super()
1121 sbi->s_rsv_window_root = RB_ROOT; in ext2_fill_super()
1124 * reservation window list --- it gives us a placeholder for in ext2_fill_super()
1125 * append-at-start-of-list which makes the allocation logic in ext2_fill_super()
1128 sbi->s_rsv_window_head.rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED; in ext2_fill_super()
1129 sbi->s_rsv_window_head.rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED; in ext2_fill_super()
1130 sbi->s_rsv_window_head.rsv_alloc_hit = 0; in ext2_fill_super()
1131 sbi->s_rsv_window_head.rsv_goal_size = 0; in ext2_fill_super()
1132 ext2_rsv_window_add(sb, &sbi->s_rsv_window_head); in ext2_fill_super()
1134 err = percpu_counter_init(&sbi->s_freeblocks_counter, in ext2_fill_super()
1137 err = percpu_counter_init(&sbi->s_freeinodes_counter, in ext2_fill_super()
1141 err = percpu_counter_init(&sbi->s_dirs_counter, in ext2_fill_super()
1151 sbi->s_ea_block_cache = ext2_xattr_create_cache(); in ext2_fill_super()
1152 if (!sbi->s_ea_block_cache) { in ext2_fill_super()
1153 ret = -ENOMEM; in ext2_fill_super()
1161 sb->s_op = &ext2_sops; in ext2_fill_super()
1162 sb->s_export_op = &ext2_export_ops; in ext2_fill_super()
1163 sb->s_xattr = ext2_xattr_handlers; in ext2_fill_super()
1166 sb->dq_op = &dquot_operations; in ext2_fill_super()
1167 sb->s_qcop = &ext2_quotactl_ops; in ext2_fill_super()
1168 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP; in ext2_fill_super()
1176 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { in ext2_fill_super()
1182 sb->s_root = d_make_root(root); in ext2_fill_super()
1183 if (!sb->s_root) { in ext2_fill_super()
1185 ret = -ENOMEM; in ext2_fill_super()
1192 sb->s_flags |= SB_RDONLY; in ext2_fill_super()
1200 sb->s_id); in ext2_fill_super()
1203 ext2_xattr_destroy_cache(sbi->s_ea_block_cache); in ext2_fill_super()
1204 percpu_counter_destroy(&sbi->s_freeblocks_counter); in ext2_fill_super()
1205 percpu_counter_destroy(&sbi->s_freeinodes_counter); in ext2_fill_super()
1206 percpu_counter_destroy(&sbi->s_dirs_counter); in ext2_fill_super()
1209 brelse(sbi->s_group_desc[i]); in ext2_fill_super()
1211 kfree(sbi->s_group_desc); in ext2_fill_super()
1212 kfree(sbi->s_debts); in ext2_fill_super()
1216 sb->s_fs_info = NULL; in ext2_fill_super()
1217 kfree(sbi->s_blockgroup_lock); in ext2_fill_super()
1226 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; in ext2_clear_super_error()
1248 spin_lock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1249 es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); in ext2_sync_super()
1250 es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); in ext2_sync_super()
1251 es->s_wtime = cpu_to_le32(ktime_get_real_seconds()); in ext2_sync_super()
1253 spin_unlock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1254 mark_buffer_dirty(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1256 sync_dirty_buffer(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1272 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_sync_fs()
1278 dquot_writeback_dquots(sb, -1); in ext2_sync_fs()
1280 spin_lock(&sbi->s_lock); in ext2_sync_fs()
1281 if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { in ext2_sync_fs()
1283 es->s_state &= cpu_to_le16(~EXT2_VALID_FS); in ext2_sync_fs()
1285 spin_unlock(&sbi->s_lock); in ext2_sync_fs()
1299 if (atomic_long_read(&sb->s_remove_count)) { in ext2_freeze()
1304 spin_lock(&sbi->s_lock); in ext2_freeze()
1305 sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state); in ext2_freeze()
1306 spin_unlock(&sbi->s_lock); in ext2_freeze()
1307 ext2_sync_super(sb, sbi->s_es, 1); in ext2_freeze()
1335 spin_lock(&sbi->s_lock); in ext2_remount()
1336 new_opts.s_mount_opt = sbi->s_mount_opt; in ext2_remount()
1337 new_opts.s_resuid = sbi->s_resuid; in ext2_remount()
1338 new_opts.s_resgid = sbi->s_resgid; in ext2_remount()
1339 spin_unlock(&sbi->s_lock); in ext2_remount()
1342 return -EINVAL; in ext2_remount()
1344 spin_lock(&sbi->s_lock); in ext2_remount()
1345 es = sbi->s_es; in ext2_remount()
1346 if ((sbi->s_mount_opt ^ new_opts.s_mount_opt) & EXT2_MOUNT_DAX) { in ext2_remount()
1354 if (le16_to_cpu(es->s_state) & EXT2_VALID_FS || in ext2_remount()
1355 !(sbi->s_mount_state & EXT2_VALID_FS)) in ext2_remount()
1362 es->s_state = cpu_to_le16(sbi->s_mount_state); in ext2_remount()
1363 es->s_mtime = cpu_to_le32(ktime_get_real_seconds()); in ext2_remount()
1364 spin_unlock(&sbi->s_lock); in ext2_remount()
1366 err = dquot_suspend(sb, -1); in ext2_remount()
1375 spin_unlock(&sbi->s_lock); in ext2_remount()
1380 return -EROFS; in ext2_remount()
1383 * Mounting a RDONLY partition read-write, so reread and in ext2_remount()
1387 sbi->s_mount_state = le16_to_cpu(es->s_state); in ext2_remount()
1389 sb->s_flags &= ~SB_RDONLY; in ext2_remount()
1390 spin_unlock(&sbi->s_lock); in ext2_remount()
1394 dquot_resume(sb, -1); in ext2_remount()
1397 spin_lock(&sbi->s_lock); in ext2_remount()
1399 sbi->s_mount_opt = new_opts.s_mount_opt; in ext2_remount()
1400 sbi->s_resuid = new_opts.s_resuid; in ext2_remount()
1401 sbi->s_resgid = new_opts.s_resgid; in ext2_remount()
1402 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext2_remount()
1404 spin_unlock(&sbi->s_lock); in ext2_remount()
1411 struct super_block *sb = dentry->d_sb; in ext2_statfs()
1413 struct ext2_super_block *es = sbi->s_es; in ext2_statfs()
1416 spin_lock(&sbi->s_lock); in ext2_statfs()
1419 sbi->s_overhead_last = 0; in ext2_statfs()
1420 else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) { in ext2_statfs()
1434 overhead = le32_to_cpu(es->s_first_data_block); in ext2_statfs()
1441 for (i = 0; i < sbi->s_groups_count; i++) in ext2_statfs()
1449 overhead += (sbi->s_groups_count * in ext2_statfs()
1450 (2 + sbi->s_itb_per_group)); in ext2_statfs()
1451 sbi->s_overhead_last = overhead; in ext2_statfs()
1453 sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count); in ext2_statfs()
1456 buf->f_type = EXT2_SUPER_MAGIC; in ext2_statfs()
1457 buf->f_bsize = sb->s_blocksize; in ext2_statfs()
1458 buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last; in ext2_statfs()
1459 buf->f_bfree = ext2_count_free_blocks(sb); in ext2_statfs()
1460 es->s_free_blocks_count = cpu_to_le32(buf->f_bfree); in ext2_statfs()
1461 buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count); in ext2_statfs()
1462 if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count)) in ext2_statfs()
1463 buf->f_bavail = 0; in ext2_statfs()
1464 buf->f_files = le32_to_cpu(es->s_inodes_count); in ext2_statfs()
1465 buf->f_ffree = ext2_count_free_inodes(sb); in ext2_statfs()
1466 es->s_free_inodes_count = cpu_to_le32(buf->f_ffree); in ext2_statfs()
1467 buf->f_namelen = EXT2_NAME_LEN; in ext2_statfs()
1468 fsid = le64_to_cpup((void *)es->s_uuid) ^ in ext2_statfs()
1469 le64_to_cpup((void *)es->s_uuid + sizeof(u64)); in ext2_statfs()
1470 buf->f_fsid = u64_to_fsid(fsid); in ext2_statfs()
1471 spin_unlock(&sbi->s_lock); in ext2_statfs()
1483 /* Read data from quotafile - avoid pagecache and such because we cannot afford
1490 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_read()
1493 int offset = off & (sb->s_blocksize - 1); in ext2_quota_read() local
1503 len = i_size-off; in ext2_quota_read()
1506 tocopy = sb->s_blocksize - offset < toread ? in ext2_quota_read()
1507 sb->s_blocksize - offset : toread; in ext2_quota_read()
1510 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_read()
1519 return -EIO; in ext2_quota_read()
1520 memcpy(data, bh->b_data+offset, tocopy); in ext2_quota_read()
1523 offset = 0; in ext2_quota_read()
1524 toread -= tocopy; in ext2_quota_read()
1535 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_write()
1538 int offset = off & (sb->s_blocksize - 1); in ext2_quota_write() local
1545 tocopy = sb->s_blocksize - offset < towrite ? in ext2_quota_write()
1546 sb->s_blocksize - offset : towrite; in ext2_quota_write()
1549 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_write()
1553 if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) in ext2_quota_write()
1558 err = -EIO; in ext2_quota_write()
1562 memcpy(bh->b_data+offset, data, tocopy); in ext2_quota_write()
1563 flush_dcache_page(bh->b_page); in ext2_quota_write()
1568 offset = 0; in ext2_quota_write()
1569 towrite -= tocopy; in ext2_quota_write()
1576 if (inode->i_size < off+len-towrite) in ext2_quota_write()
1577 i_size_write(inode, off+len-towrite); in ext2_quota_write()
1579 inode->i_mtime = inode->i_ctime = current_time(inode); in ext2_quota_write()
1581 return len - towrite; in ext2_quota_write()
1594 inode = d_inode(path->dentry); in ext2_quota_on()
1596 EXT2_I(inode)->i_flags |= EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL; in ext2_quota_on()
1607 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_off()
1618 EXT2_I(inode)->i_flags &= ~(EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL); in ext2_quota_off()