All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] resize2fs: let online resizing report new blocks count right
@ 2012-02-01  3:04 Yongqiang Yang
  2012-04-01 15:19 ` Andreas Dilger
  0 siblings, 1 reply; 2+ messages in thread
From: Yongqiang Yang @ 2012-02-01  3:04 UTC (permalink / raw)
  To: linux-ext4, tytso, dsd; +Cc: Yongqiang Yang

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] resize2fs: let online resizing report new blocks count right
  2012-02-01  3:04 [PATCH] resize2fs: let online resizing report new blocks count right Yongqiang Yang
@ 2012-04-01 15:19 ` Andreas Dilger
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Dilger @ 2012-04-01 15:19 UTC (permalink / raw)
  To: Yongqiang Yang; +Cc: linux-ext4, tytso, dsd, Yongqiang Yang


On 2012-01-31, at 20:04, Yongqiang Yang <xiaoqiangnk@gmail.com> wrote:

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

Instead of using io_channel_read_blk() directly it is also possible to use ext2fs_read_block() with a negative size to force it to bypass the ext2fs cache. 

Cheers, Andreas

> +    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
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-04-01 15:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-01  3:04 [PATCH] resize2fs: let online resizing report new blocks count right Yongqiang Yang
2012-04-01 15:19 ` Andreas Dilger

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.