1 commit 1ea06bec78a128adc995ca32bd906a6c9bb9cf91
2 Author: Niu Yawei <yawei.niu@gmail.com>
3 Date: Wed Jun 4 12:20:30 2014 +0800
5 quota: avoid unnecessary dqget()/dqput() calls
7 Avoid unnecessary dqget()/dqput() calls in __dquot_initialize(),
8 that will introduce global lock contention otherwise.
10 Signed-off-by: Lai Siyao <lai.siyao@intel.com>
11 Signed-off-by: Niu Yawei <yawei.niu@intel.com>
12 Signed-off-by: Jan Kara <jack@suse.cz>
13 Index: linux-2.6.32-431.5.1.el6/fs/quota/dquot.c
14 ===================================================================
15 --- linux-2.6.32-431.5.1.el6.orig/fs/quota/dquot.c
16 +++ linux-2.6.32-431.5.1.el6/fs/quota/dquot.c
17 @@ -1230,7 +1230,7 @@ static int info_bdq_free(struct dquot *d
18 int dquot_initialize(struct inode *inode, int type)
22 + int cnt, ret = 0, init_needed = 0;
23 struct dquot *got[MAXQUOTAS] = { NULL, NULL };
24 struct super_block *sb = inode->i_sb;
26 @@ -1244,6 +1244,15 @@ int dquot_initialize(struct inode *inode
27 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
28 if (type != -1 && cnt != type)
31 + * The i_dquot should have been initialized in most cases,
32 + * we check it without locking here to avoid unnecessary
33 + * dqget()/dqput() calls.
35 + if (inode->i_dquot[cnt])
42 @@ -1255,6 +1264,10 @@ int dquot_initialize(struct inode *inode
43 got[cnt] = dqget(sb, id, cnt);
46 + /* All required i_dquot has been initialized */
50 spin_lock(&inode->i_lock);
51 if (IS_NOQUOTA(inode))
53 @@ -1264,6 +1277,9 @@ int dquot_initialize(struct inode *inode
54 /* Avoid races with quotaoff() */
55 if (!sb_has_quota_active(sb, cnt))
57 + /* We could race with quotaon or dqget() could have failed */
60 if (!inode->i_dquot[cnt]) {
61 inode->i_dquot[cnt] = got[cnt];