Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 206305
b: refs/heads/master
c: 5c52183
h: refs/heads/master
i:
  206303: dc639c1
v: v3
  • Loading branch information
Jiaying Zhang authored and Theodore Ts'o committed Jul 27, 2010
1 parent 15bd9b1 commit 62d94ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 47def82672b3ba4e7c5e9a4fe48a556f8684d0d6
refs/heads/master: 5c521830cf3dfcf7638d409d8e02ed21020c064f
37 changes: 21 additions & 16 deletions trunk/fs/ext4/mballoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2558,6 +2558,22 @@ int ext4_mb_release(struct super_block *sb)
return 0;
}

static inline void ext4_issue_discard(struct super_block *sb,
ext4_group_t block_group, ext4_grpblk_t block, int count)
{
int ret;
ext4_fsblk_t discard_block;

discard_block = block + ext4_group_first_block_no(sb, block_group);
trace_ext4_discard_blocks(sb,
(unsigned long long) discard_block, count);
ret = sb_issue_discard(sb, discard_block, count);
if (ret == EOPNOTSUPP) {
ext4_warning(sb, "discard not supported, disabling");
clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
}
}

/*
* This function is called by the jbd2 layer once the commit has finished,
* so we know we can free the blocks that were released with that commit.
Expand All @@ -2577,22 +2593,9 @@ 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)) {
int ret;
ext4_fsblk_t discard_block;

discard_block = entry->start_blk +
ext4_group_first_block_no(sb, entry->group);
trace_ext4_discard_blocks(sb,
(unsigned long long)discard_block,
entry->count);
ret = sb_issue_discard(sb, discard_block, entry->count);
if (ret == EOPNOTSUPP) {
ext4_warning(sb,
"discard not supported, disabling");
clear_opt(EXT4_SB(sb)->s_mount_opt, DISCARD);
}
}
if (test_opt(sb, DISCARD))
ext4_issue_discard(sb, entry->group,
entry->start_blk, entry->count);

err = ext4_mb_load_buddy(sb, entry->group, &e4b);
/* we expect to find existing buddy because it's pinned */
Expand Down Expand Up @@ -4639,6 +4642,8 @@ void ext4_free_blocks(handle_t *handle, struct inode *inode,
mb_clear_bits(bitmap_bh->b_data, bit, count);
mb_free_blocks(inode, &e4b, bit, count);
ext4_mb_return_to_preallocation(inode, &e4b, block, count);
if (test_opt(sb, DISCARD))
ext4_issue_discard(sb, block_group, bit, count);
}

ret = ext4_free_blks_count(sb, gdp) + count;
Expand Down

0 comments on commit 62d94ac

Please sign in to comment.