From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751760AbbIQMX1 (ORCPT ); Thu, 17 Sep 2015 08:23:27 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:51335 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751121AbbIQMX0 (ORCPT ); Thu, 17 Sep 2015 08:23:26 -0400 X-AuditID: cbfee61b-f79d56d0000048c5-3b-55fab0bc7809 From: Chao Yu To: Jaegeuk Kim Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/7] f2fs: do in batches truncation in truncate_hole Date: Thu, 17 Sep 2015 20:22:44 +0800 Message-id: <009b01d0f143$a68066c0$f3813440$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdDw7TNboYKO65QzRq6TeqG7jO70dQ== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrNLMWRmVeSWpSXmKPExsVy+t9jQd09G36FGnT+lrZ4sn4Ws8WlRe4W l3fNYXNg9ti0qpPNY/eCz0wenzfJBTBHcdmkpOZklqUW6dslcGU8/jKFreAzf8XX29PZGhjv 8nQxcnJICJhIfJy4jxHCFpO4cG89G4gtJDCLUWL1dK4uRi4g+xWjxIa/y8GK2ARUJJZ3/GcC sUWA7EOLLrOD2MwCHhKNHd9ZQWxhAXeJ/Q+bwWwWAVWJlvtfwGxeAUuJSYuusUPYghI/Jt9j gejVkli/8zgThC0vsXnNW2aIgxQkdpx9zQixS09i64utrBA14hIbj9ximcAIdCXCqFlIRs1C MmoWkpYFjCyrGCVSC5ILipPSc43yUsv1ihNzi0vz0vWS83M3MYKD+Jn0DsbDu9wPMQpwMCrx 8Cq4/AoVYk0sK67MPcQowcGsJMKrvgAoxJuSWFmVWpQfX1Sak1p8iFGag0VJnFd25bNQIYH0 xJLU7NTUgtQimCwTB6dUA6OedFSXU5tjtG1DdjTHIiaHvq3hFpEFW7IKFBfOUy6yvWnqeMDw 4s8vd/piFl6xPXCl8OY66fkeAg8MTaUftRxazyVrarP049HXJy8tWXnhU/0qxq1W6gra1x9a TPnLtuGK+4fVitkbPq4qS41ubRSsTVqXmntxzWJhBnGraxIcufUzDCrTPyuxFGckGmoxFxUn AgBwEaeJXgIAAA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org truncate_data_blocks_range can do in batches truncation which makes all changes in dnode page content, dnode page status, extent cache, block count updating together. But previously, truncate_hole() always truncates one block in dnode page at a time by invoking truncate_data_blocks_range(,1), which make thing slow. This patch changes truncate_hole() to do in batches truncation for all target blocks in one direct node inside truncate_data_blocks_range, which can make our punch hole operation in ->fallocate more efficent. Signed-off-by: Chao Yu --- v2: changing slightly like below which is suggested by Jaegeuk: o don't have to use index variable o should not skip the entire dnode indices, when one of them is -ENOENT fs/f2fs/file.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 27a789c..6702157 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -739,23 +739,31 @@ static int fill_zero(struct inode *inode, pgoff_t index, int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end) { - pgoff_t index; int err; - for (index = pg_start; index < pg_end; index++) { + while (pg_start < pg_end) { struct dnode_of_data dn; + pgoff_t end_offset, count; set_new_dnode(&dn, inode, NULL, NULL, 0); - err = get_dnode_of_data(&dn, index, LOOKUP_NODE); + err = get_dnode_of_data(&dn, pg_start, LOOKUP_NODE); if (err) { - if (err == -ENOENT) + if (err == -ENOENT) { + pg_start++; continue; + } return err; } - if (dn.data_blkaddr != NULL_ADDR) - truncate_data_blocks_range(&dn, 1); + end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode)); + count = min(end_offset - dn.ofs_in_node, pg_end - pg_start); + + f2fs_bug_on(F2FS_I_SB(inode), count == 0 || count > end_offset); + + truncate_data_blocks_range(&dn, count); f2fs_put_dnode(&dn); + + pg_start += count; } return 0; } -- 2.5.2