Whamcloud - gitweb
efa3eae3cb390bff214d8c0fe8f63c3508c72fce
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / sles11sp2 / ext4-misc.patch
1 ---
2  fs/ext4/ext4.h         |    6 +++++
3  fs/ext4/ext4_extents.h |   10 +++++++++
4  fs/ext4/ext4_jbd2.h    |    3 ++
5  fs/ext4/extents.c      |   50 +++++++++++++++++++++++++++++++++++++++++++++++++
6  fs/ext4/super.c        |   12 +++++++++++
7  5 files changed, 81 insertions(+)
8
9 --- a/fs/ext4/ext4.h
10 +++ b/fs/ext4/ext4.h
11 @@ -1308,6 +1308,9 @@ static inline void ext4_clear_state_flag
12
13  #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
14
15 +/* Has been moved to linux/magic.h but we need it for Lustre */
16 +#define EXT4_SUPER_MAGIC       0xEF53
17 +
18  /*
19   * Codes for operating systems
20   */
21 @@ -1826,6 +1829,9 @@ extern void ext4_add_groupblocks(handle_
22                                 ext4_fsblk_t block, unsigned long count);
23  extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
24
25 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
26 +
27 +
28  /* inode.c */
29  struct buffer_head *ext4_getblk(handle_t *, struct inode *,
30                                                 ext4_lblk_t, int, int *);
31 --- a/fs/ext4/ext4_extents.h
32 +++ b/fs/ext4/ext4_extents.h
33 @@ -58,6 +58,13 @@
34   */
35  #define EXT_STATS_
36
37 +/*
38 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
39 + * are now accounted in ext4_ext_calc_credits_for_insert()
40 + */
41 +#define EXT4_ALLOC_NEEDED 0
42 +#define HAVE_EXT_PREPARE_CB_EXTENT
43 +#define HAVE_EXT4_EXT_PBLOCK
44
45  /*
46   * ext4_inode has i_block array (60 bytes total).
47 @@ -241,6 +248,7 @@ static inline ext4_fsblk_t ext4_ext_pblo
48         block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1;
49         return block;
50  }
51 +#define ext_pblock(ex) ext4_ext_pblock(ex)
52
53  /*
54   * ext4_idx_pblock:
55 @@ -287,6 +295,8 @@ extern int ext4_extent_tree_init(handle_
56  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
57                                                    int num,
58                                                    struct ext4_ext_path *path);
59 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
60 +                                           struct ext4_ext_path *);
61  extern int ext4_can_extents_be_merged(struct inode *inode,
62                                       struct ext4_extent *ex1,
63                                       struct ext4_extent *ex2);
64 --- a/fs/ext4/ext4_jbd2.h
65 +++ b/fs/ext4/ext4_jbd2.h
66 @@ -35,6 +35,8 @@
67         (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS)   \
68          ? 27U : 8U)
69
70 +#define ext4_journal_dirty_metadata(handle, bh)  \
71 +               ext4_handle_dirty_metadata(handle, NULL, bh)
72  /* Extended attribute operations touch at most two data buffers,
73   * two bitmap buffers, and two group summaries, in addition to the inode
74   * and the superblock, which are already accounted for. */
75 @@ -175,6 +177,7 @@ static inline void ext4_journal_callback
76         list_del_init(&jce->jce_list);
77         spin_unlock(&sbi->s_md_lock);
78  }
79 +#define HAVE_EXT4_JOURNAL_CALLBACK_ADD
80
81  int
82  ext4_mark_iloc_dirty(handle_t *handle,
83 --- a/fs/ext4/extents.c
84 +++ b/fs/ext4/extents.c
85 @@ -2205,6 +2205,56 @@ int ext4_ext_calc_credits_for_single_ext
86  }
87
88  /*
89 + * This routine returns max. credits extent tree can consume.
90 + * It should be OK for low-performance paths like ->writepage()
91 + * To allow many writing process to fit a single transaction,
92 + * caller should calculate credits under truncate_mutex and
93 + * pass actual path.
94 + */
95 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
96 +                                    struct ext4_ext_path *path)
97 +{
98 +       int depth, needed;
99 +
100 +       if (path) {
101 +               /* probably there is space in leaf? */
102 +               depth = ext_depth(inode);
103 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
104 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
105 +                       return 1;
106 +       }
107 +
108 +       /*
109 +        * given 32bit logical block (4294967296 blocks), max. tree
110 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
111 +        * let's also add one more level for imbalance.
112 +        */
113 +       depth = 5;
114 +
115 +       /* allocation of new data block(s) */
116 +       needed = 2;
117 +
118 +       /*
119 +        * tree can be full, so it'd need to grow in depth:
120 +        * we need one credit to modify old root, credits for
121 +        * new root will be added in split accounting
122 +        */
123 +       needed += 1;
124 +       /*
125 +        * Index split can happen, we'd need:
126 +        *    allocate intermediate indexes (bitmap + group)
127 +        *  + change two blocks at each level, but root (already included)
128 +        */
129 +       needed += (depth * 2) + (depth * 2);
130 +
131 +       /* any allocation modifies superblock */
132 +       needed += 1;
133 +
134 +       return needed;
135 +}
136 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
137 +
138 +/*
139   * How many index/leaf blocks need to change/allocate to modify nrblocks?
140   *
141   * if nrblocks are fit in a single extent (chunk flag is 1), then
142 --- a/fs/ext4/super.c
143 +++ b/fs/ext4/super.c
144 @@ -1332,12 +1332,14 @@ enum {
145         Opt_data_err_abort, Opt_data_err_ignore,
146         Opt_usrjquota, Opt_grpjquota, Opt_offusrjquota, Opt_offgrpjquota,
147         Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
148 +       Opt_iopen, Opt_noiopen, Opt_iopen_nopriv,
149         Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
150         Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
151         Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit,
152         Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity,
153         Opt_inode_readahead_blks, Opt_journal_ioprio,
154         Opt_dioread_nolock, Opt_dioread_lock,
155 +       Opt_mballoc,
156         Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
157  };
158
159 @@ -1390,6 +1392,9 @@ static const match_table_t tokens = {
160         {Opt_noquota, "noquota"},
161         {Opt_quota, "quota"},
162         {Opt_usrquota, "usrquota"},
163 +       {Opt_iopen, "iopen"},
164 +       {Opt_noiopen, "noiopen"},
165 +       {Opt_iopen_nopriv, "iopen_nopriv"},
166         {Opt_barrier, "barrier=%u"},
167         {Opt_barrier, "barrier"},
168         {Opt_nobarrier, "nobarrier"},
169 @@ -1409,6 +1414,7 @@ static const match_table_t tokens = {
170         {Opt_noauto_da_alloc, "noauto_da_alloc"},
171         {Opt_dioread_nolock, "dioread_nolock"},
172         {Opt_dioread_lock, "dioread_lock"},
173 +       {Opt_mballoc, "mballoc"},
174         {Opt_discard, "discard"},
175         {Opt_nodiscard, "nodiscard"},
176         {Opt_init_itable, "init_itable=%u"},
177 @@ -1793,6 +1799,10 @@ set_qf_format:
178                         else
179                                 clear_opt(sb, BARRIER);
180                         break;
181 +               case Opt_iopen:
182 +               case Opt_noiopen:
183 +               case Opt_iopen_nopriv:
184 +                       break;
185                 case Opt_ignore:
186                         break;
187                 case Opt_resize:
188 @@ -1904,6 +1914,8 @@ set_qf_format:
189                 case Opt_noinit_itable:
190                         clear_opt(sb, INIT_INODE_TABLE);
191                         break;
192 +               case Opt_mballoc:
193 +                       break;
194                 default:
195                         ext4_msg(sb, KERN_ERR,
196                                "Unrecognized mount option \"%s\" "