linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ext4: deaccount delayed allocations at freeing inode in ext4_evict_inode()
@ 2019-10-29  7:17 Konstantin Khlebnikov
  2019-10-29  7:20 ` Konstantin Khlebnikov
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Konstantin Khlebnikov @ 2019-10-29  7:17 UTC (permalink / raw)
  To: Andreas Dilger, linux-ext4, Theodore Ts'o, linux-kernel
  Cc: Dmitry Monakhov, Eric Whitney

If inode->i_blocks is zero then ext4_evict_inode() skips ext4_truncate().
Delayed allocation extents are freed later in ext4_clear_inode() but this
happens when quota reference is already dropped. This leads to leak of
reserved space in quota block, which disappears after umount-mount.

This seems broken for a long time but worked somehow until recent changes
in delayed allocation.

Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
---
 fs/ext4/inode.c |    9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 516faa280ced..580898145e8f 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -293,6 +293,15 @@ void ext4_evict_inode(struct inode *inode)
 				   inode->i_ino, err);
 			goto stop_handle;
 		}
+	} else if (EXT4_I(inode)->i_reserved_data_blocks) {
+		/* Deaccount reserve if inode has only delayed allocations. */
+		err = ext4_es_remove_extent(inode, 0, EXT_MAX_BLOCKS);
+		if (err) {
+			ext4_warning(inode->i_sb,
+				     "couldn't remove extents %lu (err %d)",
+				     inode->i_ino, err);
+			goto stop_handle;
+		}
 	}
 
 	/* Remove xattr references. */


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-11-15  0:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-29  7:17 [PATCH] ext4: deaccount delayed allocations at freeing inode in ext4_evict_inode() Konstantin Khlebnikov
2019-10-29  7:20 ` Konstantin Khlebnikov
2019-11-07 17:58 ` Konstantin Khlebnikov
2019-11-08  2:08 ` Ritesh Harjani
2019-11-08  8:30   ` Konstantin Khlebnikov
2019-11-08 11:54     ` Jan Kara
2019-11-15  0:27       ` Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).