[RHEL7,COMMIT] ms/quota: fix potential infinite loop

Submitted by Konstantin Khorenko on Jan. 30, 2020, 7:26 p.m.

Details

Message ID 202001301926.00UJQodt015227@finist-ce7.sw.ru
State New
Series "Series without cover letter"
Headers show

Commit Message

Konstantin Khorenko Jan. 30, 2020, 7:26 p.m.
The commit is pushed to "branch-rh7-3.10.0-1062.7.1.vz7.130.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1062.7.1.vz7.130.13
------>
commit 5f0a533594e844b134aeba3a92fd2659189af9cc
Author: zhangyi (F) <yi.zhang@huawei.com>
Date:   Thu Jan 30 22:26:50 2020 +0300

    ms/quota: fix potential infinite loop
    
    In dquot_writeback_dquots(), we write back dquot from dirty dquots
    list. There is a potential infinite loop if ->write_dquot() failure
    and forget remove dquot from the list. This patch clear dirty bit
    anyway to avoid it.
    
    Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
    Signed-off-by: Jan Kara <jack@suse.cz>
    
    https://jira.sw.ru/browse/PSBM-101043
    (cherry picked from commit dd5f6279732e8885061d7455b9d86fdcfdf7f183)
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 fs/quota/dquot.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 989dce79fa12b..d6c710c39a2af 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -633,8 +633,15 @@  int dquot_writeback_dquots(struct super_block *sb, int type)
 			spin_unlock(&dq_list_lock);
 			dqstats_inc(DQST_LOOKUPS);
 			err = sb->dq_op->write_dquot(dquot);
-			if (!ret && err)
-				ret = err;
+			if (err) {
+				/*
+				 * Clear dirty bit anyway to avoid infinite
+				 * loop here.
+				 */
+				clear_dquot_dirty(dquot);
+				if (!ret)
+					ret = err;
+			}
 			dqput(dquot);
 			spin_lock(&dq_list_lock);
 		}