Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1645647rwr; Thu, 20 Apr 2023 19:32:53 -0700 (PDT) X-Google-Smtp-Source: AKy350aVPXdX1DonLisWcFIQcuFTw+cq/y1R5Z5PGJMD0GMeKU+xYw42Wks93YHviaaR/ruQbpsZ X-Received: by 2002:a05:6a20:548f:b0:f2:7da5:f277 with SMTP id i15-20020a056a20548f00b000f27da5f277mr484220pzk.44.1682044373004; Thu, 20 Apr 2023 19:32:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682044372; cv=none; d=google.com; s=arc-20160816; b=z5ItwezlAAytAZIXXjC/UAFGmg7EV3ETNMAttyIUEMCfYg1PyvodSSv++SscwlQ33O Z2DX8KxjZNaBkZSDKsX4R0obMU4J37dQQwTGqIFRbsU3gYSRPyZVOtuQ3Y2BwiI8Mw9y QsAl0RWb5hYxx5582+HjBHLtH6cxR5zt1UuGAoSh/DBKu7myy8hWP4WoG/F4Ex4pij6K M617daDao9O8dzq9TZCxfrAfGheBQsyEVok5+u0LtRkB/KVWT/HpuNFeDYXCBeX41IuX ld4P+Z5ZaGdX47nKvuB72THutR07bDGB8YmIR7/rIqFa1fQFd10XQzui81YF67C1RD1M 2c1g== 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=mWiYSE+udsapZIJ3lW4VqXWw4CDnYW4ikf0ARXSPZME=; b=PYJM057lYG6NkKfAuoF68S9h0jL9QXc9J1sMaIJ8mVicvBK/rua3zBugqmepalrf+V U6i2FrwR2vYCYfIu2v6XqX22l4wrjHZIY303LOaUEOCi3qTA+9qtzCDQZZVPOrr2jFf7 /3AwBTLPt5C1JssclUmug0wzdQamZnU4i2VaY/MFO9suxw8qnlGZ3U7qlPEUtE0ooVIZ ooBFAMc7PyBpNEx5tnXJzzJgxG2gXyiJoBuWirgjSmBBFMI3JvBCWeIKrO528FLT9CpB XjkL9Ajkz7rMVgAsJhS7Ea3pzgP3B6tVKKypAwpMV0IM/4+f/yP4wBlqhXzML90LBC3e 3tSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PPw0tAgs; 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 j37-20020a634a65000000b005136987a02esi2754042pgl.728.2023.04.20.19.32.38; Thu, 20 Apr 2023 19:32:52 -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=@kernel.org header.s=k20201202 header.b=PPw0tAgs; 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 S233348AbjDUCYB (ORCPT + 99 others); Thu, 20 Apr 2023 22:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231488AbjDUCX7 (ORCPT ); Thu, 20 Apr 2023 22:23:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8EEE3C34 for ; Thu, 20 Apr 2023 19:23:58 -0700 (PDT) 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 738D564D18 for ; Fri, 21 Apr 2023 02:23:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7FEFCC433D2; Fri, 21 Apr 2023 02:23:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682043837; bh=1Nm5Zb6uJo/S3RC7aYlzD7h6cDUnGH6wY4UXaWEbzPs=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PPw0tAgskpKmZ3wBuiV3DQzVSL/PFsI7NlcNsk/l/rGRxd5FMaaFab11mduc8ibiu oKMu8YJIINLXmc1TsD7VDpqlXc5MlANpML2MPWJPKQU9/1xzPJBOsxy29h3K9ety/Q JzQLnnlzkw+DYYNgJ+CTPUg54zDtvh8SjrV/bC7v7JbTNe25yePmSJN+gBvkG0UQnA dkfMtbrD8CcqoV22kwdZFW1q5gtBnf56r6HicdRNyu5kK7SsapvN8llL/IOQLo0FZO LEVWhX/7UZjcnYsQ4imHKURgw+IcxRm7HIPXasl5faFJWFc3C5susW0bmOjmAudHih 7zzCEp6Ib5c1w== Message-ID: <44ca783a-da8c-aec9-ac35-76acc5475cb9@kernel.org> Date: Fri, 21 Apr 2023 10:23:54 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [f2fs-dev] [PATCH] f2fs: use cow inode data when updating atomic write Content-Language: en-US To: Daeho Jeong , linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Cc: Daeho Jeong References: <20230418175206.3282328-1-daeho43@gmail.com> From: Chao Yu In-Reply-To: <20230418175206.3282328-1-daeho43@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-8.8 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,T_SCC_BODY_TEXT_LINE 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 2023/4/19 1:52, Daeho Jeong wrote: > From: Daeho Jeong > > Need to use cow inode data content instead of the one in the original > inode, when we try to write the already updated atomic write files. > Miss a fixes line? Otherwise it looks good to me. Thanks > Signed-off-by: Daeho Jeong > --- > fs/f2fs/data.c | 15 ++++++++++----- > 1 file changed, 10 insertions(+), 5 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index 8df225014304..7165b1202f53 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -3491,7 +3491,7 @@ static int __reserve_data_block(struct inode *inode, pgoff_t index, > > static int prepare_atomic_write_begin(struct f2fs_sb_info *sbi, > struct page *page, loff_t pos, unsigned int len, > - block_t *blk_addr, bool *node_changed) > + block_t *blk_addr, bool *node_changed, bool *use_cow) > { > struct inode *inode = page->mapping->host; > struct inode *cow_inode = F2FS_I(inode)->cow_inode; > @@ -3505,10 +3505,12 @@ static int prepare_atomic_write_begin(struct f2fs_sb_info *sbi, > > /* Look for the block in COW inode first */ > err = __find_data_block(cow_inode, index, blk_addr); > - if (err) > + if (err) { > return err; > - else if (*blk_addr != NULL_ADDR) > + } else if (*blk_addr != NULL_ADDR) { > + *use_cow = true; > return 0; > + } > > if (is_inode_flag_set(inode, FI_ATOMIC_REPLACE)) > goto reserve_block; > @@ -3538,6 +3540,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, > struct page *page = NULL; > pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT; > bool need_balance = false; > + bool use_cow = false; > block_t blkaddr = NULL_ADDR; > int err = 0; > > @@ -3597,7 +3600,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, > > if (f2fs_is_atomic_file(inode)) > err = prepare_atomic_write_begin(sbi, page, pos, len, > - &blkaddr, &need_balance); > + &blkaddr, &need_balance, &use_cow); > else > err = prepare_write_begin(sbi, page, pos, len, > &blkaddr, &need_balance); > @@ -3637,7 +3640,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, > f2fs_handle_error(sbi, ERROR_INVALID_BLKADDR); > goto fail; > } > - err = f2fs_submit_page_read(inode, page, blkaddr, 0, true); > + err = f2fs_submit_page_read(use_cow ? > + F2FS_I(inode)->cow_inode : inode, page, > + blkaddr, 0, true); > if (err) > goto fail; >