From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 1/2] libgfs2: Expand out calls to die()
Date: Wed, 14 Dec 2011 16:41:22 +0000 [thread overview]
Message-ID: <1323880882.2860.24.camel@menhir> (raw)
In-Reply-To: <1323879637-28987-1-git-send-email-anprice@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);
> + }
> }
next prev parent reply other threads:[~2011-12-14 16:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2011-12-14 17:14 ` Andrew Price
2011-12-14 17:22 ` Steven Whitehouse
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=1323880882.2860.24.camel@menhir \
--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 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.