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

+14 -11
+1
fs/ext4/extents.c
··· 3879 3879 physical += offset; 3880 3880 length = EXT4_SB(inode->i_sb)->s_inode_size - offset; 3881 3881 flags |= FIEMAP_EXTENT_DATA_INLINE; 3882 + brelse(iloc.bh); 3882 3883 } else { /* external block */ 3883 3884 physical = EXT4_I(inode)->i_file_acl << blockbits; 3884 3885 length = inode->i_sb->s_blocksize;
+2 -1
fs/ext4/inode.c
··· 5375 5375 } else { 5376 5376 struct ext4_iloc iloc; 5377 5377 5378 - err = ext4_get_inode_loc(inode, &iloc); 5378 + err = __ext4_get_inode_loc(inode, &iloc, 0); 5379 5379 if (err) 5380 5380 return err; 5381 5381 if (wbc->sync_mode == WB_SYNC_ALL) ··· 5386 5386 (unsigned long long)iloc.bh->b_blocknr); 5387 5387 err = -EIO; 5388 5388 } 5389 + brelse(iloc.bh); 5389 5390 } 5390 5391 return err; 5391 5392 }
+11 -10
fs/ext4/mballoc.c
··· 2535 2535 mb_debug(1, "gonna free %u blocks in group %u (0x%p):", 2536 2536 entry->count, entry->group, entry); 2537 2537 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 + 2538 2549 err = ext4_mb_load_buddy(sb, entry->group, &e4b); 2539 2550 /* we expect to find existing buddy because it's pinned */ 2540 2551 BUG_ON(err != 0); ··· 2567 2556 page_cache_release(e4b.bd_bitmap_page); 2568 2557 } 2569 2558 ext4_unlock_group(sb, entry->group); 2570 - if (test_opt(sb, DISCARD)) { 2571 - ext4_fsblk_t discard_block; 2572 - 2573 - discard_block = entry->start_blk + 2574 - ext4_group_first_block_no(sb, entry->group); 2575 - trace_ext4_discard_blocks(sb, 2576 - (unsigned long long)discard_block, 2577 - entry->count); 2578 - sb_issue_discard(sb, discard_block, entry->count); 2579 - } 2580 2559 kmem_cache_free(ext4_free_ext_cachep, entry); 2581 2560 ext4_mb_release_desc(&e4b); 2582 2561 }