rpms/kernel/F-10 linux-2.6-ext4-write-cyclic-fix.patch, NONE, 1.1 kernel.spec, 1.1262, 1.1263

Chuck Ebbert cebbert at fedoraproject.org
Sat Feb 14 23:37:47 UTC 2009


Author: cebbert

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

Modified Files:
	kernel.spec 
Added Files:
	linux-2.6-ext4-write-cyclic-fix.patch 
Log Message:
Fix ext4 hang on livecd-creator (F10#484522)

linux-2.6-ext4-write-cyclic-fix.patch:

--- NEW FILE linux-2.6-ext4-write-cyclic-fix.patch ---
ext4: Implement range_cyclic in ext4_da_writepages instead of write_cache_pages

From: "Aneesh Kumar K.V" <aneesh.kumar at linux.vnet.ibm.com>

With delayed allocation we lock the page in write_cache_pages() and
try to build an in memory extent of contiguous blocks.  This is needed
so that we can get large contiguous blocks request.  If range_cyclic
mode is enabled, write_cache_pages() will loop back to the 0 index if
no I/O has been done yet, and try to start writing from the beginning
of the range.  That causes an attempt to take the page lock of lower
index page while holding the page lock of higher index page, which can
cause a dead lock with another writeback thread.

The solution is to implement the range_cyclic behavior in
ext4_da_writepages() instead.

http://bugzilla.kernel.org/show_bug.cgi?id=12579

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar at linux.vnet.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
---
 fs/ext4/inode.c |   21 +++++++++++++++++++--
 1 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 658c4a7..cbd2ca9 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2439,6 +2439,7 @@ static int ext4_da_writepages(struct address_space *mapping,
 	int no_nrwrite_index_update;
 	int pages_written = 0;
 	long pages_skipped;
+	int range_cyclic, cycled = 1, io_done = 0;
 	int needed_blocks, ret = 0, nr_to_writebump = 0;
 	struct ext4_sb_info *sbi = EXT4_SB(mapping->host->i_sb);
 
@@ -2490,9 +2491,15 @@ static int ext4_da_writepages(struct address_space *mapping,
 	if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
 		range_whole = 1;
 
-	if (wbc->range_cyclic)
+	range_cyclic = wbc->range_cyclic;
+	if (wbc->range_cyclic) {
 		index = mapping->writeback_index;
-	else
+		if (index)
+			cycled = 0;
+		wbc->range_start = index << PAGE_CACHE_SHIFT;
+		wbc->range_end  = LLONG_MAX;
+		wbc->range_cyclic = 0;
+	} else
 		index = wbc->range_start >> PAGE_CACHE_SHIFT;
 
 	mpd.wbc = wbc;
@@ -2506,6 +2513,7 @@ static int ext4_da_writepages(struct address_space *mapping,
 	wbc->no_nrwrite_index_update = 1;
 	pages_skipped = wbc->pages_skipped;
 
+retry:
 	while (!ret && wbc->nr_to_write > 0) {
 
 		/*
@@ -2548,6 +2556,7 @@ static int ext4_da_writepages(struct address_space *mapping,
 			pages_written += mpd.pages_written;
 			wbc->pages_skipped = pages_skipped;
 			ret = 0;
+			io_done = 1;
 		} else if (wbc->nr_to_write)
 			/*
 			 * There is no more writeout needed
@@ -2556,6 +2565,13 @@ static int ext4_da_writepages(struct address_space *mapping,
 			 */
 			break;
 	}
+	if (!io_done && !cycled) {
+		cycled = 1;
+		index = 0;
+		wbc->range_start = index << PAGE_CACHE_SHIFT;
+		wbc->range_end  = mapping->writeback_index - 1;
+		goto retry;
+	}
 	if (pages_skipped != wbc->pages_skipped)
 		printk(KERN_EMERG "This should not happen leaving %s "
 				"with nr_to_write = %ld ret = %d\n",
@@ -2563,6 +2579,7 @@ static int ext4_da_writepages(struct address_space *mapping,
 
 	/* Update index */
 	index += pages_written;
+	wbc->range_cyclic = range_cyclic;
 	if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
 		/*
 		 * set the writeback_index so that range_cyclic


Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-10/kernel.spec,v
retrieving revision 1.1262
retrieving revision 1.1263
diff -u -r1.1262 -r1.1263
--- kernel.spec	14 Feb 2009 00:47:49 -0000	1.1262
+++ kernel.spec	14 Feb 2009 23:37:16 -0000	1.1263
@@ -622,6 +622,8 @@
 Patch570: linux-2.6-selinux-mprotect-checks.patch
 Patch580: linux-2.6-sparc-selinux-mprotect-checks.patch
 
+Patch590: linux-2.6-ext4-write-cyclic-fix.patch
+
 Patch600: linux-2.6-defaults-alsa-hda-beep-off.patch
 
 Patch670: linux-2.6-ata-quirk.patch
@@ -1065,6 +1067,7 @@
 #
 
 # ext4
+ApplyPatch linux-2.6-ext4-write-cyclic-fix.patch
 
 # xfs
 
@@ -1752,6 +1755,9 @@
 %kernel_variant_files -k vmlinux %{with_kdump} kdump
 
 %changelog
+* Sat Feb 14 2009 Chuck Ebbert <cebbert at redhat.com> 2.6.29-0.33.rc5
+- Fix ext4 hang on livecd-creator (F10#484522)
+
 * Fri Feb 13 2009 Chuck Ebbert <cebbert at redhat.com>  2.6.29-0.32.rc5
 - Apply IOMMU write-buffer quirk. (F10#479996)
 




More information about the fedora-extras-commits mailing list