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.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 06106C433B4 for ; Wed, 28 Apr 2021 02:50:00 +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 B0D8C60FF1 for ; Wed, 28 Apr 2021 02:49:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B0D8C60FF1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vivo.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@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 1lbaGz-0005D2-0y; Wed, 28 Apr 2021 02:49:57 +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 1lbaGx-0005Co-AX for linux-f2fs-devel@lists.sourceforge.net; Wed, 28 Apr 2021 02:49:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vujWfLoIIMnYoD0lk81Y/nz5YyO/hBfMcElNcFGJUmM=; b=iisxpCDZ+17FWj4xWMYj4Gto+X sr+WruwkgtAt1jFNm11W77ngDU9w2Q3+IMgnaEpgbKP8a0cPgt2Slwak5TslNQCE4+0n7qqvMXW8d GOYAzzjNJ0Wa38YjBRGRQY8SIB7alWeym1CGpo6VqI5swRGSMLCe3GFoZj2BAjfdQS7A=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=vujWfLoIIMnYoD0lk81Y/nz5YyO/hBfMcElNcFGJUmM=; b=B bkBn44RIxrM6OzhURQ/pg+/rzGrxNgTIiY111Su5q0P4/YlY9ERa+uIIwueBwutx//gAJhXLawXWy goetiTl+WYJf5S0wckTfLqo+8n+YbJzPAnTXDBqFOtoraU3DIDDb+2ifcdqjnoWoaC6ql3BiALSTO bGuS84bHQg0gU/aA=; Received: from mail-m17640.qiye.163.com ([59.111.176.40]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1lbaGm-0001D4-3P for linux-f2fs-devel@lists.sourceforge.net; Wed, 28 Apr 2021 02:49:56 +0000 Received: from SZ-11126892.vivo.xyz (unknown [58.251.74.232]) by mail-m17640.qiye.163.com (Hmail) with ESMTPA id 1EB92540267; Wed, 28 Apr 2021 10:49:34 +0800 (CST) From: Fengnan Chang To: jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Wed, 28 Apr 2021 10:49:27 +0800 Message-Id: <20210428024927.645-1-changfengnan@vivo.com> X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZS1VLWVdZKFlBSE83V1ktWUFJV1kPCR oVCBIfWUFZQhodQ1YeQxkYShlNTkIfSxhVEwETFhoSFyQUDg9ZV1kWGg8SFR0UWUFZT0tIVUpKS0 hKTFVLWQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6ND46MTo4Lz8NOEsSFRcMShMY GUtPCSpVSlVKTUpCTkxDSkxPTUJOVTMWGhIXVRgTGhUcHR4VHBUaFTsNEg0UVRgUFkVZV1kSC1lB WU5DVUlOSlVMT1VJSElZV1kIAVlBSkJDTzcG X-HM-Tid: 0a791661bb34d995kuws1eb92540267 X-Headers-End: 1lbaGm-0001D4-3P Subject: [f2fs-dev] [PATCH v2] f2fs: compress: avoid unnecessary check in f2fs_prepare_compress_overwrite 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net when write compressed file with O_TRUNC, there will be a lot of unnecessary check valid blocks in f2fs_prepare_compress_overwrite, especially when written in page size, remove it. Signed-off-by: Fengnan Chang --- fs/f2fs/data.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index cf935474ffba..4cfc0472bc2d 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3270,6 +3270,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, struct f2fs_sb_info *sbi = F2FS_I_SB(inode); struct page *page = NULL; pgoff_t index = ((unsigned long long) pos) >> PAGE_SHIFT; +#ifdef CONFIG_F2FS_FS_COMPRESSION + pgoff_t end = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT; +#endif bool need_balance = false, drop_atomic = false; block_t blkaddr = NULL_ADDR; int err = 0; @@ -3306,6 +3309,9 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping, *fsdata = NULL; + if (index >= end) + goto repeat; + ret = f2fs_prepare_compress_overwrite(inode, pagep, index, fsdata); if (ret < 0) { -- 2.29.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel