summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2017-08-02 11:54:26 +0200
committerJan Kara <jack@suse.cz>2017-08-17 22:00:24 +0200
commit1e0b7cb062f227439a1d8e7921e85c8df52adc41 (patch)
treeb492f59d4d7c59f149e59b9b443edf3461b60ba1 /fs
parent4580b30ea887fc27e57dabd56724ca24d936dc8a (diff)
downloadop-kernel-dev-1e0b7cb062f227439a1d8e7921e85c8df52adc41.zip
op-kernel-dev-1e0b7cb062f227439a1d8e7921e85c8df52adc41.tar.gz
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: Andreas Dilger <adilger@dilger.ca> Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/quota/dquot.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 0393581..93adcdd 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -381,12 +381,15 @@ static inline void dqput_all(struct dquot **dquot)
dqput(dquot[cnt]);
}
-/* This function needs dq_list_lock */
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;
+ }
list_del_init(&dquot->dq_dirty);
+ spin_unlock(&dq_list_lock);
return 1;
}
@@ -451,12 +454,8 @@ int dquot_commit(struct dquot *dquot)
struct quota_info *dqopt = sb_dqopt(dquot->dq_sb);
mutex_lock(&dquot->dq_lock);
- spin_lock(&dq_list_lock);
- if (!clear_dquot_dirty(dquot)) {
- spin_unlock(&dq_list_lock);
+ if (!clear_dquot_dirty(dquot))
goto out_lock;
- }
- spin_unlock(&dq_list_lock);
/* Inactive dquot can be only if there was error during read/init
* => we have better not writing it */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
@@ -772,9 +771,7 @@ we_slept:
* We clear dirty bit anyway, so that we avoid
* infinite loop here
*/
- spin_lock(&dq_list_lock);
clear_dquot_dirty(dquot);
- spin_unlock(&dq_list_lock);
}
goto we_slept;
}
OpenPOWER on IntegriCloud