lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20240125213117.60359293@x390.bzzz77.ru>
Date: Thu, 25 Jan 2024 21:31:17 +0300
From: Alexey Zhuravlev <bzzz@...mcloud.com>
To: linux-ext4@...r.kernel.org
Subject: [PATCH] shrink extent tree

Hi,

Please have a look at the patch attempting to shrink extents tree.

Thanks, Alex
---
 fs/ext5/extents.c | 29 +++++++++++++++++++++++++----
 1 file changed, 25 insertions(+), 4 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 0fd9fbd65711..4cd2f0d57917 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2025,10 +2025,31 @@ static int ext4_ext_merge_blocks(handle_t *handle,
 		}
 	}
 
-	/*
-	 * TODO: given we've got two paths, it should be possible to
-	 * collapse those two blocks into the root one in some cases
-	 */
+	/* move the next level into the root if possible */
+	k = le16_to_cpu(path[1].p_hdr->eh_entries);
+	if (depth > 2 && le16_to_cpu(path[0].p_hdr->eh_entries == 1) &&
+		path[1].p_hdr == npath[1].p_hdr &&
+		k <= le16_to_cpu(path[0].p_hdr->eh_max)) {
+
+		next = ext4_idx_pblock(path[0].p_idx);
+
+		err = ext4_ext_get_access(handle, inode, path + 0);
+		if (err)
+			return err;
+		memcpy(EXT_FIRST_INDEX(path[0].p_hdr),
+			EXT_FIRST_INDEX(path[1].p_hdr),
+			k * sizeof(struct ext4_extent_idx));
+		path[0].p_hdr->eh_entries = cpu_to_le16(k);
+		le16_add_cpu(&path[0].p_hdr->eh_depth, -1);
+		err = ext4_ext_dirty(handle, inode, path + 0);
+		if (err)
+			return err;
+
+		ext4_free_blocks(handle, inode, NULL, next, 1,
+				EXT4_FREE_BLOCKS_METADATA |
+				EXT4_FREE_BLOCKS_FORGET);
+	}
+
 	return 1;
 }
 
-- 
2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ