Whamcloud - gitweb
LU-3866 hsm: permission checks on HSM operations
[fs/lustre-release.git] / lustre / kernel_patches / patches / quota-avoid-dqget-calls-sles11sp2.patch
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
3 @@ -1342,7 +1342,7 @@
4  static void __dquot_initialize(struct inode *inode, int type)
5  {
6         unsigned int id = 0;
7 -       int cnt;
8 +       int cnt, ret = 0, dq_get = 0;
9         struct dquot *got[MAXQUOTAS];
10         struct super_block *sb = inode->i_sb;
11         qsize_t rsv;
12 @@ -1352,7 +1352,14 @@
13         if (!dquot_active(inode))
14                 return;
15  
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))
21 +               goto init_idquot;
22 +
23 +get_dquots:
24 +       dq_get = 1;
25         for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
26                 got[cnt] = NULL;
27                 if (type != -1 && cnt != type)
28 @@ -1367,7 +1374,7 @@
29                 }
30                 got[cnt] = dqget(sb, id, cnt);
31         }
32 -
33 +init_idquot:
34         spin_lock(&inode->i_lock);
35         if (IS_NOQUOTA(inode))
36                 goto out_err;
37 @@ -1381,6 +1388,10 @@
38                 if (!got[cnt])
39                         continue;
40                 if (!inode->i_dquot[cnt]) {
41 +                       if (dq_get == 0) {
42 +                               spin_unlock(&inode->i_lock);
43 +                               goto get_dquots;
44 +                       }
45                         inode->i_dquot[cnt] = got[cnt];
46                         got[cnt] = NULL;
47                         /*
48 @@ -1388,7 +1399,7 @@
49                          * did a write before quota was turned on
50                          */
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);