Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ext4: fix the number of credits needed for ext4_unlink() and ext4_rmdir()

The ext4_unlink() and ext4_rmdir() don't actually release the blocks
associated with the file/directory. This gets done in a separate jbd2
handle called via ext4_evict_inode(). Thus, we don't need to reserve
lots of journal credits for the truncate.

Note that using too many journal credits is non-optimal because it can
leading to the journal transmit getting closed too early, before it is
strictly necessary.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reviewed-by: Jan Kara <jack@suse.cz>

+2 -8
-6
fs/ext4/ext4_jbd2.h
··· 59 59 #define EXT4_META_TRANS_BLOCKS(sb) (EXT4_XATTR_TRANS_BLOCKS + \ 60 60 EXT4_MAXQUOTAS_TRANS_BLOCKS(sb)) 61 61 62 - /* Delete operations potentially hit one directory's namespace plus an 63 - * entire inode, plus arbitrary amounts of bitmap/indirection data. Be 64 - * generous. We can grow the delete transaction later if necessary. */ 65 - 66 - #define EXT4_DELETE_TRANS_BLOCKS(sb) (2 * EXT4_DATA_TRANS_BLOCKS(sb) + 64) 67 - 68 62 /* Define an arbitrary limit for the amount of data we will anticipate 69 63 * writing to any given transaction. For unbounded transactions such as 70 64 * write(2) and truncate(2) we can write more than this, but we always
+2 -2
fs/ext4/namei.c
··· 2748 2748 goto end_rmdir; 2749 2749 2750 2750 handle = ext4_journal_start(dir, EXT4_HT_DIR, 2751 - EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); 2751 + EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); 2752 2752 if (IS_ERR(handle)) { 2753 2753 retval = PTR_ERR(handle); 2754 2754 handle = NULL; ··· 2811 2811 goto end_unlink; 2812 2812 2813 2813 handle = ext4_journal_start(dir, EXT4_HT_DIR, 2814 - EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); 2814 + EXT4_DATA_TRANS_BLOCKS(dir->i_sb)); 2815 2815 if (IS_ERR(handle)) { 2816 2816 retval = PTR_ERR(handle); 2817 2817 handle = NULL;