1 --- linux-3.0/fs/quota/dquot.c.orig 2013-07-18 09:46:28.000000000 -0400
2 +++ linux-3.0/fs/quota/dquot.c 2013-07-18 09:49:20.000000000 -0400
4 static void __dquot_initialize(struct inode *inode, int type)
8 + int cnt, ret = 0, dq_get = 0;
9 struct dquot *got[MAXQUOTAS];
10 struct super_block *sb = inode->i_sb;
12 @@ -1352,7 +1352,14 @@
13 if (!dquot_active(inode))
16 - /* First get references to structures we might need. */
17 + /* In most case, the i_dquot should have been initialized, except
18 + * the newly allocated one. We'd always try to skip the dqget() and
19 + * dqput() calls to avoid unnecessary global lock contention. */
20 + if (!(inode->i_state & I_NEW))
25 for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
27 if (type != -1 && cnt != type)
30 got[cnt] = dqget(sb, id, cnt);
34 spin_lock(&inode->i_lock);
35 if (IS_NOQUOTA(inode))
37 @@ -1381,6 +1388,10 @@
40 if (!inode->i_dquot[cnt]) {
42 + spin_unlock(&inode->i_lock);
45 inode->i_dquot[cnt] = got[cnt];
49 * did a write before quota was turned on
51 rsv = inode_get_rsv_space(inode);
52 - if (unlikely(rsv)) {
53 + if (unlikely(rsv) && likely(inode->i_dquot[cnt])) {
54 spin_lock(&dq_data_lock);
55 dquot_resv_space(inode->i_dquot[cnt], rsv);
56 spin_unlock(&dq_data_lock);