Whamcloud - gitweb
LU-6030 ldiskfs: further cleanup patches of ldiskfs
[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 @@ -1826,6 +1829,9 @@ extern void ext4_add_groupblocks(handle_
12                                 ext4_fsblk_t block, unsigned long count);
13  extern int ext4_trim_fs(struct super_block *, struct fstrim_range *);
14
15 +extern void ext4_mb_discard_inode_preallocations(struct inode *);
16 +
17 +
18  /* inode.c */
19  struct buffer_head *ext4_getblk(handle_t *, struct inode *,
20                                                 ext4_lblk_t, int, int *);
21 --- a/fs/ext4/ext4_extents.h
22 +++ b/fs/ext4/ext4_extents.h
23 @@ -58,6 +58,13 @@
24   */
25  #define EXT_STATS_
26
27 +/*
28 + * define EXT4_ALLOC_NEEDED to 0 since block bitmap, group desc. and sb
29 + * are now accounted in ext4_ext_calc_credits_for_insert()
30 + */
31 +#define EXT4_ALLOC_NEEDED 0
32 +#define HAVE_EXT_PREPARE_CB_EXTENT
33 +#define HAVE_EXT4_EXT_PBLOCK
34
35  /*
36   * ext4_inode has i_block array (60 bytes total).
37 @@ -241,6 +248,7 @@ static inline ext4_fsblk_t ext4_ext_pblo
38         block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1;
39         return block;
40  }
41 +#define ext_pblock(ex) ext4_ext_pblock(ex)
42
43  /*
44   * ext4_idx_pblock:
45 @@ -287,6 +295,8 @@ extern int ext4_extent_tree_init(handle_
46  extern int ext4_ext_calc_credits_for_single_extent(struct inode *inode,
47                                                    int num,
48                                                    struct ext4_ext_path *path);
49 +extern int ext4_ext_calc_credits_for_insert(struct inode *,
50 +                                           struct ext4_ext_path *);
51  extern int ext4_can_extents_be_merged(struct inode *inode,
52                                       struct ext4_extent *ex1,
53                                       struct ext4_extent *ex2);
54 --- a/fs/ext4/ext4_jbd2.h
55 +++ b/fs/ext4/ext4_jbd2.h
56 @@ -175,6 +177,7 @@ static inline void ext4_journal_callback
57         list_del_init(&jce->jce_list);
58         spin_unlock(&sbi->s_md_lock);
59  }
60 +#define HAVE_EXT4_JOURNAL_CALLBACK_ADD
61
62  int
63  ext4_mark_iloc_dirty(handle_t *handle,
64 --- a/fs/ext4/extents.c
65 +++ b/fs/ext4/extents.c
66 @@ -2205,6 +2205,56 @@ int ext4_ext_calc_credits_for_single_ext
67  }
68
69  /*
70 + * This routine returns max. credits extent tree can consume.
71 + * It should be OK for low-performance paths like ->writepage()
72 + * To allow many writing process to fit a single transaction,
73 + * caller should calculate credits under truncate_mutex and
74 + * pass actual path.
75 + */
76 +int ext4_ext_calc_credits_for_insert(struct inode *inode,
77 +                                    struct ext4_ext_path *path)
78 +{
79 +       int depth, needed;
80 +
81 +       if (path) {
82 +               /* probably there is space in leaf? */
83 +               depth = path->p_depth;
84 +               if (le16_to_cpu(path[depth].p_hdr->eh_entries)
85 +                               < le16_to_cpu(path[depth].p_hdr->eh_max))
86 +                       return 1;
87 +       }
88 +
89 +       /*
90 +        * given 32bit logical block (4294967296 blocks), max. tree
91 +        * can be 4 levels in depth -- 4 * 340^4 == 53453440000.
92 +        * let's also add one more level for imbalance.
93 +        */
94 +       depth = 5;
95 +
96 +       /* allocation of new data block(s) */
97 +       needed = 2;
98 +
99 +       /*
100 +        * tree can be full, so it'd need to grow in depth:
101 +        * we need one credit to modify old root, credits for
102 +        * new root will be added in split accounting
103 +        */
104 +       needed += 1;
105 +       /*
106 +        * Index split can happen, we'd need:
107 +        *    allocate intermediate indexes (bitmap + group)
108 +        *  + change two blocks at each level, but root (already included)
109 +        */
110 +       needed += (depth * 2) + (depth * 2);
111 +
112 +       /* any allocation modifies superblock */
113 +       needed += 1;
114 +
115 +       return needed;
116 +}
117 +EXPORT_SYMBOL(ext4_ext_calc_credits_for_insert);
118 +
119 +/*
120   * How many index/leaf blocks need to change/allocate to modify nrblocks?
121   *
122   * if nrblocks are fit in a single extent (chunk flag is 1), then