rpms/kernel/F-12 ext4-issue-discard-operation-before-releasing-blocks.patch, NONE, 1.1 kernel.spec, 1.2072, 1.2073
Chuck Ebbert
cebbert at fedoraproject.org
Tue Apr 27 12:37:52 UTC 2010
Author: cebbert
Update of /cvs/pkgs/rpms/kernel/F-12
In directory cvs01.phx2.fedoraproject.org:/tmp/cvs-serv12104
Modified Files:
kernel.spec
Added Files:
ext4-issue-discard-operation-before-releasing-blocks.patch
Log Message:
Fix possible data corruption with ext4 mounted with -o discard
ext4-issue-discard-operation-before-releasing-blocks.patch:
mballoc.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
--- NEW FILE ext4-issue-discard-operation-before-releasing-blocks.patch ---
From: Theodore Ts'o <tytso at mit.edu>
Date: Tue, 20 Apr 2010 20:51:59 +0000 (-0400)
Subject: ext4: Issue the discard operation *before* releasing the blocks to be reused
X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=b90f687018e6d6c77d981b09203780f7001407e5
ext4: Issue the discard operation *before* releasing the blocks to be reused
[ backported to 2.6.3[23] ]
Otherwise, we can end up having data corruption because the blocks
could get reused and then discarded!
https://bugzilla.kernel.org/show_bug.cgi?id=15579
Signed-off-by: "Theodore Ts'o" <tytso at mit.edu>
---
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 54df209..e5ab41b 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2534,6 +2534,20 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
mb_debug(1, "gonna free %u blocks in group %u (0x%p):",
entry->count, entry->group, entry);
+ if (test_opt(sb, DISCARD)) {
+ ext4_fsblk_t discard_block;
+ struct ext4_super_block *es = EXT4_SB(sb)->s_es;
+
+ discard_block = (ext4_fsblk_t)entry->group *
+ EXT4_BLOCKS_PER_GROUP(sb)
+ + entry->start_blk
+ + le32_to_cpu(es->s_first_data_block);
+ trace_ext4_discard_blocks(sb,
+ (unsigned long long)discard_block,
+ entry->count);
+ sb_issue_discard(sb, discard_block, entry->count);
+ }
+
err = ext4_mb_load_buddy(sb, entry->group, &e4b);
/* we expect to find existing buddy because it's pinned */
BUG_ON(err != 0);
@@ -2555,19 +2566,6 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
page_cache_release(e4b.bd_bitmap_page);
}
ext4_unlock_group(sb, entry->group);
- if (test_opt(sb, DISCARD)) {
- ext4_fsblk_t discard_block;
- struct ext4_super_block *es = EXT4_SB(sb)->s_es;
-
- discard_block = (ext4_fsblk_t)entry->group *
- EXT4_BLOCKS_PER_GROUP(sb)
- + entry->start_blk
- + le32_to_cpu(es->s_first_data_block);
- trace_ext4_discard_blocks(sb,
- (unsigned long long)discard_block,
- entry->count);
- sb_issue_discard(sb, discard_block, entry->count);
- }
kmem_cache_free(ext4_free_ext_cachep, entry);
ext4_mb_release_desc(&e4b);
}
Index: kernel.spec
===================================================================
RCS file: /cvs/pkgs/rpms/kernel/F-12/kernel.spec,v
retrieving revision 1.2072
retrieving revision 1.2073
diff -u -p -r1.2072 -r1.2073
--- kernel.spec 27 Apr 2010 12:11:00 -0000 1.2072
+++ kernel.spec 27 Apr 2010 12:37:52 -0000 1.2073
@@ -819,6 +819,9 @@ Patch12600: hugetlb-fix-infinite-loop-in
# CVE-2010-1146
Patch12610: reiserfs-fix-permissions-on-reiserfs-priv.patch
+# fix possible corruption with ssd
+Patch12700: ext4-issue-discard-operation-before-releasing-blocks.patch
+
# ==============================================================================
%endif
@@ -1492,6 +1495,9 @@ ApplyPatch hugetlb-fix-infinite-loop-in-
# CVE-2010-1146
ApplyPatch reiserfs-fix-permissions-on-reiserfs-priv.patch
+# fix possible corruption with ssd
+ApplyPatch ext4-issue-discard-operation-before-releasing-blocks.patch
+
# END OF PATCH APPLICATIONS ====================================================
%endif
@@ -2144,6 +2150,9 @@ fi
# and build.
%changelog
+* Tue Apr 27 2010 Chuck Ebbert <cebbert at redhat.com> 2.6.32.12-113
+- Fix possible data corruption with ext4 mounted with -o discard
+
* Tue Apr 27 2010 Chuck Ebbert <cebbert at redhat.com> 2.6.32.12-112
- hugetlb-fix-infinite-loop-in-get-futex-key.patch (#552557)
- reiserfs-fix-permissions-on-reiserfs-priv.patch (CVE-2010-1146)
More information about the scm-commits
mailing list