Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp847387pxb; Wed, 25 Aug 2021 17:17:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyyhlWTo46GYvX8gLTs96B797E80bnKwjgjGA2WhWPksDbEdf3Oh8wgtPwRsfrwjmk93ZfV X-Received: by 2002:a6b:b883:: with SMTP id i125mr850453iof.144.1629937027230; Wed, 25 Aug 2021 17:17:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629937027; cv=none; d=google.com; s=arc-20160816; b=nkJVph4zXMuEvV6XdRMzWUWrPter3+Mk80ACV4eEVty6Vw1YmjURsLbocFeJGRjcwP XkEkGyN1iu47dbYFUuwL+gX+75l+n+85cI3ubF/gcG6isb7PZsFS00VLZIARF9lV3Tov P+J9ME+wYgyQVkXrMBnauYfE/Pda0hNjTjFjdL7IxEYCv7XI104eN0bdgCSnVBdJMKAD fvQBNKjuGogzX7Z5fs2iIWYQr/Xuaq0DYbRBBPpU433NJhqPVGtNnRItQ3M9ECGdzA2Z hJo5PHFGEBBPtgNETl5980bFeZNsqZ3MytG4pdXZnCxwLD+0vQ2zyKklbHRv9gpsRNwE jddg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=g07kk3xhnLUynCkv3h4HALjGXnyjiOEbpKz99JpYfoA=; b=ZITrrYuC+5YFA7A4qSe1bZY2ePxfe+8iAL3ieqHUvF/wZY/yj1hbTwtfqmHj6HiPjT EKlsdaQ2/te5nF9eNaq6y9eIVGEQoA1tgmf8G5EvBveuVFWvLD0v7UZMjl+7+3MZrbwz L33FBTsppSX25mIc40NnyH0CCP4Dbojd5FJhS5UwBd6HqCQjLnSo6wxih/+xhhbhCC7E 1+vTQd8fp+POHirkxVoJzdFK0WFWP4u9dqW1wZRl/iyjrE/AoFj8wwhov1/Y6i/T9CUY TljdiwawtchHW8XNTOr1pHK4xd5cXh1xB3ofDLr8/Sw9dZ8vRUJ/eIDkPpApx8NLCcvl 5gWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GEDWdVTn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b13si1184058ilq.35.2021.08.25.17.16.55; Wed, 25 Aug 2021 17:17:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GEDWdVTn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234739AbhHZARB (ORCPT + 99 others); Wed, 25 Aug 2021 20:17:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:50018 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234205AbhHZARA (ORCPT ); Wed, 25 Aug 2021 20:17:00 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 35B3160F39; Thu, 26 Aug 2021 00:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629936973; bh=0ngJr9PpMHfpAYd6Uit3Fbbi1EtpGFDiQCW/shNirk4=; h=Subject:To:References:From:Date:In-Reply-To:From; b=GEDWdVTn1JAJ8v2Z18tJPMDEjntyAxEDV3AVH91IBl7pGNBI/QOBanw1L9MuRFtK1 3D6uFqQPhI1DMTHsshtvydeo06QPKw8Nv+fdS329n29L9pq/aITwfwzDDyheyUL0S1 mTQVtSMwD+Eey4MfcoG4t8JVJkzfV1gIXAqDPBTrBEIJKj4H3T/XqBM/WFpq68XnNU bhC8seMC1LcESlfooRJALK0br01Gnv7Q74DeQU0yvOkBTo9KQgf2S04Qapj7J9Jcsl olDzgeAlfpcPaNiFiHFI2FYXpa0yW5qLdsMTkQtAB1Kf0/C+exE/Zzy4vTDrwOu6ph 4Yvxr3WZoziCw== Subject: Re: [f2fs-dev] [PATCH v2] f2fs: don't ignore writing pages on fsync during checkpoint=disable To: Jaegeuk Kim , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net References: <20210823170151.1434772-1-jaegeuk@kernel.org> From: Chao Yu Message-ID: Date: Thu, 26 Aug 2021 08:16:12 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/8/26 5:33, Jaegeuk Kim wrote: > We must flush all the dirty data when enabling checkpoint back. Let's guarantee > that first. In order to mitigate any failure, let's flush data in fsync as well > during checkpoint=disable. It needs to update comments a bit with respect to update part of v2? > > Signed-off-by: Jaegeuk Kim > --- > v2 from v1: > - handle sync_inodes_sb() failure > > fs/f2fs/file.c | 5 ++--- > fs/f2fs/super.c | 11 ++++++++++- > 2 files changed, 12 insertions(+), 4 deletions(-) > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index cc2080866c54..3330efb41f22 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -263,8 +263,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > }; > unsigned int seq_id = 0; > > - if (unlikely(f2fs_readonly(inode->i_sb) || > - is_sbi_flag_set(sbi, SBI_CP_DISABLED))) > + if (unlikely(f2fs_readonly(inode->i_sb))) > return 0; > > trace_f2fs_sync_file_enter(inode); > @@ -278,7 +277,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > ret = file_write_and_wait_range(file, start, end); > clear_inode_flag(inode, FI_NEED_IPU); > > - if (ret) { > + if (ret || is_sbi_flag_set(sbi, SBI_CP_DISABLED)) { > trace_f2fs_sync_file_exit(inode, cp_reason, datasync, ret); > return ret; > } > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 49e153fd8183..d2f97dfb17af 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -2088,8 +2088,17 @@ static int f2fs_disable_checkpoint(struct f2fs_sb_info *sbi) > > static void f2fs_enable_checkpoint(struct f2fs_sb_info *sbi) > { > + int retry = DEFAULT_RETRY_IO_COUNT; > + > /* we should flush all the data to keep data consistency */ > - sync_inodes_sb(sbi->sb); > + do { > + sync_inodes_sb(sbi->sb); > + cond_resched(); > + congestion_wait(BLK_RW_ASYNC, DEFAULT_IO_TIMEOUT); > + } while (get_pages(sbi, F2FS_DIRTY_DATA) && retry--); > + > + if (unlikely(!retry)) Well, if we break the loop due to retry-- == 0, value of retry will be -1 here. So should be: if (unlikely(retry < 0)) Thanks, > + f2fs_warn(sbi, "checkpoint=enable has some unwritten data."); > > down_write(&sbi->gc_lock); > f2fs_dirty_to_prefree(sbi); >