Whamcloud - gitweb
LU-4008 mdt: update mdt_getattr comments about EA sizing
[fs/lustre-release.git] / lustre / kernel_patches / patches / quota-avoid-dqget-calls.patch
1 In dquot_initialize(), we'd call dqget() only when i_dquot not
2 initialized, which can avoid 2 pair of dqget()/dqput() in most
3 case. It could relieve the global locks contenion caused by
4 dqget()/dqput().
5 Index: linux-2.6.32-358.0.1.el6/fs/quota/dquot.c
6 ===================================================================
7 --- linux-2.6.32-358.0.1.el6.orig/fs/quota/dquot.c
8 +++ linux-2.6.32-358.0.1.el6/fs/quota/dquot.c
9 @@ -1230,7 +1230,7 @@ static int info_bdq_free(struct dquot *d
10  int dquot_initialize(struct inode *inode, int type)
11  {
12         unsigned int id = 0;
13 -       int cnt, ret = 0;
14 +       int cnt, ret = 0, dq_get = 0;
15         struct dquot *got[MAXQUOTAS] = { NULL, NULL };
16         struct super_block *sb = inode->i_sb;
17         qsize_t rsv;
18 @@ -1240,7 +1240,14 @@ int dquot_initialize(struct inode *inode
19         if (IS_NOQUOTA(inode))
20                 return 0;
21  
22 -       /* First get references to structures we might need. */
23 +       /* In most case, the i_dquot should have been initialized, except
24 +        * the newly allocated one. We'd always try to skip the dqget() and
25 +        * dqput() calls to avoid unnecessary global lock contention. */
26 +       if (!(inode->i_state & I_NEW))
27 +               goto init_idquot;
28 +
29 +get_dquots:
30 +       dq_get = 1;
31         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
32                 if (type != -1 && cnt != type)
33                         continue;
34 @@ -1254,7 +1261,7 @@ int dquot_initialize(struct inode *inode
35                 }
36                 got[cnt] = dqget(sb, id, cnt);
37         }
38 -
39 +init_idquot:
40         spin_lock(&inode->i_lock);
41         if (IS_NOQUOTA(inode))
42                 goto out_err;
43 @@ -1265,6 +1272,10 @@ int dquot_initialize(struct inode *inode
44                 if (!sb_has_quota_active(sb, cnt))
45                         continue;
46                 if (!inode->i_dquot[cnt]) {
47 +                       if (dq_get == 0) {
48 +                               spin_unlock(&inode->i_lock);
49 +                               goto get_dquots;
50 +                       }
51                         inode->i_dquot[cnt] = got[cnt];
52                         got[cnt] = NULL;
53                         /*
54 @@ -1272,7 +1283,7 @@ int dquot_initialize(struct inode *inode
55                          * did a write before quota was turned on
56                          */
57                         rsv = inode_get_rsv_space(inode);
58 -                       if (unlikely(rsv)) {
59 +                       if (unlikely(rsv) && likely(inode->i_dquot[cnt])) {
60                                 spin_lock(&dq_data_lock);
61                                 dquot_resv_space(inode->i_dquot[cnt], rsv);
62                                 spin_unlock(&dq_data_lock);