All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] quota: fix potential infinite loop
@ 2017-11-01 10:40 zhangyi (F)
  2017-11-01 13:43 ` Jan Kara
  0 siblings, 1 reply; 2+ messages in thread
From: zhangyi (F) @ 2017-11-01 10:40 UTC (permalink / raw)
  To: linux-fsdevel; +Cc: jack, yi.zhang, miaoxie, guoxuenan

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>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] quota: fix potential infinite loop
  2017-11-01 10:40 [PATCH] quota: fix potential infinite loop zhangyi (F)
@ 2017-11-01 13:43 ` Jan Kara
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Kara @ 2017-11-01 13:43 UTC (permalink / raw)
  To: zhangyi (F); +Cc: linux-fsdevel, jack, miaoxie, guoxuenan

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) <yi.zhang@huawei.com>

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 <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-11-01 13:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-01 10:40 [PATCH] quota: fix potential infinite loop zhangyi (F)
2017-11-01 13:43 ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.