On 10/29/19 12:47 PM, Konstantin Khlebnikov wrote:
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.
Sorry, I may have missed it, but could you please help understand
what recent changes in delayed allocation make this break or worse?
A silly query, since I couldn't figure it out. Maybe the code has been
there ever since like this:-
So why can't we just move drop_dquot later after the ext4_es_remove_extent() (in function ext4_clear_inode)? Any known
problems around that?
-ritesh
Signed-off-by: Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx>
---
 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. */