Whamcloud - gitweb
e0bf3646b4e1238b3fd4e236ada2b578d9191f54
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.3 / ext4-back-dquot-to.patch
1 Index: linux-stage/fs/ext4/super.c
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/super.c
4 +++ linux-stage/fs/ext4/super.c
5 @@ -1117,9 +1117,53 @@ static ssize_t ext4_quota_read(struct su
6  static ssize_t ext4_quota_write(struct super_block *sb, int type,
7                                 const char *data, size_t len, loff_t off);
8  
9 +static int ext4_dquot_initialize(struct inode *inode, int type)
10 +{
11 +       handle_t *handle;
12 +       int ret, err;
13 +
14 +       if (IS_NOQUOTA(inode))
15 +               return 0;
16 +
17 +       /* We may create quota structure so we need to reserve enough blocks */
18 +       handle = ext4_journal_start(inode, 2*EXT4_QUOTA_INIT_BLOCKS(inode->i_sb));
19 +       if (IS_ERR(handle))
20 +               return PTR_ERR(handle);
21 +       ret = dquot_initialize(inode, type);
22 +       err = ext4_journal_stop(handle);
23 +       if (!ret)
24 +               ret = err;
25 +       return ret;
26 +}
27 +
28 +static int ext4_dquot_drop(struct inode *inode)
29 +{
30 +       handle_t *handle;
31 +       int ret, err;
32 +
33 +       if (IS_NOQUOTA(inode))
34 +               return 0;
35 +
36 +       /* We may delete quota structure so we need to reserve enough blocks */
37 +       handle = ext4_journal_start(inode, 2*EXT4_QUOTA_DEL_BLOCKS(inode->i_sb));
38 +       if (IS_ERR(handle)) {
39 +               /*
40 +                * We call dquot_drop() anyway to at least release references
41 +                * to quota structures so that umount does not hang.
42 +                */
43 +               dquot_drop(inode);
44 +               return PTR_ERR(handle);
45 +       }
46 +       ret = dquot_drop(inode);
47 +       err = ext4_journal_stop(handle);
48 +       if (!ret)
49 +               ret = err;
50 +       return ret;
51 +}
52 +
53  static const struct dquot_operations ext4_quota_operations = {
54 -       .initialize     = dquot_initialize,
55 -       .drop           = dquot_drop,
56 +       .initialize     = ext4_dquot_initialize,
57 +       .drop           = ext4_dquot_drop,
58         .alloc_space    = dquot_alloc_space,
59         .reserve_space  = dquot_reserve_space,
60         .claim_space    = dquot_claim_space,
61 Index: linux-stage/fs/ext4/inode.c
62 ===================================================================
63 --- linux-stage.orig/fs/ext4/inode.c
64 +++ linux-stage/fs/ext4/inode.c
65 @@ -222,6 +222,7 @@ void ext4_delete_inode(struct inode *ino
66  {
67         handle_t *handle;
68         int err;
69 +       int extra_credits = 3;
70  
71         if (ext4_should_order_data(inode))
72                 ext4_begin_ordered_truncate(inode, 0);
73 @@ -230,7 +231,10 @@ void ext4_delete_inode(struct inode *ino
74         if (is_bad_inode(inode))
75                 goto no_delete;
76  
77 -       handle = ext4_journal_start(inode, blocks_for_truncate(inode)+3);
78 +       if (!IS_NOQUOTA(inode))
79 +               extra_credits += 2 * EXT4_QUOTA_DEL_BLOCKS(inode->i_sb);
80 +       handle = ext4_journal_start(inode,
81 +                       blocks_for_truncate(inode) + extra_credits);
82         if (IS_ERR(handle)) {
83                 ext4_std_error(inode->i_sb, PTR_ERR(handle));
84                 /*
85 @@ -266,10 +270,10 @@ void ext4_delete_inode(struct inode *ino
86          * enough credits left in the handle to remove the inode from
87          * the orphan list and set the dtime field.
88          */
89 -       if (!ext4_handle_has_enough_credits(handle, 3)) {
90 -               err = ext4_journal_extend(handle, 3);
91 +       if (!ext4_handle_has_enough_credits(handle, extra_credits)) {
92 +               err = ext4_journal_extend(handle, extra_credits);
93                 if (err > 0)
94 -                       err = ext4_journal_restart(handle, 3);
95 +                       err = ext4_journal_restart(handle, extra_credits);
96                 if (err != 0) {
97                         ext4_warning(inode->i_sb,
98                                      "couldn't extend journal (err %d)", err);