quota: Acquire dqio_sem for reading in dquot_get_next_id()
authorJan Kara <jack@suse.cz>
Thu, 8 Jun 2017 13:05:08 +0000 (15:05 +0200)
committerJan Kara <jack@suse.cz>
Thu, 17 Aug 2017 16:58:44 +0000 (18:58 +0200)
dquot_get_next_id() needs dqio_sem only for reading to protect against
racing with modification of quota file structure.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c

index 21358f31923d86beac01110f5234b57957019178..8d5ccad3bf3ea502e55ba759377cd391c1b87586 100644 (file)
@@ -2079,9 +2079,9 @@ int dquot_get_next_id(struct super_block *sb, struct kqid *qid)
                return -ESRCH;
        if (!dqopt->ops[qid->type]->get_next_id)
                return -ENOSYS;
-       down_write(&dqopt->dqio_sem);
+       down_read(&dqopt->dqio_sem);
        err = dqopt->ops[qid->type]->get_next_id(sb, qid);
-       up_write(&dqopt->dqio_sem);
+       up_read(&dqopt->dqio_sem);
        return err;
 }
 EXPORT_SYMBOL(dquot_get_next_id);