From patchwork Wed Oct 30 10:31:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yi Sun X-Patchwork-Id: 13856252 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 44E89D5CC8D for ; Wed, 30 Oct 2024 10:32:21 +0000 (UTC) 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.95) (envelope-from ) id 1t65zw-00045m-49; Wed, 30 Oct 2024 10:32:20 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1t65zs-00045c-T1 for linux-f2fs-devel@lists.sourceforge.net; Wed, 30 Oct 2024 10:32:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:Content-Transfer-Encoding:MIME-Version :Message-ID:Date:Subject:CC:To:From:Sender:Reply-To: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=+gUkfEGpi3c7fSjkZbBFyExVCFF+uBCHB+dI+sBz+J8=; b=E9TxBI+5uzRJrhz1f3M2Lu9JNg LhHAWpczG0YOnYIMIk+gnoP49swoQe/cYftwc3C8pCHOLXRISZAM+UnwgrVr5QdzhyA23VIgUPyYr LRU+1M5K3xLttxas91KxTKQ2SVR951Zo0weccuwoR4yxqo6BIdjn9VbY07iNppxnlQ+g=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:CC:To:From:Sender:Reply-To: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=+gUkfEGpi3c7fSjkZbBFyExVCFF+uBCHB+dI+sBz+J8=; b=H 1WFrkOGYVesBpF/ruqe3RGT+Csf8wRptQ06v2WopxKhYYMBRxgtGpH/uTfmEnbJksRMtkPjVHonKE 0Y7KsiP7NwocZgfOCtFf4a9DZx8yVQTFyykOE+cePpUmnD/IHn/zC3LE5T/fbfVZ3r4Xae7YUZ1q5 2owCO8R37U+5Ry8U=; Received: from mx1.unisoc.com ([222.66.158.135] helo=SHSQR01.spreadtrum.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1t65zs-0002E5-84 for linux-f2fs-devel@lists.sourceforge.net; Wed, 30 Oct 2024 10:32:17 +0000 Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 49UAVevu026664; Wed, 30 Oct 2024 18:31:40 +0800 (+08) (envelope-from Yi.Sun@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4Xdk1L6f7gz2K4lHM; Wed, 30 Oct 2024 18:31:02 +0800 (CST) Received: from tj10379pcu1.spreadtrum.com (10.5.32.15) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 30 Oct 2024 18:31:38 +0800 From: Yi Sun To: , Date: Wed, 30 Oct 2024 18:31:31 +0800 Message-ID: <20241030103136.2874140-1-yi.sun@unisoc.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Originating-IP: [10.5.32.15] X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL: SHSQR01.spreadtrum.com 49UAVevu026664 X-Headers-End: 1t65zs-0002E5-84 Subject: [f2fs-dev] [PATCH v2 0/5] Speed up f2fs truncate 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: ke.wang@unisoc.com, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, sunyibuaa@gmail.com, yi.sun@unisoc.com, hao_hao.wang@unisoc.com Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Deleting large files is time-consuming, and a large part of the time is spent in f2fs_invalidate_blocks() ->down_write(sit_info->sentry_lock) and up_write(). If some blocks are continuous, we can process these blocks at the same time. This can reduce the number of calls to the down_write() and the up_write(), thereby improving the overall speed of doing truncate. Test steps: Set the CPU and DDR frequencies to the maximum. dd if=/dev/random of=./test.txt bs=1M count=100000 sync rm test.txt Time Comparison of rm: original optimization ratio 7.17s 3.27s 54.39% Yi Sun (5): f2fs: blocks need to belong to the same segment when using update_sit_entry() f2fs: expand f2fs_invalidate_compress_page() to f2fs_invalidate_compress_pages_range() f2fs: add parameter @len to f2fs_invalidate_internal_cache() f2fs: add parameter @len to f2fs_invalidate_blocks() f2fs: Optimize f2fs_truncate_data_blocks_range() fs/f2fs/compress.c | 11 +++--- fs/f2fs/data.c | 2 +- fs/f2fs/f2fs.h | 16 +++++---- fs/f2fs/file.c | 78 ++++++++++++++++++++++++++++++++++++++---- fs/f2fs/gc.c | 2 +- fs/f2fs/node.c | 4 +-- fs/f2fs/segment.c | 84 +++++++++++++++++++++++++++++++++++++++------- 7 files changed, 161 insertions(+), 36 deletions(-)