Linux EXT4 FS development
 help / color / mirror / Atom feed
From: Yongqiang Yang <xiaoqiangnk@gmail.com>
To: linux-ext4@vger.kernel.org, tytso@mit.edu, dsd@laptop.org
Cc: Yongqiang Yang <xiaoqiangnk@gmail.com>
Subject: [PATCH] resize2fs: let online resizing report new blocks count right
Date: Wed,  1 Feb 2012 11:04:08 +0800	[thread overview]
Message-ID: <1328065448-13693-1-git-send-email-xiaoqiangnk@gmail.com> (raw)

After online resizing finishes, resize2fs loads the latest super block
so that the new blocks count is reported correctly.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@gmail.com>
---
 resize/online.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/resize/online.c b/resize/online.c
index 966ea1e..cb48556 100644
--- a/resize/online.c
+++ b/resize/online.c
@@ -97,8 +97,7 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 			exit(1);
 		}
 	} else {
-		close(fd);
-		return 0;
+		goto succeeded;
 	}
 
 	if ((ext2fs_blocks_count(sb) > MAX_32_NUM) ||
@@ -220,6 +219,19 @@ errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
 	}
 
 	ext2fs_free(new_fs);
+succeeded:
+	/*
+	 * load the lastest super block.
+ 	 */
+	io_channel_set_blksize(fs->io, SUPERBLOCK_OFFSET);
+	retval = io_channel_read_blk(fs->io, 1, -SUPERBLOCK_SIZE,
+			     fs->super);
+	if (retval == 0)
+		*new_size = ext2fs_blocks_count(fs->super);
+	else
+		printf(_("Resize succeeded, however an error happened "
+		       "when loading super block.\n\n"));
+
 	close(fd);
 
 	return 0;
-- 
1.7.5.1


             reply	other threads:[~2012-04-01 12:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-01  3:04 Yongqiang Yang [this message]
2012-04-01 15:19 ` [PATCH] resize2fs: let online resizing report new blocks count right Andreas Dilger

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=1328065448-13693-1-git-send-email-xiaoqiangnk@gmail.com \
    --to=xiaoqiangnk@gmail.com \
    --cc=dsd@laptop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox