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 6045AC433F5 for ; Wed, 13 Oct 2021 15:18:51 +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 19C9C6112D; Wed, 13 Oct 2021 15:18:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 19C9C6112D 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-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1mag1p-0003A1-6k; Wed, 13 Oct 2021 15:18:49 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mag1n-00039v-KD for linux-f2fs-devel@lists.sourceforge.net; Wed, 13 Oct 2021 15:18:47 +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: From:References:Cc:To:Subject:MIME-Version:Date:Message-ID: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=Rhk8AFqrqpJ2aC3dKzvdsuQTwGFUHN56mD9ZjOW1IRc=; b=dQyzA2zvN6zamy7TlcXdyS1lAo o9mS/W/UeQa9eTpDrmf6FWA3lCwioki3jIknRFP+8jRrw0WjwpyD4o648COtNPge+pEPpY5qOdXtO vy1C22NhzQpHK8zvoa91zuU1Ka0nGqbyULzRyY+HTVMUHhrYBVa3jC1j/AmPHYFqX+2Y=; 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:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID: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=Rhk8AFqrqpJ2aC3dKzvdsuQTwGFUHN56mD9ZjOW1IRc=; b=SX7OuP6edTDM2UmU2InIZyIP1y /qlK5R07c+zSAWZAGoDe9rUdn4uxrHu3ldEtZ/1qzeYHj7/42Voc9RzQ4t3f0fS6dDaGhsPIsvUPt 8OcrPHjazWPRhRCk8U9Dd47VoU+FebNDTDkzIk1mC3/WGM/s6MCwf5KP4ETIsJs5CEds=; 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 1mag1l-008aVf-O3 for linux-f2fs-devel@lists.sourceforge.net; Wed, 13 Oct 2021 15:18:47 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id C0C1C60F21; Wed, 13 Oct 2021 15:18:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1634138315; bh=dqpYGOfOIzYPxxzj0LBw/X73XeoxwtcibuvZw5rg61A=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=BqJxxGF/Bxp2SlpGHuqVFzzDMbaQAG+zYWxayYlb8wCFeHjODODNIDSTbKu+vfm3o MVT935vpabUrLZ1VYH47fw0zVGvNDzbxwO2Gpsbv6Hu/r1qG/bC6ksFrdV+M6+ovtl diR/KBQzXScy2YdN1Ym0vkyMLRkQ5siZBDDkhzocsp2HyHD0Ev1tZ8kGzdiNY8j368 SEf2CITBY7C8UWVTBo0POAlHUWwuTPRaMAi92WzR6TYwfCWJoXIHeGh3tdTrWBZPMV NtJLaBfQC7ktJ4ouFBy4KjD5qlrYY3L6cK78l/n3AN8W5HWI8DdVIkHS4GBJxk7RBV fvShInMeiyuGg== Message-ID: <66a243ca-53ed-cb8b-064b-5f0d3c954579@kernel.org> Date: Wed, 13 Oct 2021 23:18:31 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Content-Language: en-US To: Fengnan Chang , jaegeuk@kernel.org References: <20211009112744.33698-1-changfengnan@vivo.com> <20211009112744.33698-2-changfengnan@vivo.com> From: Chao Yu In-Reply-To: <20211009112744.33698-2-changfengnan@vivo.com> X-Headers-End: 1mag1l-008aVf-O3 Subject: Re: [f2fs-dev] [PATCH v5 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/10/9 19:27, 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 | 4 +++- > fs/f2fs/f2fs.h | 8 ++++---- > fs/f2fs/segment.c | 2 +- > 3 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index c1490b9a1345..7798f7236376 100644 > --- a/fs/f2fs/data.c > +++ b/fs/f2fs/data.c > @@ -1553,7 +1553,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 (!f2fs_lfs_mode(sbi) && flag == F2FS_GET_BLOCK_PRE_DIO && > + map->m_may_create && create) > + stat_add_inplace_blocks(sbi, 1, true); What about this case? - f2fs_preallocate_blocks - f2fs_map_blocks - stat_add_inplace_blocks map.m_len > 0 && err == -ENOSPC err = 0; - __generic_file_write_iter - generic_file_direct_write - f2fs_direct_IO - get_data_block_dio_write - __allocate_data_block - stat_inc_block_count DIO blocks will be accounted into different type? IIUC. > } else { > if (create) { > if (unlikely(f2fs_cp_error(sbi))) { > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index bf2e73e46304..a7da836ca64f 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])); \ If count always be one, we can just keep to use atomic_inc() here? Thanks, > } 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, direct_io) do { } while (0) > -#define stat_inc_inplace_blocks(sbi, direct_io) 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