[kernel] r22661 - in dists/jessie/linux/debian: . patches patches/bugfix/all

Ben Hutchings benh at moszumanska.debian.org
Tue May 19 00:00:22 UTC 2015


Author: benh
Date: Tue May 19 00:00:21 2015
New Revision: 22661

Log:
Add two ext4 fixes queued for stable

Added:
   dists/jessie/linux/debian/patches/bugfix/all/ext4-fix-data-corruption-caused-by-unwritten-and-del.patch
   dists/jessie/linux/debian/patches/bugfix/all/ext4-move-check-under-lock-scope-to-close-a-race.patch
Modified:
   dists/jessie/linux/debian/changelog
   dists/jessie/linux/debian/patches/series

Modified: dists/jessie/linux/debian/changelog
==============================================================================
--- dists/jessie/linux/debian/changelog	Mon May 18 00:51:13 2015	(r22660)
+++ dists/jessie/linux/debian/changelog	Tue May 19 00:00:21 2015	(r22661)
@@ -158,6 +158,9 @@
     2015 models (Closes: #780862)
   * [x86] thinkpad_acpi: support new BIOS version string pattern
     (Closes: #780467)
+  * ext4: fix data corruption caused by unwritten and delayed extents
+    (Closes: #785672)
+  * ext4: move check under lock scope to close a race.
 
   [ Ian Campbell ]
   * [armhf] Enable support for Freescale SNVS RTC. (Closes: #782364)

Added: dists/jessie/linux/debian/patches/bugfix/all/ext4-fix-data-corruption-caused-by-unwritten-and-del.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/jessie/linux/debian/patches/bugfix/all/ext4-fix-data-corruption-caused-by-unwritten-and-del.patch	Tue May 19 00:00:21 2015	(r22661)
@@ -0,0 +1,86 @@
+From: Lukas Czerner <lczerner at redhat.com>
+Date: Sat, 2 May 2015 21:36:55 -0400
+Subject: ext4: fix data corruption caused by unwritten and delayed extents
+Origin: https://git.kernel.org/linus/d2dc317d564a46dfc683978a2e5a4f91434e9711
+Bug-Debian: https://bugs.debian.org/785672
+
+Currently it is possible to lose whole file system block worth of data
+when we hit the specific interaction with unwritten and delayed extents
+in status extent tree.
+
+The problem is that when we insert delayed extent into extent status
+tree the only way to get rid of it is when we write out delayed buffer.
+However there is a limitation in the extent status tree implementation
+so that when inserting unwritten extent should there be even a single
+delayed block the whole unwritten extent would be marked as delayed.
+
+At this point, there is no way to get rid of the delayed extents,
+because there are no delayed buffers to write out. So when a we write
+into said unwritten extent we will convert it to written, but it still
+remains delayed.
+
+When we try to write into that block later ext4_da_map_blocks() will set
+the buffer new and delayed and map it to invalid block which causes
+the rest of the block to be zeroed loosing already written data.
+
+For now we can fix this by simply not allowing to set delayed status on
+written extent in the extent status tree. Also add WARN_ON() to make
+sure that we notice if this happens in the future.
+
+This problem can be easily reproduced by running the following xfs_io.
+
+xfs_io -f -c "pwrite -S 0xaa 4096 2048" \
+          -c "falloc 0 131072" \
+          -c "pwrite -S 0xbb 65536 2048" \
+          -c "fsync" /mnt/test/fff
+
+echo 3 > /proc/sys/vm/drop_caches
+xfs_io -c "pwrite -S 0xdd 67584 2048" /mnt/test/fff
+
+This can be theoretically also reproduced by at random by running fsx,
+but it's not very reliable, though on machines with bigger page size
+(like ppc) this can be seen more often (especially xfstest generic/127)
+
+Signed-off-by: Lukas Czerner <lczerner at redhat.com>
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+Cc: stable at vger.kernel.org
+---
+ fs/ext4/extents_status.c | 8 ++++++++
+ fs/ext4/inode.c          | 2 ++
+ 2 files changed, 10 insertions(+)
+
+--- a/fs/ext4/extents_status.c
++++ b/fs/ext4/extents_status.c
+@@ -662,6 +662,14 @@ int ext4_es_insert_extent(struct inode *
+ 
+ 	BUG_ON(end < lblk);
+ 
++	if ((status & EXTENT_STATUS_DELAYED) &&
++	    (status & EXTENT_STATUS_WRITTEN)) {
++		ext4_warning(inode->i_sb, "Inserting extent [%u/%u] as "
++				" delayed and written which can potentially "
++				" cause data loss.\n", lblk, len);
++		WARN_ON(1);
++	}
++
+ 	newes.es_lblk = lblk;
+ 	newes.es_len = len;
+ 	ext4_es_store_pblock_status(&newes, pblk, status);
+--- a/fs/ext4/inode.c
++++ b/fs/ext4/inode.c
+@@ -577,6 +577,7 @@ int ext4_map_blocks(handle_t *handle, st
+ 		status = map->m_flags & EXT4_MAP_UNWRITTEN ?
+ 				EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
+ 		if (!(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) &&
++		    !(status & EXTENT_STATUS_WRITTEN) &&
+ 		    ext4_find_delalloc_range(inode, map->m_lblk,
+ 					     map->m_lblk + map->m_len - 1))
+ 			status |= EXTENT_STATUS_DELAYED;
+@@ -691,6 +692,7 @@ found:
+ 		status = map->m_flags & EXT4_MAP_UNWRITTEN ?
+ 				EXTENT_STATUS_UNWRITTEN : EXTENT_STATUS_WRITTEN;
+ 		if (!(flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) &&
++		    !(status & EXTENT_STATUS_WRITTEN) &&
+ 		    ext4_find_delalloc_range(inode, map->m_lblk,
+ 					     map->m_lblk + map->m_len - 1))
+ 			status |= EXTENT_STATUS_DELAYED;

Added: dists/jessie/linux/debian/patches/bugfix/all/ext4-move-check-under-lock-scope-to-close-a-race.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/jessie/linux/debian/patches/bugfix/all/ext4-move-check-under-lock-scope-to-close-a-race.patch	Tue May 19 00:00:21 2015	(r22661)
@@ -0,0 +1,48 @@
+From: Davide Italiano <dccitaliano at gmail.com>
+Date: Sat, 2 May 2015 23:21:15 -0400
+Subject: ext4: move check under lock scope to close a race.
+Origin: https://git.kernel.org/linus/280227a75b56ab5d35854f3a77ef74a7ad56a203
+
+fallocate() checks that the file is extent-based and returns
+EOPNOTSUPP in case is not. Other tasks can convert from and to
+indirect and extent so it's safe to check only after grabbing
+the inode mutex.
+
+Signed-off-by: Davide Italiano <dccitaliano at gmail.com>
+Signed-off-by: Theodore Ts'o <tytso at mit.edu>
+Cc: stable at vger.kernel.org
+---
+ fs/ext4/extents.c | 15 ++++++++-------
+ 1 file changed, 8 insertions(+), 7 deletions(-)
+
+--- a/fs/ext4/extents.c
++++ b/fs/ext4/extents.c
+@@ -4933,13 +4933,6 @@ long ext4_fallocate(struct file *file, i
+ 	if (ret)
+ 		return ret;
+ 
+-	/*
+-	 * currently supporting (pre)allocate mode for extent-based
+-	 * files _only_
+-	 */
+-	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS)))
+-		return -EOPNOTSUPP;
+-
+ 	if (mode & FALLOC_FL_COLLAPSE_RANGE)
+ 		return ext4_collapse_range(inode, offset, len);
+ 
+@@ -4961,6 +4954,14 @@ long ext4_fallocate(struct file *file, i
+ 
+ 	mutex_lock(&inode->i_mutex);
+ 
++	/*
++	 * We only support preallocation for extent-based files only
++	 */
++	if (!(ext4_test_inode_flag(inode, EXT4_INODE_EXTENTS))) {
++		ret = -EOPNOTSUPP;
++		goto out;
++	}
++
+ 	if (!(mode & FALLOC_FL_KEEP_SIZE) &&
+ 	     offset + len > i_size_read(inode)) {
+ 		new_size = offset + len;

Modified: dists/jessie/linux/debian/patches/series
==============================================================================
--- dists/jessie/linux/debian/patches/series	Mon May 18 00:51:13 2015	(r22660)
+++ dists/jessie/linux/debian/patches/series	Tue May 19 00:00:21 2015	(r22661)
@@ -593,3 +593,5 @@
 bugfix/x86/input-synaptics-remove-topbuttonpad-property-for-len.patch
 bugfix/x86/input-synaptics-re-route-tracksticks-buttons-on-the-.patch
 features/x86/thinkpad_acpi-support-new-BIOS-version-string-patter.patch
+bugfix/all/ext4-fix-data-corruption-caused-by-unwritten-and-del.patch
+bugfix/all/ext4-move-check-under-lock-scope-to-close-a-race.patch



More information about the Kernel-svn-changes mailing list