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 X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1748BC433F5 for ; Thu, 16 Sep 2021 12:10:13 +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 B53156120D; Thu, 16 Sep 2021 12:10:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B53156120D 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-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1mQqDT-0005kS-Sz; Thu, 16 Sep 2021 12:10:11 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQqDR-0005jx-Qe for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Sep 2021 12:10:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject: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=O7KKGjcIHmDXGKLox6swEL10g+VtPesDsDQQLW7zOIw=; b=FW8m82O4qDJsUOcOmLEoOLFmNw gOaFtxMGuMfNrpSjoPqH9GT/MXrGWsv8DabkcKaXVI8Kr8qdLURuwbpxgBAjFVIbo8gbHdDFo7DIi aoyttnzHXXUOVn4swRUSjs5zPJ/WwMmjfYB7ecNMgGO8zfoEQB+VdlA5KcPedCiKAe8g=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject: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=O7KKGjcIHmDXGKLox6swEL10g+VtPesDsDQQLW7zOIw=; b=SOH1QqIcpO8/5XB8wnFUERRUrW 9U2/HX+1ozf8XSsZxuDnNk9wliaQLd8TPdSvQmhBrV8+WAW0HcWUMbTUeXGyWd2bMkRxxofKA7PXb 5p07Yt9ufVZ98H7RpSgMtRlt36NJvyc1+6UDLrMbb38qU9Bum6DcEzwnnxRb77dIfeHE=; Received: from mail.kernel.org ([198.145.29.99]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1mQqDR-00CiEp-4N for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Sep 2021 12:10:09 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1078260E52; Thu, 16 Sep 2021 12:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631794198; bh=e9UzXbPN/bEvTWK5YMLy3hnA4T1bnxeDveo1dsoL3Ik=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=eLOiWmADfGe9zK2rUB7bncjl9WQ8MrIFxrg/RA/9e9mL/q9jWj0+IsugPhJDZp1Yf G/KNA/ncPmv8GBr7W1hMphazzPezMm8TO/VQJKVO9jVASAByKZueNT0vItF8cXOqwX VxNQF0JzAYoHC/B1AhKojTp2IXPftbkw+pkJF9n+HH60j10sz2k6TJAmVWqme8E8M1 mOUy7wXvc22x9peE/DmZ+RDaadjdn65kQTr49lAO0daaJAFYjmUT7ReRsjcJKa6/jE JB/ZurABefds1sws5ox6s0A2zSWcBo+EOsv0E83VsVf6rQPaNO7SqX032l9Cxuf4rO PmcOKPNJ3VMDA== To: Fengnan Chang , jaegeuk@kernel.org References: <20210916113026.378385-1-changfengnan@vivo.com> <20210916113026.378385-2-changfengnan@vivo.com> From: Chao Yu Message-ID: Date: Thu, 16 Sep 2021 20:09:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.14.0 MIME-Version: 1.0 In-Reply-To: <20210916113026.378385-2-changfengnan@vivo.com> Content-Language: en-US X-Headers-End: 1mQqDR-00CiEp-4N Subject: Re: [f2fs-dev] [PATCH v2 2/2] f2fs: fix missing inplace count in overwrite with direct io 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-f2fs-devel@lists.sourceforge.net Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On 2021/9/16 19:30, Fengnan Chang wrote: > For now, overwrite file with direct io use inplace policy, but > not counted, fix it. And use stat_add_inplace_blocks(sbi, 1, ) > instead of stat_inc_inplace_blocks(sb, ). > > Signed-off-by: Fengnan Chang > --- > fs/f2fs/data.c | 7 ++++++- > fs/f2fs/f2fs.h | 8 ++++---- > fs/f2fs/segment.c | 2 +- > 3 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index c1490b9a1345..0c5728d63c33 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1491,6 +1491,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, > if (flag == F2FS_GET_BLOCK_DIO) > f2fs_wait_on_block_writeback_range(inode, > map->m_pblk, map->m_len); > + if (!f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO && > + map->m_may_create) > + stat_add_inplace_blocks(sbi, map->m_len, true); > goto out; > } > > @@ -1553,7 +1556,9 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map, > goto sync_out; > blkaddr = dn.data_blkaddr; > set_inode_flag(inode, FI_APPEND_WRITE); > - } > + } else if (!create && !f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO && > + map->m_may_create) Why not } else if {!f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_DIO && map->m_may_create) Thanks, > + stat_add_inplace_blocks(sbi, 1, true); > } else { > if (create) { > if (unlikely(f2fs_cp_error(sbi))) { > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 3d4ee444db27..2d81e9f0a0ee 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -3785,12 +3785,12 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) > else \ > ((sbi)->block_count[1][(curseg)->alloc_type]++); \ > } while (0) > -#define stat_inc_inplace_blocks(sbi, direct_io) \ > +#define stat_add_inplace_blocks(sbi, count, direct_io) \ > do { \ > if (direct_io) \ > - (atomic_inc(&(sbi)->inplace_count[0])); \ > + (atomic_add(count, &(sbi)->inplace_count[0])); \ > else \ > - (atomic_inc(&(sbi)->inplace_count[1])); \ > + (atomic_add(count, &(sbi)->inplace_count[1])); \ > } while (0) > #define stat_update_max_atomic_write(inode) \ > do { \ > @@ -3877,7 +3877,7 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi); > #define stat_inc_meta_count(sbi, blkaddr) do { } while (0) > #define stat_inc_seg_type(sbi, curseg) do { } while (0) > #define stat_inc_block_count(sbi, curseg) do { } while (0) > -#define stat_inc_inplace_blocks(sbi) do { } while (0) > +#define stat_add_inplace_blocks(sbi, count, direct_io) do { } while (0) > #define stat_inc_seg_count(sbi, type, gc_type) do { } while (0) > #define stat_inc_tot_blk_count(si, blks) do { } while (0) > #define stat_inc_data_blk_count(sbi, blks, gc_type) do { } while (0) > diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c > index ded744e880d0..c542c4b687ca 100644 > --- a/fs/f2fs/segment.c > +++ b/fs/f2fs/segment.c > @@ -3611,7 +3611,7 @@ int f2fs_inplace_write_data(struct f2fs_io_info *fio) > goto drop_bio; > } > > - stat_inc_inplace_blocks(fio->sbi, false); > + stat_add_inplace_blocks(sbi, 1, false); > > if (fio->bio && !(SM_I(sbi)->ipu_policy & (1 << F2FS_IPU_NOCACHE))) > err = f2fs_merge_page_bio(fio); > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel