1 Index: linux-2.6.32-358.0.1.el6/fs/quota/dquot.c
2 ===================================================================
3 --- linux-2.6.32-358.0.1.el6.orig/fs/quota/dquot.c
4 +++ linux-2.6.32-358.0.1.el6/fs/quota/dquot.c
5 @@ -1230,7 +1230,7 @@ static int info_bdq_free(struct dquot *d
6 int dquot_initialize(struct inode *inode, int type)
10 + int cnt, ret = 0, dq_get = 0;
11 struct dquot *got[MAXQUOTAS] = { NULL, NULL };
12 struct super_block *sb = inode->i_sb;
14 @@ -1240,7 +1240,14 @@ int dquot_initialize(struct inode *inode
15 if (IS_NOQUOTA(inode))
18 - /* First get references to structures we might need. */
19 + /* In most case, the i_dquot should have been initialized, except
20 + * the newly allocated one. We'd always try to skip the dqget() and
21 + * dqput() calls to avoid unnecessary global lock contention. */
22 + if (!(inode->i_state & I_NEW))
27 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
28 if (type != -1 && cnt != type)
30 @@ -1254,7 +1261,7 @@ int dquot_initialize(struct inode *inode
32 got[cnt] = dqget(sb, id, cnt);
36 spin_lock(&inode->i_lock);
37 if (IS_NOQUOTA(inode))
39 @@ -1265,6 +1272,10 @@ int dquot_initialize(struct inode *inode
40 if (!sb_has_quota_active(sb, cnt))
42 if (!inode->i_dquot[cnt]) {
44 + spin_unlock(&inode->i_lock);
47 inode->i_dquot[cnt] = got[cnt];
50 @@ -1272,7 +1283,7 @@ int dquot_initialize(struct inode *inode
51 * did a write before quota was turned on
53 rsv = inode_get_rsv_space(inode);
54 - if (unlikely(rsv)) {
55 + if (unlikely(rsv) && likely(inode->i_dquot[cnt])) {
56 spin_lock(&dq_data_lock);
57 dquot_resv_space(inode->i_dquot[cnt], rsv);
58 spin_unlock(&dq_data_lock);