Skip to content

Commit f4c2d37

Browse files
jankaratytso
authored andcommitted
ext4: fix leak of quota reservations
Commit 8fcc3a5 ("ext4: rework reserved cluster accounting when invalidating pages") moved freeing of delayed allocation reservations from dirty page invalidation time to time when we evict corresponding status extent from extent status tree. For inodes which don't have any blocks allocated this may actually happen only in ext4_clear_blocks() which is after we've dropped references to quota structures from the inode. Thus reservation of quota leaked. Fix the problem by clearing quota information from the inode only after evicting extent status tree in ext4_clear_inode(). Link: https://lore.kernel.org/r/20191108115420.GI20863@quack2.suse.cz Reported-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Fixes: 8fcc3a5 ("ext4: rework reserved cluster accounting when invalidating pages") Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 1e1a76e commit f4c2d37

2 files changed

Lines changed: 1 addition & 6 deletions

File tree

‎fs/ext4/ialloc.c‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,8 @@ void ext4_free_inode(handle_t *handle, struct inode *inode)
265265
ext4_debug("freeing inode %lu\n", ino);
266266
trace_ext4_free_inode(inode);
267267

268-
/*
269-
* Note: we must free any quota before locking the superblock,
270-
* as writing the quota to disk may need the lock as well.
271-
*/
272268
dquot_initialize(inode);
273269
dquot_free_inode(inode);
274-
dquot_drop(inode);
275270

276271
is_directory = S_ISDIR(inode->i_mode);
277272

‎fs/ext4/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,9 +1172,9 @@ void ext4_clear_inode(struct inode *inode)
11721172
{
11731173
invalidate_inode_buffers(inode);
11741174
clear_inode(inode);
1175-
dquot_drop(inode);
11761175
ext4_discard_preallocations(inode);
11771176
ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
1177+
dquot_drop(inode);
11781178
if (EXT4_I(inode)->jinode) {
11791179
jbd2_journal_release_jbd_inode(EXT4_JOURNAL(inode),
11801180
EXT4_I(inode)->jinode);

0 commit comments

Comments
 (0)