rpms/kernel/F-10 linux-2.6-ext4-clear-unwritten-flag.patch, NONE, 1.1 linux-2.6-ext4-fake-delalloc-bno.patch, NONE, 1.1 linux-2.6-ext4-fix-i_cached_extent-race.patch, NONE, 1.1 linux-2.6-ext4-prealloc-fixes.patch, NONE, 1.1 patch-2.6.29.4-rc1.bz2.sign, NONE, 1.1 .cvsignore, 1.1006, 1.1007 kernel.spec, 1.1363, 1.1364 sources, 1.967, 1.968 upstream, 1.878, 1.879

Chuck Ebbert cebbert at fedoraproject.org
Sat May 16 03:00:55 UTC 2009


Author: cebbert

Update of /cvs/pkgs/rpms/kernel/F-10
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv12649

Modified Files:
	.cvsignore kernel.spec sources upstream 
Added Files:
	linux-2.6-ext4-clear-unwritten-flag.patch 
	linux-2.6-ext4-fake-delalloc-bno.patch 
	linux-2.6-ext4-fix-i_cached_extent-race.patch 
	linux-2.6-ext4-prealloc-fixes.patch 
	patch-2.6.29.4-rc1.bz2.sign 
Log Message:
Linux 2.6.29.4-rc1
Add ext4 corruption fixes from F-11

linux-2.6-ext4-clear-unwritten-flag.patch:

--- NEW FILE linux-2.6-ext4-clear-unwritten-flag.patch ---
From: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Date: Thu, 14 May 2009 21:05:39 +0000 (-0400)
Subject: ext4: Clear the unwritten buffer_head flag after the extent is initialized
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=2a8964d63d50dd2d65d71d342bc7fb6ef4117614

ext4: Clear the unwritten buffer_head flag after the extent is initialized

The BH_Unwritten flag indicates that the buffer is allocated on disk
but has not been written; that is, the disk was part of a persistent
preallocation area.  That flag should only be set when a get_blocks()
function is looking up a inode's logical to physical block mapping.

When ext4_get_blocks_wrap() is called with create=1, the uninitialized
extent is converted into an initialized one, so the BH_Unwritten flag
is no longer appropriate.  Hence, we need to make sure the
BH_Unwritten is not left set, since the combination of BH_Mapped and
BH_Unwritten is not allowed; among other things, it will result ext4's
get_block() to be called over and over again during the write_begin
phase of write(2).

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
---

Index: linux-2.6.29.noarch/fs/ext4/inode.c
===================================================================
--- linux-2.6.29.noarch.orig/fs/ext4/inode.c
+++ linux-2.6.29.noarch/fs/ext4/inode.c
@@ -1069,6 +1069,7 @@ int ext4_get_blocks_wrap(handle_t *handl
 	int retval;
 
 	clear_buffer_mapped(bh);
+	clear_buffer_unwritten(bh);
 
 	/*
 	 * Try to see if we can get  the block without requesting
@@ -1099,6 +1100,18 @@ int ext4_get_blocks_wrap(handle_t *handl
 		return retval;
 
 	/*
+	 * When we call get_blocks without the create flag, the
+	 * BH_Unwritten flag could have gotten set if the blocks
+	 * requested were part of a uninitialized extent.  We need to
+	 * clear this flag now that we are committed to convert all or
+	 * part of the uninitialized extent to be an initialized
+	 * extent.  This is because we need to avoid the combination
+	 * of BH_Unwritten and BH_Mapped flags being simultaneously
+	 * set on the buffer_head.
+	 */
+	clear_buffer_unwritten(bh);
+
+	/*
 	 * New blocks allocate and/or writing to uninitialized extent
 	 * will possibly result in updating i_data, so we take
 	 * the write lock of i_data_sem, and call get_blocks()

linux-2.6-ext4-fake-delalloc-bno.patch:

--- NEW FILE linux-2.6-ext4-fake-delalloc-bno.patch ---
From: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Date: Tue, 12 May 2009 18:40:37 +0000 (-0400)
Subject: ext4: Use a fake block number for delayed new buffer_head
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=33b9817e2ae097c7b8d256e3510ac6c54fc6d9d0

ext4: Use a fake block number for delayed new buffer_head

Use a very large unsigned number (~0xffff) as as the fake block number
for the delayed new buffer. The VFS should never try to write out this
number, but if it does, this will make it obvious.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
---

Index: linux-2.6.29.noarch/fs/ext4/inode.c
===================================================================
--- linux-2.6.29.noarch.orig/fs/ext4/inode.c
+++ linux-2.6.29.noarch/fs/ext4/inode.c
@@ -2213,6 +2213,10 @@ static int ext4_da_get_block_prep(struct
 				  struct buffer_head *bh_result, int create)
 {
 	int ret = 0;
+	sector_t invalid_block = ~((sector_t) 0xffff);
+
+	if (invalid_block < ext4_blocks_count(EXT4_SB(inode->i_sb)->s_es))
+		invalid_block = ~0;
 
 	BUG_ON(create == 0);
 	BUG_ON(bh_result->b_size != inode->i_sb->s_blocksize);
@@ -2234,7 +2238,7 @@ static int ext4_da_get_block_prep(struct
 			/* not enough space to reserve */
 			return ret;
 
-		map_bh(bh_result, inode->i_sb, 0);
+		map_bh(bh_result, inode->i_sb, invalid_block);
 		set_buffer_new(bh_result);
 		set_buffer_delay(bh_result);
 	} else if (ret > 0) {

linux-2.6-ext4-fix-i_cached_extent-race.patch:

--- NEW FILE linux-2.6-ext4-fix-i_cached_extent-race.patch ---
From: Theodore Ts'o <tytso at mit.edu>
Date: Fri, 15 May 2009 13:07:28 +0000 (-0400)
Subject: ext4: Fix race in ext4_inode_info.i_cached_extent
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=2ec0ae3acec47f628179ee95fe2c4da01b5e9fc4

ext4: Fix race in ext4_inode_info.i_cached_extent

If two CPU's simultaneously call ext4_ext_get_blocks() at the same
time, there is nothing protecting the i_cached_extent structure from
being used and updated at the same time.  This could potentially cause
the wrong location on disk to be read or written to, including
potentially causing the corruption of the block group descriptors
and/or inode table.

This bug has been in the ext4 code since almost the very beginning of
ext4's development.  Fortunately once the data is stored in the page
cache cache, ext4_get_blocks() doesn't need to be called, so trying to
replicate this problem to the point where we could identify its root
cause was *extremely* difficult.  Many thanks to Kevin Shanahan for
working over several months to be able to reproduce this easily so we
could finally nail down the cause of the corruption.

Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
Reviewed-by: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>
---

Index: linux-2.6.29.noarch/fs/ext4/extents.c
===================================================================
--- linux-2.6.29.noarch.orig/fs/ext4/extents.c
+++ linux-2.6.29.noarch/fs/ext4/extents.c
@@ -1740,11 +1740,13 @@ ext4_ext_put_in_cache(struct inode *inod
 {
 	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);
 }
 
 /*
@@ -1801,12 +1803,17 @@ ext4_ext_in_cache(struct inode *inode, e
 			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);
@@ -1817,11 +1824,11 @@ ext4_ext_in_cache(struct inode *inode, e
 		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;
 }
 
 /*

linux-2.6-ext4-prealloc-fixes.patch:

--- NEW FILE linux-2.6-ext4-prealloc-fixes.patch ---
From: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Date: Wed, 13 May 2009 22:36:58 +0000 (-0400)
Subject: ext4: Fix sub-block zeroing for writes into preallocated extents
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=9c1ee184a30394e54165fa4c15923cabd952c106

ext4: Fix sub-block zeroing for writes into preallocated extents

We need to mark the buffer_head mapping preallocated space as new
during write_begin. Otherwise we don't zero out the page cache content
properly for a partial write. This will cause file corruption with
preallocation.

Now that we mark the buffer_head new we also need to have a valid
buffer_head blocknr so that unmap_underlying_metadata() unmaps the
correct block.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
---

Index: linux-2.6.29.noarch/fs/ext4/extents.c
===================================================================
--- linux-2.6.29.noarch.orig/fs/ext4/extents.c
+++ linux-2.6.29.noarch/fs/ext4/extents.c
@@ -2776,6 +2776,8 @@ int ext4_ext_get_blocks(handle_t *handle
 				if (allocated > max_blocks)
 					allocated = max_blocks;
 				set_buffer_unwritten(bh_result);
+				bh_result->b_bdev = inode->i_sb->s_bdev;
+				bh_result->b_blocknr = newblock;
 				goto out2;
 			}
 
Index: linux-2.6.29.noarch/fs/ext4/inode.c
===================================================================
--- linux-2.6.29.noarch.orig/fs/ext4/inode.c
+++ linux-2.6.29.noarch/fs/ext4/inode.c
@@ -2239,6 +2239,13 @@ static int ext4_da_get_block_prep(struct
 		set_buffer_delay(bh_result);
 	} else if (ret > 0) {
 		bh_result->b_size = (ret << inode->i_blkbits);
+		/*
+		 * With sub-block writes into unwritten extents
+		 * we also need to mark the buffer as new so that
+		 * the unwritten parts of the buffer gets correctly zeroed.
+		 */
+		if (buffer_unwritten(bh_result))
+			set_buffer_new(bh_result);
 		ret = 0;
 	}
 


--- NEW FILE patch-2.6.29.4-rc1.bz2.sign ---
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: See http://www.kernel.org/signature.html for info

iD8DBQBKDJ8PyGugalF9Dw4RAgUiAKCPA8Jd9TSUePT2q9bGo/EYqq2r/wCgj8sQ
0CftQoTZnomfDHkj90+JmEg=
=MDcV
-----END PGP SIGNATURE-----


Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/.cvsignore,v
retrieving revision 1.1006
retrieving revision 1.1007
diff -u -p -r1.1006 -r1.1007
--- .cvsignore	9 May 2009 03:37:40 -0000	1.1006
+++ .cvsignore	16 May 2009 03:00:24 -0000	1.1007
@@ -6,3 +6,4 @@ temp-*
 kernel-2.6.29
 linux-2.6.29.tar.bz2
 patch-2.6.29.3.bz2
+patch-2.6.29.4-rc1.bz2


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/kernel.spec,v
retrieving revision 1.1363
retrieving revision 1.1364
diff -u -p -r1.1363 -r1.1364
--- kernel.spec	14 May 2009 18:26:28 -0000	1.1363
+++ kernel.spec	16 May 2009 03:00:24 -0000	1.1364
@@ -36,9 +36,9 @@ Summary: The Linux kernel
 %if 0%{?released_kernel}
 
 # Do we have a -stable update to apply?
-%define stable_update 3
+%define stable_update 4
 # Is it a -stable RC?
-%define stable_rc 0
+%define stable_rc 1
 # Set rpm version accordingly
 %if 0%{?stable_update}
 %define stablerev .%{stable_update}
@@ -689,6 +689,10 @@ Patch2900: linux-2.6-v4l-dvb-fix-uint16_
 
 Patch2911: linux-2.6-ext4-flush-on-close.patch
 Patch2912: linux-2.6-ext4-really-print-warning-once.patch
+Patch2913: linux-2.6-ext4-prealloc-fixes.patch
+Patch2914: linux-2.6-ext4-fake-delalloc-bno.patch
+Patch2915: linux-2.6-ext4-clear-unwritten-flag.patch
+Patch2916: linux-2.6-ext4-fix-i_cached_extent-race.patch
 
 # relatime patches from 2.6.30
 Patch2920: fs-relatime-add-strictatime-option.patch
@@ -1199,6 +1203,12 @@ ApplyPatch linux-2.6-ext4-flush-on-close
 # missing braces cause warning to print more than once
 ApplyPatch linux-2.6-ext4-really-print-warning-once.patch
 
+# more ext4 fixes from f11
+ApplyPatch linux-2.6-ext4-prealloc-fixes.patch
+ApplyPatch linux-2.6-ext4-fake-delalloc-bno.patch
+ApplyPatch linux-2.6-ext4-clear-unwritten-flag.patch
+ApplyPatch linux-2.6-ext4-fix-i_cached_extent-race.patch
+
 # xfs
 
 # btrfs
@@ -1931,6 +1941,10 @@ fi
 %kernel_variant_files -k vmlinux %{with_kdump} kdump
 
 %changelog
+* Fri May 15 2009 Chuck Ebbert <cebbert at redhat.com> 2.6.29.4-64.rc1
+- Linux 2.6.29.4-rc1
+- Add ext4 corruption fixes from F-11
+
 * Thu May 14 2009 Chuck Ebbert <cebbert at redhat.com> 2.6.29.3-63
 - net-revert-forcedeth-power-down-phy-when-interface-is.patch:
    Fix forcedeth failures, (F11#484505)


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/sources,v
retrieving revision 1.967
retrieving revision 1.968
diff -u -p -r1.967 -r1.968
--- sources	9 May 2009 03:37:41 -0000	1.967
+++ sources	16 May 2009 03:00:25 -0000	1.968
@@ -1,2 +1,3 @@
 64921b5ff5cdadbccfcd3820f03be7d8  linux-2.6.29.tar.bz2
 4e16a087ca4455f5e95c5890c4ac23f6  patch-2.6.29.3.bz2
+c3d76d16624abfaaadedf1edc89d55c7  patch-2.6.29.4-rc1.bz2


Index: upstream
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/upstream,v
retrieving revision 1.878
retrieving revision 1.879
diff -u -p -r1.878 -r1.879
--- upstream	9 May 2009 03:37:41 -0000	1.878
+++ upstream	16 May 2009 03:00:25 -0000	1.879
@@ -1,2 +1,3 @@
 linux-2.6.29.tar.bz2
 patch-2.6.29.3.bz2
+patch-2.6.29.4-rc1.bz2




More information about the fedora-extras-commits mailing list