Return-Path: Received: from mx2.suse.de ([195.135.220.15]:57533 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751738AbdKANnM (ORCPT ); Wed, 1 Nov 2017 09:43:12 -0400 Date: Wed, 1 Nov 2017 14:43:10 +0100 From: Jan Kara To: "zhangyi (F)" Cc: linux-fsdevel@vger.kernel.org, jack@suse.cz, miaoxie@huawei.com, guoxuenan@huawei.com Subject: Re: [PATCH] quota: fix potential infinite loop Message-ID: <20171101134310.GA28572@quack2.suse.cz> References: <20171101104045.31753-1-yi.zhang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171101104045.31753-1-yi.zhang@huawei.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Wed 01-11-17 18:40:45, zhangyi (F) wrote: > 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) Thanks. Added to my tree. Honza > --- > fs/quota/dquot.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c > index 52ad151..7ff0080 100644 > --- a/fs/quota/dquot.c > +++ b/fs/quota/dquot.c > @@ -644,8 +644,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); > } > -- > 2.9.5 > -- Jan Kara SUSE Labs, CR