gfs2_grow fails to grow a filesystem with less than 3 rgrps
Hi,
Looks good to me,
Steve.
On Fri, 2011-09-30 at 11:13 -0400, Bob Peterson wrote:
> Hi,
>
> There's a problem with gfs2-utils whereby some of the utils
> can't handle a small file system with one or two rgrps.
> The biggest offender is gfs2_grow: you can't successfully
> gfs2_grow a file system that is so small that it has only one
> resource group. Also, "gfs2_edit savemeta" can't save it.
>
> This patch is designed to remedy the problem by
> creating a generic rgrp_size function in libgfs2
> that calculates the size rather than judging its
> distance from the previous rgrp.
>
> Testing results (today's gfs2_grow versus patched):
> # gfs2_grow /mnt/gfs2
> Segmentation fault (core dumped)
> # ./gfs2_grow /mnt/gfs2
> FS: Mount Point: /mnt/gfs2
> FS: Device: /dev/mapper/vg_gfs2-lv_gfs2
> FS: Size: 127997 (0x1f3fd)
> FS: RG size: 127980 (0x1f3ec)
> DEV: Size: 256000 (0x3e800)
> The file system grew by 500MB.
> gfs2_grow complete.
>
> Regards,
>
> Bob Peterson
> Red Hat File Systems
> --
> gfs2/edit/savemeta.c | 6 ++----
> gfs2/libgfs2/fs_geometry.c | 6 +++---
> gfs2/libgfs2/libgfs2.h | 5 +++++
> gfs2/libgfs2/super.c | 4 ++--
> gfs2/mkfs/main_grow.c | 27 +++++++++------------------
> 5 files changed, 21 insertions(+), 27 deletions(-)
>
> diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
> index 9e5d111..31af23d 100644
> --- a/gfs2/edit/savemeta.c
> +++ b/gfs2/edit/savemeta.c
> @@ -637,7 +637,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
> int rgcount;
> uint64_t jindex_block;
> struct gfs2_buffer_head *lbh;
> - struct rgrp_tree *last_rgd, *prev_rgd;
> + struct rgrp_tree *last_rgd;
> struct metafd mfd;
>
> slow = (saveoption == 1);
> @@ -715,9 +715,7 @@ void savemeta(char *out_fn, int saveoption, int gziplevel)
> n = osi_last(&sbd.rgtree);
> last_rgd = (struct rgrp_tree *)n;
> n = osi_prev(n);
> - prev_rgd = (struct rgrp_tree *)n;
> - fssize = last_rgd->ri.ri_addr +
> - (last_rgd->ri.ri_addr - prev_rgd->ri.ri_addr);
> + fssize = last_rgd->ri.ri_addr + rgrp_size(last_rgd);
> last_fs_block = fssize;
> fssize *= sbd.bsize;
> printf("Done. File system size: %s