Whamcloud - gitweb
LU-8364 ldiskfs: fixes for failover mode
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.3 / ext4-quota-dont-update-cmtime.patch
1 commit 21f976975cbecbdaf23ceeacc1cab2b1c05a028e
2 Author: Jan Kara <jack@suse.cz>
3 Date:   Mon Apr 4 15:33:39 2011 -0400
4
5     ext4: remove unnecessary [cm]time update of quota file
6
7     It is not necessary to update [cm]time of quota file on each quota
8     file write and it wastes journal space and IO throughput with inode
9     writes. So just remove the updating from ext4_quota_write() and only
10     update times when quotas are being turned off. Userspace cannot get
11     anything reliable from quota files while they are used by the kernel
12     anyway.
13
14     Signed-off-by: Jan Kara <jack@suse.cz>
15     Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
16
17 Index: linux-stage/fs/ext4/ext4_jbd2.h
18 ===================================================================
19 --- linux-stage.orig/fs/ext4/ext4_jbd2.h        2012-06-26 11:26:25.000000000 +0200
20 +++ linux-stage/fs/ext4/ext4_jbd2.h     2012-06-26 11:35:31.025105000 +0200
21 @@ -88,8 +88,8 @@
22  
23  #ifdef CONFIG_QUOTA
24  /* Amount of blocks needed for quota update - we know that the structure was
25 - * allocated so we need to update only inode+data */
26 -#define EXT4_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 2 : 0)
27 + * allocated so we need to update only data block */
28 +#define EXT4_QUOTA_TRANS_BLOCKS(sb) (test_opt(sb, QUOTA) ? 1 : 0)
29  /* Amount of blocks needed for quota insert/delete - we do some block writes
30   * but inode, sb and group updates are done only once */
31  #define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
32 Index: linux-stage/fs/ext4/super.c
33 ===================================================================
34 --- linux-stage.orig/fs/ext4/super.c    2012-06-26 11:35:09.000000000 +0200
35 +++ linux-stage/fs/ext4/super.c 2012-06-26 11:37:30.905374000 +0200
36 @@ -4582,6 +4582,7 @@ static int ext4_quota_on(struct super_bl
37  static int ext4_quota_off(struct super_block *sb, int type, int remount)
38  {
39         struct quota_info *dqopt = sb_dqopt(sb);
40 +       int                cnt;
41  
42         mutex_lock(&dqopt->dqonoff_mutex);
43         if (!sb_any_quota_loaded(sb)) {
44 @@ -4598,6 +4599,37 @@ static int ext4_quota_off(struct super_b
45                 up_read(&sb->s_umount);
46         }
47  
48 +       for (cnt = 0; cnt < MAXQUOTAS; cnt++) {
49 +               struct inode      *inode;
50 +               handle_t          *handle;
51 +
52 +               if (type != -1 && cnt != type)
53 +                       continue;
54 +
55 +               mutex_lock(&dqopt->dqonoff_mutex);
56 +               inode = dqopt->files[cnt];
57 +               if (!sb_has_quota_loaded(sb, cnt) || !inode) {
58 +                       mutex_unlock(&dqopt->dqonoff_mutex);
59 +                       continue;
60 +               }
61 +
62 +               inode = igrab(inode);
63 +               mutex_unlock(&dqopt->dqonoff_mutex);
64 +
65 +               if (!inode)
66 +                       continue;
67 +
68 +               /* Update modification times of quota files when userspace can
69 +                * start looking at them */
70 +               handle = ext4_journal_start(inode, 1);
71 +               if (!IS_ERR(handle)) {
72 +                       inode->i_mtime = inode->i_ctime = CURRENT_TIME;
73 +                       ext4_mark_inode_dirty(handle, inode);
74 +                       ext4_journal_stop(handle);
75 +               }
76 +               iput(inode);
77 +       }
78 +
79         return vfs_quota_off(sb, type, remount);
80  }
81  
82 @@ -4696,9 +4728,8 @@ out:
83         if (inode->i_size < off + len) {
84                 i_size_write(inode, off + len);
85                 EXT4_I(inode)->i_disksize = inode->i_size;
86 +               ext4_mark_inode_dirty(handle, inode);
87         }
88 -       inode->i_mtime = inode->i_ctime = CURRENT_TIME;
89 -       ext4_mark_inode_dirty(handle, inode);
90         mutex_unlock(&inode->i_mutex);
91         return len;
92  }