aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorJiaying Zhang <jiayingz@google.com>2010-07-27 11:56:05 -0400
committerTheodore Ts'o <tytso@mit.edu>2010-07-27 11:56:05 -0400
commit5c521830cf3dfcf7638d409d8e02ed21020c064f (patch)
treee852cf76218a55c8cb1e206f8f2a2fbb971783ea /fs/ext4/mballoc.c
parent47def82672b3ba4e7c5e9a4fe48a556f8684d0d6 (diff)
ext4: Support discard requests when running in no-journal mode
Issue discard request in ext4_free_blocks() when ext4 has no journal and is mounted with discard option. Signed-off-by: Jiaying Zhang <jiayingz@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 84185d215004..5338b1ca64bb 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2558,6 +2558,22 @@ int ext4_mb_release(struct super_block *sb)
2558 return 0; 2558 return 0;
2559} 2559}
2560 2560
2561static inline void ext4_issue_discard(struct super_block *sb,
2562 ext4_group_t block_group, ext4_grpblk_t block, int count)
2563{
2564 int ret;
2565 ext4_fsblk_t discard_block;
2566
2567 discard_block = block + ext4_group_first_block_no(sb, block_group);
2568 trace_ext4_discard_blocks(sb,
2569 (unsigned long long) discard_block, count);
2570 ret = sb_issue_discard(sb, discard_block, count);
2571 if (ret == EOPNOTSUPP) {
2572 ext4_warning(sb, "discard not supported, disabling");
2573 clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
2574 }
2575}
2576
2561/* 2577/*
2562 * This function is called by the jbd2 layer once the commit has finished, 2578 * This function is called by the jbd2 layer once the commit has finished,
2563 * so we know we can free the blocks that were released with that commit. 2579 * so we know we can free the blocks that were released with that commit.
@@ -2577,22 +2593,9 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
2577 mb_debug(1, "gonna free %u blocks in group %u (0x%p):", 2593 mb_debug(1, "gonna free %u blocks in group %u (0x%p):",
2578 entry->count, entry->group, entry); 2594 entry->count, entry->group, entry);
2579 2595
2580 if (test_opt(sb, DISCARD)) { 2596 if (test_opt(sb, DISCARD))
2581 int ret; 2597 ext4_issue_discard(sb, entry->group,
2582 ext4_fsblk_t discard_block; 2598 entry->start_blk, entry->count);
2583
2584 discard_block = entry->start_blk +
2585 ext4_group_first_block_no(sb, entry->group);
2586 trace_ext4_discard_blocks(sb,
2587 (unsigned long long)discard_block,
2588 entry->count);
2589 ret = sb_issue_discard(sb, discard_block, entry->count);
2590 if (ret == EOPNOTSUPP) {
2591 ext4_warning(sb,
2592 "discard not supported, disabling");
2593 clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
2594 }
2595 }
2596 2599
2597 err = ext4_mb_load_buddy(sb, entry->group, &e4b); 2600 err = ext4_mb_load_buddy(sb, entry->group, &e4b);
2598 /* we expect to find existing buddy because it's pinned */ 2601 /* we expect to find existing buddy because it's pinned */
@@ -4639,6 +4642,8 @@ do_more:
4639 mb_clear_bits(bitmap_bh->b_data, bit, count); 4642 mb_clear_bits(bitmap_bh->b_data, bit, count);
4640 mb_free_blocks(inode, &e4b, bit, count); 4643 mb_free_blocks(inode, &e4b, bit, count);
4641 ext4_mb_return_to_preallocation(inode, &e4b, block, count); 4644 ext4_mb_return_to_preallocation(inode, &e4b, block, count);
4645 if (test_opt(sb, DISCARD))
4646 ext4_issue_discard(sb, block_group, bit, count);
4642 } 4647 }
4643 4648
4644 ret = ext4_free_blks_count(sb, gdp) + count; 4649 ret = ext4_free_blks_count(sb, gdp) + count;