aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2010-04-20 16:51:59 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-04-20 16:51:59 -0400
commitb90f687018e6d6c77d981b09203780f7001407e5 (patch)
treed2e2b36b4d88d2098000fcb56cc56e5d2e74fdf1 /fs/ext4
parentfd2dd9fbaf9e498ec63eef298921e36556f7214c (diff)
ext4: Issue the discard operation *before* releasing the blocks to be reused
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@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/mballoc.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 54df209d2eed..e5ab41b559c0 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2534,6 +2534,17 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
2534 mb_debug(1, "gonna free %u blocks in group %u (0x%p):", 2534 mb_debug(1, "gonna free %u blocks in group %u (0x%p):",
2535 entry->count, entry->group, entry); 2535 entry->count, entry->group, entry);
2536 2536
2537 if (test_opt(sb, DISCARD)) {
2538 ext4_fsblk_t discard_block;
2539
2540 discard_block = entry->start_blk +
2541 ext4_group_first_block_no(sb, entry->group);
2542 trace_ext4_discard_blocks(sb,
2543 (unsigned long long)discard_block,
2544 entry->count);
2545 sb_issue_discard(sb, discard_block, entry->count);
2546 }
2547
2537 err = ext4_mb_load_buddy(sb, entry->group, &e4b); 2548 err = ext4_mb_load_buddy(sb, entry->group, &e4b);
2538 /* we expect to find existing buddy because it's pinned */ 2549 /* we expect to find existing buddy because it's pinned */
2539 BUG_ON(err != 0); 2550 BUG_ON(err != 0);
@@ -2555,16 +2566,6 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
2555 page_cache_release(e4b.bd_bitmap_page); 2566 page_cache_release(e4b.bd_bitmap_page);
2556 } 2567 }
2557 ext4_unlock_group(sb, entry->group); 2568 ext4_unlock_group(sb, entry->group);
2558 if (test_opt(sb, DISCARD)) {
2559 ext4_fsblk_t discard_block;
2560
2561 discard_block = entry->start_blk +
2562 ext4_group_first_block_no(sb, entry->group);
2563 trace_ext4_discard_blocks(sb,
2564 (unsigned long long)discard_block,
2565 entry->count);
2566 sb_issue_discard(sb, discard_block, entry->count);
2567 }
2568 kmem_cache_free(ext4_free_ext_cachep, entry); 2569 kmem_cache_free(ext4_free_ext_cachep, entry);
2569 ext4_mb_release_desc(&e4b); 2570 ext4_mb_release_desc(&e4b);
2570 } 2571 }