mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Chao Yu <yuchao0@huawei.com>
Cc: linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, chao@kernel.org
Subject: Re: [PATCH v2] f2fs: give another chance to issue discard with current granularity
Date: Fri, 6 Jul 2018 15:49:02 -0700	[thread overview]
Message-ID: <20180706224902.GD77984@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <20180705061551.2961-1-yuchao0@huawei.com>

On 07/05, Chao Yu wrote:
> If discard IOs are blocked by user IO, do not skip to select and issue
> discard with lower granularity, retry with current granularity.

We need to stop as soon as possible since user activity comes. Later, discard
thread will try it again in another idle time. What's your concern?

> 
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> v2:
> - fix deadloop.
>  fs/f2fs/segment.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 1f9ae8270f86..6e2b2e717a40 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1191,7 +1191,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
>  	struct discard_cmd *dc, *tmp;
>  	struct blk_plug plug;
>  	int i, iter = 0, issued = 0;
> -	bool io_interrupted = false;
> +	bool io_interrupted = false, end_up = false;
>  
>  	for (i = MAX_PLIST_NUM - 1; i >= 0; i--) {
>  		if (i + 1 < dpolicy->granularity)
> @@ -1199,6 +1199,7 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
>  		pend_list = &dcc->pend_list[i];
>  
>  		mutex_lock(&dcc->cmd_lock);
> +retry:
>  		if (list_empty(pend_list))
>  			goto next;
>  		if (unlikely(dcc->rbtree_check))
> @@ -1217,14 +1218,23 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
>  			__submit_discard_cmd(sbi, dpolicy, dc);
>  			issued++;
>  skip:
> -			if (++iter >= dpolicy->max_requests)
> +			if (++iter >= dpolicy->max_requests) {
> +				end_up = true;
>  				break;
> +			}
>  		}
>  		blk_finish_plug(&plug);
> +
> +		/*
> +		 * if discard IO was interrupted by user IOs, give another
> +		 * chance to issue discard with current granularity.
> +		 */
> +		if (io_interrupted && !end_up)
> +			goto retry;
>  next:
>  		mutex_unlock(&dcc->cmd_lock);
>  
> -		if (iter >= dpolicy->max_requests)
> +		if (end_up)
>  			break;
>  	}
>  
> -- 
> 2.18.0.rc1

  reply	other threads:[~2018-07-06 22:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-05  6:15 Chao Yu
2018-07-06 22:49 ` Jaegeuk Kim [this message]
2018-07-07  0:00   ` Chao Yu
2018-07-07  1:10     ` Jaegeuk Kim
2018-07-07  1:42       ` Chao Yu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180706224902.GD77984@jaegeuk-macbookpro.roam.corp.google.com \
    --to=jaegeuk@kernel.org \
    --cc=chao@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuchao0@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®