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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20101025190840.GI16981@thunk.org>
Date:	Mon, 25 Oct 2010 15:08:41 -0400
From:	Ted Ts'o <tytso@....edu>
To:	Lukas Czerner <lczerner@...hat.com>
Cc:	linux-ext4@...r.kernel.org, rwheeler@...hat.com,
	sandeen@...hat.com, adilger@...ger.ca,
	Dmitry Monakhov <dmonakhov@...nvz.org>
Subject: Re: [PATCH 3/4] ext4: Add batched discard support for ext4

The following diff (against this patch) allows the ext4 tree to build
on 32-bit x86.  I'm still not entirely convinced the right thing
happens when start+len goes beyond the end of the file system....

	     	       	    	   - Ted

diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index 8cbef43..e3bcc06 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -4761,7 +4761,6 @@ ext4_grpblk_t ext4_trim_all_free(struct super_block *sb, struct ext4_buddy *e4b,
 	ext4_lock_group(sb, group);
 
 	while (start < max) {
-
 		start = mb_find_next_zero_bit(bitmap, max, start);
 		if (start >= max)
 			break;
@@ -4816,10 +4815,9 @@ ext4_grpblk_t ext4_trim_all_free(struct super_block *sb, struct ext4_buddy *e4b,
 int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
 {
 	struct ext4_buddy e4b;
-	ext4_fsblk_t first_group, last_group;
+	ext4_group_t first_group, last_group;
 	ext4_group_t group, ngroups = ext4_get_groups_count(sb);
 	ext4_grpblk_t cnt = 0, first_block, last_block;
-	struct ext4_super_block *es = EXT4_SB(sb)->s_es;
 	uint64_t start, len, minlen, trimmed;
 	int ret = 0;
 
@@ -4832,21 +4830,17 @@ int ext4_trim_fs(struct super_block *sb, struct fstrim_range *range)
 		return -EINVAL;
 
 	/* Determine first and last group to examine based on start and len */
-	first_group = (start - le32_to_cpu(es->s_first_data_block)) /
-		      EXT4_BLOCKS_PER_GROUP(sb);
-	last_group = (start + len - le32_to_cpu(es->s_first_data_block)) /
-		     EXT4_BLOCKS_PER_GROUP(sb);
+	ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) start,
+				     &first_group, &first_block);
+	ext4_get_group_no_and_offset(sb, (ext4_fsblk_t) (start + len),
+				     &last_group, &last_block);
 	last_group = (last_group > ngroups - 1) ? ngroups - 1 : last_group;
+	last_block = EXT4_BLOCKS_PER_GROUP(sb);
 
 	if (first_group > last_group)
 		return -EINVAL;
 
-	first_block = (start - le32_to_cpu(es->s_first_data_block)) %
-			EXT4_BLOCKS_PER_GROUP(sb);
-	last_block = EXT4_BLOCKS_PER_GROUP(sb);
-
 	for (group = first_group; group <= last_group; group++) {
-
 		ret = ext4_mb_load_buddy(sb, group, &e4b);
 		if (ret) {
 			ext4_error(sb, "Error in loading buddy "
--
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