Message ID | 20221021023136.22863-1-qixiaoyu1@xiaomi.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp441280wrr; Thu, 20 Oct 2022 19:37:39 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5TVT9LcVNdrEGV1IQU++AVjUydkraiEHMZwANFbWAi9NmTq6FxPkUQXkIbHNCeN1rTqpEb X-Received: by 2002:a17:90b:4f46:b0:20d:1fe8:dcd2 with SMTP id pj6-20020a17090b4f4600b0020d1fe8dcd2mr54928231pjb.235.1666319859407; Thu, 20 Oct 2022 19:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666319859; cv=none; d=google.com; s=arc-20160816; b=iGkqq3PwcYN3voGwwMIVMxembS3BVsfXPe9v/6nypSCUys+QKwmF1ttP8zZBrtGnz1 PAUW0EUH4iYWVo0XEOa+D5JpYCJzxAh99fy6MVhEkk3w6Vye6E2jnHK1sv40TF5junCL hMnFZ9hEBHkSyUanACbxe1zUFL693PH/YQwdzBpGMM5gzh3X+zGTRsG6qyhmTkeW3r25 6ej2ePDu9QXqQkq1kdBIQJ/7I4Dnb1NRaN9kNL27a1Onhm2OZdHVaKWFrHh0c68nL+2t id060iNZ6vKOn/e4z3e9Xeby0Da0ryV4QemoA//oyseD6MLU7cKdADyug+gU+1Ptjbtk Jeiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EsvLhV+cbznBpgyq6mtNJgNZycGH3T3tCrg6LonEOp4=; b=j4f8tx+Y4CI92oVdHPYuZH+lVkoVwZTeLoxD7b9j34U5GsWMlNM1+mttkr/niqumIm +Ln82g9wo3hVSZoxUWlJ8rLcfJ+U+PUQIDi+KTJTPEepUS4w55idigoVr7Px/p51LR8j zLusdEloGFVuKIK9yQkxdWoJppOwZNLa6rD2kXrpUjjLCsg25z1dS/1wHtT2aQa0pWMf xCeFFhLmUT8K9MMMcKSjSyg9KVq1uPWxSvSqMboSAqi6D2SFrEtJnfPe/VWTWKC3MPG/ gBVHjnkqfMPIb8XY5iv3UiM5tcSOpEcbnfe9NmUvS+h4UH/WEvb/g4Z20wn9AFnfSgq2 32hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="j/PynzD1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a637541000000b0045a2b6e23b6si24590823pgn.290.2022.10.20.19.37.27; Thu, 20 Oct 2022 19:37:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="j/PynzD1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbiJUCca (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Thu, 20 Oct 2022 22:32:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbiJUCc2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 20 Oct 2022 22:32:28 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBC4810F891 for <linux-kernel@vger.kernel.org>; Thu, 20 Oct 2022 19:32:27 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id f8-20020a17090a664800b00212464cd49fso1470917pjm.4 for <linux-kernel@vger.kernel.org>; Thu, 20 Oct 2022 19:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EsvLhV+cbznBpgyq6mtNJgNZycGH3T3tCrg6LonEOp4=; b=j/PynzD1zbRkpecTxyYqHEf9VOlhdAnPFJOV+1z+gFkB1FSq6HINXXtTMGuFuIo6Ep wEQl2D20Ee1cv5aTkporTtwe1KX0xnjVB6MRsj5mecJRoCDoG0OyB663+yD0NRGrxC2n Wj61WEZrQUN9h6rOa7UpVVm+goCuZjsCSElc/VBeiDJvdjyNp6cFoc5JaZlCj6rKVBWe mrahL6X5dThTNxDZ0uSvimWvEHIM7ToHfEcJ4rD7Wqvc/AVQiiRkyq02KQ87OM7lzVt1 1LKIjfxxR0cpcrkZS+dcv3HhTYsjuDY5Qf8G60IcL5OnioJ/qJr9awS47USK4Vsqa9Pq UrVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EsvLhV+cbznBpgyq6mtNJgNZycGH3T3tCrg6LonEOp4=; b=1VZ9ILD+xhkxvQNJDjbGEFxwAfgZZqfXCdKDWsrEljppsz3M/8qIYZnoOMZQeAyywW 4NUJbO1hTo78Isw5Mw48g+lwIfULplQGzXHjoOb2dRQV4c/0Eq7UhdTNymGafPtM1+1M qfoXVs9GW1RJwRf/FmfCMrsEscuM4Q7vflyCKbUl/uwRdFQwWoh1Ewwkg/AEu80IdvbJ PZyKoQ3rmj6aMv2+Da44lH9TyQBSM32M/DxzARno/lk6CntGJiz1yvmpD3v1gn9q/e/G rxAtJUqYtqWBQZJIH7xH6e/PoX8FIBm9N084s+KwH3GyElo2QaQm6FtgJudFOtTlvt7o CtRA== X-Gm-Message-State: ACrzQf1/JiDgyfYnuqD8cZnCLxXLhW28ACV8saBdMBKyGFhuLgWaRDeQ USW/WUXOjVbJDakUKiAzcoQ= X-Received: by 2002:a17:902:ed93:b0:185:4421:24b with SMTP id e19-20020a170902ed9300b001854421024bmr16735349plj.158.1666319547482; Thu, 20 Oct 2022 19:32:27 -0700 (PDT) Received: from mi-HP-ProDesk-680-G4-MT.mioffice.cn ([43.224.245.252]) by smtp.gmail.com with ESMTPSA id v129-20020a626187000000b00565f4efbc0csm1291080pfb.49.2022.10.20.19.32.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Oct 2022 19:32:25 -0700 (PDT) From: qixiaoyu1 <qxy65535@gmail.com> X-Google-Original-From: qixiaoyu1 <qixiaoyu1@xiaomi.com> To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org> Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, qixiaoyu1 <qixiaoyu1@xiaomi.com> Subject: [PATCH] f2fs: separate IPU policy for fdatasync from F2FS_IPU_FSYNC Date: Fri, 21 Oct 2022 10:31:36 +0800 Message-Id: <20221021023136.22863-1-qixiaoyu1@xiaomi.com> X-Mailer: git-send-email 2.36.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747263013160077340?= X-GMAIL-MSGID: =?utf-8?q?1747263013160077340?= |
Series |
f2fs: separate IPU policy for fdatasync from F2FS_IPU_FSYNC
|
|
Commit Message
qixiaoyu1
Oct. 21, 2022, 2:31 a.m. UTC
Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC.
Fix to apply it to all IPU policy.
Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com>
---
fs/f2fs/data.c | 8 +++-----
fs/f2fs/file.c | 4 +++-
2 files changed, 6 insertions(+), 6 deletions(-)
Comments
Friendly ping... On Fri, Oct 21, 2022 at 10:31:36AM +0800, qixiaoyu1 wrote: > Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. > Fix to apply it to all IPU policy. > > Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> > --- > fs/f2fs/data.c | 8 +++----- > fs/f2fs/file.c | 4 +++- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index a71e818cd67b..fec8e15fe820 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, > if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && > is_inode_flag_set(inode, FI_OPU_WRITE)) > return false; > + /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ > + if (is_inode_flag_set(inode, FI_NEED_IPU)) > + return true; > if (policy & (0x1 << F2FS_IPU_FORCE)) > return true; > if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) > @@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, > !IS_ENCRYPTED(inode)) > return true; > > - /* this is only set during fdatasync */ > - if (policy & (0x1 << F2FS_IPU_FSYNC) && > - is_inode_flag_set(inode, FI_NEED_IPU)) > - return true; > - > if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && > !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) > return true; > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 82cda1258227..08091550cdf2 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > goto go_write; > > /* if fdatasync is triggered, let's do in-place-update */ > - if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > + if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && > + get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) > set_inode_flag(inode, FI_NEED_IPU); > + > ret = file_write_and_wait_range(file, start, end); > clear_inode_flag(inode, FI_NEED_IPU); > > -- > 2.36.1 >
On 2022/10/21 10:31, qixiaoyu1 wrote: > Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. > Fix to apply it to all IPU policy. Xiaoyu, Sorry for the delay. I didn't get the point, can you please explain more about the issue? Thanks, > > Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> > --- > fs/f2fs/data.c | 8 +++----- > fs/f2fs/file.c | 4 +++- > 2 files changed, 6 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index a71e818cd67b..fec8e15fe820 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, > if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && > is_inode_flag_set(inode, FI_OPU_WRITE)) > return false; > + /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ > + if (is_inode_flag_set(inode, FI_NEED_IPU)) > + return true; > if (policy & (0x1 << F2FS_IPU_FORCE)) > return true; > if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) > @@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, > !IS_ENCRYPTED(inode)) > return true; > > - /* this is only set during fdatasync */ > - if (policy & (0x1 << F2FS_IPU_FSYNC) && > - is_inode_flag_set(inode, FI_NEED_IPU)) > - return true; > - > if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && > !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) > return true; > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > index 82cda1258227..08091550cdf2 100644 > --- a/fs/f2fs/file.c > +++ b/fs/f2fs/file.c > @@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > goto go_write; > > /* if fdatasync is triggered, let's do in-place-update */ > - if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > + if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && > + get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) > set_inode_flag(inode, FI_NEED_IPU); > + > ret = file_write_and_wait_range(file, start, end); > clear_inode_flag(inode, FI_NEED_IPU); >
Hi Chao, fdatasync do in-place-update to avoid additional node writes, but currently it only do that with F2FS_IPU_FSYNC as: f2fs_do_sync_file: if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) set_inode_flag(inode, FI_NEED_IPU); check_inplace_update_policy: /* this is only set during fdatasync */ if (policy & (0x1 << F2FS_IPU_FSYNC) && is_inode_flag_set(inode, FI_NEED_IPU)) return true; So this patch separate in-place-update of fdatasync from F2FS_IPU_FSYNC to apply it to all IPU policy. BTW, we found small performance improvement with this patch on AndroBench app using F2FS_IPU_SSR_UTIL on our product: F2FS_IPU_FSYNC F2FS_IPU_SSR_UTIL F2FS_IPU_SSR_UTIL(with patch) SQLite Insert(QPS) 6818.08 6327.09(-7.20%) 6757.72 SQLite Update(QPS) 6528.81 6336.57(-2.94%) 6490.77 SQLite Delete(QPS) 9724.68 9378.37(-3.56%) 9622.27 Thanks On Tue, Nov 01, 2022 at 11:14:55PM +0800, Chao Yu wrote: > On 2022/10/21 10:31, qixiaoyu1 wrote: > >Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. > >Fix to apply it to all IPU policy. > > Xiaoyu, > > Sorry for the delay. > > I didn't get the point, can you please explain more about the > issue? > > Thanks, > > > > >Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> > >--- > > fs/f2fs/data.c | 8 +++----- > > fs/f2fs/file.c | 4 +++- > > 2 files changed, 6 insertions(+), 6 deletions(-) > > > >diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > >index a71e818cd67b..fec8e15fe820 100644 > >--- a/fs/f2fs/data.c > >+++ b/fs/f2fs/data.c > >@@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, > > if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && > > is_inode_flag_set(inode, FI_OPU_WRITE)) > > return false; > >+ /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ > >+ if (is_inode_flag_set(inode, FI_NEED_IPU)) > >+ return true; > > if (policy & (0x1 << F2FS_IPU_FORCE)) > > return true; > > if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) > >@@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, > > !IS_ENCRYPTED(inode)) > > return true; > >- /* this is only set during fdatasync */ > >- if (policy & (0x1 << F2FS_IPU_FSYNC) && > >- is_inode_flag_set(inode, FI_NEED_IPU)) > >- return true; > >- > > if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && > > !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) > > return true; > >diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > >index 82cda1258227..08091550cdf2 100644 > >--- a/fs/f2fs/file.c > >+++ b/fs/f2fs/file.c > >@@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > > goto go_write; > > /* if fdatasync is triggered, let's do in-place-update */ > >- if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > >+ if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && > >+ get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) > > set_inode_flag(inode, FI_NEED_IPU); > >+ > > ret = file_write_and_wait_range(file, start, end); > > clear_inode_flag(inode, FI_NEED_IPU);
On 2022/11/2 20:25, qixiaoyu wrote: > Hi Chao, > > fdatasync do in-place-update to avoid additional node writes, but currently > it only do that with F2FS_IPU_FSYNC as: > > f2fs_do_sync_file: > if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > set_inode_flag(inode, FI_NEED_IPU); > > check_inplace_update_policy: > /* this is only set during fdatasync */ > if (policy & (0x1 << F2FS_IPU_FSYNC) && > is_inode_flag_set(inode, FI_NEED_IPU)) > return true; > > So this patch separate in-place-update of fdatasync from F2FS_IPU_FSYNC to > apply it to all IPU policy. > > BTW, we found small performance improvement with this patch on AndroBench app > using F2FS_IPU_SSR_UTIL on our product: How this patch affects performance when F2FS_IPU_SSR_UTIL is on? Thanks, > > F2FS_IPU_FSYNC F2FS_IPU_SSR_UTIL F2FS_IPU_SSR_UTIL(with patch) > SQLite Insert(QPS) 6818.08 6327.09(-7.20%) 6757.72 > SQLite Update(QPS) 6528.81 6336.57(-2.94%) 6490.77 > SQLite Delete(QPS) 9724.68 9378.37(-3.56%) 9622.27 > > Thanks > > On Tue, Nov 01, 2022 at 11:14:55PM +0800, Chao Yu wrote: >> On 2022/10/21 10:31, qixiaoyu1 wrote: >>> Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. >>> Fix to apply it to all IPU policy. >> >> Xiaoyu, >> >> Sorry for the delay. >> >> I didn't get the point, can you please explain more about the >> issue? >> >> Thanks, >> >>> >>> Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> >>> --- >>> fs/f2fs/data.c | 8 +++----- >>> fs/f2fs/file.c | 4 +++- >>> 2 files changed, 6 insertions(+), 6 deletions(-) >>> >>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>> index a71e818cd67b..fec8e15fe820 100644 >>> --- a/fs/f2fs/data.c >>> +++ b/fs/f2fs/data.c >>> @@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, >>> if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && >>> is_inode_flag_set(inode, FI_OPU_WRITE)) >>> return false; >>> + /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ >>> + if (is_inode_flag_set(inode, FI_NEED_IPU)) >>> + return true; >>> if (policy & (0x1 << F2FS_IPU_FORCE)) >>> return true; >>> if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) >>> @@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, >>> !IS_ENCRYPTED(inode)) >>> return true; >>> - /* this is only set during fdatasync */ >>> - if (policy & (0x1 << F2FS_IPU_FSYNC) && >>> - is_inode_flag_set(inode, FI_NEED_IPU)) >>> - return true; >>> - >>> if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && >>> !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) >>> return true; >>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>> index 82cda1258227..08091550cdf2 100644 >>> --- a/fs/f2fs/file.c >>> +++ b/fs/f2fs/file.c >>> @@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, >>> goto go_write; >>> /* if fdatasync is triggered, let's do in-place-update */ >>> - if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) >>> + if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && >>> + get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) >>> set_inode_flag(inode, FI_NEED_IPU); >>> + >>> ret = file_write_and_wait_range(file, start, end); >>> clear_inode_flag(inode, FI_NEED_IPU);
On Sun, Nov 06, 2022 at 09:54:59PM +0800, Chao Yu wrote: > On 2022/11/2 20:25, qixiaoyu wrote: > >Hi Chao, > > > >fdatasync do in-place-update to avoid additional node writes, but currently > >it only do that with F2FS_IPU_FSYNC as: > > > >f2fs_do_sync_file: > > if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > > set_inode_flag(inode, FI_NEED_IPU); > > > >check_inplace_update_policy: > > /* this is only set during fdatasync */ > > if (policy & (0x1 << F2FS_IPU_FSYNC) && > > is_inode_flag_set(inode, FI_NEED_IPU)) > > return true; > > > >So this patch separate in-place-update of fdatasync from F2FS_IPU_FSYNC to > >apply it to all IPU policy. > > > >BTW, we found small performance improvement with this patch on AndroBench app > >using F2FS_IPU_SSR_UTIL on our product: > > How this patch affects performance when F2FS_IPU_SSR_UTIL is on? > > Thanks, > SQLite test in AndroBench app use fdatasync to sync file to the disk. When switch to F2FS_IPU_SSR_UTIL ipu_policy, it will use out-of-place-update even though SQLite calls fdatasync, which will introduce extra meta data write. Thanks. > > > > F2FS_IPU_FSYNC F2FS_IPU_SSR_UTIL F2FS_IPU_SSR_UTIL(with patch) > >SQLite Insert(QPS) 6818.08 6327.09(-7.20%) 6757.72 > >SQLite Update(QPS) 6528.81 6336.57(-2.94%) 6490.77 > >SQLite Delete(QPS) 9724.68 9378.37(-3.56%) 9622.27 > > > >Thanks > > > >On Tue, Nov 01, 2022 at 11:14:55PM +0800, Chao Yu wrote: > >>On 2022/10/21 10:31, qixiaoyu1 wrote: > >>>Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. > >>>Fix to apply it to all IPU policy. > >> > >>Xiaoyu, > >> > >>Sorry for the delay. > >> > >>I didn't get the point, can you please explain more about the > >>issue? > >> > >>Thanks, > >> > >>> > >>>Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> > >>>--- > >>> fs/f2fs/data.c | 8 +++----- > >>> fs/f2fs/file.c | 4 +++- > >>> 2 files changed, 6 insertions(+), 6 deletions(-) > >>> > >>>diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > >>>index a71e818cd67b..fec8e15fe820 100644 > >>>--- a/fs/f2fs/data.c > >>>+++ b/fs/f2fs/data.c > >>>@@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, > >>> if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && > >>> is_inode_flag_set(inode, FI_OPU_WRITE)) > >>> return false; > >>>+ /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ > >>>+ if (is_inode_flag_set(inode, FI_NEED_IPU)) > >>>+ return true; > >>> if (policy & (0x1 << F2FS_IPU_FORCE)) > >>> return true; > >>> if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) > >>>@@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, > >>> !IS_ENCRYPTED(inode)) > >>> return true; > >>>- /* this is only set during fdatasync */ > >>>- if (policy & (0x1 << F2FS_IPU_FSYNC) && > >>>- is_inode_flag_set(inode, FI_NEED_IPU)) > >>>- return true; > >>>- > >>> if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && > >>> !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) > >>> return true; > >>>diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > >>>index 82cda1258227..08091550cdf2 100644 > >>>--- a/fs/f2fs/file.c > >>>+++ b/fs/f2fs/file.c > >>>@@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > >>> goto go_write; > >>> /* if fdatasync is triggered, let's do in-place-update */ > >>>- if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > >>>+ if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && > >>>+ get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) > >>> set_inode_flag(inode, FI_NEED_IPU); > >>>+ > >>> ret = file_write_and_wait_range(file, start, end); > >>> clear_inode_flag(inode, FI_NEED_IPU);
On 2022/11/8 20:32, qixiaoyu wrote: > On Sun, Nov 06, 2022 at 09:54:59PM +0800, Chao Yu wrote: >> On 2022/11/2 20:25, qixiaoyu wrote: >>> Hi Chao, >>> >>> fdatasync do in-place-update to avoid additional node writes, but currently >>> it only do that with F2FS_IPU_FSYNC as: >>> >>> f2fs_do_sync_file: >>> if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) >>> set_inode_flag(inode, FI_NEED_IPU); >>> >>> check_inplace_update_policy: >>> /* this is only set during fdatasync */ >>> if (policy & (0x1 << F2FS_IPU_FSYNC) && >>> is_inode_flag_set(inode, FI_NEED_IPU)) >>> return true; >>> >>> So this patch separate in-place-update of fdatasync from F2FS_IPU_FSYNC to >>> apply it to all IPU policy. >>> >>> BTW, we found small performance improvement with this patch on AndroBench app >>> using F2FS_IPU_SSR_UTIL on our product: >> >> How this patch affects performance when F2FS_IPU_SSR_UTIL is on? >> >> Thanks, >> > > SQLite test in AndroBench app use fdatasync to sync file to the disk. > When switch to F2FS_IPU_SSR_UTIL ipu_policy, it will use out-of-place-update > even though SQLite calls fdatasync, which will introduce extra meta data write. Why not using F2FS_IPU_SSR_UTIL | F2FS_IPU_FSYNC, I guess these two flags cover different scenarios, F2FS_IPU_SSR_UTIL for ssr case, and F2FS_IPU_FSYNC for f{data,}sync case. Thanks, > > Thanks. > >>> >>> F2FS_IPU_FSYNC F2FS_IPU_SSR_UTIL F2FS_IPU_SSR_UTIL(with patch) >>> SQLite Insert(QPS) 6818.08 6327.09(-7.20%) 6757.72 >>> SQLite Update(QPS) 6528.81 6336.57(-2.94%) 6490.77 >>> SQLite Delete(QPS) 9724.68 9378.37(-3.56%) 9622.27 >>> >>> Thanks >>> >>> On Tue, Nov 01, 2022 at 11:14:55PM +0800, Chao Yu wrote: >>>> On 2022/10/21 10:31, qixiaoyu1 wrote: >>>>> Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. >>>>> Fix to apply it to all IPU policy. >>>> >>>> Xiaoyu, >>>> >>>> Sorry for the delay. >>>> >>>> I didn't get the point, can you please explain more about the >>>> issue? >>>> >>>> Thanks, >>>> >>>>> >>>>> Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> >>>>> --- >>>>> fs/f2fs/data.c | 8 +++----- >>>>> fs/f2fs/file.c | 4 +++- >>>>> 2 files changed, 6 insertions(+), 6 deletions(-) >>>>> >>>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>>> index a71e818cd67b..fec8e15fe820 100644 >>>>> --- a/fs/f2fs/data.c >>>>> +++ b/fs/f2fs/data.c >>>>> @@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, >>>>> if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && >>>>> is_inode_flag_set(inode, FI_OPU_WRITE)) >>>>> return false; >>>>> + /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ >>>>> + if (is_inode_flag_set(inode, FI_NEED_IPU)) >>>>> + return true; >>>>> if (policy & (0x1 << F2FS_IPU_FORCE)) >>>>> return true; >>>>> if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) >>>>> @@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, >>>>> !IS_ENCRYPTED(inode)) >>>>> return true; >>>>> - /* this is only set during fdatasync */ >>>>> - if (policy & (0x1 << F2FS_IPU_FSYNC) && >>>>> - is_inode_flag_set(inode, FI_NEED_IPU)) >>>>> - return true; >>>>> - >>>>> if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && >>>>> !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) >>>>> return true; >>>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>>>> index 82cda1258227..08091550cdf2 100644 >>>>> --- a/fs/f2fs/file.c >>>>> +++ b/fs/f2fs/file.c >>>>> @@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, >>>>> goto go_write; >>>>> /* if fdatasync is triggered, let's do in-place-update */ >>>>> - if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) >>>>> + if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && >>>>> + get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) >>>>> set_inode_flag(inode, FI_NEED_IPU); >>>>> + >>>>> ret = file_write_and_wait_range(file, start, end); >>>>> clear_inode_flag(inode, FI_NEED_IPU);
On Tue, Nov 08, 2022 at 10:30:13PM +0800, Chao Yu wrote: > On 2022/11/8 20:32, qixiaoyu wrote: > >On Sun, Nov 06, 2022 at 09:54:59PM +0800, Chao Yu wrote: > >>On 2022/11/2 20:25, qixiaoyu wrote: > >>>Hi Chao, > >>> > >>>fdatasync do in-place-update to avoid additional node writes, but currently > >>>it only do that with F2FS_IPU_FSYNC as: > >>> > >>>f2fs_do_sync_file: > >>> if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > >>> set_inode_flag(inode, FI_NEED_IPU); > >>> > >>>check_inplace_update_policy: > >>> /* this is only set during fdatasync */ > >>> if (policy & (0x1 << F2FS_IPU_FSYNC) && > >>> is_inode_flag_set(inode, FI_NEED_IPU)) > >>> return true; > >>> > >>>So this patch separate in-place-update of fdatasync from F2FS_IPU_FSYNC to > >>>apply it to all IPU policy. > >>> > >>>BTW, we found small performance improvement with this patch on AndroBench app > >>>using F2FS_IPU_SSR_UTIL on our product: > >> > >>How this patch affects performance when F2FS_IPU_SSR_UTIL is on? > >> > >>Thanks, > >> > > > >SQLite test in AndroBench app use fdatasync to sync file to the disk. > >When switch to F2FS_IPU_SSR_UTIL ipu_policy, it will use out-of-place-update > >even though SQLite calls fdatasync, which will introduce extra meta data write. > > Why not using F2FS_IPU_SSR_UTIL | F2FS_IPU_FSYNC, I guess these two flags > cover different scenarios, F2FS_IPU_SSR_UTIL for ssr case, and F2FS_IPU_FSYNC > for f{data,}sync case. > > Thanks, > As fsync(2) says: fdatasync() is similar to fsync(), but does not flush modified metadata unless that metadata is needed in order to allow a subsequent data retrieval to be correctly handled. I think fdatasync should try to perform in-place-update to avoid unnecessary metadata update whatever the ipu_policy is, and F2FS_IPU_FSYNC is used for fsync independently. Thanks > > > >Thanks. > > > >>> > >>> F2FS_IPU_FSYNC F2FS_IPU_SSR_UTIL F2FS_IPU_SSR_UTIL(with patch) > >>>SQLite Insert(QPS) 6818.08 6327.09(-7.20%) 6757.72 > >>>SQLite Update(QPS) 6528.81 6336.57(-2.94%) 6490.77 > >>>SQLite Delete(QPS) 9724.68 9378.37(-3.56%) 9622.27 > >>> > >>>Thanks > >>> > >>>On Tue, Nov 01, 2022 at 11:14:55PM +0800, Chao Yu wrote: > >>>>On 2022/10/21 10:31, qixiaoyu1 wrote: > >>>>>Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. > >>>>>Fix to apply it to all IPU policy. > >>>> > >>>>Xiaoyu, > >>>> > >>>>Sorry for the delay. > >>>> > >>>>I didn't get the point, can you please explain more about the > >>>>issue? > >>>> > >>>>Thanks, > >>>> > >>>>> > >>>>>Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> > >>>>>--- > >>>>> fs/f2fs/data.c | 8 +++----- > >>>>> fs/f2fs/file.c | 4 +++- > >>>>> 2 files changed, 6 insertions(+), 6 deletions(-) > >>>>> > >>>>>diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > >>>>>index a71e818cd67b..fec8e15fe820 100644 > >>>>>--- a/fs/f2fs/data.c > >>>>>+++ b/fs/f2fs/data.c > >>>>>@@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, > >>>>> if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && > >>>>> is_inode_flag_set(inode, FI_OPU_WRITE)) > >>>>> return false; > >>>>>+ /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ > >>>>>+ if (is_inode_flag_set(inode, FI_NEED_IPU)) > >>>>>+ return true; > >>>>> if (policy & (0x1 << F2FS_IPU_FORCE)) > >>>>> return true; > >>>>> if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) > >>>>>@@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, > >>>>> !IS_ENCRYPTED(inode)) > >>>>> return true; > >>>>>- /* this is only set during fdatasync */ > >>>>>- if (policy & (0x1 << F2FS_IPU_FSYNC) && > >>>>>- is_inode_flag_set(inode, FI_NEED_IPU)) > >>>>>- return true; > >>>>>- > >>>>> if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && > >>>>> !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) > >>>>> return true; > >>>>>diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > >>>>>index 82cda1258227..08091550cdf2 100644 > >>>>>--- a/fs/f2fs/file.c > >>>>>+++ b/fs/f2fs/file.c > >>>>>@@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, > >>>>> goto go_write; > >>>>> /* if fdatasync is triggered, let's do in-place-update */ > >>>>>- if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) > >>>>>+ if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && > >>>>>+ get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) > >>>>> set_inode_flag(inode, FI_NEED_IPU); > >>>>>+ > >>>>> ret = file_write_and_wait_range(file, start, end); > >>>>> clear_inode_flag(inode, FI_NEED_IPU);
On 2022/11/9 20:56, qixiaoyu wrote: > On Tue, Nov 08, 2022 at 10:30:13PM +0800, Chao Yu wrote: >> On 2022/11/8 20:32, qixiaoyu wrote: >>> On Sun, Nov 06, 2022 at 09:54:59PM +0800, Chao Yu wrote: >>>> On 2022/11/2 20:25, qixiaoyu wrote: >>>>> Hi Chao, >>>>> >>>>> fdatasync do in-place-update to avoid additional node writes, but currently >>>>> it only do that with F2FS_IPU_FSYNC as: >>>>> >>>>> f2fs_do_sync_file: >>>>> if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) >>>>> set_inode_flag(inode, FI_NEED_IPU); >>>>> >>>>> check_inplace_update_policy: >>>>> /* this is only set during fdatasync */ >>>>> if (policy & (0x1 << F2FS_IPU_FSYNC) && >>>>> is_inode_flag_set(inode, FI_NEED_IPU)) >>>>> return true; >>>>> >>>>> So this patch separate in-place-update of fdatasync from F2FS_IPU_FSYNC to >>>>> apply it to all IPU policy. >>>>> >>>>> BTW, we found small performance improvement with this patch on AndroBench app >>>>> using F2FS_IPU_SSR_UTIL on our product: >>>> >>>> How this patch affects performance when F2FS_IPU_SSR_UTIL is on? >>>> >>>> Thanks, >>>> >>> >>> SQLite test in AndroBench app use fdatasync to sync file to the disk. >>> When switch to F2FS_IPU_SSR_UTIL ipu_policy, it will use out-of-place-update >>> even though SQLite calls fdatasync, which will introduce extra meta data write. >> >> Why not using F2FS_IPU_SSR_UTIL | F2FS_IPU_FSYNC, I guess these two flags >> cover different scenarios, F2FS_IPU_SSR_UTIL for ssr case, and F2FS_IPU_FSYNC >> for f{data,}sync case. >> >> Thanks, >> > > As fsync(2) says: > fdatasync() is similar to fsync(), but does not flush modified metadata unless that > metadata is needed in order to allow a subsequent data retrieval to be correctly handled. I guess it says it allows fdatasync to flush metatdata in order to recovery data in SPO case. > > I think fdatasync should try to perform in-place-update to avoid unnecessary metadata > update whatever the ipu_policy is, and F2FS_IPU_FSYNC is used for fsync independently. IMO, FSYNC key word in F2FS_IPU_FSYNC means fsync path or interface name as below: int (*fsync) (struct file *, loff_t, loff_t, int datasync); And by default, f2fs enables F2FS_IPU_FSYNC, I didn't get why we need to disable it. To Jaegeuk, any comments? Thanks, > > Thanks > >>> >>> Thanks. >>> >>>>> >>>>> F2FS_IPU_FSYNC F2FS_IPU_SSR_UTIL F2FS_IPU_SSR_UTIL(with patch) >>>>> SQLite Insert(QPS) 6818.08 6327.09(-7.20%) 6757.72 >>>>> SQLite Update(QPS) 6528.81 6336.57(-2.94%) 6490.77 >>>>> SQLite Delete(QPS) 9724.68 9378.37(-3.56%) 9622.27 >>>>> >>>>> Thanks >>>>> >>>>> On Tue, Nov 01, 2022 at 11:14:55PM +0800, Chao Yu wrote: >>>>>> On 2022/10/21 10:31, qixiaoyu1 wrote: >>>>>>> Currently IPU policy for fdatasync is coupled with F2FS_IPU_FSYNC. >>>>>>> Fix to apply it to all IPU policy. >>>>>> >>>>>> Xiaoyu, >>>>>> >>>>>> Sorry for the delay. >>>>>> >>>>>> I didn't get the point, can you please explain more about the >>>>>> issue? >>>>>> >>>>>> Thanks, >>>>>> >>>>>>> >>>>>>> Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com> >>>>>>> --- >>>>>>> fs/f2fs/data.c | 8 +++----- >>>>>>> fs/f2fs/file.c | 4 +++- >>>>>>> 2 files changed, 6 insertions(+), 6 deletions(-) >>>>>>> >>>>>>> diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c >>>>>>> index a71e818cd67b..fec8e15fe820 100644 >>>>>>> --- a/fs/f2fs/data.c >>>>>>> +++ b/fs/f2fs/data.c >>>>>>> @@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, >>>>>>> if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && >>>>>>> is_inode_flag_set(inode, FI_OPU_WRITE)) >>>>>>> return false; >>>>>>> + /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ >>>>>>> + if (is_inode_flag_set(inode, FI_NEED_IPU)) >>>>>>> + return true; >>>>>>> if (policy & (0x1 << F2FS_IPU_FORCE)) >>>>>>> return true; >>>>>>> if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) >>>>>>> @@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, >>>>>>> !IS_ENCRYPTED(inode)) >>>>>>> return true; >>>>>>> - /* this is only set during fdatasync */ >>>>>>> - if (policy & (0x1 << F2FS_IPU_FSYNC) && >>>>>>> - is_inode_flag_set(inode, FI_NEED_IPU)) >>>>>>> - return true; >>>>>>> - >>>>>>> if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && >>>>>>> !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) >>>>>>> return true; >>>>>>> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c >>>>>>> index 82cda1258227..08091550cdf2 100644 >>>>>>> --- a/fs/f2fs/file.c >>>>>>> +++ b/fs/f2fs/file.c >>>>>>> @@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, >>>>>>> goto go_write; >>>>>>> /* if fdatasync is triggered, let's do in-place-update */ >>>>>>> - if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) >>>>>>> + if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && >>>>>>> + get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) >>>>>>> set_inode_flag(inode, FI_NEED_IPU); >>>>>>> + >>>>>>> ret = file_write_and_wait_range(file, start, end); >>>>>>> clear_inode_flag(inode, FI_NEED_IPU);
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index a71e818cd67b..fec8e15fe820 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2518,6 +2518,9 @@ static inline bool check_inplace_update_policy(struct inode *inode, if (policy & (0x1 << F2FS_IPU_HONOR_OPU_WRITE) && is_inode_flag_set(inode, FI_OPU_WRITE)) return false; + /* this is set by fdatasync or F2FS_IPU_FSYNC policy */ + if (is_inode_flag_set(inode, FI_NEED_IPU)) + return true; if (policy & (0x1 << F2FS_IPU_FORCE)) return true; if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi)) @@ -2538,11 +2541,6 @@ static inline bool check_inplace_update_policy(struct inode *inode, !IS_ENCRYPTED(inode)) return true; - /* this is only set during fdatasync */ - if (policy & (0x1 << F2FS_IPU_FSYNC) && - is_inode_flag_set(inode, FI_NEED_IPU)) - return true; - if (unlikely(fio && is_sbi_flag_set(sbi, SBI_CP_DISABLED) && !f2fs_is_checkpointed_data(sbi, fio->old_blkaddr))) return true; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 82cda1258227..08091550cdf2 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -270,8 +270,10 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end, goto go_write; /* if fdatasync is triggered, let's do in-place-update */ - if (datasync || get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks) + if (datasync || (SM_I(sbi)->ipu_policy & (0x1 << F2FS_IPU_FSYNC) && + get_dirty_pages(inode) <= SM_I(sbi)->min_fsync_blocks)) set_inode_flag(inode, FI_NEED_IPU); + ret = file_write_and_wait_range(file, start, end); clear_inode_flag(inode, FI_NEED_IPU);