Whamcloud - gitweb
Branch HEAD
[fs/lustre-release.git] / ldiskfs / kernel_patches / patches / ext4-lock-cached_extent.patch
1 Index: linux-2.6.27.21-0.1/fs/ext4/extents.c
2 ===================================================================
3 --- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c  2009-06-19 15:50:57.000000000 +0530
4 +++ linux-2.6.27.21-0.1/fs/ext4/extents.c       2009-06-19 15:56:32.000000000 +0530
5 @@ -1736,11 +1736,13 @@
6  {
7         struct ext4_ext_cache *cex;
8         BUG_ON(len == 0);
9 +       spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
10         cex = &EXT4_I(inode)->i_cached_extent;
11         cex->ec_type = type;
12         cex->ec_block = block;
13         cex->ec_len = len;
14         cex->ec_start = start;
15 +       spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
16  }
17  
18  /*
19 @@ -1797,12 +1799,17 @@
20                         struct ext4_extent *ex)
21  {
22         struct ext4_ext_cache *cex;
23 +       int ret = EXT4_EXT_CACHE_NO;
24  
25 +       /*
26 +        * We borrow i_block_reservation_lock to protect i_cached_extent
27 +        */
28 +       spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
29         cex = &EXT4_I(inode)->i_cached_extent;
30  
31         /* has cache valid data? */
32         if (cex->ec_type == EXT4_EXT_CACHE_NO)
33 -               return EXT4_EXT_CACHE_NO;
34 +               goto errout;
35  
36         BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP &&
37                         cex->ec_type != EXT4_EXT_CACHE_EXTENT);
38 @@ -1813,11 +1820,12 @@
39                 ext_debug("%u cached by %u:%u:%llu\n",
40                                 block,
41                                 cex->ec_block, cex->ec_len, cex->ec_start);
42 -               return cex->ec_type;
43 +               ret = cex->ec_type;
44         }
45  
46 -       /* not in cache */
47 -       return EXT4_EXT_CACHE_NO;
48 +errout:
49 +       spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
50 +       return ret;
51  }
52  
53  /*