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 kvfree(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, NULL); 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()
209 inode_init_once(&ei->vfs_inode); in init_once()
222 return -ENOMEM; in init_inodecache()
229 * Make sure all delayed rcu free inodes are flushed before we in destroy_inodecache()
238 struct super_block *sb = root->d_sb; in ext2_show_options()
240 struct ext2_super_block *es = sbi->s_es; in ext2_show_options()
243 spin_lock(&sbi->s_lock); in ext2_show_options()
244 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); in ext2_show_options()
246 if (sbi->s_sb_block != 1) in ext2_show_options()
247 seq_printf(seq, ",sb=%lu", sbi->s_sb_block); in ext2_show_options()
254 if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) || in ext2_show_options()
255 le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) { in ext2_show_options()
257 from_kuid_munged(&init_user_ns, sbi->s_resuid)); in ext2_show_options()
259 if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) || in ext2_show_options()
260 le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) { in ext2_show_options()
262 from_kgid_munged(&init_user_ns, sbi->s_resgid)); in ext2_show_options()
265 int def_errors = le16_to_cpu(es->s_errors); in ext2_show_options()
269 seq_puts(seq, ",errors=remount-ro"); in ext2_show_options()
314 spin_unlock(&sbi->s_lock); in ext2_show_options()
325 return EXT2_I(inode)->i_dquot; in ext2_get_dquots()
365 return ERR_PTR(-ESTALE); in ext2_nfs_get_inode()
366 if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count)) in ext2_nfs_get_inode()
367 return ERR_PTR(-ESTALE); in ext2_nfs_get_inode()
377 if (generation && inode->i_generation != generation) { in ext2_nfs_get_inode()
380 return ERR_PTR(-ESTALE); in ext2_nfs_get_inode()
415 printk("EXT2-fs: Invalid sb specification: %s\n", in get_sb_block()
446 {Opt_err_ro, "errors=remount-ro"},
487 clear_opt (opts->s_mount_opt, MINIX_DF); in parse_options()
490 set_opt (opts->s_mount_opt, MINIX_DF); in parse_options()
493 set_opt (opts->s_mount_opt, GRPID); in parse_options()
496 clear_opt (opts->s_mount_opt, GRPID); in parse_options()
507 opts->s_resuid = uid; in parse_options()
517 opts->s_resgid = gid; in parse_options()
524 clear_opt (opts->s_mount_opt, ERRORS_CONT); in parse_options()
525 clear_opt (opts->s_mount_opt, ERRORS_RO); in parse_options()
526 set_opt (opts->s_mount_opt, ERRORS_PANIC); in parse_options()
529 clear_opt (opts->s_mount_opt, ERRORS_CONT); in parse_options()
530 clear_opt (opts->s_mount_opt, ERRORS_PANIC); in parse_options()
531 set_opt (opts->s_mount_opt, ERRORS_RO); in parse_options()
534 clear_opt (opts->s_mount_opt, ERRORS_RO); in parse_options()
535 clear_opt (opts->s_mount_opt, ERRORS_PANIC); in parse_options()
536 set_opt (opts->s_mount_opt, ERRORS_CONT); in parse_options()
539 set_opt (opts->s_mount_opt, NO_UID32); in parse_options()
542 set_opt (opts->s_mount_opt, DEBUG); in parse_options()
545 set_opt (opts->s_mount_opt, OLDALLOC); in parse_options()
548 clear_opt (opts->s_mount_opt, OLDALLOC); in parse_options()
556 set_opt (opts->s_mount_opt, XATTR_USER); in parse_options()
559 clear_opt (opts->s_mount_opt, XATTR_USER); in parse_options()
570 set_opt(opts->s_mount_opt, POSIX_ACL); in parse_options()
573 clear_opt(opts->s_mount_opt, POSIX_ACL); in parse_options()
584 set_opt(opts->s_mount_opt, XIP); in parse_options()
590 set_opt(opts->s_mount_opt, DAX); in parse_options()
599 set_opt(opts->s_mount_opt, USRQUOTA); in parse_options()
603 set_opt(opts->s_mount_opt, GRPQUOTA); in parse_options()
615 set_opt(opts->s_mount_opt, RESERVATION); in parse_options()
619 clear_opt(opts->s_mount_opt, RESERVATION); in parse_options()
638 if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) { in ext2_setup_super()
641 "forcing read-only mode"); in ext2_setup_super()
646 if (!(sbi->s_mount_state & EXT2_VALID_FS)) in ext2_setup_super()
650 else if ((sbi->s_mount_state & EXT2_ERROR_FS)) in ext2_setup_super()
654 else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 && in ext2_setup_super()
655 le16_to_cpu(es->s_mnt_count) >= in ext2_setup_super()
656 (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count)) in ext2_setup_super()
660 else if (le32_to_cpu(es->s_checkinterval) && in ext2_setup_super()
661 (le32_to_cpu(es->s_lastcheck) + in ext2_setup_super()
662 le32_to_cpu(es->s_checkinterval) <= in ext2_setup_super()
667 if (!le16_to_cpu(es->s_max_mnt_count)) in ext2_setup_super()
668 es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT); in ext2_setup_super()
669 le16_add_cpu(&es->s_mnt_count, 1); in ext2_setup_super()
673 EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize, in ext2_setup_super()
674 sbi->s_groups_count, in ext2_setup_super()
677 sbi->s_mount_opt); in ext2_setup_super()
688 for (i = 0; i < sbi->s_groups_count; i++) { in ext2_check_descriptors()
693 if (le32_to_cpu(gdp->bg_block_bitmap) < first_block || in ext2_check_descriptors()
694 le32_to_cpu(gdp->bg_block_bitmap) > last_block) in ext2_check_descriptors()
699 i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap)); in ext2_check_descriptors()
702 if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block || in ext2_check_descriptors()
703 le32_to_cpu(gdp->bg_inode_bitmap) > last_block) in ext2_check_descriptors()
708 i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap)); in ext2_check_descriptors()
711 if (le32_to_cpu(gdp->bg_inode_table) < first_block || in ext2_check_descriptors()
712 le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 > in ext2_check_descriptors()
718 i, (unsigned long) le32_to_cpu(gdp->bg_inode_table)); in ext2_check_descriptors()
726 * Maximal file size. There is a direct, and {,double-,triple-}indirect
727 * block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
735 unsigned int ppb = 1 << (bits-2); in ext2_max_size()
740 * does not exceed 2^32 -1 in ext2_max_size()
744 upper_limit = (1LL << 32) - 1; in ext2_max_size()
747 upper_limit >>= (bits - 9); in ext2_max_size()
750 res += 1LL << (bits-2); in ext2_max_size()
751 res += 1LL << (2*(bits-2)); in ext2_max_size()
752 res += 1LL << (3*(bits-2)); in ext2_max_size()
763 upper_limit -= EXT2_NDIR_BLOCKS; in ext2_max_size()
766 upper_limit -= ppb; in ext2_max_size()
770 res -= meta_blocks; in ext2_max_size()
774 upper_limit -= ppb * ppb; in ext2_max_size()
778 res -= meta_blocks; in ext2_max_size()
794 first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg); in descriptor_loc()
799 bg = sbi->s_desc_per_block * nr; in descriptor_loc()
813 unsigned long offset = 0; in ext2_fill_super() local
815 long ret = -ENOMEM; in ext2_fill_super()
825 return -ENOMEM; in ext2_fill_super()
827 sbi->s_blockgroup_lock = in ext2_fill_super()
829 if (!sbi->s_blockgroup_lock) { in ext2_fill_super()
831 return -ENOMEM; in ext2_fill_super()
833 sb->s_fs_info = sbi; in ext2_fill_super()
834 sbi->s_sb_block = sb_block; in ext2_fill_super()
835 sbi->s_daxdev = fs_dax_get_by_bdev(sb->s_bdev, &sbi->s_dax_part_off, in ext2_fill_super()
838 spin_lock_init(&sbi->s_lock); in ext2_fill_super()
839 ret = -EINVAL; in ext2_fill_super()
856 * calculate the offset. in ext2_fill_super()
860 offset = (sb_block*BLOCK_SIZE) % blocksize; in ext2_fill_super()
871 * some ext2 macro-instructions depend on its value in ext2_fill_super()
873 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); in ext2_fill_super()
874 sbi->s_es = es; in ext2_fill_super()
875 sb->s_magic = le16_to_cpu(es->s_magic); in ext2_fill_super()
877 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
882 def_mount_opts = le32_to_cpu(es->s_default_mount_opts); in ext2_fill_super()
898 if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC) in ext2_fill_super()
900 else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE) in ext2_fill_super()
905 opts.s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid)); in ext2_fill_super()
906 opts.s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid)); in ext2_fill_super()
913 sbi->s_mount_opt = opts.s_mount_opt; in ext2_fill_super()
914 sbi->s_resuid = opts.s_resuid; in ext2_fill_super()
915 sbi->s_resgid = opts.s_resgid; in ext2_fill_super()
917 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext2_fill_super()
919 sb->s_iflags |= SB_I_CGROUPWB; in ext2_fill_super()
921 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV && in ext2_fill_super()
947 if (le32_to_cpu(es->s_log_block_size) > in ext2_fill_super()
948 (EXT2_MAX_BLOCK_LOG_SIZE - BLOCK_SIZE_BITS)) { in ext2_fill_super()
951 le32_to_cpu(es->s_log_block_size)); in ext2_fill_super()
954 blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); in ext2_fill_super()
957 if (!sbi->s_daxdev) { in ext2_fill_super()
960 clear_opt(sbi->s_mount_opt, DAX); in ext2_fill_super()
963 clear_opt(sbi->s_mount_opt, DAX); in ext2_fill_super()
967 /* If the blocksize doesn't match, re-read the thing.. */ in ext2_fill_super()
968 if (sb->s_blocksize != blocksize) { in ext2_fill_super()
978 offset = (sb_block*BLOCK_SIZE) % blocksize; in ext2_fill_super()
985 es = (struct ext2_super_block *) (((char *)bh->b_data) + offset); in ext2_fill_super()
986 sbi->s_es = es; in ext2_fill_super()
987 if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) { in ext2_fill_super()
993 sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits); in ext2_fill_super()
994 sb->s_max_links = EXT2_LINK_MAX; in ext2_fill_super()
995 sb->s_time_min = S32_MIN; in ext2_fill_super()
996 sb->s_time_max = S32_MAX; in ext2_fill_super()
998 if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) { in ext2_fill_super()
999 sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE; in ext2_fill_super()
1000 sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO; in ext2_fill_super()
1002 sbi->s_inode_size = le16_to_cpu(es->s_inode_size); in ext2_fill_super()
1003 sbi->s_first_ino = le32_to_cpu(es->s_first_ino); in ext2_fill_super()
1004 if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) || in ext2_fill_super()
1005 !is_power_of_2(sbi->s_inode_size) || in ext2_fill_super()
1006 (sbi->s_inode_size > blocksize)) { in ext2_fill_super()
1009 sbi->s_inode_size); in ext2_fill_super()
1014 sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group); in ext2_fill_super()
1015 sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group); in ext2_fill_super()
1017 sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb); in ext2_fill_super()
1018 if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0) in ext2_fill_super()
1020 sbi->s_itb_per_group = sbi->s_inodes_per_group / in ext2_fill_super()
1021 sbi->s_inodes_per_block; in ext2_fill_super()
1022 sbi->s_desc_per_block = sb->s_blocksize / in ext2_fill_super()
1024 sbi->s_sbh = bh; in ext2_fill_super()
1025 sbi->s_mount_state = le16_to_cpu(es->s_state); in ext2_fill_super()
1026 sbi->s_addr_per_block_bits = in ext2_fill_super()
1028 sbi->s_desc_per_block_bits = in ext2_fill_super()
1031 if (sb->s_magic != EXT2_SUPER_MAGIC) in ext2_fill_super()
1034 if (sb->s_blocksize != bh->b_size) { in ext2_fill_super()
1040 if (es->s_log_frag_size != es->s_log_block_size) { in ext2_fill_super()
1043 le32_to_cpu(es->s_log_frag_size), sb->s_blocksize_bits); in ext2_fill_super()
1047 if (sbi->s_blocks_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1050 sbi->s_blocks_per_group); in ext2_fill_super()
1054 if (sbi->s_blocks_per_group <= sbi->s_itb_per_group + 3) { in ext2_fill_super()
1057 sbi->s_blocks_per_group, sbi->s_inodes_per_group + 3); in ext2_fill_super()
1060 if (sbi->s_inodes_per_group < sbi->s_inodes_per_block || in ext2_fill_super()
1061 sbi->s_inodes_per_group > sb->s_blocksize * 8) { in ext2_fill_super()
1064 sbi->s_inodes_per_group); in ext2_fill_super()
1067 if (sb_bdev_nr_blocks(sb) < le32_to_cpu(es->s_blocks_count)) { in ext2_fill_super()
1070 le32_to_cpu(es->s_blocks_count), in ext2_fill_super()
1075 sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) - in ext2_fill_super()
1076 le32_to_cpu(es->s_first_data_block) - 1) in ext2_fill_super()
1078 if ((u64)sbi->s_groups_count * sbi->s_inodes_per_group != in ext2_fill_super()
1079 le32_to_cpu(es->s_inodes_count)) { in ext2_fill_super()
1081 le32_to_cpu(es->s_inodes_count), in ext2_fill_super()
1082 (u64)sbi->s_groups_count * sbi->s_inodes_per_group); in ext2_fill_super()
1085 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / in ext2_fill_super()
1087 sbi->s_group_desc = kvmalloc_array(db_count, in ext2_fill_super()
1090 if (sbi->s_group_desc == NULL) { in ext2_fill_super()
1091 ret = -ENOMEM; in ext2_fill_super()
1095 bgl_lock_init(sbi->s_blockgroup_lock); in ext2_fill_super()
1096 sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL); in ext2_fill_super()
1097 if (!sbi->s_debts) { in ext2_fill_super()
1098 ret = -ENOMEM; in ext2_fill_super()
1104 sbi->s_group_desc[i] = sb_bread(sb, block); in ext2_fill_super()
1105 if (!sbi->s_group_desc[i]) { in ext2_fill_super()
1107 brelse (sbi->s_group_desc[j]); in ext2_fill_super()
1117 sbi->s_gdb_count = db_count; in ext2_fill_super()
1118 get_random_bytes(&sbi->s_next_generation, sizeof(u32)); in ext2_fill_super()
1119 spin_lock_init(&sbi->s_next_gen_lock); in ext2_fill_super()
1122 spin_lock_init(&sbi->s_rsv_window_lock); in ext2_fill_super()
1123 sbi->s_rsv_window_root = RB_ROOT; in ext2_fill_super()
1126 * reservation window list --- it gives us a placeholder for in ext2_fill_super()
1127 * append-at-start-of-list which makes the allocation logic in ext2_fill_super()
1130 sbi->s_rsv_window_head.rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED; in ext2_fill_super()
1131 sbi->s_rsv_window_head.rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED; in ext2_fill_super()
1132 sbi->s_rsv_window_head.rsv_alloc_hit = 0; in ext2_fill_super()
1133 sbi->s_rsv_window_head.rsv_goal_size = 0; in ext2_fill_super()
1134 ext2_rsv_window_add(sb, &sbi->s_rsv_window_head); in ext2_fill_super()
1136 err = percpu_counter_init(&sbi->s_freeblocks_counter, in ext2_fill_super()
1139 err = percpu_counter_init(&sbi->s_freeinodes_counter, in ext2_fill_super()
1143 err = percpu_counter_init(&sbi->s_dirs_counter, in ext2_fill_super()
1153 sbi->s_ea_block_cache = ext2_xattr_create_cache(); in ext2_fill_super()
1154 if (!sbi->s_ea_block_cache) { in ext2_fill_super()
1155 ret = -ENOMEM; in ext2_fill_super()
1163 sb->s_op = &ext2_sops; in ext2_fill_super()
1164 sb->s_export_op = &ext2_export_ops; in ext2_fill_super()
1165 sb->s_xattr = ext2_xattr_handlers; in ext2_fill_super()
1168 sb->dq_op = &dquot_operations; in ext2_fill_super()
1169 sb->s_qcop = &ext2_quotactl_ops; in ext2_fill_super()
1170 sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP; in ext2_fill_super()
1178 if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) { in ext2_fill_super()
1184 sb->s_root = d_make_root(root); in ext2_fill_super()
1185 if (!sb->s_root) { in ext2_fill_super()
1187 ret = -ENOMEM; in ext2_fill_super()
1194 sb->s_flags |= SB_RDONLY; in ext2_fill_super()
1202 sb->s_id); in ext2_fill_super()
1205 ext2_xattr_destroy_cache(sbi->s_ea_block_cache); in ext2_fill_super()
1206 percpu_counter_destroy(&sbi->s_freeblocks_counter); in ext2_fill_super()
1207 percpu_counter_destroy(&sbi->s_freeinodes_counter); in ext2_fill_super()
1208 percpu_counter_destroy(&sbi->s_dirs_counter); in ext2_fill_super()
1211 brelse(sbi->s_group_desc[i]); in ext2_fill_super()
1213 kvfree(sbi->s_group_desc); in ext2_fill_super()
1214 kfree(sbi->s_debts); in ext2_fill_super()
1218 fs_put_dax(sbi->s_daxdev, NULL); in ext2_fill_super()
1219 sb->s_fs_info = NULL; in ext2_fill_super()
1220 kfree(sbi->s_blockgroup_lock); in ext2_fill_super()
1227 struct buffer_head *sbh = EXT2_SB(sb)->s_sbh; in ext2_clear_super_error()
1249 spin_lock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1250 es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb)); in ext2_sync_super()
1251 es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb)); in ext2_sync_super()
1252 es->s_wtime = cpu_to_le32(ktime_get_real_seconds()); in ext2_sync_super()
1254 spin_unlock(&EXT2_SB(sb)->s_lock); in ext2_sync_super()
1255 mark_buffer_dirty(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1257 sync_dirty_buffer(EXT2_SB(sb)->s_sbh); in ext2_sync_super()
1273 struct ext2_super_block *es = EXT2_SB(sb)->s_es; in ext2_sync_fs()
1279 dquot_writeback_dquots(sb, -1); in ext2_sync_fs()
1281 spin_lock(&sbi->s_lock); in ext2_sync_fs()
1282 if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) { in ext2_sync_fs()
1284 es->s_state &= cpu_to_le16(~EXT2_VALID_FS); in ext2_sync_fs()
1286 spin_unlock(&sbi->s_lock); in ext2_sync_fs()
1300 if (atomic_long_read(&sb->s_remove_count)) { in ext2_freeze()
1305 spin_lock(&sbi->s_lock); in ext2_freeze()
1306 sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state); in ext2_freeze()
1307 spin_unlock(&sbi->s_lock); in ext2_freeze()
1308 ext2_sync_super(sb, sbi->s_es, 1); in ext2_freeze()
1336 spin_lock(&sbi->s_lock); in ext2_remount()
1337 new_opts.s_mount_opt = sbi->s_mount_opt; in ext2_remount()
1338 new_opts.s_resuid = sbi->s_resuid; in ext2_remount()
1339 new_opts.s_resgid = sbi->s_resgid; in ext2_remount()
1340 spin_unlock(&sbi->s_lock); in ext2_remount()
1343 return -EINVAL; in ext2_remount()
1345 spin_lock(&sbi->s_lock); in ext2_remount()
1346 es = sbi->s_es; in ext2_remount()
1347 if ((sbi->s_mount_opt ^ new_opts.s_mount_opt) & EXT2_MOUNT_DAX) { in ext2_remount()
1355 if (le16_to_cpu(es->s_state) & EXT2_VALID_FS || in ext2_remount()
1356 !(sbi->s_mount_state & EXT2_VALID_FS)) in ext2_remount()
1363 es->s_state = cpu_to_le16(sbi->s_mount_state); in ext2_remount()
1364 es->s_mtime = cpu_to_le32(ktime_get_real_seconds()); in ext2_remount()
1365 spin_unlock(&sbi->s_lock); in ext2_remount()
1367 err = dquot_suspend(sb, -1); in ext2_remount()
1376 spin_unlock(&sbi->s_lock); in ext2_remount()
1381 return -EROFS; in ext2_remount()
1384 * Mounting a RDONLY partition read-write, so reread and in ext2_remount()
1388 sbi->s_mount_state = le16_to_cpu(es->s_state); in ext2_remount()
1390 sb->s_flags &= ~SB_RDONLY; in ext2_remount()
1391 spin_unlock(&sbi->s_lock); in ext2_remount()
1395 dquot_resume(sb, -1); in ext2_remount()
1398 spin_lock(&sbi->s_lock); in ext2_remount()
1400 sbi->s_mount_opt = new_opts.s_mount_opt; in ext2_remount()
1401 sbi->s_resuid = new_opts.s_resuid; in ext2_remount()
1402 sbi->s_resgid = new_opts.s_resgid; in ext2_remount()
1403 sb->s_flags = (sb->s_flags & ~SB_POSIXACL) | in ext2_remount()
1405 spin_unlock(&sbi->s_lock); in ext2_remount()
1412 struct super_block *sb = dentry->d_sb; in ext2_statfs()
1414 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 buf->f_fsid = uuid_to_fsid(es->s_uuid); in ext2_statfs()
1469 spin_unlock(&sbi->s_lock); in ext2_statfs()
1481 /* Read data from quotafile - avoid pagecache and such because we cannot afford
1488 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_read()
1491 int offset = off & (sb->s_blocksize - 1); in ext2_quota_read() local
1501 len = i_size-off; in ext2_quota_read()
1504 tocopy = min_t(size_t, sb->s_blocksize - offset, toread); in ext2_quota_read()
1507 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_read()
1516 return -EIO; in ext2_quota_read()
1517 memcpy(data, bh->b_data+offset, tocopy); in ext2_quota_read()
1520 offset = 0; in ext2_quota_read()
1521 toread -= tocopy; in ext2_quota_read()
1532 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_write()
1535 int offset = off & (sb->s_blocksize - 1); in ext2_quota_write() local
1542 tocopy = min_t(size_t, sb->s_blocksize - offset, towrite); in ext2_quota_write()
1545 tmp_bh.b_size = sb->s_blocksize; in ext2_quota_write()
1549 if (offset || tocopy != EXT2_BLOCK_SIZE(sb)) in ext2_quota_write()
1554 err = -EIO; in ext2_quota_write()
1558 memcpy(bh->b_data+offset, data, tocopy); in ext2_quota_write()
1559 flush_dcache_page(bh->b_page); in ext2_quota_write()
1564 offset = 0; in ext2_quota_write()
1565 towrite -= tocopy; in ext2_quota_write()
1572 if (inode->i_size < off+len-towrite) in ext2_quota_write()
1573 i_size_write(inode, off+len-towrite); in ext2_quota_write()
1575 inode->i_mtime = inode_set_ctime_current(inode); in ext2_quota_write()
1577 return len - towrite; in ext2_quota_write()
1590 inode = d_inode(path->dentry); in ext2_quota_on()
1592 EXT2_I(inode)->i_flags |= EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL; in ext2_quota_on()
1603 struct inode *inode = sb_dqopt(sb)->files[type]; in ext2_quota_off()
1614 EXT2_I(inode)->i_flags &= ~(EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL); in ext2_quota_off()