Skip to content

Commit 202f2bb

Browse files
committed
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: Issue the discard operation *before* releasing the blocks to be reused ext4: Fix buffer head leaks after calls to ext4_get_inode_loc() ext4: Fix possible lost inode write in no journal mode
2 parents ddc9b34 + b90f687 commit 202f2bb

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

fs/ext4/extents.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3879,6 +3879,7 @@ static int ext4_xattr_fiemap(struct inode *inode,
38793879
physical += offset;
38803880
length = EXT4_SB(inode->i_sb)->s_inode_size - offset;
38813881
flags |= FIEMAP_EXTENT_DATA_INLINE;
3882+
brelse(iloc.bh);
38823883
} else { /* external block */
38833884
physical = EXT4_I(inode)->i_file_acl << blockbits;
38843885
length = inode->i_sb->s_blocksize;

fs/ext4/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5375,7 +5375,7 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
53755375
} else {
53765376
struct ext4_iloc iloc;
53775377

5378-
err = ext4_get_inode_loc(inode, &iloc);
5378+
err = __ext4_get_inode_loc(inode, &iloc, 0);
53795379
if (err)
53805380
return err;
53815381
if (wbc->sync_mode == WB_SYNC_ALL)
@@ -5386,6 +5386,7 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
53865386
(unsigned long long)iloc.bh->b_blocknr);
53875387
err = -EIO;
53885388
}
5389+
brelse(iloc.bh);
53895390
}
53905391
return err;
53915392
}

fs/ext4/mballoc.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2535,6 +2535,17 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
25352535
mb_debug(1, "gonna free %u blocks in group %u (0x%p):",
25362536
entry->count, entry->group, entry);
25372537

2538+
if (test_opt(sb, DISCARD)) {
2539+
ext4_fsblk_t discard_block;
2540+
2541+
discard_block = entry->start_blk +
2542+
ext4_group_first_block_no(sb, entry->group);
2543+
trace_ext4_discard_blocks(sb,
2544+
(unsigned long long)discard_block,
2545+
entry->count);
2546+
sb_issue_discard(sb, discard_block, entry->count);
2547+
}
2548+
25382549
err = ext4_mb_load_buddy(sb, entry->group, &e4b);
25392550
/* we expect to find existing buddy because it's pinned */
25402551
BUG_ON(err != 0);
@@ -2556,16 +2567,6 @@ static void release_blocks_on_commit(journal_t *journal, transaction_t *txn)
25562567
page_cache_release(e4b.bd_bitmap_page);
25572568
}
25582569
ext4_unlock_group(sb, entry->group);
2559-
if (test_opt(sb, DISCARD)) {
2560-
ext4_fsblk_t discard_block;
2561-
2562-
discard_block = entry->start_blk +
2563-
ext4_group_first_block_no(sb, entry->group);
2564-
trace_ext4_discard_blocks(sb,
2565-
(unsigned long long)discard_block,
2566-
entry->count);
2567-
sb_issue_discard(sb, discard_block, entry->count);
2568-
}
25692570
kmem_cache_free(ext4_free_ext_cachep, entry);
25702571
ext4_mb_release_desc(&e4b);
25712572
}

0 commit comments

Comments
 (0)