Cluster-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/2] libgfs2: Remove die from fix_device_geometry
Date: Tue, 07 Apr 2009 13:34:40 +0100	[thread overview]
Message-ID: <1239107680.29604.30.camel@localhost.localdomain> (raw)
In-Reply-To: <1239107163-17128-1-git-send-email-andy@andrewprice.me.uk>

Hi,

On Tue, 2009-04-07 at 13:26 +0100, Andrew Price wrote:
> This patch removes the die call from fix_device_geometry and adds error
> reporting. All callers are updated to provide the same behaviour as before.
> 
> Signed-off-by: Andrew Price <andy@andrewprice.me.uk>
> ---
>  gfs2/edit/hexedit.c            |    6 +++++-
>  gfs2/edit/savemeta.c           |    6 +++++-
>  gfs2/fsck/rgrepair.c           |    7 ++++++-
>  gfs2/libgfs2/device_geometry.c |   10 ++++++----
>  gfs2/libgfs2/libgfs2.h         |    2 +-
>  gfs2/mkfs/main_grow.c          |    7 ++++++-
>  gfs2/mkfs/main_mkfs.c          |    6 +++++-
>  7 files changed, 34 insertions(+), 10 deletions(-)
> 
> diff --git a/gfs2/edit/hexedit.c b/gfs2/edit/hexedit.c
> index ac21ebd..8a5f3bb 100644
> --- a/gfs2/edit/hexedit.c
> +++ b/gfs2/edit/hexedit.c
> @@ -1752,7 +1752,11 @@ void read_superblock(int fd)
>  	}
>  	block = 0x10 * (GFS2_DEFAULT_BSIZE / sbd.bsize);
>  	device_geometry(&sbd);
> -	fix_device_geometry(&sbd);
> +	if (fix_device_geometry(&sbd)) {
> +		fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n",
> +				sbd.device.length << GFS2_BASIC_BLOCK_SHIFT);
> +		exit(-1);
> +	}
>  	if(gfs1) {
>  		sbd.sd_inptrs = (sbd.bsize - sizeof(struct gfs_indirect)) /
>  			sizeof(uint64_t);
> diff --git a/gfs2/edit/savemeta.c b/gfs2/edit/savemeta.c
> index 7c2ba04..2f70a24 100644
> --- a/gfs2/edit/savemeta.c
> +++ b/gfs2/edit/savemeta.c
> @@ -477,7 +477,11 @@ void savemeta(char *out_fn, int saveoption)
>  			fprintf(stderr, "Geometery error\n");
>  			exit(-1);
>  		}
> -		fix_device_geometry(&sbd);
> +		if (fix_device_geometry(&sbd)) {
> +			fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n",
> +				sbd.device.length << GFS2_BASIC_BLOCK_SHIFT);
> +			exit(-1);
> +		}
>  		osi_list_init(&sbd.rglist);
>  		init_buf_list(&sbd, &sbd.buf_list, 128 << 20);
>  		init_buf_list(&sbd, &sbd.nvbuf_list, 0xffffffff);
> diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
> index 783d216..60f97b4 100644
> --- a/gfs2/fsck/rgrepair.c
> +++ b/gfs2/fsck/rgrepair.c
> @@ -348,7 +348,12 @@ int gfs2_rindex_calculate(struct gfs2_sbd *sdp, osi_list_t *ret_list,
>  		fprintf(stderr, _("Geometry error\n"));
>  		exit(-1);
>  	}
> -	fix_device_geometry(sdp);
> +	if (fix_device_geometry(sdp)) {
> +		fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n",
> +				sdp->device.length << GFS2_BASIC_BLOCK_SHIFT);
> +		exit(-1);
> +	}
> +
This is missing the gettext markup around the string.

>  	/* Compute the default resource group layout as mkfs would have done */
>  	compute_rgrp_layout(sdp, FALSE);
>  	build_rgrps(sdp, FALSE); /* FALSE = calc but don't write to disk. */
> diff --git a/gfs2/libgfs2/device_geometry.c b/gfs2/libgfs2/device_geometry.c
> index f37defa..b2d5861 100644
> --- a/gfs2/libgfs2/device_geometry.c
> +++ b/gfs2/libgfs2/device_geometry.c
> @@ -43,7 +43,7 @@ int device_geometry(struct gfs2_sbd *sdp)
>   *
>   */
>  
> -void fix_device_geometry(struct gfs2_sbd *sdp)
> +int fix_device_geometry(struct gfs2_sbd *sdp)
>  {
>  	struct device *device = &sdp->device;
>  	unsigned int bbsize = sdp->bsize >> GFS2_BASIC_BLOCK_SHIFT;
> @@ -61,9 +61,10 @@ void fix_device_geometry(struct gfs2_sbd *sdp)
>  	start = device->start;
>  	length = device->length;
>  
> -	if (length < 1 << (20 - GFS2_BASIC_BLOCK_SHIFT))
> -		die("device is way too small (%"PRIu64" bytes)\n",
> -		    length << GFS2_BASIC_BLOCK_SHIFT);
> +	if (length < 1 << (20 - GFS2_BASIC_BLOCK_SHIFT)) {
> +		errno = ENOSPC;
> +		return -1;
> +	}
>  
>  	remainder = start % bbsize;
>  	if (remainder) {
> @@ -85,4 +86,5 @@ void fix_device_geometry(struct gfs2_sbd *sdp)
>  		       device->start, device->length, device->rgf_flags);
>  		printf("\nDevice Size: %"PRIu64"\n", sdp->device_size);
>  	}
> +	return 0;
>  }
> diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
> index 0742f9e..633aff3 100644
> --- a/gfs2/libgfs2/libgfs2.h
> +++ b/gfs2/libgfs2/libgfs2.h
> @@ -398,7 +398,7 @@ extern void __bcommit(struct buf_list *bl, int line, const char *caller);
>  
>  /* device_geometry.c */
>  extern int device_geometry(struct gfs2_sbd *sdp);
> -extern void fix_device_geometry(struct gfs2_sbd *sdp);
> +extern int fix_device_geometry(struct gfs2_sbd *sdp);
>  
>  /* fs_bits.c */
>  #define BFITNOENT (0xFFFFFFFF)
> diff --git a/gfs2/mkfs/main_grow.c b/gfs2/mkfs/main_grow.c
> index 94c7d71..3f4d38b 100644
> --- a/gfs2/mkfs/main_grow.c
> +++ b/gfs2/mkfs/main_grow.c
> @@ -299,7 +299,12 @@ main_grow(int argc, char *argv[])
>  		if(read_sb(sdp) < 0)
>  			die( _("gfs: Error reading superblock.\n"));
>  
> -		fix_device_geometry(sdp);
> +		if (fix_device_geometry(sdp)) {
> +			fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n",
> +				sdp->device.length << GFS2_BASIC_BLOCK_SHIFT);
> +			exit(-1);
> +		}
> +
 ... and so is this

>  		if (mount_gfs2_meta(sdp)) {
>  			fprintf(stderr, _("Error mounting GFS2 metafs: %s\n"),
>  					strerror(errno));
> diff --git a/gfs2/mkfs/main_mkfs.c b/gfs2/mkfs/main_mkfs.c
> index ce3a6ae..feb1aa8 100644
> --- a/gfs2/mkfs/main_mkfs.c
> +++ b/gfs2/mkfs/main_mkfs.c
> @@ -530,7 +530,11 @@ void main_mkfs(int argc, char *argv[])
>  		}
>  		sdp->device.length = sdp->orig_fssize;
>  	}
> -	fix_device_geometry(sdp);
> +	if (fix_device_geometry(sdp)) {
> +		fprintf(stderr, "Device is too small (%"PRIu64" bytes)\n",
> +				sdp->device.length << GFS2_BASIC_BLOCK_SHIFT);
> +		exit(-1);
> +	}
>  
>  	/* Compute the resource group layouts */
>  
 and this.

Otherwise it looks good,

Steve.




      reply	other threads:[~2009-04-07 12:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-07 12:26 [Cluster-devel] [PATCH 2/2] libgfs2: Remove die from fix_device_geometry Andrew Price
2009-04-07 12:34 ` Steven Whitehouse [this message]

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=1239107680.29604.30.camel@localhost.localdomain \
    --to=swhiteho@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