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] f2fs: avoid race between zero_range and background GC
Date: Fri, 27 Jul 2018 19:29:16 +0900 [thread overview]
Message-ID: <20180727102916.GI16155@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <20180726104536.114340-1-yuchao0@huawei.com>
On 07/26, Chao Yu wrote:
> Thread A Background GC
> - f2fs_zero_range
> - truncate_pagecache_range
> - gc_data_segment
> - get_read_data_page
> - move_data_page
> - set_page_dirty
> - set_cold_data
> - f2fs_do_zero_range
> - dn->data_blkaddr = NEW_ADDR;
> - f2fs_set_data_blkaddr
>
> Actually, we don't need to set dirty & checked flag on the page, since
> all valid data in the page should be zeroed by zero_range().
But, it doesn't matter too much, right?
> Use i_gc_rwsem[WRITE] to avoid such race condition.
Hope to avoid abusing i_gc_rwsem[] tho.
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> fs/f2fs/file.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 267ec3794e1e..7bd2412a8c37 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1309,6 +1309,7 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
> if (ret)
> return ret;
>
> + down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
> down_write(&F2FS_I(inode)->i_mmap_sem);
> ret = filemap_write_and_wait_range(mapping, offset, offset + len - 1);
> if (ret)
> @@ -1389,6 +1390,7 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
> }
> out_sem:
> up_write(&F2FS_I(inode)->i_mmap_sem);
> + up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
>
> return ret;
> }
> --
> 2.18.0.rc1
next prev parent reply other threads:[~2018-07-27 10:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-26 10:45 Chao Yu
2018-07-27 10:29 ` Jaegeuk Kim [this message]
2018-07-27 12:16 ` Chao Yu
2018-07-29 2:02 ` Jaegeuk Kim
2018-07-29 2:53 ` Chao Yu
2018-07-29 2:59 ` Jaegeuk Kim
2018-07-29 3:03 ` Chao Yu
2018-07-29 5:14 ` Jaegeuk Kim
2018-07-30 1:38 ` [f2fs-dev] " Jaegeuk Kim
2018-07-30 1:55 ` 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=20180727102916.GI16155@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®