Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 4 Apr 2016 20:18:27 +0000 (13:18 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 4 Apr 2016 20:18:27 +0000 (13:18 -0700)
Pull quota fixes from Jan Kara:
 "Fixes for oopses when the new quotactl gets used with quotas disabled"

* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  ocfs2: Fix Q_GETNEXTQUOTA for filesystem without quotas
  quota: Handle Q_GETNEXTQUOTA when quota is disabled

fs/ocfs2/quota_global.c
fs/quota/dquot.c

index 3892f3c079ca83dae1a8b92bf6263cf4b3851be5..ab6a6cdcf91c856d5ff1fcc04692a6abb9f141f4 100644 (file)
@@ -867,6 +867,10 @@ static int ocfs2_get_next_id(struct super_block *sb, struct kqid *qid)
        int status = 0;
 
        trace_ocfs2_get_next_id(from_kqid(&init_user_ns, *qid), type);
+       if (!sb_has_quota_loaded(sb, type)) {
+               status = -ESRCH;
+               goto out;
+       }
        status = ocfs2_lock_global_qf(info, 0);
        if (status < 0)
                goto out;
@@ -878,8 +882,11 @@ static int ocfs2_get_next_id(struct super_block *sb, struct kqid *qid)
 out_global:
        ocfs2_unlock_global_qf(info, 0);
 out:
-       /* Avoid logging ENOENT since it just means there isn't next ID */
-       if (status && status != -ENOENT)
+       /*
+        * Avoid logging ENOENT since it just means there isn't next ID and
+        * ESRCH which means quota isn't enabled for the filesystem.
+        */
+       if (status && status != -ENOENT && status != -ESRCH)
                mlog_errno(status);
        return status;
 }
index ba827daea5a0b2a7883327a18a83a43315c9bd2a..ff21980d0119a58aa41c825258e435aa799042c7 100644 (file)
@@ -2047,11 +2047,20 @@ int dquot_get_next_id(struct super_block *sb, struct kqid *qid)
        struct quota_info *dqopt = sb_dqopt(sb);
        int err;
 
-       if (!dqopt->ops[qid->type]->get_next_id)
-               return -ENOSYS;
+       mutex_lock(&dqopt->dqonoff_mutex);
+       if (!sb_has_quota_active(sb, qid->type)) {
+               err = -ESRCH;
+               goto out;
+       }
+       if (!dqopt->ops[qid->type]->get_next_id) {
+               err = -ENOSYS;
+               goto out;
+       }
        mutex_lock(&dqopt->dqio_mutex);
        err = dqopt->ops[qid->type]->get_next_id(sb, qid);
        mutex_unlock(&dqopt->dqio_mutex);
+out:
+       mutex_unlock(&dqopt->dqonoff_mutex);
 
        return err;
 }