From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADFF8C4332F for ; Fri, 29 Oct 2021 17:43:47 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 67EAC61038 for ; Fri, 29 Oct 2021 17:43:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 67EAC61038 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.94.2) (envelope-from ) id 1mgVur-0000xf-Uq; Fri, 29 Oct 2021 17:43:46 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mgVuq-0000xY-FV for linux-f2fs-devel@lists.sourceforge.net; Fri, 29 Oct 2021 17:43:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Transfer-Encoding:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=pj4a1+I88NFqPE/JyEQR+FLPbZuzCd7+8bOb8HPS5p0=; b=iMmi8RZ8ED94cx7bWGXbTvn0mT wwPyH6+wd/19AhXxRcOI4R3Ss+8EdpQ1LbQmtjmCVi9V83+7zWCXI/0JiVjVXQZYiqgld2KpWSD4R aE+ppgsC1KQcI+Mi8J/ui5qvrezw4wTdsEDMTEkNk6DAq4YgD4hfm3Ib2x/Od6PKH0tg=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=pj4a1+I88NFqPE/JyEQR+FLPbZuzCd7+8bOb8HPS5p0=; b=erLM/9Klw8t7xlLQe5Y5uk2Vm1 GOs6Q7BSqoEoAEtoVuhYhbQ31wepExYKC1P1XbH767xWaCARr1lEeCuWE1sWA8eEX7tYmk3trs1z7 RRBWtoUp8IhiK0raMrzTf71/MpYN30a7aPNk76frWdBLqgqHR/gMIIwdlAeMF3Oaj4Vk=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mgVuj-0005p6-V4 for linux-f2fs-devel@lists.sourceforge.net; Fri, 29 Oct 2021 17:43:44 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 92B7A61040; Fri, 29 Oct 2021 17:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635529407; bh=rsaoqoFMJRkFW8HbI1/g5SAhlNrxOJ2ODlLw2rtjQVw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TWI+jjY0ML1p9Nw0Dtl1KOyq5HJqk87BImQU70Cl4KdrO+WFa4/1eXJxAHGo0I3B1 P/NvnMbfHSuOP2R46KsW2PdDpFH+Ejzgy2WcXm8VdW+MoO8hklvBq403DcDAKYxGDV mHxsKA5ZC4yWlQanMq8jCrM8qWeXEku+Kg22esQqwvs1SMJSMjIlaZ5R1n656tYy3b Lx5l4t9du+GMlRyUCeJsgwxECQ88Oq1feTNOL4xZBJ0gQ0YwGpafGfCWUZB7L8YPix ksi7CCHYMIS34CwUiqSHNy3RC+DlXPwoPjbQWjjzyX44QJPRpzSWY2aJhdtHO45LE4 YcDzGXpMmMTQA== Date: Fri, 29 Oct 2021 10:43:26 -0700 From: Jaegeuk Kim To: Chao Yu Message-ID: References: <20210928151911.11189-1-chao@kernel.org> <65f6c366-9e5b-fe7f-7c38-061996d1882b@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1mgVuj-0005p6-V4 Subject: Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 10/29, Chao Yu wrote: > Ping, > = > On 2021/9/29 8:05, Chao Yu wrote: > > On 2021/9/29 3:08, Jaegeuk Kim wrote: > > > On 09/28, Chao Yu wrote: > > > > In f2fs_file_write_iter(), let's use f2fs_overwrite_io() to > > > > check whethere it is overwrite case, for such case, we can skip > > > > f2fs_preallocate_blocks() in order to avoid f2fs_do_map_lock(), > > > > which may be blocked by checkpoint() potentially. > > > > = > > > > Signed-off-by: Chao Yu > > > > --- > > > > =A0 fs/f2fs/file.c | 4 ++++ > > > > =A0 1 file changed, 4 insertions(+) > > > > = > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > > > index 13deae03df06..51fecb2f4db5 100644 > > > > --- a/fs/f2fs/file.c > > > > +++ b/fs/f2fs/file.c > > > > @@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct k= iocb *iocb, struct iov_iter *from) > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0 preallocated =3D true; > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0 target_size =3D iocb->ki_pos + iov_iter= _count(from); > > > > +=A0=A0=A0=A0=A0=A0=A0 if (f2fs_overwrite_io(inode, iocb->ki_pos, > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0= =A0 iov_iter_count(from))) > > > > +=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 goto write; > > > = > > > This calls f2fs_map_blocks() which can be duplicate, if it's not the = overwirte > > > case. Do we have other benefit? > > = > > f2fs_overwrite_io() will break for append write case w/ below check: > > = > > =A0=A0=A0=A0if (pos + len > i_size_read(inode)) > > =A0=A0=A0=A0=A0=A0=A0 return false; > > = > > I guess we may only suffer double f2fs_map_blocks() for write hole > > case, e.g. truncate to large size & write inside the filesize. For > > this case, how about adding a condition to allow double f2fs_map_blocks= () > > only if write size is smaller than a threshold? I still don't see the benefit much to do double f2fs_map_blocks. What is the problem here? > > = > > Thanks, > > = > > > = > > > > + > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0 err =3D f2fs_preallocate_blocks(iocb, f= rom); > > > > =A0=A0=A0=A0=A0=A0=A0=A0=A0 if (err) { > > > > =A0 out_err: > > > > -- = > > > > 2.32.0 > > = > > = > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > https://apc01.safelinks.protection.outlook.com/?url=3Dhttps%3A%2F%2Flis= ts.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=3D04%7C01= %7Cchao.yu%40oppo.com%7C421c06812eba4f922b0908d982dcdcc5%7Cf1905eb1c35341c5= 951662b4a54b5ee6%7C0%7C0%7C637684707374940190%7CUnknown%7CTWFpbGZsb3d8eyJWI= joiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sd= ata=3Du22eEWDAPaAZCyISyjTUOtQDLDuyKxTnNCI3eSwwWro%3D&reserved=3D0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23A10C433EF for ; Fri, 29 Oct 2021 17:43:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EF906108F for ; Fri, 29 Oct 2021 17:43:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230119AbhJ2Rp6 (ORCPT ); Fri, 29 Oct 2021 13:45:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:56948 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhJ2Rp4 (ORCPT ); Fri, 29 Oct 2021 13:45:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 92B7A61040; Fri, 29 Oct 2021 17:43:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635529407; bh=rsaoqoFMJRkFW8HbI1/g5SAhlNrxOJ2ODlLw2rtjQVw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TWI+jjY0ML1p9Nw0Dtl1KOyq5HJqk87BImQU70Cl4KdrO+WFa4/1eXJxAHGo0I3B1 P/NvnMbfHSuOP2R46KsW2PdDpFH+Ejzgy2WcXm8VdW+MoO8hklvBq403DcDAKYxGDV mHxsKA5ZC4yWlQanMq8jCrM8qWeXEku+Kg22esQqwvs1SMJSMjIlaZ5R1n656tYy3b Lx5l4t9du+GMlRyUCeJsgwxECQ88Oq1feTNOL4xZBJ0gQ0YwGpafGfCWUZB7L8YPix ksi7CCHYMIS34CwUiqSHNy3RC+DlXPwoPjbQWjjzyX44QJPRpzSWY2aJhdtHO45LE4 YcDzGXpMmMTQA== Date: Fri, 29 Oct 2021 10:43:26 -0700 From: Jaegeuk Kim To: Chao Yu Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Subject: Re: [f2fs-dev] [PATCH] f2fs: skip f2fs_preallocate_blocks() for overwrite case Message-ID: References: <20210928151911.11189-1-chao@kernel.org> <65f6c366-9e5b-fe7f-7c38-061996d1882b@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/29, Chao Yu wrote: > Ping, > > On 2021/9/29 8:05, Chao Yu wrote: > > On 2021/9/29 3:08, Jaegeuk Kim wrote: > > > On 09/28, Chao Yu wrote: > > > > In f2fs_file_write_iter(), let's use f2fs_overwrite_io() to > > > > check whethere it is overwrite case, for such case, we can skip > > > > f2fs_preallocate_blocks() in order to avoid f2fs_do_map_lock(), > > > > which may be blocked by checkpoint() potentially. > > > > > > > > Signed-off-by: Chao Yu > > > > --- > > > >   fs/f2fs/file.c | 4 ++++ > > > >   1 file changed, 4 insertions(+) > > > > > > > > diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c > > > > index 13deae03df06..51fecb2f4db5 100644 > > > > --- a/fs/f2fs/file.c > > > > +++ b/fs/f2fs/file.c > > > > @@ -4321,6 +4321,10 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from) > > > >           preallocated = true; > > > >           target_size = iocb->ki_pos + iov_iter_count(from); > > > > +        if (f2fs_overwrite_io(inode, iocb->ki_pos, > > > > +                        iov_iter_count(from))) > > > > +            goto write; > > > > > > This calls f2fs_map_blocks() which can be duplicate, if it's not the overwirte > > > case. Do we have other benefit? > > > > f2fs_overwrite_io() will break for append write case w/ below check: > > > >     if (pos + len > i_size_read(inode)) > >         return false; > > > > I guess we may only suffer double f2fs_map_blocks() for write hole > > case, e.g. truncate to large size & write inside the filesize. For > > this case, how about adding a condition to allow double f2fs_map_blocks() > > only if write size is smaller than a threshold? I still don't see the benefit much to do double f2fs_map_blocks. What is the problem here? > > > > Thanks, > > > > > > > > > + > > > >           err = f2fs_preallocate_blocks(iocb, from); > > > >           if (err) { > > > >   out_err: > > > > -- > > > > 2.32.0 > > > > > > _______________________________________________ > > Linux-f2fs-devel mailing list > > Linux-f2fs-devel@lists.sourceforge.net > > https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.sourceforge.net%2Flists%2Flistinfo%2Flinux-f2fs-devel&data=04%7C01%7Cchao.yu%40oppo.com%7C421c06812eba4f922b0908d982dcdcc5%7Cf1905eb1c35341c5951662b4a54b5ee6%7C0%7C0%7C637684707374940190%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=u22eEWDAPaAZCyISyjTUOtQDLDuyKxTnNCI3eSwwWro%3D&reserved=0