From patchwork Sat Apr 27 06:35:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Alexey Zhuravlev X-Patchwork-Id: 1928442 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=whamcloud.com header.i=@whamcloud.com header.a=rsa-sha256 header.s=selector2 header.b=oSOq8Q0K; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=gandalf.ozlabs.org; envelope-from=srs0=eiay=ma=vger.kernel.org=linux-ext4+bounces-2220-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VRKcM1Vqkz1yZk for ; Sat, 27 Apr 2024 16:36:18 +1000 (AEST) Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4VRKcH66HMz4wc5 for ; Sat, 27 Apr 2024 16:36:15 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4VRKcH5bWZz4wcC; Sat, 27 Apr 2024 16:36:15 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=whamcloud.com Authentication-Results: gandalf.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=whamcloud.com header.i=@whamcloud.com header.a=rsa-sha256 header.s=selector2 header.b=oSOq8Q0K; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.80.249; helo=am.mirrors.kernel.org; envelope-from=linux-ext4+bounces-2220-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4VRKcG0l1Vz4wc5 for ; Sat, 27 Apr 2024 16:36:14 +1000 (AEST) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1D0931F231FC for ; Sat, 27 Apr 2024 06:36:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 68FE8288A4; Sat, 27 Apr 2024 06:36:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=whamcloud.com header.i=@whamcloud.com header.b="oSOq8Q0K" X-Original-To: linux-ext4@vger.kernel.org Received: from outbound-ip191a.ess.barracuda.com (outbound-ip191a.ess.barracuda.com [209.222.82.58]) (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 B82F28BFA for ; Sat, 27 Apr 2024 06:36:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=209.222.82.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714199764; cv=fail; b=oNBalLI+q5WUf5FQfGcWU/uW9oH/CzMVb5k4rdej1SUjBAlR9nNCBIJXIUoxD3N9lOuJe7Nj+uA3lW9PU+n+mmWBeVuENbcCuhc/i7c99NQZI+wpmw+EaJ/mGix6GC6iZICCu69oOsVYgAE78Oofb27dbXKnjkWEx/AJTbCWhjk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714199764; c=relaxed/simple; bh=OHlIk8fmzeg78d17HsFnz2ZvfK0Bmu0W6Bit0ofOIW0=; h=Date:From:To:Subject:Message-ID:Content-Type:MIME-Version; b=FPD94FsjhRXokQW3o2f26lmKnJkkiCg0n3rHRXMjLwzab5f8cUUBpdw80yQLdDmG+sNxjQPDf5zUouaQH+TWvq+URlAjerbOoD67q0ZIOkFAjyqmWCPSefKWYbtczsKKgAZqyaw9Y5L1cQtgvq8I5dz7JQBm+VOSEql60tvXNk0= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=whamcloud.com; spf=pass smtp.mailfrom=ddn.com; dkim=pass (1024-bit key) header.d=whamcloud.com header.i=@whamcloud.com header.b=oSOq8Q0K; arc=fail smtp.client-ip=209.222.82.58 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=whamcloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ddn.com Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2101.outbound.protection.outlook.com [104.47.70.101]) by mx-outbound10-6.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 27 Apr 2024 06:35:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eI2nZZB48SWbmRCl/QEqu11tyH0dXzQfJuQFjRU0vK2PwDl+6b7DGkMxJaxc+GiGk8WwinQavUCnn4syhwLiV2ViQBawEc3nXS8hoSxpkLcJ3a/E5Ie6S2LwLlM40oZkAtr4mz9yj0blNoyxBWS7qIbpMEwE0pmf28DdJEqZKjYKNgt8s1LWloh70TuwrmiBWkPPuvyasFeJN7o+8uf3L2en70VVddQJJ+2+WXPbfiqjDcIY838nM6uZ5oll/gKX9ZDPyD5quZdAq53vadwh1p3rxQ3INWFwd+27iVn1BxuQ7FPjl9SeoKJwkJl7P5OCeg9t9LEc7Pc3aQU+vKe+qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aYQJ9kUsuaTS7H4B3ZkUj47DfzONrgYrSa0k7rbLv64=; b=HIbv4BFdn2Hs5qYhaIYcUoKl1NNJWKV+VFq4/Q8QUfsYyrWJMXrW4B7Uzf80Rj/Cb99D2Tgc1lARyExTx5JzXYnDgsca+tUbLzNnSjg7/9gMZ31XpK/gk1PC+bogVEawmOjRhkPWJhJHwhv603b0sx71lPcvzx04VO1BZqH4vMGY7wDH16bNQgQPywxjp9GIKkVDYPWPyjte5bsN/KEf3z22O8QZcemM/L6iaMRiz0QEyDzR/RTuLU/qwIb4wiZlfV7CERZcC22juqdz6TAZVtrcDW2tQadXaid4Q72CHPnWXGJcJY5V+dTN1hWT6Li1oHD/jLpu5iWaWnbevWGJ9Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ddn.com; dmarc=pass action=none header.from=whamcloud.com; dkim=pass header.d=whamcloud.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=whamcloud.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aYQJ9kUsuaTS7H4B3ZkUj47DfzONrgYrSa0k7rbLv64=; b=oSOq8Q0KESjaLVAdlBNYY81XxHtrQ9HXXR5xdK/7JWGuZ+7B1cDZTN0KxWac/GOY0SOsGEAI4gkvObOYu+cSxEev7GgDGYkUGTaBkJxBF/Mm8mblsqp4E4Me2l5nov0O6Kv0EmmExo2fI/Su3hL34ssIYtHjptRaw0it812YGCc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=whamcloud.com; Received: from DM4PR19MB5835.namprd19.prod.outlook.com (2603:10b6:8:66::17) by DM4PR19MB5980.namprd19.prod.outlook.com (2603:10b6:8:6c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Sat, 27 Apr 2024 06:35:49 +0000 Received: from DM4PR19MB5835.namprd19.prod.outlook.com ([fe80::bbd1:7a5b:d8c3:4a8]) by DM4PR19MB5835.namprd19.prod.outlook.com ([fe80::bbd1:7a5b:d8c3:4a8%4]) with mapi id 15.20.7472.045; Sat, 27 Apr 2024 06:35:49 +0000 Date: Sat, 27 Apr 2024 09:35:41 +0300 From: Alexey Zhuravlev To: linux-ext4@vger.kernel.org Subject: merge extent blocks when possible Message-ID: <20240427093541.77f14d8b@x390.bzzz77.ru> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-redhat-linux-gnu) X-ClientProxiedBy: GVYP280CA0020.SWEP280.PROD.OUTLOOK.COM (2603:10a6:150:fa::16) To DM4PR19MB5835.namprd19.prod.outlook.com (2603:10b6:8:66::17) Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM4PR19MB5835:EE_|DM4PR19MB5980:EE_ X-MS-Office365-Filtering-Correlation-Id: 9d3bbd35-1f35-421a-c134-08dc668446d8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|1800799015|376005; X-Microsoft-Antispam-Message-Info: =?utf-8?q?S0sxCykaPz284iZEJ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= =?utf-8?q?tAK6Yg20ZQeeJg+tx3PkQzC0dyV5xiegGp9DNqH3KVxaOKa7Xff6n4pbBNbJaKb12?= =?utf-8?q?lwelX+T6mRs8orkcHAFRaN3i3f4AA9QFF3IyYH7yxeA8d2x/hPvK5I1aKdVQIKyCP?= =?utf-8?q?jrswlW6rVhfS2HExjWKpEP/sMvhmX77Ag1Q1Qgl4wei74FA7gYumylNaGGDGZSbLY?= =?utf-8?q?JOm/XaeR22kjJ9ZZHzJFnBz7hnn7wwuKiFjOJ+LGc0hQmarj9tDTAIQpPb1y3yaRJ?= =?utf-8?q?Cg27HV/7L7/Y9qVcWkwNvlCfhbSRn6mTMYN49UsYdqji1h40eJCwPBhgUZzWagcwg?= =?utf-8?q?r/Csxub1AtGrbyPON/7+8jxxRmHn3LPe5gWw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM4PR19MB5835.namprd19.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(366007)(1800799015)(376005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?YI3ddGxTRE+RJKyPd2v7wtUZg1kU?= =?utf-8?q?YFjs2TC2HP5PuEC2V9bYXEmzQ+r71q9yJUodeeqAScFtH2ygJQuQu11GS4g3NDyIT?= =?utf-8?q?CO4H5iTEnscE+JuffU9u+LCAxHCzg9EjW0HocP4eVsgCetD0tN7zXIkRZlO/EDJ6p?= =?utf-8?q?z8fzKOOXnOnUYhjn9H0JVPItESQz/R1Dq0ZllnClu/VZwbewhmeVmb/qZmCIeA+AO?= =?utf-8?q?CX8DpyPvNz0OovdAbYeaQExAFtFJEgOXj0/53OaapPq2i/G4lfpMyI4LyDZzC8uRa?= =?utf-8?q?jBzQDnG50zc2Cpb7aVVqQ/IvFUbwdmNuC+uU75H1QWy9TPLyhsBHF2nIDMFat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h9B2FEs0OSsKpRVJg8spHDfbjCan3p+ST93kHRlxwepXu1D0Aiij9JDQhQvMoRzMBNlGWh2FZhqkwG0UDOSZiTWyy8= X-OriginatorOrg: whamcloud.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9d3bbd35-1f35-421a-c134-08dc668446d8 X-MS-Exchange-CrossTenant-AuthSource: DM4PR19MB5835.namprd19.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Apr 2024 06:35:49.1409 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 753b6e26-6fd3-43e6-8248-3f1735d59bb4 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AQUnMkFA5ZOR+9CJbTU+tNWJ+Q3UZZMPE+6lUq8VTzMLsqQuVfAn1m0La6qJ9+BUVheEjuSQ5MflSkUHUZO6Qg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR19MB5980 X-BESS-ID: 1714199753-102566-12631-81649-1 X-BESS-VER: 2019.1_20240424.2033 X-BESS-Apparent-Source-IP: 104.47.70.101 X-BESS-Parts: H4sIAAAAAAACA4uuVkqtKFGyUioBkjpK+cVKVoYGBgamQGYGUNTMMMXQNC05LT Ep0TAxyTLZ2Cw5KS3F3MjC0tLALNkoVak2FgCe9wU1QgAAAA== X-BESS-Outbound-Spam-Score: 0.50 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.255853 [from cloudscan11-205.us-east-2a.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.50 BSF_RULE7568M META: Custom Rule 7568M 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.50 using account:ESS124931 scores of KILL_LEVEL=7.0 tests=BSF_RULE7568M, BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Hi, Please, consider for inclusion the patch attempting to handle the problem with deep extent tree. Thanks, Alex From 0dd791c266e2d00c3217d0f1b836abdbfd4f146f Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 19 Jul 2023 21:22:20 +0300 Subject: [PATCH 1/2] In some cases when a lot of extents are created initially by sparse file writes, they get merged over time, but there is no way to merge blocks in different indexes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For example, if a file is written synchronously, all even blocks first, then odd blocks. The resulting extents tree looks like the following in "debugfs stat" output, often with only a single block in each index/leaf: EXTENTS: (ETB0):33796 (ETB1):33795 (0-677):2588672-2589349 (ETB1):2590753 (678):2589350 (ETB1):2590720 (679-1357):2589351-2590029 (ETB1):2590752 (1358):2590030 (ETB1):2590721 (1359-2037):2590031-2590709 (ETB1):2590751 (2038):2590710 (ETB1):2590722 : : With the patch applied the index and lead blocks are properly merged (0.6% slower under this random sync write workload, but later read IOPS are greatly reduced): EXTENTS: (ETB0):33796 (ETB1):2590736 (0-2047):2588672-2590719 (2048-11999):2592768-2602719 Originally the problem was hit with a real application operating on huge datasets and with just 27371 extents "inode has invalid extent depth: 6” problem occurred. With the patch applied the application succeeded having finally 73637 in 3-level tree. Signed-off-by: Alex Zhuravlev --- fs/ext4/extents.c | 185 ++++++++++++++++++++++++++++++++++++++++-- fs/jbd2/transaction.c | 1 + 2 files changed, 180 insertions(+), 6 deletions(-) diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e57054bdc5fd..a2de6b863df1 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c @@ -1885,7 +1885,7 @@ static void ext4_ext_try_to_merge_up(handle_t *handle, * This function tries to merge the @ex extent to neighbours in the tree, then * tries to collapse the extent tree into the inode. */ -static void ext4_ext_try_to_merge(handle_t *handle, +static int ext4_ext_try_to_merge(handle_t *handle, struct inode *inode, struct ext4_ext_path *path, struct ext4_extent *ex) @@ -1902,9 +1902,178 @@ static void ext4_ext_try_to_merge(handle_t *handle, merge_done = ext4_ext_try_to_merge_right(inode, path, ex - 1); if (!merge_done) - (void) ext4_ext_try_to_merge_right(inode, path, ex); + merge_done = ext4_ext_try_to_merge_right(inode, path, ex); ext4_ext_try_to_merge_up(handle, inode, path); + + return merge_done; +} + +/* + * This function tries to merge blocks from @path into @npath + */ +static int ext4_ext_merge_blocks(handle_t *handle, + struct inode *inode, + struct ext4_ext_path *path, + struct ext4_ext_path *npath) +{ + unsigned int depth = ext_depth(inode); + int used, nused, free, i, k, err; + ext4_fsblk_t next; + + if (path[depth].p_hdr == npath[depth].p_hdr) + return 0; + + used = le16_to_cpu(path[depth].p_hdr->eh_entries); + free = le16_to_cpu(npath[depth].p_hdr->eh_max) - + le16_to_cpu(npath[depth].p_hdr->eh_entries); + if (free < used) + return 0; + + err = ext4_ext_get_access(handle, inode, path + depth); + if (err) + return err; + err = ext4_ext_get_access(handle, inode, npath + depth); + if (err) + return err; + + /* move entries from the current leave to the next one */ + nused = le16_to_cpu(npath[depth].p_hdr->eh_entries); + memmove(EXT_FIRST_EXTENT(npath[depth].p_hdr) + used, + EXT_FIRST_EXTENT(npath[depth].p_hdr), + nused * sizeof(struct ext4_extent)); + memcpy(EXT_FIRST_EXTENT(npath[depth].p_hdr), + EXT_FIRST_EXTENT(path[depth].p_hdr), + used * sizeof(struct ext4_extent)); + le16_add_cpu(&npath[depth].p_hdr->eh_entries, used); + le16_add_cpu(&path[depth].p_hdr->eh_entries, -used); + ext4_ext_try_to_merge_right(inode, npath, + EXT_FIRST_EXTENT(npath[depth].p_hdr)); + + err = ext4_ext_dirty(handle, inode, path + depth); + if (err) + return err; + err = ext4_ext_dirty(handle, inode, npath + depth); + if (err) + return err; + + /* otherwise the index won't get corrected */ + npath[depth].p_ext = EXT_FIRST_EXTENT(npath[depth].p_hdr); + err = ext4_ext_correct_indexes(handle, inode, npath); + if (err) + return err; + + for (i = depth - 1; i >= 0; i--) { + + next = ext4_idx_pblock(path[i].p_idx); + ext4_free_blocks(handle, inode, NULL, next, 1, + EXT4_FREE_BLOCKS_METADATA | + EXT4_FREE_BLOCKS_FORGET); + err = ext4_ext_get_access(handle, inode, path + i); + if (err) + return err; + le16_add_cpu(&path[i].p_hdr->eh_entries, -1); + if (le16_to_cpu(path[i].p_hdr->eh_entries) == 0) { + /* whole index block collapsed, go up */ + continue; + } + /* remove index pointer */ + used = EXT_LAST_INDEX(path[i].p_hdr) - path[i].p_idx + 1; + memmove(path[i].p_idx, path[i].p_idx + 1, + used * sizeof(struct ext4_extent_idx)); + + err = ext4_ext_dirty(handle, inode, path + i); + if (err) + return err; + + if (path[i].p_hdr == npath[i].p_hdr) + break; + + /* try to move index pointers */ + used = le16_to_cpu(path[i].p_hdr->eh_entries); + free = le16_to_cpu(npath[i].p_hdr->eh_max) - + le16_to_cpu(npath[i].p_hdr->eh_entries); + if (used > free) + break; + err = ext4_ext_get_access(handle, inode, npath + i); + if (err) + return err; + memmove(EXT_FIRST_INDEX(npath[i].p_hdr) + used, + EXT_FIRST_INDEX(npath[i].p_hdr), + npath[i].p_hdr->eh_entries * sizeof(struct ext4_extent_idx)); + memcpy(EXT_FIRST_INDEX(npath[i].p_hdr), EXT_FIRST_INDEX(path[i].p_hdr), + used * sizeof(struct ext4_extent_idx)); + le16_add_cpu(&path[i].p_hdr->eh_entries, -used); + le16_add_cpu(&npath[i].p_hdr->eh_entries, used); + err = ext4_ext_dirty(handle, inode, path + i); + if (err) + return err; + err = ext4_ext_dirty(handle, inode, npath + i); + if (err) + return err; + + /* correct index above */ + for (k = i; k > 0; k--) { + err = ext4_ext_get_access(handle, inode, npath + k - 1); + if (err) + return err; + npath[k-1].p_idx->ei_block = + EXT_FIRST_INDEX(npath[k].p_hdr)->ei_block; + err = ext4_ext_dirty(handle, inode, npath + k - 1); + if (err) + return err; + } + } + + /* + * TODO: given we've got two paths, it should be possible to + * collapse those two blocks into the root one in some cases + */ + return 1; +} + +static int ext4_ext_try_to_merge_blocks(handle_t *handle, + struct inode *inode, + struct ext4_ext_path *path) +{ + struct ext4_ext_path *npath = NULL; + unsigned int depth = ext_depth(inode); + ext4_lblk_t next; + int used, rc = 0; + + if (depth == 0) + return 0; + + used = le16_to_cpu(path[depth].p_hdr->eh_entries); + /* don't be too agressive as checking space in + * the next block is not free */ + if (used > ext4_ext_space_block(inode, 0) / 4) + return 0; + + /* try to merge to the next block */ + next = ext4_ext_next_leaf_block(path); + if (next == EXT_MAX_BLOCKS) + return 0; + npath = ext4_find_extent(inode, next, NULL, 0); + if (IS_ERR(npath)) + return 0; + rc = ext4_ext_merge_blocks(handle, inode, path, npath); + ext4_ext_drop_refs(npath); + kfree(npath); + if (rc) + return rc > 0 ? 0 : rc; + + /* try to merge with the previous block */ + if (EXT_FIRST_EXTENT(path[depth].p_hdr)->ee_block == 0) + return 0; + next = EXT_FIRST_EXTENT(path[depth].p_hdr)->ee_block - 1; + npath = ext4_find_extent(inode, next, NULL, 0); + if (IS_ERR(npath)) + return 0; + rc = ext4_ext_merge_blocks(handle, inode, npath, path); + ext4_ext_drop_refs(npath); + kfree(npath); + return rc > 0 ? 0 : rc; } /* @@ -1976,6 +2145,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, int depth, len, err; ext4_lblk_t next; int mb_flags = 0, unwritten; + int merged = 0; if (gb_flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) mb_flags |= EXT4_MB_DELALLOC_RESERVED; @@ -2167,8 +2337,7 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, merge: /* try to merge extents */ if (!(gb_flags & EXT4_GET_BLOCKS_PRE_IO)) - ext4_ext_try_to_merge(handle, inode, path, nearex); - + merged = ext4_ext_try_to_merge(handle, inode, path, nearex); /* time to correct all indexes above */ err = ext4_ext_correct_indexes(handle, inode, path); @@ -2176,6 +2345,8 @@ int ext4_ext_insert_extent(handle_t *handle, struct inode *inode, goto cleanup; err = ext4_ext_dirty(handle, inode, path + path->p_depth); + if (!err && merged) + err = ext4_ext_try_to_merge_blocks(handle, inode, path); cleanup: ext4_free_ext_path(npath); @@ -3741,7 +3912,8 @@ static int ext4_convert_unwritten_extents_endio(handle_t *handle, /* note: ext4_ext_correct_indexes() isn't needed here because * borders are not changed */ - ext4_ext_try_to_merge(handle, inode, path, ex); + if (ext4_ext_try_to_merge(handle, inode, path, ex)) + ext4_ext_try_to_merge_blocks(handle, inode, path); /* Mark modified extent as dirty */ err = ext4_ext_dirty(handle, inode, path + path->p_depth); @@ -3804,7 +3976,8 @@ convert_initialized_extent(handle_t *handle, struct inode *inode, /* note: ext4_ext_correct_indexes() isn't needed here because * borders are not changed */ - ext4_ext_try_to_merge(handle, inode, path, ex); + if (ext4_ext_try_to_merge(handle, inode, path, ex)) + ext4_ext_try_to_merge_blocks(handle, inode, path); /* Mark modified extent as dirty */ err = ext4_ext_dirty(handle, inode, path + path->p_depth); diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index cb0b8d6fc0c6..4cd738fa408e 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c @@ -513,6 +513,7 @@ handle_t *jbd2__journal_start(journal_t *journal, int nblocks, int rsv_blocks, } rsv_handle->h_reserved = 1; rsv_handle->h_journal = journal; + rsv_handle->h_revoke_credits = revoke_records; handle->h_rsv_handle = rsv_handle; } handle->h_revoke_credits = revoke_records;