Add support for on-line resizing to resize2fs
If the filesystem is mounted, attempt to use the on-line resizing
ioctls to resize the filesystem.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index f2cd2fb..eb8c09c 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,9 @@
+2006-03-17 Theodore Ts'o <tytso@mit.edu>
+
+ * ext2_fs.h (EXT2_IOC_GETVERSION_NEW, EXT2_IOC_SETVERSION_NEW,
+ EXT2_IOC_GROUP_EXTEND, EXT2_IOC_GROUP_ADD): Add ioctl
+ definitions
+
2005-12-10 Theodore Ts'o <tytso@mit.edu>
* Makefile.in: Add a dependency to make sure that the
diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h
index ff615c4..e427add 100644
--- a/lib/ext2fs/ext2_fs.h
+++ b/lib/ext2fs/ext2_fs.h
@@ -242,10 +242,26 @@
/*
* ioctl commands
*/
+
+/* Used for online resize */
+struct ext2_new_group_input {
+ __u32 group; /* Group number for this data */
+ __u32 block_bitmap; /* Absolute block number of block bitmap */
+ __u32 inode_bitmap; /* Absolute block number of inode bitmap */
+ __u32 inode_table; /* Absolute block number of inode table start */
+ __u32 blocks_count; /* Total number of blocks in this group */
+ __u16 reserved_blocks; /* Number of reserved blocks in this group */
+ __u16 unused; /* Number of reserved GDT blocks in group */
+};
+
#define EXT2_IOC_GETFLAGS _IOR('f', 1, long)
#define EXT2_IOC_SETFLAGS _IOW('f', 2, long)
#define EXT2_IOC_GETVERSION _IOR('v', 1, long)
#define EXT2_IOC_SETVERSION _IOW('v', 2, long)
+#define EXT2_IOC_GETVERSION_NEW _IOR('f', 3, long)
+#define EXT2_IOC_SETVERSION_NEW _IOW('f', 4, long)
+#define EXT2_IOC_GROUP_EXTEND _IOW('f', 7, unsigned long)
+#define EXT2_IOC_GROUP_ADD _IOW('f', 8,struct ext2_new_group_input)
/*
* Structure of an inode on the disk
diff --git a/resize/ChangeLog b/resize/ChangeLog
index a6b2ac3..07ca8f4 100644
--- a/resize/ChangeLog
+++ b/resize/ChangeLog
@@ -1,3 +1,24 @@
+2006-03-17 Theodore Ts'o <tytso@mit.edu>
+
+ * resize2fs.8.in: Update manpage to document that that resize2fs
+ can expand a mounted filesystem.
+
+ * online.c (online_resize_fs): New file which contains the on-line
+ resizing code.
+
+ * main.c (main): If the filesystem to be resized is already
+ mounted, determine the mountpoint, and call online_resize_fs().
+
+ * resize2fs.c (adjust_fs_info, adjust_superblock): Factor out code
+ which only adjusts the in-memory data structures from the
+ code which writes to the disk, since the former can be
+ used by the on-line resizing code.
+
+ * resize2fs.h: Add function prototypes for online_resize_fs() and
+ adjust_fs_info().
+
+ * Makefile.in (RESIZE_OBJS): Add online.o to list of files to be built.
+
2005-12-29 Theodore Ts'o <tytso@mit.edu>
* resize2fs.c (mark_table_blocks): Remove unused variables to
diff --git a/resize/Makefile.in b/resize/Makefile.in
index ebf3e72..6758912 100644
--- a/resize/Makefile.in
+++ b/resize/Makefile.in
@@ -16,13 +16,14 @@
TEST_PROGS= test_extent
MANPAGES= resize2fs.8
-RESIZE_OBJS= extent.o resize2fs.o main.o sim_progress.o
+RESIZE_OBJS= extent.o resize2fs.o main.o online.o sim_progress.o
TEST_EXTENT_OBJS= extent.o test_extent.o
SRCS= $(srcdir)/extent.c \
$(srcdir)/resize2fs.c \
$(srcdir)/main.c \
+ $(srcdir)/online.c \
$(srcdir)/sim_progress.c
LIBS= $(LIBE2P) $(LIBEXT2FS) $(LIBCOM_ERR) $(LIBINTL)
@@ -159,6 +160,11 @@
$(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
$(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h \
$(top_srcdir)/version.h
+online.o: $(srcdir)/online.c $(srcdir)/resize2fs.h \
+ $(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
+ $(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
+ $(top_srcdir)/lib/et/com_err.h $(top_srcdir)/lib/ext2fs/ext2_io.h \
+ $(top_builddir)/lib/ext2fs/ext2_err.h $(top_srcdir)/lib/ext2fs/bitops.h
sim_progress.o: $(srcdir)/sim_progress.c $(srcdir)/resize2fs.h \
$(top_srcdir)/lib/ext2fs/ext2_fs.h $(top_builddir)/lib/ext2fs/ext2_types.h \
$(top_srcdir)/lib/ext2fs/ext2fs.h $(top_srcdir)/lib/ext2fs/ext2_fs.h \
diff --git a/resize/main.c b/resize/main.c
index 1142c9c..d6ddaa7 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -94,26 +94,6 @@
return 0;
}
-static void check_mount(char *device)
-{
- errcode_t retval;
- int mount_flags;
-
- retval = ext2fs_check_if_mounted(device, &mount_flags);
- if (retval) {
- com_err("ext2fs_check_if_mount", retval,
- _("while determining whether %s is mounted."),
- device);
- return;
- }
- if (!(mount_flags & EXT2_MF_MOUNTED))
- return;
-
- fprintf(stderr, _("%s is mounted; can't resize a "
- "mounted filesystem!\n\n"), device);
- exit(1);
-}
-
int main (int argc, char ** argv)
{
errcode_t retval;
@@ -135,6 +115,8 @@
__s64 new_file_size;
unsigned int sys_page_size = 4096;
long sysval;
+ int len, mount_flags;
+ char *mtpt;
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
@@ -184,7 +166,29 @@
if (io_options)
*io_options++ = 0;
- check_mount(device_name);
+ /*
+ * Figure out whether or not the device is mounted, and if it is
+ * where it is mounted.
+ */
+ len=80;
+ while (1) {
+ mtpt = malloc(len);
+ if (!mtpt)
+ return ENOMEM;
+ mtpt[len-1] = 0;
+ retval = ext2fs_check_mount_point(device_name, &mount_flags,
+ mtpt, len);
+ if (retval) {
+ com_err("ext2fs_check_mount_point", retval,
+ _("while determining whether %s is mounted."),
+ device_name);
+ exit(1);
+ }
+ if (!(mount_flags & EXT2_MF_MOUNTED) || (mtpt[len-1] == 0))
+ break;
+ free(mtpt);
+ len = 2 * len;
+ }
#ifdef HAVE_OPEN64
fd = open64(device_name, O_RDWR);
@@ -314,18 +318,23 @@
"long. Nothing to do!\n\n"), new_size);
exit(0);
}
- if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
- (fs->super->s_state & EXT2_ERROR_FS) ||
- ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
- fprintf(stderr, _("Please run 'e2fsck -f %s' first.\n\n"),
- device_name);
- exit(1);
+ if (mount_flags & EXT2_MF_MOUNTED) {
+ retval = online_resize_fs(fs, mtpt, &new_size, flags);
+ } else {
+ if (!force && ((fs->super->s_lastcheck < fs->super->s_mtime) ||
+ (fs->super->s_state & EXT2_ERROR_FS) ||
+ ((fs->super->s_state & EXT2_VALID_FS) == 0))) {
+ fprintf(stderr,
+ _("Please run 'e2fsck -f %s' first.\n\n"),
+ device_name);
+ exit(1);
+ }
+ printf("Resizing the filesystem on %s to %d (%dk) blocks.\n",
+ device_name, new_size, fs->blocksize / 1024);
+ retval = resize_fs(fs, &new_size, flags,
+ ((flags & RESIZE_PERCENT_COMPLETE) ?
+ resize_progress_func : 0));
}
- printf("Resizing the filesystem on %s to %d (%dk) blocks.\n",
- device_name, new_size, fs->blocksize / 1024);
- retval = resize_fs(fs, &new_size, flags,
- ((flags & RESIZE_PERCENT_COMPLETE) ?
- resize_progress_func : 0));
if (retval) {
com_err(program_name, retval, _("while trying to resize %s"),
device_name);
diff --git a/resize/online.c b/resize/online.c
new file mode 100644
index 0000000..45262b1
--- /dev/null
+++ b/resize/online.c
@@ -0,0 +1,141 @@
+/*
+ * online.c --- Do on-line resizing of the ext3 filesystem
+ *
+ * Copyright (C) 2006 by Theodore Ts'o
+ *
+ * %Begin-Header%
+ * This file may be redistributed under the terms of the GNU Public
+ * License.
+ * %End-Header%
+ */
+
+#include "resize2fs.h"
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#include <sys/stat.h>
+#include <fcntl.h>
+
+extern char *program_name;
+
+errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
+ blk_t *new_size, int flags)
+{
+ struct ext2_new_group_input input;
+ struct ext2_super_block *sb = fs->super;
+ ext2_filsys new_fs;
+ errcode_t retval;
+ dgrp_t i;
+ blk_t size;
+ int fd, r_frac, overhead;
+
+ printf(_("Filesystem at %s is mounted on %s; "
+ "on-line resizing required\n"), fs->device_name, mtpt);
+
+ if (*new_size < sb->s_blocks_count) {
+ printf(_("On-line shrinking from %u to %u not supported.\n"),
+ sb->s_blocks_count, *new_size);
+ exit(1);
+ }
+
+ fd = open(mtpt, O_RDONLY);
+ if (fd < 0) {
+ com_err(program_name, errno,
+ _("while trying to open mountpoint %s"), mtpt);
+ exit(1);
+ }
+
+ size=sb->s_blocks_count;
+ if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) {
+ if (errno == EPERM)
+ com_err(program_name, 0,
+ _("Permission denied to resize filesystem"));
+ else if (errno == ENOTTY)
+ com_err(program_name, 0,
+ _("Filesystem does not support online resizing"));
+ else
+ com_err(program_name, errno,
+ _("While checking for on-line resizing support"));
+ exit(1);
+ }
+
+ r_frac = ((100 * sb->s_r_blocks_count) + sb->s_blocks_count-1) /
+ sb->s_blocks_count;
+
+ retval = ext2fs_read_bitmaps(fs);
+ if (retval)
+ return retval;
+
+ retval = ext2fs_dup_handle(fs, &new_fs);
+ if (retval)
+ return retval;
+
+ retval = adjust_fs_info(new_fs, fs, *new_size);
+ if (retval)
+ return retval;
+
+ printf(_("Performing an on-line resize of %s to %d (%dk) blocks.\n"),
+ fs->device_name, *new_size, fs->blocksize / 1024);
+
+ size = fs->group_desc_count * sb->s_blocks_per_group +
+ sb->s_first_data_block;
+ if (size > *new_size)
+ size = *new_size;
+
+ if (ioctl(fd, EXT2_IOC_GROUP_EXTEND, &size)) {
+ com_err(program_name, errno,
+ _("While trying to extend the last group"));
+ exit(1);
+ }
+
+ for (i = fs->group_desc_count;
+ i < new_fs->group_desc_count; i++) {
+
+ overhead = (int) (2 + new_fs->inode_blocks_per_group);
+
+ if (ext2fs_bg_has_super(new_fs, new_fs->group_desc_count - 1))
+ overhead += 1 + new_fs->desc_blocks +
+ new_fs->super->s_reserved_gdt_blocks;
+
+ input.group = i;
+ input.block_bitmap = new_fs->group_desc[i].bg_block_bitmap;
+ input.inode_bitmap = new_fs->group_desc[i].bg_inode_bitmap;
+ input.inode_table = new_fs->group_desc[i].bg_inode_table;
+ input.blocks_count = sb->s_blocks_per_group;
+ if (i == new_fs->group_desc_count-1) {
+ input.blocks_count = new_fs->super->s_blocks_count -
+ sb->s_first_data_block -
+ (i * sb->s_blocks_per_group);
+ }
+ input.reserved_blocks = input.blocks_count * r_frac / 100;
+
+#if 0
+ printf("new block bitmap is at 0x%04x\n", input.block_bitmap);
+ printf("new inode bitmap is at 0x%04x\n", input.inode_bitmap);
+ printf("new inode table is at 0x%04x-0x%04x\n",
+ input.inode_table,
+ input.inode_table + new_fs->inode_blocks_per_group-1);
+ printf("new group has %d blocks\n", input.blocks_count);
+ printf("new group will reserve %d blocks\n",
+ input.reserved_blocks);
+ printf("new group has %d free blocks\n",
+ new_fs->group_desc[i].bg_free_blocks_count);
+ printf("new group has %d free inodes (%d blocks)\n",
+ new_fs->group_desc[i].bg_free_inodes_count,
+ new_fs->inode_blocks_per_group);
+ printf("Adding group #%d\n", input.group);
+#endif
+
+ if (ioctl(fd, EXT2_IOC_GROUP_ADD, &input) < 0) {
+ com_err(program_name, errno,
+ _("While trying to add group #%d"),
+ input.group);
+ exit(1);
+ }
+ }
+
+ ext2fs_free(new_fs);
+ close(fd);
+
+ return 0;
+}
diff --git a/resize/resize2fs.8.in b/resize/resize2fs.8.in
index 81a5135..426c3ce 100644
--- a/resize/resize2fs.8.in
+++ b/resize/resize2fs.8.in
@@ -28,8 +28,13 @@
The
.B resize2fs
program will resize ext2 file systems. It can be used to enlarge or
-shrink an ext2 file system located on
+shrink an unmounted ext2 file system located on
.IR device .
+If the filesystem is mounted, it can be used to expand the size of the
+mounted filesystem, assuming the kernel supports on-line resizing. (As
+of this writing, the Linux 2.6 kernel supports on-line resize for
+filesystems mounted using ext3 only.).
+.PP
The
.I size
parameter specifies the requested new size of the filesystem.
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 4eefd0d..d920bef 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -172,27 +172,22 @@
*/
/*
- * This routine adjusts the superblock and other data structures...
+ * This routine is shared by the online and offline resize routines.
+ * All of the information which is adjusted in memory is done here.
*/
-static errcode_t adjust_superblock(ext2_resize_t rfs, blk_t new_size)
+errcode_t adjust_fs_info(ext2_filsys fs, ext2_filsys old_fs, blk_t new_size)
{
- ext2_filsys fs;
- int overhead = 0;
- int rem, adj = 0;
errcode_t retval;
- ext2_ino_t real_end;
+ int overhead = 0;
+ int rem;
blk_t blk, group_block;
- unsigned long i, j, old_desc_blocks;
- int old_numblocks, numblocks, adjblocks;
+ ext2_ino_t real_end;
+ int adj, old_numblocks, numblocks, adjblocks;
+ unsigned long i, j, old_desc_blocks, max_group;
unsigned int meta_bg, meta_bg_size;
int has_super;
- unsigned long max_group;
-
- fs = rfs->new_fs;
+
fs->super->s_blocks_count = new_size;
- ext2fs_mark_super_dirty(fs);
- ext2fs_mark_bb_dirty(fs);
- ext2fs_mark_ib_dirty(fs);
retry:
fs->group_desc_count = (fs->super->s_blocks_count -
@@ -239,7 +234,7 @@
/*
* Adjust the number of free blocks
*/
- blk = rfs->old_fs->super->s_blocks_count;
+ blk = old_fs->super->s_blocks_count;
if (blk > fs->super->s_blocks_count)
fs->super->s_free_blocks_count -=
(blk - fs->super->s_blocks_count);
@@ -250,8 +245,8 @@
/*
* Adjust the number of reserved blocks
*/
- blk = rfs->old_fs->super->s_r_blocks_count * 100 /
- rfs->old_fs->super->s_blocks_count;
+ blk = old_fs->super->s_r_blocks_count * 100 /
+ old_fs->super->s_blocks_count;
fs->super->s_r_blocks_count = ((fs->super->s_blocks_count * blk)
/ 100);
@@ -274,31 +269,21 @@
/*
* Reallocate the group descriptors as necessary.
*/
- if (rfs->old_fs->desc_blocks != fs->desc_blocks) {
- retval = ext2fs_resize_mem(rfs->old_fs->desc_blocks *
+ if (old_fs->desc_blocks != fs->desc_blocks) {
+ retval = ext2fs_resize_mem(old_fs->desc_blocks *
fs->blocksize,
fs->desc_blocks * fs->blocksize,
&fs->group_desc);
if (retval)
goto errout;
- if (fs->desc_blocks > rfs->old_fs->desc_blocks)
+ if (fs->desc_blocks > old_fs->desc_blocks)
memset((char *) fs->group_desc +
- (rfs->old_fs->desc_blocks * fs->blocksize), 0,
- (fs->desc_blocks - rfs->old_fs->desc_blocks) *
+ (old_fs->desc_blocks * fs->blocksize), 0,
+ (fs->desc_blocks - old_fs->desc_blocks) *
fs->blocksize);
}
/*
- * Check to make sure there are enough inodes
- */
- if ((rfs->old_fs->super->s_inodes_count -
- rfs->old_fs->super->s_free_inodes_count) >
- rfs->new_fs->super->s_inodes_count) {
- retval = ENOSPC;
- goto errout;
- }
-
- /*
* If the resize_inode feature is set, and we are changing the
* number of descriptor blocks, then adjust
* s_reserved_gdt_blocks if possible to avoid needing to move
@@ -306,11 +291,11 @@
*/
if ((fs->super->s_feature_compat &
EXT2_FEATURE_COMPAT_RESIZE_INODE) &&
- (rfs->old_fs->desc_blocks != fs->desc_blocks)) {
+ (old_fs->desc_blocks != fs->desc_blocks)) {
int new;
new = ((int) fs->super->s_reserved_gdt_blocks) +
- (rfs->old_fs->desc_blocks - fs->desc_blocks);
+ (old_fs->desc_blocks - fs->desc_blocks);
if (new < 0)
new = 0;
if (new > fs->blocksize/4)
@@ -325,27 +310,28 @@
* If we are shrinking the number block groups, we're done and
* can exit now.
*/
- if (rfs->old_fs->group_desc_count > fs->group_desc_count) {
+ if (old_fs->group_desc_count > fs->group_desc_count) {
retval = 0;
goto errout;
}
+
/*
* Fix the count of the last (old) block group
*/
- old_numblocks = (rfs->old_fs->super->s_blocks_count -
- rfs->old_fs->super->s_first_data_block) %
- rfs->old_fs->super->s_blocks_per_group;
+ old_numblocks = (old_fs->super->s_blocks_count -
+ old_fs->super->s_first_data_block) %
+ old_fs->super->s_blocks_per_group;
if (!old_numblocks)
- old_numblocks = rfs->old_fs->super->s_blocks_per_group;
- if (rfs->old_fs->group_desc_count == fs->group_desc_count) {
- numblocks = (rfs->new_fs->super->s_blocks_count -
- rfs->new_fs->super->s_first_data_block) %
- rfs->new_fs->super->s_blocks_per_group;
+ old_numblocks = old_fs->super->s_blocks_per_group;
+ if (old_fs->group_desc_count == fs->group_desc_count) {
+ numblocks = (fs->super->s_blocks_count -
+ fs->super->s_first_data_block) %
+ fs->super->s_blocks_per_group;
if (!numblocks)
- numblocks = rfs->new_fs->super->s_blocks_per_group;
+ numblocks = fs->super->s_blocks_per_group;
} else
- numblocks = rfs->new_fs->super->s_blocks_per_group;
- i = rfs->old_fs->group_desc_count - 1;
+ numblocks = fs->super->s_blocks_per_group;
+ i = old_fs->group_desc_count - 1;
fs->group_desc[i].bg_free_blocks_count += (numblocks-old_numblocks);
/*
@@ -353,36 +339,25 @@
* done and can exit now. (If the number block groups is
* shrinking, we had exited earlier.)
*/
- if (rfs->old_fs->group_desc_count >= fs->group_desc_count) {
+ if (old_fs->group_desc_count >= fs->group_desc_count) {
retval = 0;
goto errout;
}
+
/*
* Initialize the new block group descriptors
*/
- retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group,
- &rfs->itable_buf);
- if (retval)
- goto errout;
-
- memset(rfs->itable_buf, 0, fs->blocksize * fs->inode_blocks_per_group);
group_block = fs->super->s_first_data_block +
- rfs->old_fs->group_desc_count * fs->super->s_blocks_per_group;
+ old_fs->group_desc_count * fs->super->s_blocks_per_group;
- adj = rfs->old_fs->group_desc_count;
+ adj = old_fs->group_desc_count;
max_group = fs->group_desc_count - adj;
- if (rfs->progress) {
- retval = rfs->progress(rfs, E2_RSZ_EXTEND_ITABLE_PASS,
- 0, max_group);
- if (retval)
- goto errout;
- }
if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
old_desc_blocks = fs->super->s_first_meta_bg;
else
old_desc_blocks = fs->desc_blocks +
fs->super->s_reserved_gdt_blocks;
- for (i = rfs->old_fs->group_desc_count;
+ for (i = old_fs->group_desc_count;
i < fs->group_desc_count; i++) {
memset(&fs->group_desc[i], 0,
sizeof(struct ext2_group_desc));
@@ -438,6 +413,87 @@
retval = ext2fs_allocate_group_table(fs, i, 0);
if (retval) goto errout;
+ group_block += fs->super->s_blocks_per_group;
+ }
+ retval = 0;
+
+errout:
+ return (retval);
+}
+
+/*
+ * This routine adjusts the superblock and other data structures, both
+ * in disk as well as in memory...
+ */
+static errcode_t adjust_superblock(ext2_resize_t rfs, blk_t new_size)
+{
+ ext2_filsys fs;
+ int adj = 0;
+ errcode_t retval;
+ blk_t group_block;
+ unsigned long i;
+ unsigned long max_group;
+
+ fs = rfs->new_fs;
+ ext2fs_mark_super_dirty(fs);
+ ext2fs_mark_bb_dirty(fs);
+ ext2fs_mark_ib_dirty(fs);
+
+ retval = adjust_fs_info(fs, rfs->old_fs, new_size);
+ if (retval)
+ goto errout;
+
+ /*
+ * Check to make sure there are enough inodes
+ */
+ if ((rfs->old_fs->super->s_inodes_count -
+ rfs->old_fs->super->s_free_inodes_count) >
+ rfs->new_fs->super->s_inodes_count) {
+ retval = ENOSPC;
+ goto errout;
+ }
+
+ /*
+ * If we are shrinking the number block groups, we're done and
+ * can exit now.
+ */
+ if (rfs->old_fs->group_desc_count > fs->group_desc_count) {
+ retval = 0;
+ goto errout;
+ }
+
+ /*
+ * If the number of block groups is staying the same, we're
+ * done and can exit now. (If the number block groups is
+ * shrinking, we had exited earlier.)
+ */
+ if (rfs->old_fs->group_desc_count >= fs->group_desc_count) {
+ retval = 0;
+ goto errout;
+ }
+
+ /*
+ * Initialize the new block group descriptors
+ */
+ retval = ext2fs_get_mem(fs->blocksize * fs->inode_blocks_per_group,
+ &rfs->itable_buf);
+ if (retval)
+ goto errout;
+
+ memset(rfs->itable_buf, 0, fs->blocksize * fs->inode_blocks_per_group);
+ group_block = fs->super->s_first_data_block +
+ rfs->old_fs->group_desc_count * fs->super->s_blocks_per_group;
+
+ adj = rfs->old_fs->group_desc_count;
+ max_group = fs->group_desc_count - adj;
+ if (rfs->progress) {
+ retval = rfs->progress(rfs, E2_RSZ_EXTEND_ITABLE_PASS,
+ 0, max_group);
+ if (retval)
+ goto errout;
+ }
+ for (i = rfs->old_fs->group_desc_count;
+ i < fs->group_desc_count; i++) {
/*
* Write out the new inode table
*/
diff --git a/resize/resize2fs.h b/resize/resize2fs.h
index 6f262c2..8d325c1 100644
--- a/resize/resize2fs.h
+++ b/resize/resize2fs.h
@@ -125,6 +125,10 @@
int pass, unsigned long cur,
unsigned long max));
+extern errcode_t adjust_fs_info(ext2_filsys fs, ext2_filsys old_fs,
+ blk_t new_size);
+
+
/* extent.c */
extern errcode_t ext2fs_create_extent_table(ext2_extent *ret_extent,
int size);
@@ -136,6 +140,10 @@
extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u32 *old_loc,
__u32 *new_loc, int *size);
+/* online.c */
+extern errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
+ blk_t *new_size, int flags);
+
/* sim_progress.c */
extern errcode_t ext2fs_progress_init(ext2_sim_progmeter *ret_prog,
const char *label,