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(+)
11 @@ -1308,6 +1308,9 @@ static inline void ext4_clear_state_flag
13 #define NEXT_ORPHAN(inode) EXT4_I(inode)->i_dtime
15 +/* Has been moved to linux/magic.h but we need it for Lustre */
16 +#define EXT4_SUPER_MAGIC 0xEF53
19 * Codes for operating systems
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 *);
25 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
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
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()
41 +#define EXT4_ALLOC_NEEDED 0
42 +#define HAVE_EXT_PREPARE_CB_EXTENT
43 +#define HAVE_EXT4_EXT_PBLOCK
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;
51 +#define ext_pblock(ex) ext4_ext_pblock(ex)
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,
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
67 (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_EXTENTS) \
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);
79 +#define HAVE_EXT4_JOURNAL_CALLBACK_ADD
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
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
95 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
96 + struct ext4_ext_path *path)
101 + /* probably there is space in leaf? */
102 + depth = path->p_depth;
103 + if (le16_to_cpu(path[depth].p_hdr->eh_entries)
104 + < le16_to_cpu(path[depth].p_hdr->eh_max))
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.
115 + /* allocation of new data block(s) */
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
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)
129 + needed += (depth * 2) + (depth * 2);
131 + /* any allocation modifies superblock */
136 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
139 * How many index/leaf blocks need to change/allocate to modify nrblocks?
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,
156 Opt_discard, Opt_nodiscard, Opt_init_itable, Opt_noinit_itable,
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:
179 clear_opt(sb, BARRIER);
183 + case Opt_iopen_nopriv:
188 @@ -1904,6 +1914,8 @@ set_qf_format:
189 case Opt_noinit_itable:
190 clear_opt(sb, INIT_INODE_TABLE);
195 ext4_msg(sb, KERN_ERR,
196 "Unrecognized mount option \"%s\" "