quota: Push dqio_sem down to ->release_dqblk()
authorJan Kara <jack@suse.cz>
Thu, 8 Jun 2017 15:20:36 +0000 (17:20 +0200)
committerJan Kara <jack@suse.cz>
Thu, 17 Aug 2017 17:04:01 +0000 (19:04 +0200)
Push down acquisition of dqio_sem into ->release_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_v2.c

index 562f5978488ff1d944affa6d381799eddf5ba578..3b3c7f094ff8eb4a348dbb60f741a878c42f81a1 100644 (file)
@@ -478,19 +478,19 @@ int dquot_release(struct dquot *dquot)
        /* Check whether we are not racing with some other dqget() */
        if (atomic_read(&dquot->dq_count) > 1)
                goto out_dqlock;
        /* Check whether we are not racing with some other dqget() */
        if (atomic_read(&dquot->dq_count) > 1)
                goto out_dqlock;
-       down_write(&dqopt->dqio_sem);
        if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
                ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
                /* Write the info */
                if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
        if (dqopt->ops[dquot->dq_id.type]->release_dqblk) {
                ret = dqopt->ops[dquot->dq_id.type]->release_dqblk(dquot);
                /* Write the info */
                if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
+                       down_write(&dqopt->dqio_sem);
                        ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
                                                dquot->dq_sb, dquot->dq_id.type);
                        ret2 = dqopt->ops[dquot->dq_id.type]->write_file_info(
                                                dquot->dq_sb, dquot->dq_id.type);
+                       up_write(&dqopt->dqio_sem);
                }
                if (ret >= 0)
                        ret = ret2;
        }
        clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
                }
                if (ret >= 0)
                        ret = ret2;
        }
        clear_bit(DQ_ACTIVE_B, &dquot->dq_flags);
-       up_write(&dqopt->dqio_sem);
 out_dqlock:
        mutex_unlock(&dquot->dq_lock);
        return ret;
 out_dqlock:
        mutex_unlock(&dquot->dq_lock);
        return ret;
index 7a05b80f3b8ceb7c620f52f99a8b24fe2cf1c12d..8f54b159e4236c1cafdfa46985161324185bb59e 100644 (file)
@@ -322,7 +322,14 @@ static int v2_write_dquot(struct dquot *dquot)
 
 static int v2_release_dquot(struct dquot *dquot)
 {
 
 static int v2_release_dquot(struct dquot *dquot)
 {
-       return qtree_release_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_write(&dqopt->dqio_sem);
+       ret = qtree_release_dquot(sb_dqinfo(dquot->dq_sb, dquot->dq_id.type)->dqi_priv, dquot);
+       up_write(&dqopt->dqio_sem);
+
+       return ret;
 }
 
 static int v2_free_file_info(struct super_block *sb, int type)
 }
 
 static int v2_free_file_info(struct super_block *sb, int type)