All of lore.kernel.org
 help / color / mirror / Atom feed
From: Valerie Aurora Henson <vaurora@redhat.com>
To: linux-ext4@vger.kernel.org
Cc: Theodore Tso <tytso@mit.edu>, kylerlaird0@users.sourceforge.net
Subject: [PATCH] Add some missing ext2_div64_ceil() calls
Date: Wed, 15 Apr 2009 16:55:20 -0400	[thread overview]
Message-ID: <20090415205520.GI1668@shell> (raw)

commit 350f9efc9cd06209b03e920711ee00fd1b512835
Author: Valerie Aurora (Henson) <vaurora@redhat.com>
Date:   Wed Apr 15 13:41:45 2009 -0700

    Add some missing ext2_div64_ceil() calls
    
    Original bug report:
    
    http://sourceforge.net/tracker/?func=detail&aid=2710927&group_id=2406&atid=102406

diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index c8bdbe6..2b280ad 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -77,6 +77,10 @@ static unsigned int calc_reserved_gdt_blocks(ext2_filsys fs)
 	 */
 	if (ext2fs_blocks_count(sb) < max_blocks / 1024)
 		max_blocks = ext2fs_blocks_count(sb) * 1024;
+	/*
+	 * ext2fs_div64_ceil() is unnecessary because max_blocks is
+	 * max _GDT_ blocks, which is limited to 32 bits.
+	 */
 	rsv_groups = ext2fs_div_ceil(max_blocks - sb->s_first_data_block, bpg);
 	rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) - fs->desc_blocks;
 	if (rsv_gdb > EXT2_ADDR_PER_BLOCK(sb))
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 44e7e66..9c3f736 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -689,7 +689,8 @@ static void parse_extended_opts(struct ext2_super_block *param,
 				continue;
 			}
 		} else if (!strcmp(token, "resize")) {
-			unsigned long resize, bpg, rsv_groups;
+			blk64_t resize;
+			unsigned long bpg, rsv_groups;
 			unsigned long group_desc_count, desc_blocks;
 			unsigned int gdpb, blocksize;
 			int rsv_gdb;
@@ -727,7 +728,7 @@ static void parse_extended_opts(struct ext2_super_block *param,
 				ext2fs_blocks_count(param), bpg);
 			desc_blocks = (group_desc_count +
 				       gdpb - 1) / gdpb;
-			rsv_groups = ext2fs_div_ceil(resize, bpg);
+			rsv_groups = ext2fs_div64_ceil(resize, bpg);
 			rsv_gdb = ext2fs_div_ceil(rsv_groups, gdpb) -
 				desc_blocks;
 			if (rsv_gdb > (int) EXT2_ADDR_PER_BLOCK(param))
diff --git a/resize/online.c b/resize/online.c
index 704e4bb..57ed2c2 100644
--- a/resize/online.c
+++ b/resize/online.c
@@ -48,9 +48,9 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 	 * the on-line resizing inode must be present.
 	 */
 	new_desc_blocks = ext2fs_div_ceil(
-		ext2fs_div_ceil(*new_size -
-				fs->super->s_first_data_block,
-				EXT2_BLOCKS_PER_GROUP(fs->super)),
+		ext2fs_div64_ceil(*new_size -
+				  fs->super->s_first_data_block,
+				  EXT2_BLOCKS_PER_GROUP(fs->super)),
 		EXT2_DESC_PER_BLOCK(fs->super));
 	printf("old desc_blocks = %lu, new_desc_blocks = %lu\n",
 	       fs->desc_blocks, new_desc_blocks);
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index c27df86..6a17de0 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -1850,8 +1850,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 	blks_needed = ext2fs_div_ceil(inode_count,
 				      fs->super->s_inodes_per_group) *
 		EXT2_BLOCKS_PER_GROUP(fs->super);
-	groups = ext2fs_div_ceil(blks_needed,
-				 EXT2_BLOCKS_PER_GROUP(fs->super));
+	groups = ext2fs_div64_ceil(blks_needed,
+				   EXT2_BLOCKS_PER_GROUP(fs->super));
 
 	/*
 	 * we need to figure out how many backup superblocks we have so we can
@@ -1901,8 +1901,8 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs)
 		blk64_t extra_grps;
 
 		/* figure out how many more groups we need for the data */
-		extra_grps = ext2fs_div_ceil(remainder,
-					     EXT2_BLOCKS_PER_GROUP(fs->super));
+		extra_grps = ext2fs_div64_ceil(remainder,
+					       EXT2_BLOCKS_PER_GROUP(fs->super));
 
 		data_blocks += extra_grps * EXT2_BLOCKS_PER_GROUP(fs->super);
 

                 reply	other threads:[~2009-04-15 20:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090415205520.GI1668@shell \
    --to=vaurora@redhat.com \
    --cc=kylerlaird0@users.sourceforge.net \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.