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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1396788965-11777-1-git-send-email-dmonakhov@openvz.org>
Date:	Sun,  6 Apr 2014 16:56:05 +0400
From:	Dmitry Monakhov <dmonakhov@...nvz.org>
To:	linux-ext4@...r.kernel.org
Cc:	tytso@....edu, Dmitry Monakhov <dmonakhov@...nvz.org>
Subject: [PATCH] resize2fs: fix over-pessimistic heuristic.

In worst case we need one extent per moved block. Number of blocks to
be moved is less or equals to blks_needed.

Signed-off-by: Dmitry Monakhov <dmonakhov@...nvz.org>
---
 resize/resize2fs.c |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index f5f1337..8ca53a3 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -2587,11 +2587,17 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
 	/*
 	 * We need to reserve a few extra blocks if extents are
 	 * enabled, in case we need to grow the extent tree.  The more
-	 * we shrink the file system, the more space we need.
+	 * we shrink the file system, the more blocks will be moved.
+	 * Worse case is one extent per moved block.
 	 */
 	if (fs->super->s_feature_incompat & EXT3_FEATURE_INCOMPAT_EXTENTS) {
-		blk64_t safe_margin = (ext2fs_blocks_count(fs->super) -
-				       blks_needed)/500;
+		blk64_t safe_margin = ext2fs_blocks_count(fs->super)
+			- blks_needed;
+
+		if (safe_margin > blks_needed)
+			safe_margin = blks_needed;
+		safe_margin /= 500;
+
 #ifdef RESIZE2FS_DEBUG
 		if (flags & RESIZE_DEBUG_MIN_CALC)
 			printf("Extents safety margin: %llu\n", safe_margin);
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ