cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die()
@ 2011-12-14 16:20 Andrew Price
  2011-12-14 16:20 ` [Cluster-devel] [PATCH 2/2] libgfs2: Push down die() into the utils and remove it Andrew Price
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Andrew Price @ 2011-12-14 16:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Expand out the calls to die() to prepare for the removal of the function
from libgfs2.h

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/libgfs2/fs_ops.c |   67 ++++++++++++++++++++++++++++++++-----------------
 gfs2/libgfs2/gfs1.c   |   12 ++++++---
 2 files changed, 52 insertions(+), 27 deletions(-)

diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e2e64d6..befa25a 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -136,8 +136,10 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
 			break;
 	}
 
-	if (n == NULL)
-		die("out of space\n");
+	if (n == NULL) {
+		fprintf(stderr, "out of space\n");
+		exit(1);
+	}
 
 	ri = &rl->ri;
 	rg = &rl->rg;
@@ -155,15 +157,18 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
 			}
 	}
 
-	die("allocation is broken (1): %"PRIu64" %u\n",
+	fprintf(stderr, "allocation is broken (1): %"PRIu64" %u\n",
 	    (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
+	exit(1);
 
 found:
-	if (bn >= ri->ri_bitbytes * GFS2_NBBY)
-		die("allocation is broken (2): bn: %u %u rgrp: %"PRIu64
+	if (bn >= ri->ri_bitbytes * GFS2_NBBY) {
+		fprintf(stderr, "allocation is broken (2): bn: %u %u rgrp: %"PRIu64
 		    " (0x%" PRIx64 ") Free:%u\n",
 		    bn, ri->ri_bitbytes * GFS2_NBBY, (uint64_t)rl->ri.ri_addr,
 		    (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
+		exit(1);
+	}
 
 	switch (type) {
 	case DATA:
@@ -175,7 +180,8 @@ found:
 		rg->rg_dinodes++;
 		break;
 	default:
-		die("bad state\n");
+		fprintf(stderr, "bad state\n");
+		exit(1);
 	}
 
 	bh->b_data[x] &= ~(0x03 << (GFS2_BIT_SIZE * y));
@@ -684,8 +690,10 @@ struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn,
 		unstuff_dinode(ip);
 
 	block_map(ip, lbn, &new, &dbn, NULL, prealloc);
-	if (!dbn)
-		die("get_file_buf\n");
+	if (!dbn) {
+		fprintf(stderr, "get_file_buf\n");
+		exit(1);
+	}
 
 	if (!prealloc && new &&
 	    ip->i_di.di_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) {
@@ -841,8 +849,10 @@ void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
 		return gfs_get_leaf_nr(dip, lindex, leaf_out);
 	count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(uint64_t),
 			   sizeof(uint64_t));
-	if (count != sizeof(uint64_t))
-		die("gfs2_get_leaf_nr:  Bad internal read.\n");
+	if (count != sizeof(uint64_t)) {
+		fprintf(stderr, "gfs2_get_leaf_nr:  Bad internal read.\n");
+		exit(1);
+	}
 
 	*leaf_out = be64_to_cpu(leaf_no);
 }
@@ -859,8 +869,10 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
 	leaf_no = cpu_to_be64(leaf_out);
 	count = gfs2_writei(dip, (char *)&leaf_no, inx * sizeof(uint64_t),
 			    sizeof(uint64_t));
-	if (count != sizeof(uint64_t))
-		die("gfs2_put_leaf_nr:  Bad internal write.\n");
+	if (count != sizeof(uint64_t)) {
+		fprintf(stderr, "gfs2_put_leaf_nr:  Bad internal write.\n");
+		exit(1);
+	}
 }
 
 static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
@@ -912,8 +924,10 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
 	else
 		count = gfs2_writei(dip, (char *)lp, start * sizeof(uint64_t),
 				    half_len * sizeof(uint64_t));
-	if (count != half_len * sizeof(uint64_t))
-		die("dir_split_leaf (2)\n");
+	if (count != half_len * sizeof(uint64_t)) {
+		fprintf(stderr, "dir_split_leaf (2)\n");
+		exit(1);
+	}
 
 	free(lp);
 
@@ -930,8 +944,10 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
 		    be32_to_cpu(dent->de_hash) < divider) {
 			name_len = be16_to_cpu(dent->de_name_len);
 
-			if (dirent_alloc(dip, nbh, name_len, &new))
-				die("dir_split_leaf (3)\n");
+			if (dirent_alloc(dip, nbh, name_len, &new)) {
+				fprintf(stderr, "dir_split_leaf (3)\n");
+				exit(1);
+			}
 
 			new->de_inum = dent->de_inum;
 			new->de_hash = dent->de_hash;
@@ -954,8 +970,10 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
 	} while (dent);
 
 	if (!moved) {
-		if (dirent_alloc(dip, nbh, 0, &new))
-			die("dir_split_leaf (4)\n");
+		if (dirent_alloc(dip, nbh, 0, &new)) {
+			fprintf(stderr, "dir_split_leaf (4)\n");
+			exit(1);
+		}
 		new->de_inum.no_formal_ino = 0;
 		/* Don't count the sentinel dirent as an entry */
 		dip->i_di.di_entries--;
@@ -993,8 +1011,10 @@ static void dir_double_exhash(struct gfs2_inode *dip)
 		count = gfs2_readi(dip, (char *)buf,
 			      block * sdp->sd_hash_bsize,
 			      sdp->sd_hash_bsize);
-		if (count != sdp->sd_hash_bsize)
-			die("dir_double_exhash (1)\n");
+		if (count != sdp->sd_hash_bsize) {
+			fprintf(stderr, "dir_double_exhash (1)\n");
+			exit(1);
+		}
 
 		from = buf;
 		to = (uint64_t *)((char *)buf + sdp->sd_hash_bsize);
@@ -1012,9 +1032,10 @@ static void dir_double_exhash(struct gfs2_inode *dip)
 			count = gfs2_writei(dip, (char *)buf +
 					    sdp->sd_hash_bsize,
 					    block * sdp->bsize, sdp->bsize);
-		if (count != sdp->bsize)
-			die("dir_double_exhash (2)\n");
-
+		if (count != sdp->bsize) {
+			fprintf(stderr, "dir_double_exhash (2)\n");
+			exit(1);
+		}
 	}
 
 	free(buf);
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 4549959..8e3fc93 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -403,8 +403,10 @@ void gfs_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
 
 	count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(uint64_t),
 			   sizeof(uint64_t));
-	if (count != sizeof(uint64_t))
-		die("gfs_get_leaf_nr:  Bad internal read.\n");
+	if (count != sizeof(uint64_t)) {
+		fprintf(stderr, "gfs_get_leaf_nr:  Bad internal read.\n");
+		exit(1);
+	}
 
 	*leaf_out = be64_to_cpu(leaf_no);
 }
@@ -417,6 +419,8 @@ void gfs_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
 	leaf_no = cpu_to_be64(leaf_out);
 	count = gfs1_writei(dip, (char *)&leaf_no, inx * sizeof(uint64_t),
 			   sizeof(uint64_t));
-	if (count != sizeof(uint64_t))
-		die("gfs_put_leaf_nr:  Bad internal write.\n");
+	if (count != sizeof(uint64_t)) {
+		fprintf(stderr, "gfs_put_leaf_nr:  Bad internal write.\n");
+		exit(1);
+	}
 }
-- 
1.7.6.4



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

* [Cluster-devel] [PATCH 2/2] libgfs2: Push down die() into the utils and remove it
  2011-12-14 16:20 [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Andrew Price
@ 2011-12-14 16:20 ` Andrew Price
  2011-12-14 16:23 ` [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Bob Peterson
  2011-12-14 16:41 ` Steven Whitehouse
  2 siblings, 0 replies; 6+ messages in thread
From: Andrew Price @ 2011-12-14 16:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch removes the definition of die() from libgfs2.h and pushes it
down into the utils which still require it. In the case of gfs2_convert,
which only had a few die() calls, it was dropped altogether.

Signed-off-by: Andrew Price <anprice@redhat.com>
---
 gfs2/convert/gfs2_convert.c |   18 ++++++++++++------
 gfs2/edit/hexedit.h         |   12 ++++++++++++
 gfs2/fsck/util.c            |    1 +
 gfs2/libgfs2/libgfs2.h      |   12 ------------
 gfs2/mkfs/gfs2_mkfs.h       |   13 +++++++++++++
 gfs2/quota/gfs2_quota.h     |   13 +++++++++++++
 gfs2/tool/gfs2_tool.h       |   13 +++++++++++++
 7 files changed, 64 insertions(+), 18 deletions(-)

diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index 09a689c..ff5f50f 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -1847,8 +1847,10 @@ static void update_inode_file(struct gfs2_sbd *sdp)
 	
 	buf = cpu_to_be64(sdp->md.next_inum);
 	count = gfs2_writei(ip, &buf, 0, sizeof(uint64_t));
-	if (count != sizeof(uint64_t))
-		die("update_inode_file\n");
+	if (count != sizeof(uint64_t)) {
+		fprintf(stderr, "update_inode_file\n");
+		exit(1);
+	}
 	
 	log_debug(_("\nNext Inum: %llu\n"), (unsigned long long)sdp->md.next_inum);
 }/* update_inode_file */
@@ -1869,8 +1871,10 @@ static void write_statfs_file(struct gfs2_sbd *sdp)
 
 	gfs2_statfs_change_out(&sc, buf);
 	count = gfs2_writei(ip, buf, 0, sizeof(struct gfs2_statfs_change));
-	if (count != sizeof(struct gfs2_statfs_change))
-		die("do_init (2)\n");
+	if (count != sizeof(struct gfs2_statfs_change)) {
+		fprintf(stderr, "do_init (2)\n");
+		exit(1);
+	}
 }/* write_statfs_file */
 
 /* ------------------------------------------------------------------------- */
@@ -2043,8 +2047,10 @@ static void copy_quotas(struct gfs2_sbd *sdp)
 	int err;
 
 	err = gfs2_lookupi(sdp->master_dir, "quota", 5, &nq_ip);
-	if (err)
-		die(_("Couldn't lookup new quota file: %d\n"), err);
+	if (err) {
+		fprintf(stderr, _("Couldn't lookup new quota file: %d\n"), err);
+		exit(1);
+	}
 
 	gfs2_inum_in(&inum, (char *)&raw_gfs1_ondisk_sb.sb_quota_di);
 	oq_ip = inode_read(sdp, inum.no_addr);
diff --git a/gfs2/edit/hexedit.h b/gfs2/edit/hexedit.h
index 27950b0..b05b5c0 100644
--- a/gfs2/edit/hexedit.h
+++ b/gfs2/edit/hexedit.h
@@ -124,6 +124,18 @@ static inline int block_is_rgtree(void)
 #define SCREEN_HEIGHT   (16)
 #define SCREEN_WIDTH    (16)
 
+/* die() used to be in libgfs2.h */
+static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
+void die(const char *fmt, ...)
+{
+	va_list ap;
+	fprintf(stderr, "%s: ", __FILE__);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	exit(-1);
+}
+
 /*  Memory macros  */
 
 #define type_alloc(ptr, type, count) \
diff --git a/gfs2/fsck/util.c b/gfs2/fsck/util.c
index d912920..f37fe7d 100644
--- a/gfs2/fsck/util.c
+++ b/gfs2/fsck/util.c
@@ -6,6 +6,7 @@
 #include <unistd.h>
 #include <sys/time.h>
 #include <stdio.h>
+#include <stdarg.h>
 #include <termios.h>
 #include <libintl.h>
 #include <ctype.h>
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index c356bbf..0e521fb 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -3,7 +3,6 @@
 
 #include <features.h>
 #include <inttypes.h>
-#include <stdarg.h>
 #include <stdio.h>
 #include <errno.h>
 #include <sys/types.h>
@@ -86,17 +85,6 @@ struct lgfs2_dev_info {
 	uint64_t size;
 };
 
-static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
-void die(const char *fmt, ...)
-{
-	va_list ap;
-	fprintf(stderr, "%s: ", __FILE__);
-	va_start(ap, fmt);
-	vfprintf(stderr, fmt, ap);
-	va_end(ap);
-	exit(-1);
-}
-
 struct device {
 	uint64_t length;
 };
diff --git a/gfs2/mkfs/gfs2_mkfs.h b/gfs2/mkfs/gfs2_mkfs.h
index 6f0ac2b..d7d7da7 100644
--- a/gfs2/mkfs/gfs2_mkfs.h
+++ b/gfs2/mkfs/gfs2_mkfs.h
@@ -1,6 +1,7 @@
 #ifndef __GFS2_MKFS_DOT_H__
 #define __GFS2_MKFS_DOT_H__
 
+#include <stdarg.h>
 #include <linux/gfs2_ondisk.h>
 #include "osi_list.h"
 #include "copyright.cf"
@@ -18,6 +19,18 @@ extern void main_mkfs(int argc, char *argv[]);
 /* main_shrink */
 extern void main_shrink(int argc, char *argv[]);
 
+/* die() used to be in libgfs2.h */
+static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
+void die(const char *fmt, ...)
+{
+	va_list ap;
+	fprintf(stderr, "%s: ", __FILE__);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	exit(-1);
+}
+
 /*
  * The following inode IOCTL macros and inode flags 
  * are copied from linux/fs.h, because we have duplicate 
diff --git a/gfs2/quota/gfs2_quota.h b/gfs2/quota/gfs2_quota.h
index 80c0d3f..744f02b 100644
--- a/gfs2/quota/gfs2_quota.h
+++ b/gfs2/quota/gfs2_quota.h
@@ -1,6 +1,7 @@
 #ifndef __GFS2_QUOTA_DOT_H__
 #define __GFS2_QUOTA_DOT_H__
 
+#include <stdarg.h>
 #include "libgfs2.h"
 #include <linux/gfs2_ondisk.h>
 
@@ -79,4 +80,16 @@ void do_quota_init(struct gfs2_sbd *sdp, commandline_t *comline);
 uint32_t name_to_id(int user, char *name, int numbers);
 char *id_to_name(int user, uint32_t id, int numbers);
 
+/* die() used to be in libgfs2.h */
+static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
+void die(const char *fmt, ...)
+{
+	va_list ap;
+	fprintf(stderr, "%s: ", __FILE__);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	exit(-1);
+}
+
 #endif /* __GFS2_QUOTA_DOT_H__ */
diff --git a/gfs2/tool/gfs2_tool.h b/gfs2/tool/gfs2_tool.h
index 884856f..3a181ff 100644
--- a/gfs2/tool/gfs2_tool.h
+++ b/gfs2/tool/gfs2_tool.h
@@ -1,6 +1,7 @@
 #ifndef __GFS2_TOOL_DOT_H__
 #define __GFS2_TOOL_DOT_H__
 
+#include <stdarg.h>
 
 #define OUTPUT_BLOCKS 0
 #define OUTPUT_K      1
@@ -48,4 +49,16 @@ void do_sb(int argc, char **argv);
 void get_tune(int argc, char **argv);
 void set_tune(int argc, char **argv);
 
+/* die() used to be in libgfs2.h */
+static __inline__ __attribute__((noreturn, format (printf, 1, 2)))
+void die(const char *fmt, ...)
+{
+	va_list ap;
+	fprintf(stderr, "%s: ", __FILE__);
+	va_start(ap, fmt);
+	vfprintf(stderr, fmt, ap);
+	va_end(ap);
+	exit(-1);
+}
+
 #endif /* __GFS2_TOOL_DOT_H__ */
-- 
1.7.6.4



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

* [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die()
  2011-12-14 16:20 [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Andrew Price
  2011-12-14 16:20 ` [Cluster-devel] [PATCH 2/2] libgfs2: Push down die() into the utils and remove it Andrew Price
@ 2011-12-14 16:23 ` Bob Peterson
  2011-12-14 16:41 ` Steven Whitehouse
  2 siblings, 0 replies; 6+ messages in thread
From: Bob Peterson @ 2011-12-14 16:23 UTC (permalink / raw)
  To: cluster-devel.redhat.com

----- Original Message -----
| Expand out the calls to die() to prepare for the removal of the
| function
| from libgfs2.h
| 
| Signed-off-by: Andrew Price <anprice@redhat.com>
| ---

Hi,

ACK

Bob Peterson
Red Hat File Systems



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

* [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die()
  2011-12-14 16:20 [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Andrew Price
  2011-12-14 16:20 ` [Cluster-devel] [PATCH 2/2] libgfs2: Push down die() into the utils and remove it Andrew Price
  2011-12-14 16:23 ` [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Bob Peterson
@ 2011-12-14 16:41 ` Steven Whitehouse
  2011-12-14 17:14   ` Andrew Price
  2 siblings, 1 reply; 6+ messages in thread
From: Steven Whitehouse @ 2011-12-14 16:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

Those look like a good start, but we also need to figure out how to push
the error handling back into the apps too, 

Steve.

On Wed, 2011-12-14 at 16:20 +0000, Andrew Price wrote:
> Expand out the calls to die() to prepare for the removal of the function
> from libgfs2.h
> 
> Signed-off-by: Andrew Price <anprice@redhat.com>
> ---
>  gfs2/libgfs2/fs_ops.c |   67 ++++++++++++++++++++++++++++++++-----------------
>  gfs2/libgfs2/gfs1.c   |   12 ++++++---
>  2 files changed, 52 insertions(+), 27 deletions(-)
> 
> diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
> index e2e64d6..befa25a 100644
> --- a/gfs2/libgfs2/fs_ops.c
> +++ b/gfs2/libgfs2/fs_ops.c
> @@ -136,8 +136,10 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
>  			break;
>  	}
>  
> -	if (n == NULL)
> -		die("out of space\n");
> +	if (n == NULL) {
> +		fprintf(stderr, "out of space\n");
> +		exit(1);
> +	}
>  
>  	ri = &rl->ri;
>  	rg = &rl->rg;
> @@ -155,15 +157,18 @@ static uint64_t blk_alloc_i(struct gfs2_sbd *sdp, unsigned int type)
>  			}
>  	}
>  
> -	die("allocation is broken (1): %"PRIu64" %u\n",
> +	fprintf(stderr, "allocation is broken (1): %"PRIu64" %u\n",
>  	    (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
> +	exit(1);
>  
>  found:
> -	if (bn >= ri->ri_bitbytes * GFS2_NBBY)
> -		die("allocation is broken (2): bn: %u %u rgrp: %"PRIu64
> +	if (bn >= ri->ri_bitbytes * GFS2_NBBY) {
> +		fprintf(stderr, "allocation is broken (2): bn: %u %u rgrp: %"PRIu64
>  		    " (0x%" PRIx64 ") Free:%u\n",
>  		    bn, ri->ri_bitbytes * GFS2_NBBY, (uint64_t)rl->ri.ri_addr,
>  		    (uint64_t)rl->ri.ri_addr, rl->rg.rg_free);
> +		exit(1);
> +	}
>  
>  	switch (type) {
>  	case DATA:
> @@ -175,7 +180,8 @@ found:
>  		rg->rg_dinodes++;
>  		break;
>  	default:
> -		die("bad state\n");
> +		fprintf(stderr, "bad state\n");
> +		exit(1);
>  	}
>  
>  	bh->b_data[x] &= ~(0x03 << (GFS2_BIT_SIZE * y));
> @@ -684,8 +690,10 @@ struct gfs2_buffer_head *get_file_buf(struct gfs2_inode *ip, uint64_t lbn,
>  		unstuff_dinode(ip);
>  
>  	block_map(ip, lbn, &new, &dbn, NULL, prealloc);
> -	if (!dbn)
> -		die("get_file_buf\n");
> +	if (!dbn) {
> +		fprintf(stderr, "get_file_buf\n");
> +		exit(1);
> +	}
>  
>  	if (!prealloc && new &&
>  	    ip->i_di.di_size < (lbn + 1) << sdp->sd_sb.sb_bsize_shift) {
> @@ -841,8 +849,10 @@ void gfs2_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
>  		return gfs_get_leaf_nr(dip, lindex, leaf_out);
>  	count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(uint64_t),
>  			   sizeof(uint64_t));
> -	if (count != sizeof(uint64_t))
> -		die("gfs2_get_leaf_nr:  Bad internal read.\n");
> +	if (count != sizeof(uint64_t)) {
> +		fprintf(stderr, "gfs2_get_leaf_nr:  Bad internal read.\n");
> +		exit(1);
> +	}
>  
>  	*leaf_out = be64_to_cpu(leaf_no);
>  }
> @@ -859,8 +869,10 @@ void gfs2_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
>  	leaf_no = cpu_to_be64(leaf_out);
>  	count = gfs2_writei(dip, (char *)&leaf_no, inx * sizeof(uint64_t),
>  			    sizeof(uint64_t));
> -	if (count != sizeof(uint64_t))
> -		die("gfs2_put_leaf_nr:  Bad internal write.\n");
> +	if (count != sizeof(uint64_t)) {
> +		fprintf(stderr, "gfs2_put_leaf_nr:  Bad internal write.\n");
> +		exit(1);
> +	}
>  }
>  
>  static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
> @@ -912,8 +924,10 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
>  	else
>  		count = gfs2_writei(dip, (char *)lp, start * sizeof(uint64_t),
>  				    half_len * sizeof(uint64_t));
> -	if (count != half_len * sizeof(uint64_t))
> -		die("dir_split_leaf (2)\n");
> +	if (count != half_len * sizeof(uint64_t)) {
> +		fprintf(stderr, "dir_split_leaf (2)\n");
> +		exit(1);
> +	}
>  
>  	free(lp);
>  
> @@ -930,8 +944,10 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
>  		    be32_to_cpu(dent->de_hash) < divider) {
>  			name_len = be16_to_cpu(dent->de_name_len);
>  
> -			if (dirent_alloc(dip, nbh, name_len, &new))
> -				die("dir_split_leaf (3)\n");
> +			if (dirent_alloc(dip, nbh, name_len, &new)) {
> +				fprintf(stderr, "dir_split_leaf (3)\n");
> +				exit(1);
> +			}
>  
>  			new->de_inum = dent->de_inum;
>  			new->de_hash = dent->de_hash;
> @@ -954,8 +970,10 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
>  	} while (dent);
>  
>  	if (!moved) {
> -		if (dirent_alloc(dip, nbh, 0, &new))
> -			die("dir_split_leaf (4)\n");
> +		if (dirent_alloc(dip, nbh, 0, &new)) {
> +			fprintf(stderr, "dir_split_leaf (4)\n");
> +			exit(1);
> +		}
>  		new->de_inum.no_formal_ino = 0;
>  		/* Don't count the sentinel dirent as an entry */
>  		dip->i_di.di_entries--;
> @@ -993,8 +1011,10 @@ static void dir_double_exhash(struct gfs2_inode *dip)
>  		count = gfs2_readi(dip, (char *)buf,
>  			      block * sdp->sd_hash_bsize,
>  			      sdp->sd_hash_bsize);
> -		if (count != sdp->sd_hash_bsize)
> -			die("dir_double_exhash (1)\n");
> +		if (count != sdp->sd_hash_bsize) {
> +			fprintf(stderr, "dir_double_exhash (1)\n");
> +			exit(1);
> +		}
>  
>  		from = buf;
>  		to = (uint64_t *)((char *)buf + sdp->sd_hash_bsize);
> @@ -1012,9 +1032,10 @@ static void dir_double_exhash(struct gfs2_inode *dip)
>  			count = gfs2_writei(dip, (char *)buf +
>  					    sdp->sd_hash_bsize,
>  					    block * sdp->bsize, sdp->bsize);
> -		if (count != sdp->bsize)
> -			die("dir_double_exhash (2)\n");
> -
> +		if (count != sdp->bsize) {
> +			fprintf(stderr, "dir_double_exhash (2)\n");
> +			exit(1);
> +		}
>  	}
>  
>  	free(buf);
> diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
> index 4549959..8e3fc93 100644
> --- a/gfs2/libgfs2/gfs1.c
> +++ b/gfs2/libgfs2/gfs1.c
> @@ -403,8 +403,10 @@ void gfs_get_leaf_nr(struct gfs2_inode *dip, uint32_t lindex,
>  
>  	count = gfs2_readi(dip, (char *)&leaf_no, lindex * sizeof(uint64_t),
>  			   sizeof(uint64_t));
> -	if (count != sizeof(uint64_t))
> -		die("gfs_get_leaf_nr:  Bad internal read.\n");
> +	if (count != sizeof(uint64_t)) {
> +		fprintf(stderr, "gfs_get_leaf_nr:  Bad internal read.\n");
> +		exit(1);
> +	}
>  
>  	*leaf_out = be64_to_cpu(leaf_no);
>  }
> @@ -417,6 +419,8 @@ void gfs_put_leaf_nr(struct gfs2_inode *dip, uint32_t inx, uint64_t leaf_out)
>  	leaf_no = cpu_to_be64(leaf_out);
>  	count = gfs1_writei(dip, (char *)&leaf_no, inx * sizeof(uint64_t),
>  			   sizeof(uint64_t));
> -	if (count != sizeof(uint64_t))
> -		die("gfs_put_leaf_nr:  Bad internal write.\n");
> +	if (count != sizeof(uint64_t)) {
> +		fprintf(stderr, "gfs_put_leaf_nr:  Bad internal write.\n");
> +		exit(1);
> +	}
>  }




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

* [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die()
  2011-12-14 16:41 ` Steven Whitehouse
@ 2011-12-14 17:14   ` Andrew Price
  2011-12-14 17:22     ` Steven Whitehouse
  0 siblings, 1 reply; 6+ messages in thread
From: Andrew Price @ 2011-12-14 17:14 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 14/12/11 16:41, Steven Whitehouse wrote:
> Hi,
>
> Those look like a good start, but we also need to figure out how to push
> the error handling back into the apps too,

Yes, I made a tentative start on this a while ago. Each libgfs2 function 
which calls exit() will need all of its callers (and their callers, and 
their...) updating so it's going to take a fair deal more work.

If we're agreed on the convention of setting errno and returning 
non-zero (or non-valid values) to flag errors, then the way forward is 
reasonably clear.

Andy



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

* [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die()
  2011-12-14 17:14   ` Andrew Price
@ 2011-12-14 17:22     ` Steven Whitehouse
  0 siblings, 0 replies; 6+ messages in thread
From: Steven Whitehouse @ 2011-12-14 17:22 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Wed, 2011-12-14 at 17:14 +0000, Andrew Price wrote:
> On 14/12/11 16:41, Steven Whitehouse wrote:
> > Hi,
> >
> > Those look like a good start, but we also need to figure out how to push
> > the error handling back into the apps too,
> 
> Yes, I made a tentative start on this a while ago. Each libgfs2 function 
> which calls exit() will need all of its callers (and their callers, and 
> their...) updating so it's going to take a fair deal more work.
> 
> If we're agreed on the convention of setting errno and returning 
> non-zero (or non-valid values) to flag errors, then the way forward is 
> reasonably clear.
> 
> Andy

Yes, I think that is a good way to do it. The only issues are likely to
arise when it is not obvious from this method exactly what has gone
wrong. In some cases this is due to doing the checks in the wrong place,
or there is some other complication. So its just a case of converting
things bit by bit and checking each place individually, which does make
it a rather slow job, but I'm not sure there is much alternative,

Steve.




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

end of thread, other threads:[~2011-12-14 17:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-14 16:20 [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Andrew Price
2011-12-14 16:20 ` [Cluster-devel] [PATCH 2/2] libgfs2: Push down die() into the utils and remove it Andrew Price
2011-12-14 16:23 ` [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die() Bob Peterson
2011-12-14 16:41 ` Steven Whitehouse
2011-12-14 17:14   ` Andrew Price
2011-12-14 17:22     ` Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).