Commit 1e0b7cb0 authored by Jan Kara's avatar Jan Kara

quota: Move locking into clear_dquot_dirty()

Move locking of dq_list_lock into clear_dquot_dirty(). It makes the
function more self-contained and will simplify our life later.
Reviewed-by: default avatarAndreas Dilger <adilger@dilger.ca>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
parent 4580b30e
...@@ -381,12 +381,15 @@ static inline void dqput_all(struct dquot **dquot) ...@@ -381,12 +381,15 @@ static inline void dqput_all(struct dquot **dquot)
dqput(dquot[cnt]); dqput(dquot[cnt]);
} }
/* This function needs dq_list_lock */
static inline int clear_dquot_dirty(struct dquot *dquot) static inline int clear_dquot_dirty(struct dquot *dquot)
{ {
if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags)) spin_lock(&dq_list_lock);
if (!test_and_clear_bit(DQ_MOD_B, &dquot->dq_flags)) {
spin_unlock(&dq_list_lock);
return 0; return 0;
}
list_del_init(&dquot->dq_dirty); list_del_init(&dquot->dq_dirty);
spin_unlock(&dq_list_lock);
return 1; return 1;
} }
...@@ -451,12 +454,8 @@ int dquot_commit(struct dquot *dquot) ...@@ -451,12 +454,8 @@ int dquot_commit(struct dquot *dquot)
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb); struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
mutex_lock(&dquot->dq_lock); mutex_lock(&dquot->dq_lock);
spin_lock(&dq_list_lock); if (!clear_dquot_dirty(dquot))
if (!clear_dquot_dirty(dquot)) {
spin_unlock(&dq_list_lock);
goto out_lock; goto out_lock;
}
spin_unlock(&dq_list_lock);
/* Inactive dquot can be only if there was error during read/init /* Inactive dquot can be only if there was error during read/init
* => we have better not writing it */ * => we have better not writing it */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
...@@ -772,9 +771,7 @@ void dqput(struct dquot *dquot) ...@@ -772,9 +771,7 @@ void dqput(struct dquot *dquot)
* We clear dirty bit anyway, so that we avoid * We clear dirty bit anyway, so that we avoid
* infinite loop here * infinite loop here
*/ */
spin_lock(&dq_list_lock);
clear_dquot_dirty(dquot); clear_dquot_dirty(dquot);
spin_unlock(&dq_list_lock);
} }
goto we_slept; goto we_slept;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment