[RHEL7,COMMIT] ext4: writecounters leak in ext4_convert_unwritten_extents()

Submitted by Konstantin Khorenko on May 22, 2020, 10:37 a.m.

Details

Message ID 202005221037.04MAb5We030093@finist-ce7.sw.ru
State New
Series "ext4: writecounters leak in ext4_convert_unwritten_extents()"
Headers show

Commit Message

Konstantin Khorenko May 22, 2020, 10:37 a.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.151.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.151.4
------>
commit 9f50c56e038585e8a1e0e0978074b7ddfdfe0ffb
Author: Vasily Averin <vvs@virtuozzo.com>
Date:   Fri May 22 13:37:04 2020 +0300

    ext4: writecounters leak in ext4_convert_unwritten_extents()
    
    sb_start_intwrite() increased sb.s_writers counter
    but balanced sb_end_intwrite() was not called.
    As result fs_freeze attempt can hang forever.
    
    Fixes e86034daac1898 ("ext4: fix race aio-dio vs freeze_fs")
    
    https://jira.sw.ru/browse/PSBM-104084
    Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
---
 fs/ext4/extents.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 2c2bc9d220989..78dd03a0453c4 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -5088,8 +5088,10 @@  int ext4_convert_unwritten_extents(handle_t *handle, struct inode *inode,
 	if (handle) {
 		handle = ext4_journal_start_reserved(handle,
 						     EXT4_HT_EXT_CONVERT);
-		if (IS_ERR(handle))
+		if (IS_ERR(handle)) {
+			sb_end_intwrite(inode->i_sb);
 			return PTR_ERR(handle);
+		}
 		credits = 0;
 	} else {
 		/*