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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1251905704-10078-1-git-send-email-bergwolf@gmail.com>
Date:	Wed,  2 Sep 2009 23:35:04 +0800
From:	Peng Tao <bergwolf@...il.com>
To:	linux-ext4@...r.kernel.org
Cc:	Theodore Tso <tytso@....edu>,
	Akira Fujita <a-fujita@...jp.nec.com>,
	Peng Tao <bergwolf@...il.com>
Subject: [PATCH] e4defrag: fallocate donor file only once

If we allocate the donor file once for all, it will have a better chance
to be continuous.

Signed-off-by: "Peng Tao" <bergwolf@...il.com>
---
 misc/e4defrag.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index c25514a..c1e9213 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -1603,6 +1603,7 @@ static int file_defrag(const char *file, const struct stat64 *buf,
 	struct fiemap_extent_list	*donor_list_logical = NULL;
 	struct fiemap_extent_group	*orig_group_head = NULL;
 	struct fiemap_extent_group	*orig_group_tmp = NULL;
+	ext4_fsblk_t	orig_block_count;
 
 	defraged_file_count++;
 
@@ -1742,19 +1743,17 @@ static int file_defrag(const char *file, const struct stat64 *buf,
 	/* Allocate space for donor inode */
 	orig_group_tmp = orig_group_head;
 	do {
-		ret = fallocate(donor_fd, 0,
-		  (loff_t)orig_group_tmp->start->data.logical * block_size,
-		  (loff_t)orig_group_tmp->len * block_size);
-		if (ret < 0) {
-			if (mode_flag & DETAIL) {
-				PRINT_FILE_NAME(file);
-				PRINT_ERR_MSG_WITH_ERRNO("Failed to fallocate");
-			}
-			goto out;
-		}
-
+		orig_block_count += orig_group_tmp->len;
 		orig_group_tmp = orig_group_tmp->next;
 	} while (orig_group_tmp != orig_group_head);
+	ret = fallocate(donor_fd, 0, 0, (loff_t)orig_block_count * block_size);
+	if (ret < 0) {
+		if (mode_flag & DETAIL) {
+			PRINT_FILE_NAME(file);
+			PRINT_ERR_MSG_WITH_ERRNO("Failed to fallocate");
+		}
+		goto out;
+	}
 
 	/* Get donor inode's extents */
 	ret = get_file_extents(donor_fd, &donor_list_physical);
-- 
1.6.2-rc2.GIT

--
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