diff options
author | Dmitry Monakhov <dmonakhov@openvz.org> | 2010-03-27 15:15:38 +0300 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-05-21 21:30:37 +0400 |
commit | eabf290d1470921f0ce5a9b22464ae30646a0677 (patch) | |
tree | ba3a4ae74101a2ca31fabdbfa3576776cbddf2ed /fs/quota/dquot.c | |
parent | 46891532370e862d6bddedef9e6ca22a59a51fa4 (diff) | |
download | linux-eabf290d1470921f0ce5a9b22464ae30646a0677.tar.xz |
quota: optimize mark_dirty logic
- Skip locking if quota is dirty already.
- Return old quota state to help fs-specciffic implementation to optimize
case where quota was dirty already.
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r-- | fs/quota/dquot.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 788b5802a7ce..05c590e10ac2 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -317,14 +317,23 @@ static inline int mark_dquot_dirty(struct dquot *dquot) return dquot->dq_sb->dq_op->mark_dirty(dquot); } +/* Mark dquot dirty in atomic manner, and return it's old dirty flag state */ int dquot_mark_dquot_dirty(struct dquot *dquot) { + int ret = 1; + + /* If quota is dirty already, we don't have to acquire dq_list_lock */ + if (test_bit(DQ_MOD_B, &dquot->dq_flags)) + return 1; + spin_lock(&dq_list_lock); - if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) + if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) { list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)-> info[dquot->dq_type].dqi_dirty_list); + ret = 0; + } spin_unlock(&dq_list_lock); - return 0; + return ret; } EXPORT_SYMBOL(dquot_mark_dquot_dirty); |