Commit eabf290d1470921f0ce5a9b22464ae30646a0677
Committed by
Jan Kara
1 parent
4689153237
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 11 additions and 2 deletions Side-by-side Diff
fs/quota/dquot.c
... | ... | @@ -317,14 +317,23 @@ |
317 | 317 | return dquot->dq_sb->dq_op->mark_dirty(dquot); |
318 | 318 | } |
319 | 319 | |
320 | +/* Mark dquot dirty in atomic manner, and return it's old dirty flag state */ | |
320 | 321 | int dquot_mark_dquot_dirty(struct dquot *dquot) |
321 | 322 | { |
323 | + int ret = 1; | |
324 | + | |
325 | + /* If quota is dirty already, we don't have to acquire dq_list_lock */ | |
326 | + if (test_bit(DQ_MOD_B, &dquot->dq_flags)) | |
327 | + return 1; | |
328 | + | |
322 | 329 | spin_lock(&dq_list_lock); |
323 | - if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) | |
330 | + if (!test_and_set_bit(DQ_MOD_B, &dquot->dq_flags)) { | |
324 | 331 | list_add(&dquot->dq_dirty, &sb_dqopt(dquot->dq_sb)-> |
325 | 332 | info[dquot->dq_type].dqi_dirty_list); |
333 | + ret = 0; | |
334 | + } | |
326 | 335 | spin_unlock(&dq_list_lock); |
327 | - return 0; | |
336 | + return ret; | |
328 | 337 | } |
329 | 338 | EXPORT_SYMBOL(dquot_mark_dquot_dirty); |
330 | 339 |