quota: Push dqio_sem down to ->read_dqblk()
authorJan Kara <jack@suse.cz>
Thu, 8 Jun 2017 13:30:45 +0000 (15:30 +0200)
committerJan Kara <jack@suse.cz>
Thu, 17 Aug 2017 17:01:00 +0000 (19:01 +0200)
Push down acquisition of dqio_sem into ->read_dqblk() callback. It will
allow quota formats to decide whether they need it or not.

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

index 8b52e852eba253da4b20cb4de295072831d028a1..46046523abf0fc55216ae958a9cfb254dccb1b05 100644 (file)
@@ -403,11 +403,8 @@ int dquot_acquire(struct dquot *dquot)
        struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
 
        mutex_lock(&dquot->dq_lock);
        struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
 
        mutex_lock(&dquot->dq_lock);
-       if (!test_bit(DQ_READ_B, &dquot->dq_flags)) {
-               down_read(&dqopt->dqio_sem);
+       if (!test_bit(DQ_READ_B, &dquot->dq_flags))
                ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
                ret = dqopt->ops[dquot->dq_id.type]->read_dqblk(dquot);
-               up_read(&dqopt->dqio_sem);
-       }
        if (ret < 0)
                goto out_iolock;
        /* Make sure flags update is visible after dquot has been filled */
        if (ret < 0)
                goto out_iolock;
        /* Make sure flags update is visible after dquot has been filled */
index 8fe79beced5cc05c77ad0d536fe017beeb4a2f9e..d534c4043237d6742ed22a92318502da072ad8b2 100644 (file)
@@ -56,10 +56,12 @@ static int v1_read_dqblk(struct dquot *dquot)
 {
        int type = dquot->dq_id.type;
        struct v1_disk_dqblk dqblk;
 {
        int type = dquot->dq_id.type;
        struct v1_disk_dqblk dqblk;
+       struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
 
 
-       if (!sb_dqopt(dquot->dq_sb)->files[type])
+       if (!dqopt->files[type])
                return -EINVAL;
 
                return -EINVAL;
 
+       down_read(&dqopt->dqio_sem);
        /* Set structure to 0s in case read fails/is after end of file */
        memset(&dqblk, 0, sizeof(struct v1_disk_dqblk));
        dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk,
        /* Set structure to 0s in case read fails/is after end of file */
        memset(&dqblk, 0, sizeof(struct v1_disk_dqblk));
        dquot->dq_sb->s_op->quota_read(dquot->dq_sb, type, (char *)&dqblk,
@@ -73,6 +75,7 @@ static int v1_read_dqblk(struct dquot *dquot)
            dquot->dq_dqb.dqb_isoftlimit == 0)
                set_bit(DQ_FAKE_B, &dquot->dq_flags);
        dqstats_inc(DQST_READS);
            dquot->dq_dqb.dqb_isoftlimit == 0)
                set_bit(DQ_FAKE_B, &dquot->dq_flags);
        dqstats_inc(DQST_READS);
+       up_read(&dqopt->dqio_sem);
 
        return 0;
 }
 
        return 0;
 }
index ca71bf881ad1e33d11c1fdd10b71070c5079358d..b2cd34f6b3da8bb17a6fdfe1d10018250b5f162b 100644 (file)
@@ -285,7 +285,15 @@ static int v2r1_is_id(void *dp, struct dquot *dquot)
 
 static int v2_read_dquot(struct dquot *dquot)
 {
 
 static int v2_read_dquot(struct dquot *dquot)
 {
-       return qtree_read_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
+       struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
+       int ret;
+
+       down_read(&dqopt->dqio_sem);
+       ret = qtree_read_dquot(
+                       sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv,
+                       dquot);
+       up_read(&dqopt->dqio_sem);
+       return ret;
 }
 
 static int v2_write_dquot(struct dquot *dquot)
 }
 
 static int v2_write_dquot(struct dquot *dquot)