Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp533232rwb; Wed, 9 Nov 2022 05:52:37 -0800 (PST) X-Google-Smtp-Source: AMsMyM6PfygHeLLY64cUInJXA8Uzmy5SzxQa2UMZBKyA8j+41/O+kzIh6VH06kir9BR2O5u4iEUk X-Received: by 2002:a17:903:494:b0:186:a227:436f with SMTP id jj20-20020a170903049400b00186a227436fmr60776774plb.133.1668001957596; Wed, 09 Nov 2022 05:52:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668001957; cv=none; d=google.com; s=arc-20160816; b=U3VsxhGltBsXD1NXlM6Cg3/2Sc5T5DuULLSMmb5/XE0z5Ooen8kaD915fiHxqfV7TT gp2ofGmrXD33jpHmD3RcVObAdeEdrcri/VPxtnlUeSFVnXUtYmM6Zfmobs33qt5JEHbx wY1CqC10dCDfxnRKTCbMhtn9PxMD14n2iV6hofnD1b79mK/wIl5eJPvuUjWTeu3A4sbF pjR3/lTpEJVJwvmBhRNWRIcLsYpz2ryesT65H1+V51WykI/yQzlCyAMLc95LJ2bo6meO KH1SjGgThrBWhJocsnRYQ4pRLoXvtC07FNP2E8Dts6sE3aCVZ8rcrLH3Ezq4iegk07ao 7wnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=/2QugQ7qiD72tQ18q/uoHEafoxX1jEX/ixxmyE9OGJ0=; b=tWJLWldzJDPcyB9jM56n2y8Fuwh1nxYw8Q5m+py3GhNUXEeeulPow/v6eksZxI+D7X oPN1yWqHv+hsMszCgeYToXTGZUL+aV+eGVMm1VnnKTRmrhmxkvUF338cS0HXQ8SHNQGP GOEdLvvt1fpjztlbAYL1kPu02PRpYOj50DemNuDc63MjYdt94z18ZR2YFjNCDTThSAC/ PHRaGI1WLswHzfrTTuColOVHFDbAQfKC4ZZtWyXQrxipBoza9QmPyAuYTkscuyPe5TYf +dxkr3MA/pkrKxm7Y4p8X7bMutk15IVMn4vfT2HO94p6k7HW5g4gCO2OqBGhCO+vUz44 bmeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aJdGIOYj; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y18-20020a1709027c9200b0017a0f71990dsi15662095pll.141.2022.11.09.05.52.25; Wed, 09 Nov 2022 05:52:37 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=aJdGIOYj; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229936AbiKINkG (ORCPT + 92 others); Wed, 9 Nov 2022 08:40:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229733AbiKINkE (ORCPT ); Wed, 9 Nov 2022 08:40:04 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73D9B233A3 for ; Wed, 9 Nov 2022 05:40:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1022161AB2 for ; Wed, 9 Nov 2022 13:40:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 097A0C433D6; Wed, 9 Nov 2022 13:40:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668001202; bh=R5D/mual96ln/JPqzbIm8Tg82MFVZP6ncu4epnJxztA=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=aJdGIOYjXTenNHND7xhh42IpIgD3S6NE0OECKL14T4to7SrNmNm6EFryNC0YjdQf7 rf/VJngQZhIV/cqxtmB7XegrcJ5PCNjHgG1aI2RkHYmrkskJCI9limk+T90nVFnd/a nFPo/gJEQ8rkNa1uXnOGvK5qOXCCZGPkV9ZL77TQNC2UTQvXWgLRFP/Q1/6Ql3UCOd GR4H8yRztwpfS4PH/ZdEQtmvUdFCg21VkLuhYIccMdZYNrrIIeGCCrV/ndFz3TWXqz 9BSBhKOSoXR1SlMyj/tfjvod+FZ2egpCI5x0TeEb7I3Gr1DGy/xo3zBps4fAw2LwUE u/Pu2f4mHfkSg== Message-ID: <8fe7450e-6d21-e85a-c6dc-89134206b264@kernel.org> Date: Wed, 9 Nov 2022 21:39:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH] f2fs: separate IPU policy for fdatasync from F2FS_IPU_FSYNC Content-Language: en-US To: qixiaoyu , Jaegeuk Kim Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, qixiaoyu1 References: <20221021023136.22863-1-qixiaoyu1@xiaomi.com> <20221102122518.GB22857@mi-HP-ProDesk-680-G4-MT> <3d2b1141-995a-4bfb-4bf0-5227be25105a@kernel.org> <20221108123218.GC22857@mi-HP-ProDesk-680-G4-MT> <8368702c-ae33-b810-a6c3-ac8fa29998df@kernel.org> <20221109125605.GD22857@mi-HP-ProDesk-680-G4-MT> From: Chao Yu In-Reply-To: <20221109125605.GD22857@mi-HP-ProDesk-680-G4-MT> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_HI,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: X-Mailing-List: linux-kernel@vger.kernel.org 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 >>>>>>> --- >>>>>>> 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);