mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <yuchao0@huawei.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>,
	Sahitya Tummala <stummala@codeaurora.org>
Cc: <linux-f2fs-devel@lists.sourceforge.net>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] f2fs: prevent meta updates while checkpoint is in progress
Date: Sat, 28 Mar 2020 16:38:00 +0800	[thread overview]
Message-ID: <397da8a6-fdb4-9637-c6ea-803492c408a2@huawei.com> (raw)
In-Reply-To: <20200327192412.GA186975@google.com>

Hi all,

On 2020/3/28 3:24, Jaegeuk Kim wrote:
> Hi Sahitya,
> 
> On 03/26, Sahitya Tummala wrote:
>> allocate_segment_for_resize() can cause metapage updates if
>> it requires to change the current node/data segments for resizing.
>> Stop these meta updates when there is a checkpoint already
>> in progress to prevent inconsistent CP data.
> 
> Doesn't freeze|thaw_bdev(sbi->sb->s_bdev); work for you?

That can avoid foreground ops racing? rather than background ops like
balance_fs() from kworker?

BTW, I found that {freeze,thaw}_bdev is not enough to freeze all
foreground fs ops, it needs to use {freeze,thaw}_super instead.

---
 fs/f2fs/gc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 26248c8936db..acdc8b99b543 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -1538,7 +1538,7 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 		return -EINVAL;
 	}

-	freeze_bdev(sbi->sb->s_bdev);
+	freeze_super(sbi->sb);

 	shrunk_blocks = old_block_count - block_count;
 	secs = div_u64(shrunk_blocks, BLKS_PER_SEC(sbi));
@@ -1551,7 +1551,7 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 		sbi->user_block_count -= shrunk_blocks;
 	spin_unlock(&sbi->stat_lock);
 	if (err) {
-		thaw_bdev(sbi->sb->s_bdev, sbi->sb);
+		thaw_super(sbi->sb);
 		return err;
 	}

@@ -1613,6 +1613,6 @@ int f2fs_resize_fs(struct f2fs_sb_info *sbi, __u64 block_count)
 	}
 	clear_sbi_flag(sbi, SBI_IS_RESIZEFS);
 	mutex_unlock(&sbi->resize_mutex);
-	thaw_bdev(sbi->sb->s_bdev, sbi->sb);
+	thaw_super(sbi->sb);
 	return err;
 }
-- 
2.18.0.rc1

> 
>>
>> Signed-off-by: Sahitya Tummala <stummala@codeaurora.org>
>> ---
>>  fs/f2fs/gc.c | 2 ++
>>  1 file changed, 2 insertions(+)
>>
>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
>> index 5bca560..6122bad 100644
>> --- a/fs/f2fs/gc.c
>> +++ b/fs/f2fs/gc.c
>> @@ -1399,8 +1399,10 @@ static int free_segment_range(struct f2fs_sb_info *sbi, unsigned int start,
>>  	int err = 0;
>>  
>>  	/* Move out cursegs from the target range */
>> +	f2fs_lock_op(sbi);
>>  	for (type = CURSEG_HOT_DATA; type < NR_CURSEG_TYPE; type++)
>>  		allocate_segment_for_resize(sbi, type, start, end);
>> +	f2fs_unlock_op(sbi);
>>  
>>  	/* do GC to move out valid blocks in the range */
>>  	for (segno = start; segno <= end; segno += sbi->segs_per_sec) {
>> -- 
>> Qualcomm India Private Limited, on behalf of Qualcomm Innovation Center, Inc.
>> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project.
> .
> 

  reply	other threads:[~2020-03-28  8:38 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-26 10:36 Sahitya Tummala
2020-03-27 19:24 ` Jaegeuk Kim
2020-03-28  8:38   ` Chao Yu [this message]
2020-03-30  8:40     ` Sahitya Tummala
2020-03-30 18:34       ` Jaegeuk Kim
2020-03-31  0:58 ` Chao Yu
2020-03-31  3:54 ` Jaegeuk Kim
2020-03-31  9:06   ` Sahitya Tummala
2020-03-31 18:43     ` Jaegeuk Kim
2020-04-01  2:54       ` Chao Yu
2020-04-03 16:20         ` Jaegeuk Kim
2020-04-01  5:08       ` Sahitya Tummala
2020-04-03 17:17         ` Jaegeuk Kim
2020-04-03 17:27           ` [f2fs-dev] " Jaegeuk Kim
2020-04-07  2:34             ` Chao Yu
2020-04-07  2:58               ` Jaegeuk Kim
2020-04-07  3:21                 ` Chao Yu
2020-04-09  2:25                   ` Jaegeuk Kim
2020-04-13 17:42             ` Jaegeuk Kim
2020-04-14  9:58               ` Sahitya Tummala
2020-04-14 11:44               ` Chao Yu
2020-04-14 13:44               ` Jaegeuk Kim
2020-04-16  7:04                 ` Chao Yu
2020-04-16 21:40                 ` Jaegeuk Kim
2020-04-17  7:26                   ` Chao Yu
2020-04-17 16:15                     ` Jaegeuk Kim
2020-04-20 11:37                       ` Sahitya Tummala
2020-04-20 15:52                         ` Jaegeuk Kim

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=397da8a6-fdb4-9637-c6ea-803492c408a2@huawei.com \
    --to=yuchao0@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stummala@codeaurora.org \
    /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®