]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
quota: optimize mark_dirty logic
authorDmitry Monakhov <dmonakhov@openvz.org>
Sat, 27 Mar 2010 12:15:38 +0000 (15:15 +0300)
committerJan Kara <jack@suse.cz>
Fri, 21 May 2010 17:30:37 +0000 (19:30 +0200)
- 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>
fs/quota/dquot.c

index 788b5802a7ce5dc043066d9fa20278aa0e9ef2bf..05c590e10ac21dce7e1796531dbda1ea7d64eb11 100644 (file)
@@ -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);