linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Ext4 Developers List <linux-ext4@vger.kernel.org>
Cc: sandeen@redhat.com, Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 2/4] resize2fs: fix -M size calculations to avoid cutting off the inode table
Date: Mon, 30 Sep 2013 23:59:32 -0400	[thread overview]
Message-ID: <1380599974-2886-2-git-send-email-tytso@mit.edu> (raw)
In-Reply-To: <1380599974-2886-1-git-send-email-tytso@mit.edu>

If the file system's inode table blocks in the last block group are
located in the middle or the end of the block group, it's possible for
resize2fs -M to use a size which will require relocating the inode
table blocks in the last block group.  This can lead to all sorts of
problems, so solve it by simply guaranteeing that we will never do
that.

Reported-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 resize/resize2fs.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 51b85b8..1e4ac19 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -2224,6 +2224,15 @@ blk64_t calculate_minimum_resize_size(ext2_filsys fs, int flags)
 	blks_needed = (groups-1) * EXT2_BLOCKS_PER_GROUP(fs->super);
 	blks_needed += overhead;
 
+	/*
+	 * Make sure blks_needed covers the end of the inode table in
+	 * the last block group.
+	 */
+	overhead = ext2fs_inode_table_loc(fs, groups-1) +
+		fs->inode_blocks_per_group;
+	if (blks_needed < overhead)
+		blks_needed = overhead;
+
 #ifdef RESIZE2FS_DEBUG
 	if (flags & RESIZE_DEBUG_MIN_CALC)
 		printf("Estimated blocks needed: %llu\n", blks_needed);
-- 
1.7.12.rc0.22.gcdd159b


  reply	other threads:[~2013-10-01  3:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-02 19:14 [PATCH] e2fsprogs: allocate inode table wholly within group Eric Sandeen
2013-07-04 14:19 ` [PATCH] e2fsprogs FTBFS: " Eric Sandeen
2013-07-07 15:53 ` [PATCH] e2fsprogs: " Theodore Ts'o
2013-07-07 23:34   ` Theodore Ts'o
2013-07-08  1:59   ` Eric Sandeen
2013-07-08 18:34   ` Eric Sandeen
2013-07-08 21:27 ` Eric Sandeen
2013-10-01  1:57   ` Theodore Ts'o
2013-10-01  3:59     ` [PATCH 1/4] resize2fs: add debugging support for resize2fs -M calcuations Theodore Ts'o
2013-10-01  3:59       ` Theodore Ts'o [this message]
2013-10-01  3:59       ` [PATCH 3/4] resize2fs: relocate inode table blocks if necessary when shrinking Theodore Ts'o
2013-10-01  3:59       ` [PATCH 4/4] tests: add test for resize2fs -M with inode table in middle of block group Theodore Ts'o
2013-10-01 15:26     ` [PATCH] e2fsprogs: allocate inode table wholly within group Eric Sandeen
2013-10-01 15:35       ` Eric Sandeen
2013-10-01 16:29         ` Eric Sandeen

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=1380599974-2886-2-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=sandeen@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).