[gfs2-utils] 12/12: libgfs2: Remove the remaining exit() calls
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit 95cd681c3144ad6d23aebea54109ba9efc23cd90
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 11 11:49:04 2023 +0000
libgfs2: Remove the remaining exit() calls
Phew.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 2 +-
gfs2/libgfs2/gfs1.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index db256227..bf22c787 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1202,7 +1202,7 @@ restart:
.mh_format = cpu_to_be32(GFS2_FORMAT_LF)
};
if (lgfs2_meta_alloc(dip, &bn))
- exit(1);
+ return -1;
nbh = lgfs2_bget(dip->i_sbd, bn);
memcpy(nbh->b_data, &mh, sizeof(mh));
lgfs2_bmodified(nbh);
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 531ba5a8..0f41dca6 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -207,7 +207,7 @@ int lgfs2_gfs1_writei(struct lgfs2_inode *ip, void *buf, uint64_t offset,
if (!extlen){
new = 1;
if (lgfs2_gfs1_block_map(ip, lblock, &new, &dblock, &extlen, 0))
- exit(1);
+ return -1;
if (!dblock)
return -1;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 11/12: Add error checking to dir_double_exhash()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit b53325e147129d54365b4b87157ac210bcf193f6
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 11 11:41:50 2023 +0000
Add error checking to dir_double_exhash()
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 2a70d4da..db256227 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1021,7 +1021,7 @@ int lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf_
return 0;
}
-static void dir_double_exhash(struct lgfs2_inode *dip)
+static int dir_double_exhash(struct lgfs2_inode *dip)
{
struct lgfs2_sbd *sdp = dip->i_sbd;
uint64_t *buf;
@@ -1031,19 +1031,15 @@ static void dir_double_exhash(struct lgfs2_inode *dip)
int count;
buf = calloc(1, 3 * sdp->sd_hash_bsize);
- if (buf == NULL) {
- fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
- exit(-1);
- }
+ if (buf == NULL)
+ return -1;
for (block = dip->i_size >> sdp->sd_hash_bsize_shift; block--;) {
count = lgfs2_readi(dip, (char *)buf,
block * sdp->sd_hash_bsize,
sdp->sd_hash_bsize);
- if (count != sdp->sd_hash_bsize) {
- fprintf(stderr, "dir_double_exhash (1)\n");
- exit(1);
- }
+ if (count != sdp->sd_hash_bsize)
+ return -1;
from = buf;
to = (uint64_t *)((char *)buf + sdp->sd_hash_bsize);
@@ -1061,16 +1057,15 @@ static void dir_double_exhash(struct lgfs2_inode *dip)
count = lgfs2_writei(dip, (char *)buf +
sdp->sd_hash_bsize,
block * sdp->sd_bsize, sdp->sd_bsize);
- if (count != sdp->sd_bsize) {
- fprintf(stderr, "dir_double_exhash (2)\n");
- exit(1);
- }
+ if (count != sdp->sd_bsize)
+ return -1;
}
free(buf);
dip->i_depth++;
lgfs2_bmodified(dip->i_bh);
+ return 0;
}
/**
@@ -1191,7 +1186,8 @@ restart:
} else if (dip->i_depth < GFS2_DIR_MAX_DEPTH) {
lgfs2_brelse(bh);
- dir_double_exhash(dip);
+ if (dir_double_exhash(dip))
+ return -1;
goto restart;
} else if (leaf->lf_next) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 10/12: Add error checking to dir_make_exhash()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit 39d9de94dd3942d6c667e3198895c5c62080b123
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 11 11:30:47 2023 +0000
Add error checking to dir_make_exhash()
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 2798bdde..2a70d4da 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -1243,7 +1243,7 @@ restart:
}
}
-static void dir_make_exhash(struct lgfs2_inode *dip)
+static int dir_make_exhash(struct lgfs2_inode *dip)
{
struct lgfs2_sbd *sdp = dip->i_sbd;
struct gfs2_dirent *dent;
@@ -1256,7 +1256,7 @@ static void dir_make_exhash(struct lgfs2_inode *dip)
__be64 *lp;
if (lgfs2_meta_alloc(dip, &bn))
- exit(1);
+ return -1;
bh = lgfs2_bget(sdp, bn);
{
struct gfs2_meta_header mh = {
@@ -1310,6 +1310,7 @@ static void dir_make_exhash(struct lgfs2_inode *dip)
lgfs2_dinode_out(dip, dip->i_bh->b_data);
lgfs2_bwrite(dip->i_bh);
+ return 0;
}
static int dir_l_add(struct lgfs2_inode *dip, const char *filename, int len,
@@ -1320,7 +1321,9 @@ static int dir_l_add(struct lgfs2_inode *dip, const char *filename, int len,
int err = 0;
if (dirent_alloc(dip, dip->i_bh, len, &dent)) {
- dir_make_exhash(dip);
+ err = dir_make_exhash(dip);
+ if (err != 0)
+ return err;
err = dir_e_add(dip, filename, len, inum, type);
return err;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 09/12: Add error checking to lgfs2_dir_split_leaf()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit a142c7c583718eb5ba8bbe9aefd9ff1c26b1ff85
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 11 11:24:42 2023 +0000
Add error checking to lgfs2_dir_split_leaf()
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/fsck/pass2.c | 6 +++++-
gfs2/libgfs2/fs_ops.c | 42 +++++++++++++++++++++++++-----------------
gfs2/libgfs2/libgfs2.h | 4 ++--
3 files changed, 32 insertions(+), 20 deletions(-)
diff --git a/gfs2/fsck/pass2.c b/gfs2/fsck/pass2.c
index a0681ba8..6792f795 100644
--- a/gfs2/fsck/pass2.c
+++ b/gfs2/fsck/pass2.c
@@ -1399,7 +1399,11 @@ static int fix_hashtable(struct fsck_cx *cx, struct lgfs2_inode *ip, __be64 *tbl
"0x%x.\n"), factor, len, proper_start);
changes++;
new_leaf_blk = find_free_blk(ip->i_sbd);
- lgfs2_dir_split_leaf(ip, lindex, leafblk, lbh);
+ if (lgfs2_dir_split_leaf(ip, lindex, leafblk, lbh)) {
+ log_crit(_("Failed to split directory leaf block at 0x%"PRIx64": %s\n"),
+ ip->i_num.in_addr, strerror(errno));
+ exit(1);
+ }
/* re-read the leaf to pick up lgfs2_dir_split_leaf's changes */
lgfs2_leaf_in(&leaf, lbh->b_data);
*proper_len = 1 << (ip->i_depth - leaf.lf_depth);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 66809014..2798bdde 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -894,8 +894,12 @@ int lgfs2_get_leaf_ptr(struct lgfs2_inode *dip, const uint32_t lindex, uint64_t
return 0;
}
-void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf_no,
- struct lgfs2_buffer_head *obh)
+/**
+ * Split a directory leaf.
+ * Returns 0 on success and non-zero with errno set on failure.
+ */
+int lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf_no,
+ struct lgfs2_buffer_head *obh)
{
struct lgfs2_buffer_head *nbh;
struct gfs2_leaf *nleaf, *oleaf;
@@ -908,8 +912,10 @@ void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf
int x, moved = 0;
int count;
- if (lgfs2_meta_alloc(dip, &bn))
- exit(1);
+ if (lgfs2_meta_alloc(dip, &bn)) {
+ errno = EIO;
+ return -1;
+ }
nbh = lgfs2_bget(dip->i_sbd, bn);
{
struct gfs2_meta_header mh = {
@@ -932,10 +938,9 @@ void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf
half_len = len >> 1;
lp = calloc(1, half_len * sizeof(__be64));
- if (lp == NULL) {
- fprintf(stderr, "Out of memory in %s\n", __FUNCTION__);
- exit(-1);
- }
+ if (lp == NULL)
+ return -1;
+
for (x = 0; x < half_len; x++)
lp[x] = cpu_to_be64(bn);
@@ -946,8 +951,8 @@ void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf
count = lgfs2_writei(dip, (char *)lp, start * sizeof(uint64_t),
half_len * sizeof(uint64_t));
if (count != half_len * sizeof(uint64_t)) {
- fprintf(stderr, "lgfs2_dir_split_leaf (2)\n");
- exit(1);
+ errno = EINVAL;
+ return -1;
}
free(lp);
@@ -968,8 +973,8 @@ void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf
name_len = be16_to_cpu(dent->de_name_len);
if (dirent_alloc(dip, nbh, name_len, &new)) {
- fprintf(stderr, "lgfs2_dir_split_leaf (3)\n");
- exit(1);
+ errno = ENOSPC;
+ return -1;
}
new->de_inum = dent->de_inum;
@@ -994,8 +999,8 @@ void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf
if (!moved) {
if (dirent_alloc(dip, nbh, 0, &new)) {
- fprintf(stderr, "lgfs2_dir_split_leaf (4)\n");
- exit(1);
+ errno = ENOSPC;
+ return -1;
}
new->de_inum.no_formal_ino = 0;
/* Don't count the sentinel dirent as an entry */
@@ -1013,6 +1018,7 @@ void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf
lgfs2_bmodified(obh); /* Need to do this in case nothing was moved */
lgfs2_bmodified(nbh);
lgfs2_brelse(nbh);
+ return 0;
}
static void dir_double_exhash(struct lgfs2_inode *dip)
@@ -1155,7 +1161,7 @@ static int dir_e_add(struct lgfs2_inode *dip, const char *filename, int len,
hash = lgfs2_disk_hash(filename, len);
restart:
- /* Have to kludge because (hash >> 32) gives hash for some reason. */
+ /* (hash >> 32) is undefined behaviour */
if (dip->i_depth)
lindex = hash >> (32 - dip->i_depth);
else
@@ -1176,8 +1182,10 @@ restart:
if (be16_to_cpu(leaf->lf_depth) < dip->i_depth) {
llen = 1 << (dip->i_depth -
be16_to_cpu(leaf->lf_depth));
- lgfs2_dir_split_leaf(dip, lindex & ~(llen - 1),
- leaf_no, bh);
+ if (lgfs2_dir_split_leaf(dip, lindex & ~(llen - 1), leaf_no, bh)) {
+ lgfs2_brelse(bh);
+ return -1;
+ }
lgfs2_brelse(bh);
goto restart;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 493961a8..7186126d 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -531,8 +531,8 @@ extern int lgfs2_dirent_del(struct lgfs2_inode *dip, const char *filename, int n
extern int lgfs2_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, uint64_t *dblock,
uint32_t *extlen, int prealloc) __attribute__((warn_unused_result));
extern int lgfs2_get_leaf_ptr(struct lgfs2_inode *dip, uint32_t index, uint64_t *ptr) __attribute__((warn_unused_result));
-extern void lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start,
- uint64_t leaf_no, struct lgfs2_buffer_head *obh);
+extern int lgfs2_dir_split_leaf(struct lgfs2_inode *dip, uint32_t start, uint64_t leaf_no,
+ struct lgfs2_buffer_head *obh) __attribute__((warn_unused_result));
extern void lgfs2_free_block(struct lgfs2_sbd *sdp, uint64_t block);
extern int lgfs2_freedi(struct lgfs2_sbd *sdp, uint64_t block);
extern int lgfs2_get_leaf(struct lgfs2_inode *dip, uint64_t leaf_no,
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 08/12: Remove some exit() calls
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit 4ec44027fbaf99bf4749dd2e83e358416e794974
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 11 10:41:31 2023 +0000
Remove some exit() calls
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 6 +++---
gfs2/libgfs2/recovery.c | 4 ++--
gfs2/libgfs2/structures.c | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 515b527f..66809014 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -617,9 +617,9 @@ int lgfs2_readi(struct lgfs2_inode *ip, void *buf, uint64_t offset, unsigned int
if (!extlen) {
if (sdp->gfs1) {
if (lgfs2_gfs1_block_map(ip, lblock, ¬_new, &dblock, &extlen, 0))
- exit(1);
+ return -1;
} else if (lgfs2_block_map(ip, lblock, ¬_new, &dblock, &extlen, 0))
- exit(1);
+ return -1;
}
if (dblock) {
@@ -702,7 +702,7 @@ int __lgfs2_writei(struct lgfs2_inode *ip, void *buf,
if (!extlen) {
new = 1;
if (lgfs2_block_map(ip, lblock, &new, &dblock, &extlen, 0))
- exit(1);
+ return -1;
}
if (new) {
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 7d5057e7..9db19fff 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -29,7 +29,7 @@ int lgfs2_replay_read_block(struct lgfs2_inode *ip, unsigned int blk,
uint64_t dblock;
if (lgfs2_block_map(ip, blk, &new, &dblock, NULL, 0))
- exit(1);
+ return -EINVAL;
if (!dblock)
return -EIO;
@@ -243,7 +243,7 @@ int lgfs2_clean_journal(struct lgfs2_inode *ip, struct lgfs2_log_header *head)
lblock = head->lh_blkno;
lgfs2_replay_incr_blk(ip, &lblock);
if (lgfs2_block_map(ip, lblock, &new, &dblock, NULL, 0))
- exit(1);
+ return -EINVAL;
if (!dblock)
return -EIO;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index aeb20ba8..fa413f7d 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -161,7 +161,7 @@ static struct lgfs2_buffer_head *lgfs2_get_file_buf(struct lgfs2_inode *ip, uint
return NULL;
if (lgfs2_block_map(ip, lbn, &new, &dbn, NULL, prealloc))
- exit(1);
+ return NULL;
if (!dbn)
return NULL;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 07/12: Add error checking to lgfs2_unstuff_dinode()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit ed0113b634c200e5908e457aba8a2b640d550287
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Wed Jan 11 10:29:41 2023 +0000
Add error checking to lgfs2_unstuff_dinode()
Propagate lgfs2_meta_alloc() failures to callers.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/convert/gfs2_convert.c | 13 ++++++++-----
gfs2/libgfs2/fs_ops.c | 8 +++++---
gfs2/libgfs2/gfs1.c | 3 ++-
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/libgfs2/structures.c | 4 ++--
5 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/gfs2/convert/gfs2_convert.c b/gfs2/convert/gfs2_convert.c
index de0a9b02..8b3c459b 100644
--- a/gfs2/convert/gfs2_convert.c
+++ b/gfs2/convert/gfs2_convert.c
@@ -272,8 +272,10 @@ static void fix_metatree(struct lgfs2_sbd *sbp, struct lgfs2_inode *ip,
mh.mh_magic = cpu_to_be32(GFS2_MAGIC);
mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN);
mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
- if (!ip->i_height)
- lgfs2_unstuff_dinode(ip);
+ if (ip->i_height == 0 && lgfs2_unstuff_dinode(ip)) {
+ log_crit(_("Failed to unstuff dinode at 0x%"PRIx64".\n"), ip->i_num.in_addr);
+ exit(1);
+ }
ptramt = blk->mp.mp_list[blk->height] * sizeof(uint64_t);
amount = size;
@@ -430,9 +432,10 @@ static uint64_t fix_jdatatree(struct lgfs2_sbd *sbp, struct lgfs2_inode *ip,
mh.mh_type = cpu_to_be32(GFS2_METATYPE_IN);
mh.mh_format = cpu_to_be32(GFS2_FORMAT_IN);
- if (!ip->i_height)
- lgfs2_unstuff_dinode(ip);
-
+ if (ip->i_height == 0 && lgfs2_unstuff_dinode(ip)) {
+ log_crit(_("Failed to unstuff dinode at 0x%"PRIx64".\n"), ip->i_num.in_addr);
+ exit(1);
+ }
ptramt = blk->mp.mp_list[blk->height];
amount = size;
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index d2dcc76d..515b527f 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -230,7 +230,7 @@ buffer_copy_tail(struct lgfs2_sbd *sdp,
lgfs2_bmodified(to_bh);
}
-void lgfs2_unstuff_dinode(struct lgfs2_inode *ip)
+int lgfs2_unstuff_dinode(struct lgfs2_inode *ip)
{
struct lgfs2_sbd *sdp = ip->i_sbd;
struct lgfs2_buffer_head *bh;
@@ -239,7 +239,7 @@ void lgfs2_unstuff_dinode(struct lgfs2_inode *ip)
if (ip->i_size) {
if (lgfs2_meta_alloc(ip, &block))
- exit(1);
+ return -1;
if (isdir) {
struct gfs2_meta_header mh = {
.mh_magic = cpu_to_be32(GFS2_MAGIC),
@@ -273,6 +273,7 @@ void lgfs2_unstuff_dinode(struct lgfs2_inode *ip)
}
ip->i_height = 1;
+ return 0;
}
/**
@@ -676,7 +677,8 @@ int __lgfs2_writei(struct lgfs2_inode *ip, void *buf,
if (inode_is_stuffed(ip) &&
((start + size) > (sdp->sd_bsize - sizeof(struct gfs2_dinode))))
- lgfs2_unstuff_dinode(ip);
+ if (lgfs2_unstuff_dinode(ip))
+ return -1;
if (isdir) {
lblock = offset;
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index 53972d38..531ba5a8 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -183,7 +183,8 @@ int lgfs2_gfs1_writei(struct lgfs2_inode *ip, void *buf, uint64_t offset,
if (!ip->i_height && /* stuffed */
((start + size) > (sdp->sd_bsize - sizeof(struct gfs_dinode))))
- lgfs2_unstuff_dinode(ip);
+ if (lgfs2_unstuff_dinode(ip))
+ return -1;
if (journaled) {
lblock = offset / sdp->sd_jbsize;
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 07a9bf1b..493961a8 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -543,7 +543,7 @@ extern int lgfs2_dirent_first(struct lgfs2_inode *dip,
extern int lgfs2_dirent_next(struct lgfs2_inode *dip, struct lgfs2_buffer_head *bh,
struct gfs2_dirent **dent);
extern int lgfs2_build_height(struct lgfs2_inode *ip, int height) __attribute__((warn_unused_result));
-extern void lgfs2_unstuff_dinode(struct lgfs2_inode *ip);
+extern int lgfs2_unstuff_dinode(struct lgfs2_inode *ip) __attribute__((warn_unused_result));
extern unsigned int lgfs2_calc_tree_height(struct lgfs2_inode *ip, uint64_t size);
extern uint32_t lgfs2_log_header_hash(char *buf);
extern uint32_t lgfs2_log_header_crc(char *buf, unsigned bsize);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 700ed75e..aeb20ba8 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -157,8 +157,8 @@ static struct lgfs2_buffer_head *lgfs2_get_file_buf(struct lgfs2_inode *ip, uint
uint64_t dbn;
int new = 1;
- if (ip->i_height == 0)
- lgfs2_unstuff_dinode(ip);
+ if (ip->i_height == 0 && lgfs2_unstuff_dinode(ip))
+ return NULL;
if (lgfs2_block_map(ip, lbn, &new, &dbn, NULL, prealloc))
exit(1);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 06/12: Remove lgfs2_breadm()
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit c30414ee8f54a484e86cc6305f6b56a13c7fa17b
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 10 15:37:27 2023 +0000
Remove lgfs2_breadm()
Nothing uses this function as, when a multi-block extent needs to be
read, it's cleaner to avoid using buffer_head structures altogether.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/buf.c | 33 ---------------------------------
gfs2/libgfs2/libgfs2.h | 2 --
2 files changed, 35 deletions(-)
diff --git a/gfs2/libgfs2/buf.c b/gfs2/libgfs2/buf.c
index cb5a3ea4..4de41e35 100644
--- a/gfs2/libgfs2/buf.c
+++ b/gfs2/libgfs2/buf.c
@@ -38,39 +38,6 @@ struct lgfs2_buffer_head *lgfs2_bget(struct lgfs2_sbd *sdp, uint64_t num)
return bh;
}
-int __lgfs2_breadm(struct lgfs2_sbd *sdp, struct lgfs2_buffer_head **bhs, size_t n,
- uint64_t block, int line, const char *caller)
-{
- size_t v = (n < IOV_MAX) ? n : IOV_MAX;
- struct iovec *iov = alloca(v * sizeof(struct iovec));
- struct iovec *iovbase = iov;
- size_t i = 0;
-
- while (i < n) {
- int j;
- ssize_t ret;
- ssize_t size = 0;
-
- for (j = 0; (i + j < n) && (j < IOV_MAX); j++) {
- bhs[i + j] = lgfs2_bget(sdp, block + i + j);
- if (bhs[i + j] == NULL)
- return -1;
- iov[j] = bhs[i + j]->iov;
- size += bhs[i + j]->iov.iov_len;
- }
-
- ret = preadv(sdp->device_fd, iovbase, j, (block + i) * sdp->sd_bsize);
- if (ret != size) {
- fprintf(stderr, "bad read: %s from %s:%d: block %"PRIu64" "
- "count: %d size: %zd ret: %zd\n", strerror(errno),
- caller, line, block, j, size, ret);
- exit(-1);
- }
- i += j;
- }
- return 0;
-}
-
struct lgfs2_buffer_head *__lgfs2_bread(struct lgfs2_sbd *sdp, uint64_t num, int line,
const char *caller)
{
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 5530ab2b..07a9bf1b 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -459,7 +459,6 @@ extern int lgfs2_field_assign(char *blk, const struct lgfs2_metafield *field, co
extern struct lgfs2_buffer_head *lgfs2_bget(struct lgfs2_sbd *sdp, uint64_t num);
extern struct lgfs2_buffer_head *__lgfs2_bread(struct lgfs2_sbd *sdp, uint64_t num,
int line, const char *caller);
-extern int __lgfs2_breadm(struct lgfs2_sbd *sdp, struct lgfs2_buffer_head **bhs, size_t n, uint64_t block, int line, const char *caller);
extern int lgfs2_bwrite(struct lgfs2_buffer_head *bh);
extern int lgfs2_brelse(struct lgfs2_buffer_head *bh);
extern uint32_t lgfs2_get_block_type(const char *buf);
@@ -467,7 +466,6 @@ extern uint32_t lgfs2_get_block_type(const char *buf);
#define lgfs2_bmodified(bh) do { bh->b_modified = 1; } while(0)
#define lgfs2_bread(bl, num) __lgfs2_bread(bl, num, __LINE__, __FUNCTION__)
-#define lgfs2_breadm(bl, bhs, n, block) __lgfs2_breadm(bl, bhs, n, block, __LINE__, __FUNCTION__)
/* device_geometry.c */
extern int lgfs2_get_dev_info(int fd, struct lgfs2_dev_info *i);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 05/12: Don't call exit() in lgfs2_build_quota_change
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit 2701208877b3be6d2cee4ff5c4eaaf1aa528ea24
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 10 15:31:02 2023 +0000
Don't call exit() in lgfs2_build_quota_change
Propagate the error condition from lgfs2_build_height() to callers.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/structures.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index faeac9da..700ed75e 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -337,7 +337,7 @@ struct lgfs2_inode *lgfs2_build_quota_change(struct lgfs2_inode *per_node, unsig
hgt = lgfs2_calc_tree_height(ip, (blocks + 1) * sdp->sd_bsize);
if (lgfs2_build_height(ip, hgt))
- exit(1);
+ return NULL;
for (x = 0; x < blocks; x++) {
bh = lgfs2_get_file_buf(ip, x, 0);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months
[gfs2-utils] 04/12: Don't call exit() in lgfs2_write_journal
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a commit to branch andyp-removeexit
in repository gfs2-utils.
commit a48fbe6b24a32e4221a5dac5e81cd44a43ff0305
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 10 15:29:09 2023 +0000
Don't call exit() in lgfs2_write_journal
Propagate the error condition from lgfs2_build_height() to callers.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/structures.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 45c3a5ce..faeac9da 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -188,7 +188,7 @@ int lgfs2_write_journal(struct lgfs2_inode *jnl, unsigned bsize, unsigned int bl
/* not broken up by indirect block pages. */
height = lgfs2_calc_tree_height(jnl, (blocks + 1) * bsize);
if (lgfs2_build_height(jnl, height))
- exit(1);
+ return -1;
for (x = 0; x < blocks; x++) {
struct lgfs2_buffer_head *bh = lgfs2_get_file_buf(jnl, x, 1);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 4 months