checkpoint ext4 patches
[ext4-patch-queue.git] / avoid-calling-get_next_id-if-quota-not-enabled
blobcd10fd2046ca4178dc47c73d55dba7d17c543c75
1 ext4: avoid calling dquot_get_next_id() if quota is not enabled
3 This should be fixed in the quota layer so we can test with the quota
4 mutex held, but for now, we need this to avoid tests from crashing the
5 kernel aborting the regression test suite.
7 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
8 ---
9  fs/ext4/super.c | 14 +++++++++++++-
10  1 file changed, 13 insertions(+), 1 deletion(-)
12 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
13 index 63fe83d..0e6231b 100644
14 --- a/fs/ext4/super.c
15 +++ b/fs/ext4/super.c
16 @@ -1113,6 +1113,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type,
17  static int ext4_quota_enable(struct super_block *sb, int type, int format_id,
18                              unsigned int flags);
19  static int ext4_enable_quotas(struct super_block *sb);
20 +static int ext4_get_next_id(struct super_block *sb, struct kqid *qid);
22  static struct dquot **ext4_get_dquots(struct inode *inode)
23  {
24 @@ -1129,7 +1130,7 @@ static const struct dquot_operations ext4_quota_operations = {
25         .alloc_dquot    = dquot_alloc,
26         .destroy_dquot  = dquot_destroy,
27         .get_projid     = ext4_get_projid,
28 -       .get_next_id    = dquot_get_next_id,
29 +       .get_next_id    = ext4_get_next_id,
30  };
32  static const struct quotactl_ops ext4_qctl_operations = {
33 @@ -5255,6 +5256,17 @@ out:
34         return len;
35  }
37 +static int ext4_get_next_id(struct super_block *sb, struct kqid *qid)
39 +       const struct quota_format_ops   *ops;
41 +       if (!sb_has_quota_loaded(sb, qid->type))
42 +               return -ESRCH;
43 +       ops = sb_dqopt(sb)->ops[qid->type];
44 +       if (!ops || !ops->get_next_id)
45 +               return -ENOSYS;
46 +       return dquot_get_next_id(sb, qid);
48  #endif
50  static struct dentry *ext4_mount(struct file_system_type *fs_type, int flags,