From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C9E7EEB5 for ; Mon, 23 Dec 2024 08:13:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734941584; cv=none; b=rp/BDHUXC0OgKOlaGEV+52SxH7gihfZCEWu8Gfeoa3oERtc8NsFt8f3kA4A8Eyxdnzy0+Qb4SncuoxTcgik4AFY8G3inSIevemx65X6u0InPEHBBoXAETiPvTZYJCPyaITDnSworwnhV5T9ik6yP0hKxT7ux+71pU3gWkNE0IZo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734941584; c=relaxed/simple; bh=VY3hjdCXSi6ogKN12tWEocEU4LVWBpJg/y0b5v5LKC4=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=WgxxB9a3E+FTMRp8pVt7xrprl8zrvGaQTEjgjVoJCWVF26K4TJ5/fwi4yXbXycG6dXVKJYXKhwpWcTA9XENsZyUEtt/H2HoAf6D0sGx3jG0MVMAXaCAFu9/JBnRTSFGnp9oNaN/sbAra3GTdqxIpM8+0tBBTuu5J+qBLfxrykbw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 4BN8AmNM033124; Mon, 23 Dec 2024 16:10:48 +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 4YGrHq276fz2MnTyj; Mon, 23 Dec 2024 16:08:23 +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; Mon, 23 Dec 2024 16:10:46 +0800 From: Yi Sun To: , CC: , , , , , , Subject: [PATCH v4 0/4] Speed up f2fs truncate Date: Mon, 23 Dec 2024 16:10:40 +0800 Message-ID: <20241223081044.1126291-1-yi.sun@unisoc.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) X-MAIL:SHSQR01.spreadtrum.com 4BN8AmNM033124 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% ---- v4: - introduce update_sit_entry_for_alloc(). - [patch 2,3,4 / 4] have no changes compared to v3. Yi Sun (4): f2fs: introduce update_sit_entry_for_release/alloc() f2fs: update_sit_entry_for_release() supports consecutive blocks. f2fs: add parameter @len to f2fs_invalidate_blocks() f2fs: Optimize f2fs_truncate_data_blocks_range() fs/f2fs/compress.c | 4 +- fs/f2fs/f2fs.h | 3 +- fs/f2fs/file.c | 78 +++++++++++++++++-- fs/f2fs/node.c | 4 +- fs/f2fs/segment.c | 185 +++++++++++++++++++++++++++++---------------- 5 files changed, 198 insertions(+), 76 deletions(-) -- 2.25.1