Whamcloud - gitweb
b=19875
authorgirish <girish>
Fri, 19 Jun 2009 11:29:26 +0000 (11:29 +0000)
committergirish <girish>
Fri, 19 Jun 2009 11:29:26 +0000 (11:29 +0000)
i=adilger
i=johann

add locking for i_cached_extent

ldiskfs/kernel_patches/patches/ext4-lock-cached_extent.patch [new file with mode: 0644]
ldiskfs/kernel_patches/series/ldiskfs-2.6-sles11.series

diff --git a/ldiskfs/kernel_patches/patches/ext4-lock-cached_extent.patch b/ldiskfs/kernel_patches/patches/ext4-lock-cached_extent.patch
new file mode 100644 (file)
index 0000000..1751057
--- /dev/null
@@ -0,0 +1,53 @@
+Index: linux-2.6.27.21-0.1/fs/ext4/extents.c
+===================================================================
+--- linux-2.6.27.21-0.1.orig/fs/ext4/extents.c 2009-06-19 15:50:57.000000000 +0530
++++ linux-2.6.27.21-0.1/fs/ext4/extents.c      2009-06-19 15:56:32.000000000 +0530
+@@ -1736,11 +1736,13 @@
+ {
+       struct ext4_ext_cache *cex;
+       BUG_ON(len == 0);
++      spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
+       cex = &EXT4_I(inode)->i_cached_extent;
+       cex->ec_type = type;
+       cex->ec_block = block;
+       cex->ec_len = len;
+       cex->ec_start = start;
++      spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
+ }
+ /*
+@@ -1797,12 +1799,17 @@
+                       struct ext4_extent *ex)
+ {
+       struct ext4_ext_cache *cex;
++      int ret = EXT4_EXT_CACHE_NO;
++      /*
++       * We borrow i_block_reservation_lock to protect i_cached_extent
++       */
++      spin_lock(&EXT4_I(inode)->i_block_reservation_lock);
+       cex = &EXT4_I(inode)->i_cached_extent;
+       /* has cache valid data? */
+       if (cex->ec_type == EXT4_EXT_CACHE_NO)
+-              return EXT4_EXT_CACHE_NO;
++              goto errout;
+       BUG_ON(cex->ec_type != EXT4_EXT_CACHE_GAP &&
+                       cex->ec_type != EXT4_EXT_CACHE_EXTENT);
+@@ -1813,11 +1820,12 @@
+               ext_debug("%u cached by %u:%u:%llu\n",
+                               block,
+                               cex->ec_block, cex->ec_len, cex->ec_start);
+-              return cex->ec_type;
++              ret = cex->ec_type;
+       }
+-      /* not in cache */
+-      return EXT4_EXT_CACHE_NO;
++errout:
++      spin_unlock(&EXT4_I(inode)->i_block_reservation_lock);
++      return ret;
+ }
+ /*
index 577c091..f3f5596 100644 (file)
@@ -22,3 +22,4 @@ ext4-super-warning.patch
 ext4-alloc-policy-2.6-sles11.patch
 ext4-disable-delalloc-sles11.patch
 ext4-lustre-i_version.patch
+ext4-lock-cached_extent.patch