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>
This commit is contained in:
zhangyi (F) 2017-11-01 18:40:45 +08:00 committed by Jan Kara
parent cb91775711
commit dd5f627973
1 changed files with 9 additions and 2 deletions

View File

@ -644,8 +644,15 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
spin_unlock(&dq_list_lock); spin_unlock(&dq_list_lock);
dqstats_inc(DQST_LOOKUPS); dqstats_inc(DQST_LOOKUPS);
err = sb->dq_op->write_dquot(dquot); err = sb->dq_op->write_dquot(dquot);
if (!ret && err) if (err) {
ret = err; /*
* Clear dirty bit anyway to avoid infinite
* loop here.
*/
clear_dquot_dirty(dquot);
if (!ret)
ret = err;
}
dqput(dquot); dqput(dquot);
spin_lock(&dq_list_lock); spin_lock(&dq_list_lock);
} }