diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 539297515896..304c712dbe12 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -1113,6 +1113,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
1113 | static int ext4_quota_enable(struct super_block *sb, int type, int format_id, | 1113 | static int ext4_quota_enable(struct super_block *sb, int type, int format_id, |
1114 | unsigned int flags); | 1114 | unsigned int flags); |
1115 | static int ext4_enable_quotas(struct super_block *sb); | 1115 | static int ext4_enable_quotas(struct super_block *sb); |
1116 | static int ext4_get_next_id(struct super_block *sb, struct kqid *qid); | ||
1116 | 1117 | ||
1117 | static struct dquot **ext4_get_dquots(struct inode *inode) | 1118 | static struct dquot **ext4_get_dquots(struct inode *inode) |
1118 | { | 1119 | { |
@@ -1129,7 +1130,7 @@ static const struct dquot_operations ext4_quota_operations = { | |||
1129 | .alloc_dquot = dquot_alloc, | 1130 | .alloc_dquot = dquot_alloc, |
1130 | .destroy_dquot = dquot_destroy, | 1131 | .destroy_dquot = dquot_destroy, |
1131 | .get_projid = ext4_get_projid, | 1132 | .get_projid = ext4_get_projid, |
1132 | .get_next_id = dquot_get_next_id, | 1133 | .get_next_id = ext4_get_next_id, |
1133 | }; | 1134 | }; |
1134 | 1135 | ||
1135 | static const struct quotactl_ops ext4_qctl_operations = { | 1136 | static const struct quotactl_ops ext4_qctl_operations = { |
@@ -1323,9 +1324,9 @@ static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) | |||
1323 | return -1; | 1324 | return -1; |
1324 | } | 1325 | } |
1325 | if (ext4_has_feature_quota(sb)) { | 1326 | if (ext4_has_feature_quota(sb)) { |
1326 | ext4_msg(sb, KERN_ERR, "Cannot set journaled quota options " | 1327 | ext4_msg(sb, KERN_INFO, "Journaled quota options " |
1327 | "when QUOTA feature is enabled"); | 1328 | "ignored when QUOTA feature is enabled"); |
1328 | return -1; | 1329 | return 1; |
1329 | } | 1330 | } |
1330 | qname = match_strdup(args); | 1331 | qname = match_strdup(args); |
1331 | if (!qname) { | 1332 | if (!qname) { |
@@ -1688,10 +1689,10 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, | |||
1688 | return -1; | 1689 | return -1; |
1689 | } | 1690 | } |
1690 | if (ext4_has_feature_quota(sb)) { | 1691 | if (ext4_has_feature_quota(sb)) { |
1691 | ext4_msg(sb, KERN_ERR, | 1692 | ext4_msg(sb, KERN_INFO, |
1692 | "Cannot set journaled quota options " | 1693 | "Quota format mount options ignored " |
1693 | "when QUOTA feature is enabled"); | 1694 | "when QUOTA feature is enabled"); |
1694 | return -1; | 1695 | return 1; |
1695 | } | 1696 | } |
1696 | sbi->s_jquota_fmt = m->mount_opt; | 1697 | sbi->s_jquota_fmt = m->mount_opt; |
1697 | #endif | 1698 | #endif |
@@ -1756,11 +1757,11 @@ static int parse_options(char *options, struct super_block *sb, | |||
1756 | #ifdef CONFIG_QUOTA | 1757 | #ifdef CONFIG_QUOTA |
1757 | if (ext4_has_feature_quota(sb) && | 1758 | if (ext4_has_feature_quota(sb) && |
1758 | (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) { | 1759 | (test_opt(sb, USRQUOTA) || test_opt(sb, GRPQUOTA))) { |
1759 | ext4_msg(sb, KERN_ERR, "Cannot set quota options when QUOTA " | 1760 | ext4_msg(sb, KERN_INFO, "Quota feature enabled, usrquota and grpquota " |
1760 | "feature is enabled"); | 1761 | "mount options ignored."); |
1761 | return 0; | 1762 | clear_opt(sb, USRQUOTA); |
1762 | } | 1763 | clear_opt(sb, GRPQUOTA); |
1763 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { | 1764 | } else if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { |
1764 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) | 1765 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) |
1765 | clear_opt(sb, USRQUOTA); | 1766 | clear_opt(sb, USRQUOTA); |
1766 | 1767 | ||
@@ -1784,7 +1785,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1784 | int blocksize = | 1785 | int blocksize = |
1785 | BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); | 1786 | BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size); |
1786 | 1787 | ||
1787 | if (blocksize < PAGE_CACHE_SIZE) { | 1788 | if (blocksize < PAGE_SIZE) { |
1788 | ext4_msg(sb, KERN_ERR, "can't mount with " | 1789 | ext4_msg(sb, KERN_ERR, "can't mount with " |
1789 | "dioread_nolock if block size != PAGE_SIZE"); | 1790 | "dioread_nolock if block size != PAGE_SIZE"); |
1790 | return 0; | 1791 | return 0; |
@@ -3808,7 +3809,7 @@ no_journal: | |||
3808 | } | 3809 | } |
3809 | 3810 | ||
3810 | if ((DUMMY_ENCRYPTION_ENABLED(sbi) || ext4_has_feature_encrypt(sb)) && | 3811 | if ((DUMMY_ENCRYPTION_ENABLED(sbi) || ext4_has_feature_encrypt(sb)) && |
3811 | (blocksize != PAGE_CACHE_SIZE)) { | 3812 | (blocksize != PAGE_SIZE)) { |
3812 | ext4_msg(sb, KERN_ERR, | 3813 | ext4_msg(sb, KERN_ERR, |
3813 | "Unsupported blocksize for fs encryption"); | 3814 | "Unsupported blocksize for fs encryption"); |
3814 | goto failed_mount_wq; | 3815 | goto failed_mount_wq; |
@@ -5028,6 +5029,20 @@ static int ext4_quota_on_mount(struct super_block *sb, int type) | |||
5028 | EXT4_SB(sb)->s_jquota_fmt, type); | 5029 | EXT4_SB(sb)->s_jquota_fmt, type); |
5029 | } | 5030 | } |
5030 | 5031 | ||
5032 | static void lockdep_set_quota_inode(struct inode *inode, int subclass) | ||
5033 | { | ||
5034 | struct ext4_inode_info *ei = EXT4_I(inode); | ||
5035 | |||
5036 | /* The first argument of lockdep_set_subclass has to be | ||
5037 | * *exactly* the same as the argument to init_rwsem() --- in | ||
5038 | * this case, in init_once() --- or lockdep gets unhappy | ||
5039 | * because the name of the lock is set using the | ||
5040 | * stringification of the argument to init_rwsem(). | ||
5041 | */ | ||
5042 | (void) ei; /* shut up clang warning if !CONFIG_LOCKDEP */ | ||
5043 | lockdep_set_subclass(&ei->i_data_sem, subclass); | ||
5044 | } | ||
5045 | |||
5031 | /* | 5046 | /* |
5032 | * Standard function to be called on quota_on | 5047 | * Standard function to be called on quota_on |
5033 | */ | 5048 | */ |
@@ -5067,8 +5082,12 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
5067 | if (err) | 5082 | if (err) |
5068 | return err; | 5083 | return err; |
5069 | } | 5084 | } |
5070 | 5085 | lockdep_set_quota_inode(path->dentry->d_inode, I_DATA_SEM_QUOTA); | |
5071 | return dquot_quota_on(sb, type, format_id, path); | 5086 | err = dquot_quota_on(sb, type, format_id, path); |
5087 | if (err) | ||
5088 | lockdep_set_quota_inode(path->dentry->d_inode, | ||
5089 | I_DATA_SEM_NORMAL); | ||
5090 | return err; | ||
5072 | } | 5091 | } |
5073 | 5092 | ||
5074 | static int ext4_quota_enable(struct super_block *sb, int type, int format_id, | 5093 | static int ext4_quota_enable(struct super_block *sb, int type, int format_id, |
@@ -5095,8 +5114,11 @@ static int ext4_quota_enable(struct super_block *sb, int type, int format_id, | |||
5095 | 5114 | ||
5096 | /* Don't account quota for quota files to avoid recursion */ | 5115 | /* Don't account quota for quota files to avoid recursion */ |
5097 | qf_inode->i_flags |= S_NOQUOTA; | 5116 | qf_inode->i_flags |= S_NOQUOTA; |
5117 | lockdep_set_quota_inode(qf_inode, I_DATA_SEM_QUOTA); | ||
5098 | err = dquot_enable(qf_inode, type, format_id, flags); | 5118 | err = dquot_enable(qf_inode, type, format_id, flags); |
5099 | iput(qf_inode); | 5119 | iput(qf_inode); |
5120 | if (err) | ||
5121 | lockdep_set_quota_inode(qf_inode, I_DATA_SEM_NORMAL); | ||
5100 | 5122 | ||
5101 | return err; | 5123 | return err; |
5102 | } | 5124 | } |
@@ -5253,6 +5275,17 @@ out: | |||
5253 | return len; | 5275 | return len; |
5254 | } | 5276 | } |
5255 | 5277 | ||
5278 | static int ext4_get_next_id(struct super_block *sb, struct kqid *qid) | ||
5279 | { | ||
5280 | const struct quota_format_ops *ops; | ||
5281 | |||
5282 | if (!sb_has_quota_loaded(sb, qid->type)) | ||
5283 | return -ESRCH; | ||
5284 | ops = sb_dqopt(sb)->ops[qid->type]; | ||
5285 | if (!ops || !ops->get_next_id) | ||
5286 | return -ENOSYS; | ||
5287 | return dquot_get_next_id(sb, qid); | ||
5288 | } | ||
5256 | #endif | 5289 | #endif |
5257 | 5290 | ||
5258 | static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags, | 5291 | static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags, |