Whamcloud - gitweb
9c87a928410a37483bef1fbd9100b41c73c88070
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / rhel6.3 / ext4-store-tree-generation-at-find.patch
1 Index: linux-stage/fs/ext4/ext4_extents.h
2 ===================================================================
3 --- linux-stage.orig/fs/ext4/ext4_extents.h
4 +++ linux-stage/fs/ext4/ext4_extents.h
5 @@ -113,6 +113,7 @@ struct ext4_extent_header {
6   * Truncate uses it to simulate recursive walking.
7   */
8  struct ext4_ext_path {
9 +       unsigned long                   p_generation;
10         ext4_fsblk_t                    p_block;
11         __u16                           p_depth;
12         struct ext4_extent              *p_ext;
13 Index: linux-stage/fs/ext4/extents.c
14 ===================================================================
15 --- linux-stage.orig/fs/ext4/extents.c
16 +++ linux-stage/fs/ext4/extents.c
17 @@ -1855,7 +1855,7 @@ int ext4_ext_walk_space(struct inode *in
18  {
19         struct ext4_ext_path *path = NULL;
20         struct ext4_ext_cache cbex;
21 -       struct ext4_extent *ex;
22 +       struct ext4_extent _ex, *ex;
23         ext4_lblk_t next, start = 0, end = 0;
24         ext4_lblk_t last = block + num;
25         int depth, exists, err = 0;
26 @@ -1868,21 +1868,29 @@ int ext4_ext_walk_space(struct inode *in
27                 /* find extent for this block */
28                 down_read(&EXT4_I(inode)->i_data_sem);
29                 path = ext4_ext_find_extent(inode, block, path);
30 -               up_read(&EXT4_I(inode)->i_data_sem);
31                 if (IS_ERR(path)) {
32 +                       up_read(&EXT4_I(inode)->i_data_sem);
33                         err = PTR_ERR(path);
34                         path = NULL;
35                         break;
36                 }
37  
38 +               path[0].p_generation = EXT4_I(inode)->i_ext_generation;
39 +
40                 depth = ext_depth(inode);
41                 if (unlikely(path[depth].p_hdr == NULL)) {
42 +                       up_read(&EXT4_I(inode)->i_data_sem);
43                         EXT4_ERROR_INODE(inode, "path[%d].p_hdr == NULL", depth);
44                         err = -EIO;
45                         break;
46                 }
47 -               ex = path[depth].p_ext;
48 +               ex = NULL;
49 +               if (path[depth].p_ext) {
50 +                       _ex = *path[depth].p_ext;
51 +                       ex = &_ex;
52 +               }
53                 next = ext4_ext_next_allocated_block(path);
54 +               up_read(&EXT4_I(inode)->i_data_sem);
55  
56                 exists = 0;
57                 if (!ex) {
58 @@ -1936,7 +1944,7 @@ int ext4_ext_walk_space(struct inode *in
59                         err = -EIO;
60                         break;
61                 }
62 -               err = func(inode, path, &cbex, ex, cbdata);
63 +               err = func(inode, path, &cbex, NULL, cbdata);
64                 ext4_ext_drop_refs(path);
65  
66                 if (err < 0)