linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Yunlong Song <yunlong.song@huawei.com>
Cc: cm224.lee@samsung.com, yuchao0@huawei.com, chao@kernel.org,
	sylinux@163.com, bintian.wang@huawei.com,
	linux-fsdevel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: fix small discards when se->valid_blocks is zero
Date: Tue, 3 Jan 2017 17:55:10 -0800	[thread overview]
Message-ID: <20170104015510.GB16504@jaegeuk.local> (raw)
In-Reply-To: <1483434117-24427-1-git-send-email-yunlong.song@huawei.com>

Hi Yunlong,

On 01/03, Yunlong Song wrote:
> In the small discard case, when se->valid_blocks is zero, the add_discard_addrs
> will directly return without __add_discard_entry. This will cause the file
> delete have no small discard. The case is like this:
> 
> 1. Allocate free 2M segment
> 2. Write a file (size n blocks < 512) in that 2M segment, se->valid_blocks = n
> 3. Delete that file, se->valid_blocks = 0, add_discard_addrs will return without
> sending any discard of that file, and forever due to cur_map[i] ^ ckpt_map[i] =
> 0 after that checkpoint

During this checkpoint, that'll be discarded as a prefree segment, no?
Note that, if this is a current segment, f2fs won't discard it until it is
fully allocated.

Thanks,

> 
> Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
> ---
>  fs/f2fs/segment.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index 0738f48..8610f14 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -838,7 +838,7 @@ static void add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc)
>  		return;
>  
>  	if (!force) {
> -		if (!test_opt(sbi, DISCARD) || !se->valid_blocks ||
> +		if (!test_opt(sbi, DISCARD) ||
>  		    SM_I(sbi)->nr_discards >= SM_I(sbi)->max_discards)
>  			return;
>  	}
> -- 
> 1.8.5.2

  parent reply	other threads:[~2017-01-04  2:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-03  9:01 [PATCH] f2fs: fix small discards when se->valid_blocks is zero Yunlong Song
2017-01-04  1:54 ` Chao Yu
2017-01-04  1:55 ` Jaegeuk Kim [this message]
2017-01-04  3:59   ` Yunlong Song
2017-01-04 22:36     ` Jaegeuk Kim
2017-01-05  2:38       ` Yunlong Song

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=20170104015510.GB16504@jaegeuk.local \
    --to=jaegeuk@kernel.org \
    --cc=bintian.wang@huawei.com \
    --cc=chao@kernel.org \
    --cc=cm224.lee@samsung.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sylinux@163.com \
    --cc=yuchao0@huawei.com \
    --cc=yunlong.song@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;
as well as URLs for NNTP newsgroup(s).