]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
ext4: fix reserved space counter leakage
authorJeffle Xu <jefflexu@linux.alibaba.com>
Mon, 23 Aug 2021 06:13:58 +0000 (14:13 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 5 Nov 2021 08:12:50 +0000 (09:12 +0100)
commit0347924f0dd26bac645b08d8b7d1e84be925beec
tree3e3d4e30258389a157d9b497f19316e5f7e5fc38
parente607ac0485515b9aded139cab02bac1154634398
ext4: fix reserved space counter leakage

BugLink: https://bugs.launchpad.net/bugs/1947888
commit 6fed83957f21eff11c8496e9f24253b03d2bc1dc upstream.

When ext4_insert_delayed block receives and recovers from an error from
ext4_es_insert_delayed_block(), e.g., ENOMEM, it does not release the
space it has reserved for that block insertion as it should. One effect
of this bug is that s_dirtyclusters_counter is not decremented and
remains incorrectly elevated until the file system has been unmounted.
This can result in premature ENOSPC returns and apparent loss of free
space.

Another effect of this bug is that
/sys/fs/ext4/<dev>/delayed_allocation_blocks can remain non-zero even
after syncfs has been executed on the filesystem.

Besides, add check for s_dirtyclusters_counter when inode is going to be
evicted and freed. s_dirtyclusters_counter can still keep non-zero until
inode is written back in .evict_inode(), and thus the check is delayed
to .destroy_inode().

Fixes: 51865fda28e5 ("ext4: let ext4 maintain extent status tree")
Cc: stable@kernel.org
Suggested-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20210823061358.84473-1-jefflexu@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/ext4/inode.c
fs/ext4/super.c