aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/balloc.c4
-rw-r--r--fs/ext4/ext4.h7
-rw-r--r--fs/ext4/extents.c6
-rw-r--r--fs/ext4/ialloc.c4
-rw-r--r--fs/ext4/inode.c34
-rw-r--r--fs/ext4/migrate.c4
-rw-r--r--fs/ext4/namei.c5
-rw-r--r--fs/ext4/super.c94
8 files changed, 74 insertions, 84 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 4bbd07a6fa1..c45c41129a3 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -461,8 +461,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
461 return 1; 461 return 1;
462 462
463 /* Hm, nope. Are (enough) root reserved clusters available? */ 463 /* Hm, nope. Are (enough) root reserved clusters available? */
464 if (sbi->s_resuid == current_fsuid() || 464 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
465 ((sbi->s_resgid != 0) && in_group_p(sbi->s_resgid)) || 465 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
466 capable(CAP_SYS_RESOURCE) || 466 capable(CAP_SYS_RESOURCE) ||
467 (flags & EXT4_MB_USE_ROOT_BLOCKS)) { 467 (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
468 468
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index ab2594a30f8..c21b1de51af 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1153,8 +1153,8 @@ struct ext4_sb_info {
1153 unsigned int s_mount_flags; 1153 unsigned int s_mount_flags;
1154 unsigned int s_def_mount_opt; 1154 unsigned int s_def_mount_opt;
1155 ext4_fsblk_t s_sb_block; 1155 ext4_fsblk_t s_sb_block;
1156 uid_t s_resuid; 1156 kuid_t s_resuid;
1157 gid_t s_resgid; 1157 kgid_t s_resgid;
1158 unsigned short s_mount_state; 1158 unsigned short s_mount_state;
1159 unsigned short s_pad; 1159 unsigned short s_pad;
1160 int s_addr_per_block_bits; 1160 int s_addr_per_block_bits;
@@ -1203,9 +1203,6 @@ struct ext4_sb_info {
1203 unsigned long s_ext_blocks; 1203 unsigned long s_ext_blocks;
1204 unsigned long s_ext_extents; 1204 unsigned long s_ext_extents;
1205#endif 1205#endif
1206 /* ext4 extent cache stats */
1207 unsigned long extent_cache_hits;
1208 unsigned long extent_cache_misses;
1209 1206
1210 /* for buddy allocator */ 1207 /* for buddy allocator */
1211 struct ext4_group_info ***s_group_info; 1208 struct ext4_group_info ***s_group_info;
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 1421938e679..abcdeab67f5 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2066,10 +2066,6 @@ static int ext4_ext_check_cache(struct inode *inode, ext4_lblk_t block,
2066 ret = 1; 2066 ret = 1;
2067 } 2067 }
2068errout: 2068errout:
2069 if (!ret)
2070 sbi->extent_cache_misses++;
2071 else
2072 sbi->extent_cache_hits++;
2073 trace_ext4_ext_in_cache(inode, block, ret); 2069 trace_ext4_ext_in_cache(inode, block, ret);
2074 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock); 2070 spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
2075 return ret; 2071 return ret;
@@ -2882,7 +2878,7 @@ static int ext4_split_extent_at(handle_t *handle,
2882 if (err) 2878 if (err)
2883 goto fix_extent_len; 2879 goto fix_extent_len;
2884 /* update the extent length and mark as initialized */ 2880 /* update the extent length and mark as initialized */
2885 ex->ee_len = cpu_to_le32(ee_len); 2881 ex->ee_len = cpu_to_le16(ee_len);
2886 ext4_ext_try_to_merge(inode, path, ex); 2882 ext4_ext_try_to_merge(inode, path, ex);
2887 err = ext4_ext_dirty(handle, inode, path + depth); 2883 err = ext4_ext_dirty(handle, inode, path + depth);
2888 goto out; 2884 goto out;
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index 409c2ee7750..9f9acac6c43 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -808,8 +808,8 @@ got:
808 } 808 }
809 if (owner) { 809 if (owner) {
810 inode->i_mode = mode; 810 inode->i_mode = mode;
811 inode->i_uid = owner[0]; 811 i_uid_write(inode, owner[0]);
812 inode->i_gid = owner[1]; 812 i_gid_write(inode, owner[1]);
813 } else if (test_opt(sb, GRPID)) { 813 } else if (test_opt(sb, GRPID)) {
814 inode->i_mode = mode; 814 inode->i_mode = mode;
815 inode->i_uid = current_fsuid(); 815 inode->i_uid = current_fsuid();
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index c77b0bd2c71..07eaf565fdc 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -3630,6 +3630,8 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
3630 journal_t *journal = EXT4_SB(sb)->s_journal; 3630 journal_t *journal = EXT4_SB(sb)->s_journal;
3631 long ret; 3631 long ret;
3632 int block; 3632 int block;
3633 uid_t i_uid;
3634 gid_t i_gid;
3633 3635
3634 inode = iget_locked(sb, ino); 3636 inode = iget_locked(sb, ino);
3635 if (!inode) 3637 if (!inode)
@@ -3645,12 +3647,14 @@ struct inode *ext4_iget(struct super_block *sb, unsigned long ino)
3645 goto bad_inode; 3647 goto bad_inode;
3646 raw_inode = ext4_raw_inode(&iloc); 3648 raw_inode = ext4_raw_inode(&iloc);
3647 inode->i_mode = le16_to_cpu(raw_inode->i_mode); 3649 inode->i_mode = le16_to_cpu(raw_inode->i_mode);
3648 inode->i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low); 3650 i_uid = (uid_t)le16_to_cpu(raw_inode->i_uid_low);
3649 inode->i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low); 3651 i_gid = (gid_t)le16_to_cpu(raw_inode->i_gid_low);
3650 if (!(test_opt(inode->i_sb, NO_UID32))) { 3652 if (!(test_opt(inode->i_sb, NO_UID32))) {
3651 inode->i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16; 3653 i_uid |= le16_to_cpu(raw_inode->i_uid_high) << 16;
3652 inode->i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16; 3654 i_gid |= le16_to_cpu(raw_inode->i_gid_high) << 16;
3653 } 3655 }
3656 i_uid_write(inode, i_uid);
3657 i_gid_write(inode, i_gid);
3654 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count)); 3658 set_nlink(inode, le16_to_cpu(raw_inode->i_links_count));
3655 3659
3656 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */ 3660 ext4_clear_state_flags(ei); /* Only relevant on 32-bit archs */
@@ -3870,6 +3874,8 @@ static int ext4_do_update_inode(handle_t *handle,
3870 struct ext4_inode_info *ei = EXT4_I(inode); 3874 struct ext4_inode_info *ei = EXT4_I(inode);
3871 struct buffer_head *bh = iloc->bh; 3875 struct buffer_head *bh = iloc->bh;
3872 int err = 0, rc, block; 3876 int err = 0, rc, block;
3877 uid_t i_uid;
3878 gid_t i_gid;
3873 3879
3874 /* For fields not not tracking in the in-memory inode, 3880 /* For fields not not tracking in the in-memory inode,
3875 * initialise them to zero for new inodes. */ 3881 * initialise them to zero for new inodes. */
@@ -3878,27 +3884,27 @@ static int ext4_do_update_inode(handle_t *handle,
3878 3884
3879 ext4_get_inode_flags(ei); 3885 ext4_get_inode_flags(ei);
3880 raw_inode->i_mode = cpu_to_le16(inode->i_mode); 3886 raw_inode->i_mode = cpu_to_le16(inode->i_mode);
3887 i_uid = i_uid_read(inode);
3888 i_gid = i_gid_read(inode);
3881 if (!(test_opt(inode->i_sb, NO_UID32))) { 3889 if (!(test_opt(inode->i_sb, NO_UID32))) {
3882 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(inode->i_uid)); 3890 raw_inode->i_uid_low = cpu_to_le16(low_16_bits(i_uid));
3883 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(inode->i_gid)); 3891 raw_inode->i_gid_low = cpu_to_le16(low_16_bits(i_gid));
3884/* 3892/*
3885 * Fix up interoperability with old kernels. Otherwise, old inodes get 3893 * Fix up interoperability with old kernels. Otherwise, old inodes get
3886 * re-used with the upper 16 bits of the uid/gid intact 3894 * re-used with the upper 16 bits of the uid/gid intact
3887 */ 3895 */
3888 if (!ei->i_dtime) { 3896 if (!ei->i_dtime) {
3889 raw_inode->i_uid_high = 3897 raw_inode->i_uid_high =
3890 cpu_to_le16(high_16_bits(inode->i_uid)); 3898 cpu_to_le16(high_16_bits(i_uid));
3891 raw_inode->i_gid_high = 3899 raw_inode->i_gid_high =
3892 cpu_to_le16(high_16_bits(inode->i_gid)); 3900 cpu_to_le16(high_16_bits(i_gid));
3893 } else { 3901 } else {
3894 raw_inode->i_uid_high = 0; 3902 raw_inode->i_uid_high = 0;
3895 raw_inode->i_gid_high = 0; 3903 raw_inode->i_gid_high = 0;
3896 } 3904 }
3897 } else { 3905 } else {
3898 raw_inode->i_uid_low = 3906 raw_inode->i_uid_low = cpu_to_le16(fs_high2lowuid(i_uid));
3899 cpu_to_le16(fs_high2lowuid(inode->i_uid)); 3907 raw_inode->i_gid_low = cpu_to_le16(fs_high2lowgid(i_gid));
3900 raw_inode->i_gid_low =
3901 cpu_to_le16(fs_high2lowgid(inode->i_gid));
3902 raw_inode->i_uid_high = 0; 3908 raw_inode->i_uid_high = 0;
3903 raw_inode->i_gid_high = 0; 3909 raw_inode->i_gid_high = 0;
3904 } 3910 }
@@ -4084,8 +4090,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
4084 4090
4085 if (is_quota_modification(inode, attr)) 4091 if (is_quota_modification(inode, attr))
4086 dquot_initialize(inode); 4092 dquot_initialize(inode);
4087 if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || 4093 if ((ia_valid & ATTR_UID && !uid_eq(attr->ia_uid, inode->i_uid)) ||
4088 (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { 4094 (ia_valid & ATTR_GID && !gid_eq(attr->ia_gid, inode->i_gid))) {
4089 handle_t *handle; 4095 handle_t *handle;
4090 4096
4091 /* (user+group)*(old+new) structure, inode write (sb, 4097 /* (user+group)*(old+new) structure, inode write (sb,
diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
index f39f80f8f2c..f1bb32ec016 100644
--- a/fs/ext4/migrate.c
+++ b/fs/ext4/migrate.c
@@ -466,8 +466,8 @@ int ext4_ext_migrate(struct inode *inode)
466 } 466 }
467 goal = (((inode->i_ino - 1) / EXT4_INODES_PER_GROUP(inode->i_sb)) * 467 goal = (((inode->i_ino - 1) / EXT4_INODES_PER_GROUP(inode->i_sb)) *
468 EXT4_INODES_PER_GROUP(inode->i_sb)) + 1; 468 EXT4_INODES_PER_GROUP(inode->i_sb)) + 1;
469 owner[0] = inode->i_uid; 469 owner[0] = i_uid_read(inode);
470 owner[1] = inode->i_gid; 470 owner[1] = i_gid_read(inode);
471 tmp_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode, 471 tmp_inode = ext4_new_inode(handle, inode->i_sb->s_root->d_inode,
472 S_IFREG, NULL, goal, owner); 472 S_IFREG, NULL, goal, owner);
473 if (IS_ERR(tmp_inode)) { 473 if (IS_ERR(tmp_inode)) {
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 349d7b3671c..e2a3f4b0ff7 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -1052,10 +1052,7 @@ static struct dentry *ext4_lookup(struct inode *dir, struct dentry *dentry, stru
1052struct dentry *ext4_get_parent(struct dentry *child) 1052struct dentry *ext4_get_parent(struct dentry *child)
1053{ 1053{
1054 __u32 ino; 1054 __u32 ino;
1055 static const struct qstr dotdot = { 1055 static const struct qstr dotdot = QSTR_INIT("..", 2);
1056 .name = "..",
1057 .len = 2,
1058 };
1059 struct ext4_dir_entry_2 * de; 1056 struct ext4_dir_entry_2 * de;
1060 struct buffer_head *bh; 1057 struct buffer_head *bh;
1061 1058
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 2484f560483..35b5954489e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1305,20 +1305,20 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
1305 ext4_msg(sb, KERN_ERR, 1305 ext4_msg(sb, KERN_ERR,
1306 "Cannot change journaled " 1306 "Cannot change journaled "
1307 "quota options when quota turned on"); 1307 "quota options when quota turned on");
1308 return 0; 1308 return -1;
1309 } 1309 }
1310 qname = match_strdup(args); 1310 qname = match_strdup(args);
1311 if (!qname) { 1311 if (!qname) {
1312 ext4_msg(sb, KERN_ERR, 1312 ext4_msg(sb, KERN_ERR,
1313 "Not enough memory for storing quotafile name"); 1313 "Not enough memory for storing quotafile name");
1314 return 0; 1314 return -1;
1315 } 1315 }
1316 if (sbi->s_qf_names[qtype] && 1316 if (sbi->s_qf_names[qtype] &&
1317 strcmp(sbi->s_qf_names[qtype], qname)) { 1317 strcmp(sbi->s_qf_names[qtype], qname)) {
1318 ext4_msg(sb, KERN_ERR, 1318 ext4_msg(sb, KERN_ERR,
1319 "%s quota file already specified", QTYPE2NAME(qtype)); 1319 "%s quota file already specified", QTYPE2NAME(qtype));
1320 kfree(qname); 1320 kfree(qname);
1321 return 0; 1321 return -1;
1322 } 1322 }
1323 sbi->s_qf_names[qtype] = qname; 1323 sbi->s_qf_names[qtype] = qname;
1324 if (strchr(sbi->s_qf_names[qtype], '/')) { 1324 if (strchr(sbi->s_qf_names[qtype], '/')) {
@@ -1326,7 +1326,7 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args)
1326 "quotafile must be on filesystem root"); 1326 "quotafile must be on filesystem root");
1327 kfree(sbi->s_qf_names[qtype]); 1327 kfree(sbi->s_qf_names[qtype]);
1328 sbi->s_qf_names[qtype] = NULL; 1328 sbi->s_qf_names[qtype] = NULL;
1329 return 0; 1329 return -1;
1330 } 1330 }
1331 set_opt(sb, QUOTA); 1331 set_opt(sb, QUOTA);
1332 return 1; 1332 return 1;
@@ -1341,7 +1341,7 @@ static int clear_qf_name(struct super_block *sb, int qtype)
1341 sbi->s_qf_names[qtype]) { 1341 sbi->s_qf_names[qtype]) {
1342 ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options" 1342 ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options"
1343 " when quota turned on"); 1343 " when quota turned on");
1344 return 0; 1344 return -1;
1345 } 1345 }
1346 /* 1346 /*
1347 * The space will be released later when all options are confirmed 1347 * The space will be released later when all options are confirmed
@@ -1448,8 +1448,20 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1448{ 1448{
1449 struct ext4_sb_info *sbi = EXT4_SB(sb); 1449 struct ext4_sb_info *sbi = EXT4_SB(sb);
1450 const struct mount_opts *m; 1450 const struct mount_opts *m;
1451 kuid_t uid;
1452 kgid_t gid;
1451 int arg = 0; 1453 int arg = 0;
1452 1454
1455#ifdef CONFIG_QUOTA
1456 if (token == Opt_usrjquota)
1457 return set_qf_name(sb, USRQUOTA, &args[0]);
1458 else if (token == Opt_grpjquota)
1459 return set_qf_name(sb, GRPQUOTA, &args[0]);
1460 else if (token == Opt_offusrjquota)
1461 return clear_qf_name(sb, USRQUOTA);
1462 else if (token == Opt_offgrpjquota)
1463 return clear_qf_name(sb, GRPQUOTA);
1464#endif
1453 if (args->from && match_int(args, &arg)) 1465 if (args->from && match_int(args, &arg))
1454 return -1; 1466 return -1;
1455 switch (token) { 1467 switch (token) {
@@ -1464,10 +1476,20 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1464 "Ignoring removed %s option", opt); 1476 "Ignoring removed %s option", opt);
1465 return 1; 1477 return 1;
1466 case Opt_resuid: 1478 case Opt_resuid:
1467 sbi->s_resuid = arg; 1479 uid = make_kuid(current_user_ns(), arg);
1480 if (!uid_valid(uid)) {
1481 ext4_msg(sb, KERN_ERR, "Invalid uid value %d", arg);
1482 return -1;
1483 }
1484 sbi->s_resuid = uid;
1468 return 1; 1485 return 1;
1469 case Opt_resgid: 1486 case Opt_resgid:
1470 sbi->s_resgid = arg; 1487 gid = make_kgid(current_user_ns(), arg);
1488 if (!gid_valid(gid)) {
1489 ext4_msg(sb, KERN_ERR, "Invalid gid value %d", arg);
1490 return -1;
1491 }
1492 sbi->s_resgid = gid;
1471 return 1; 1493 return 1;
1472 case Opt_abort: 1494 case Opt_abort:
1473 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; 1495 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED;
@@ -1549,18 +1571,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token,
1549 sbi->s_mount_opt |= m->mount_opt; 1571 sbi->s_mount_opt |= m->mount_opt;
1550 } 1572 }
1551#ifdef CONFIG_QUOTA 1573#ifdef CONFIG_QUOTA
1552 } else if (token == Opt_usrjquota) {
1553 if (!set_qf_name(sb, USRQUOTA, &args[0]))
1554 return -1;
1555 } else if (token == Opt_grpjquota) {
1556 if (!set_qf_name(sb, GRPQUOTA, &args[0]))
1557 return -1;
1558 } else if (token == Opt_offusrjquota) {
1559 if (!clear_qf_name(sb, USRQUOTA))
1560 return -1;
1561 } else if (token == Opt_offgrpjquota) {
1562 if (!clear_qf_name(sb, GRPQUOTA))
1563 return -1;
1564 } else if (m->flags & MOPT_QFMT) { 1574 } else if (m->flags & MOPT_QFMT) {
1565 if (sb_any_quota_loaded(sb) && 1575 if (sb_any_quota_loaded(sb) &&
1566 sbi->s_jquota_fmt != m->mount_opt) { 1576 sbi->s_jquota_fmt != m->mount_opt) {
@@ -1599,7 +1609,9 @@ static int parse_options(char *options, struct super_block *sb,
1599 unsigned int *journal_ioprio, 1609 unsigned int *journal_ioprio,
1600 int is_remount) 1610 int is_remount)
1601{ 1611{
1612#ifdef CONFIG_QUOTA
1602 struct ext4_sb_info *sbi = EXT4_SB(sb); 1613 struct ext4_sb_info *sbi = EXT4_SB(sb);
1614#endif
1603 char *p; 1615 char *p;
1604 substring_t args[MAX_OPT_ARGS]; 1616 substring_t args[MAX_OPT_ARGS];
1605 int token; 1617 int token;
@@ -1732,12 +1744,14 @@ static int _ext4_show_options(struct seq_file *seq, struct super_block *sb,
1732 SEQ_OPTS_PRINT("%s", token2str(m->token)); 1744 SEQ_OPTS_PRINT("%s", token2str(m->token));
1733 } 1745 }
1734 1746
1735 if (nodefs || sbi->s_resuid != EXT4_DEF_RESUID || 1747 if (nodefs || !uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT4_DEF_RESUID)) ||
1736 le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID) 1748 le16_to_cpu(es->s_def_resuid) != EXT4_DEF_RESUID)
1737 SEQ_OPTS_PRINT("resuid=%u", sbi->s_resuid); 1749 SEQ_OPTS_PRINT("resuid=%u",
1738 if (nodefs || sbi->s_resgid != EXT4_DEF_RESGID || 1750 from_kuid_munged(&init_user_ns, sbi->s_resuid));
1751 if (nodefs || !gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT4_DEF_RESGID)) ||
1739 le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID) 1752 le16_to_cpu(es->s_def_resgid) != EXT4_DEF_RESGID)
1740 SEQ_OPTS_PRINT("resgid=%u", sbi->s_resgid); 1753 SEQ_OPTS_PRINT("resgid=%u",
1754 from_kgid_munged(&init_user_ns, sbi->s_resgid));
1741 def_errors = nodefs ? -1 : le16_to_cpu(es->s_errors); 1755 def_errors = nodefs ? -1 : le16_to_cpu(es->s_errors);
1742 if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO) 1756 if (test_opt(sb, ERRORS_RO) && def_errors != EXT4_ERRORS_RO)
1743 SEQ_OPTS_PUTS("errors=remount-ro"); 1757 SEQ_OPTS_PUTS("errors=remount-ro");
@@ -2366,18 +2380,6 @@ static ssize_t lifetime_write_kbytes_show(struct ext4_attr *a,
2366 EXT4_SB(sb)->s_sectors_written_start) >> 1))); 2380 EXT4_SB(sb)->s_sectors_written_start) >> 1)));
2367} 2381}
2368 2382
2369static ssize_t extent_cache_hits_show(struct ext4_attr *a,
2370 struct ext4_sb_info *sbi, char *buf)
2371{
2372 return snprintf(buf, PAGE_SIZE, "%lu\n", sbi->extent_cache_hits);
2373}
2374
2375static ssize_t extent_cache_misses_show(struct ext4_attr *a,
2376 struct ext4_sb_info *sbi, char *buf)
2377{
2378 return snprintf(buf, PAGE_SIZE, "%lu\n", sbi->extent_cache_misses);
2379}
2380
2381static ssize_t inode_readahead_blks_store(struct ext4_attr *a, 2383static ssize_t inode_readahead_blks_store(struct ext4_attr *a,
2382 struct ext4_sb_info *sbi, 2384 struct ext4_sb_info *sbi,
2383 const char *buf, size_t count) 2385 const char *buf, size_t count)
@@ -2435,8 +2437,6 @@ static struct ext4_attr ext4_attr_##name = __ATTR(name, mode, show, store)
2435EXT4_RO_ATTR(delayed_allocation_blocks); 2437EXT4_RO_ATTR(delayed_allocation_blocks);
2436EXT4_RO_ATTR(session_write_kbytes); 2438EXT4_RO_ATTR(session_write_kbytes);
2437EXT4_RO_ATTR(lifetime_write_kbytes); 2439EXT4_RO_ATTR(lifetime_write_kbytes);
2438EXT4_RO_ATTR(extent_cache_hits);
2439EXT4_RO_ATTR(extent_cache_misses);
2440EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show, 2440EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show,
2441 inode_readahead_blks_store, s_inode_readahead_blks); 2441 inode_readahead_blks_store, s_inode_readahead_blks);
2442EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal); 2442EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal);
@@ -2452,8 +2452,6 @@ static struct attribute *ext4_attrs[] = {
2452 ATTR_LIST(delayed_allocation_blocks), 2452 ATTR_LIST(delayed_allocation_blocks),
2453 ATTR_LIST(session_write_kbytes), 2453 ATTR_LIST(session_write_kbytes),
2454 ATTR_LIST(lifetime_write_kbytes), 2454 ATTR_LIST(lifetime_write_kbytes),
2455 ATTR_LIST(extent_cache_hits),
2456 ATTR_LIST(extent_cache_misses),
2457 ATTR_LIST(inode_readahead_blks), 2455 ATTR_LIST(inode_readahead_blks),
2458 ATTR_LIST(inode_goal), 2456 ATTR_LIST(inode_goal),
2459 ATTR_LIST(mb_stats), 2457 ATTR_LIST(mb_stats),
@@ -2996,8 +2994,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
2996 } 2994 }
2997 sb->s_fs_info = sbi; 2995 sb->s_fs_info = sbi;
2998 sbi->s_mount_opt = 0; 2996 sbi->s_mount_opt = 0;
2999 sbi->s_resuid = EXT4_DEF_RESUID; 2997 sbi->s_resuid = make_kuid(&init_user_ns, EXT4_DEF_RESUID);
3000 sbi->s_resgid = EXT4_DEF_RESGID; 2998 sbi->s_resgid = make_kgid(&init_user_ns, EXT4_DEF_RESGID);
3001 sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS; 2999 sbi->s_inode_readahead_blks = EXT4_DEF_INODE_READAHEAD_BLKS;
3002 sbi->s_sb_block = sb_block; 3000 sbi->s_sb_block = sb_block;
3003 if (sb->s_bdev->bd_part) 3001 if (sb->s_bdev->bd_part)
@@ -3076,8 +3074,8 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
3076 if (def_mount_opts & EXT4_DEFM_DISCARD) 3074 if (def_mount_opts & EXT4_DEFM_DISCARD)
3077 set_opt(sb, DISCARD); 3075 set_opt(sb, DISCARD);
3078 3076
3079 sbi->s_resuid = le16_to_cpu(es->s_def_resuid); 3077 sbi->s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
3080 sbi->s_resgid = le16_to_cpu(es->s_def_resgid); 3078 sbi->s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
3081 sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ; 3079 sbi->s_commit_interval = JBD2_DEFAULT_MAX_COMMIT_AGE * HZ;
3082 sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME; 3080 sbi->s_min_batch_time = EXT4_DEF_MIN_BATCH_TIME;
3083 sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME; 3081 sbi->s_max_batch_time = EXT4_DEF_MAX_BATCH_TIME;
@@ -4229,8 +4227,8 @@ static int ext4_unfreeze(struct super_block *sb)
4229struct ext4_mount_options { 4227struct ext4_mount_options {
4230 unsigned long s_mount_opt; 4228 unsigned long s_mount_opt;
4231 unsigned long s_mount_opt2; 4229 unsigned long s_mount_opt2;
4232 uid_t s_resuid; 4230 kuid_t s_resuid;
4233 gid_t s_resgid; 4231 kgid_t s_resgid;
4234 unsigned long s_commit_interval; 4232 unsigned long s_commit_interval;
4235 u32 s_min_batch_time, s_max_batch_time; 4233 u32 s_min_batch_time, s_max_batch_time;
4236#ifdef CONFIG_QUOTA 4234#ifdef CONFIG_QUOTA
@@ -4760,7 +4758,6 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
4760 return -EIO; 4758 return -EIO;
4761 } 4759 }
4762 4760
4763 mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA);
4764 bh = ext4_bread(handle, inode, blk, 1, &err); 4761 bh = ext4_bread(handle, inode, blk, 1, &err);
4765 if (!bh) 4762 if (!bh)
4766 goto out; 4763 goto out;
@@ -4776,16 +4773,13 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
4776 err = ext4_handle_dirty_metadata(handle, NULL, bh); 4773 err = ext4_handle_dirty_metadata(handle, NULL, bh);
4777 brelse(bh); 4774 brelse(bh);
4778out: 4775out:
4779 if (err) { 4776 if (err)
4780 mutex_unlock(&inode->i_mutex);
4781 return err; 4777 return err;
4782 }
4783 if (inode->i_size < off + len) { 4778 if (inode->i_size < off + len) {
4784 i_size_write(inode, off + len); 4779 i_size_write(inode, off + len);
4785 EXT4_I(inode)->i_disksize = inode->i_size; 4780 EXT4_I(inode)->i_disksize = inode->i_size;
4786 ext4_mark_inode_dirty(handle, inode); 4781 ext4_mark_inode_dirty(handle, inode);
4787 } 4782 }
4788 mutex_unlock(&inode->i_mutex);
4789 return len; 4783 return len;
4790} 4784}
4791 4785