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 C93A6C433EF for ; Thu, 16 Sep 2021 09:42:11 +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 68F056112E; Thu, 16 Sep 2021 09:42:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 68F056112E 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.92.3) (envelope-from ) id 1mQnuE-0007z1-RH; Thu, 16 Sep 2021 09:42:10 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1mQnuC-0007yo-PN for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Sep 2021 09:42:08 +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=OLtoXOHXKre0fp3CwyVjSyVEc2GFjGwqbu03K0Uq+a8=; b=EPfKFmyz7ElEYzS+fe765UlRwv 8oZTqWkU5qcVZlt5B+gX4vNE2gDiI9i5VQVrWzndir2YsyCP49/4V9URQIVCAPwPo+MfSRL0qGKbU v+e1TND9E2uY3lQ6eILKw2vW6udu6h73oIDpW8KCzeJ5dE3v984/7J2BCvnzD1+JzYdY=; 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=OLtoXOHXKre0fp3CwyVjSyVEc2GFjGwqbu03K0Uq+a8=; b=gQ9jgfNDH4rR8BrRHfm+GywJjD gqZK+xRFpAUFPBZqekDvgquyvy9v7dK26EKa0Q1GSCd3NGjoVs+vtl/jVRirA/ltu/mQ00KL75HCP w4x1fwVX3GHNZiQFEZTSVwo/aNilJtjBMgiH1aZglxNnoCBnyLqi7f0crGpLEFaIaPsA=; 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 1mQnu7-00Cayp-HC for linux-f2fs-devel@lists.sourceforge.net; Thu, 16 Sep 2021 09:42:04 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id 53CEC60EB2; Thu, 16 Sep 2021 09:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631785318; bh=85dA2XyjoY542QEmjgXn4UFfziCeIubbSdkj/bi8v5E=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=mVuWXwRCAjg64D5w94FYhtprYgk8y+oVi1NAg6/ZrvxCyl5Es6WgS6Scjud2FP5Xf 0aipPJW38/GwWtb2Z/5BJ5NMsyWqOnShgGrTGO/NwYjFzic5WE0AJVjdXf1sLiPTI1 eKVVDED/GWmyXgp7q52UWcsFwM7ZJBbFbOfPJpGgIuJ8HzfVW2BMXZAONQ6zoK+3QZ Kh/s4GbByc3Ma0DieS36S76K61WJGd1RlrIZxd/d1TBCFgIqrdkc8Mr88V5gGFqKwe hJbl/Z5Eum+2xfgnkVM8uj07Gq0MPH48lTg/0JR1It7JI3cbX1nxpBAgjKr/W13Wzp h1KPC9ZSnP7CA== To: Fengnan Chang , jaegeuk@kernel.org References: <20210912015058.14063-1-fengnanchang@gmail.com> <20210912015058.14063-2-fengnanchang@gmail.com> From: Chao Yu Message-ID: <65c81c0c-1799-9154-b588-ff34c427defa@kernel.org> Date: Thu, 16 Sep 2021 17:41:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210912015058.14063-2-fengnanchang@gmail.com> Content-Language: en-US X-Headers-End: 1mQnu7-00Cayp-HC Subject: Re: [f2fs-dev] [PATCH 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: Fengnan Chang , 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/12 9:50, Fengnan Chang wrote: > From: Fengnan Chang > > For now, overwrite file with direct io use inplace policy, but > not counted, fix it. > > Signed-off-by: Fengnan Chang > --- > fs/f2fs/data.c | 7 ++++++- > fs/f2fs/f2fs.h | 7 +++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c > index c1490b9a1345..b5d488c9f9f9 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) > + stat_inc_inplace_blocks(sbi, true); So, it's better to use stat_add_inplace_blocks(sbi, 1, ) instead of stat_inc_inplace_blocks(sb, )? Thanks, > } else { > if (create) { > if (unlikely(f2fs_cp_error(sbi))) { > diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h > index 3d4ee444db27..49230115d241 100644 > --- a/fs/f2fs/f2fs.h > +++ b/fs/f2fs/f2fs.h > @@ -3792,6 +3792,13 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi) > else \ > (atomic_inc(&(sbi)->inplace_count[1])); \ > } while (0) > +#define stat_add_inplace_blocks(sbi, count, direct_io) \ > + do { \ > + if (direct_io) \ > + (atomic_add(count, &(sbi)->inplace_count[0])); \ > + else \ > + (atomic_add(count, &(sbi)->inplace_count[1])); \ > + } while (0) > #define stat_update_max_atomic_write(inode) \ > do { \ > int cur = F2FS_I_SB(inode)->atomic_files; \ > _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel