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 5f2ac4402c50f2ed7fa66483c290c8d52451d892
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 10 14:57:54 2023 +0000
Add error checking to lgfs2_build_height()
Push down the exit calls into the callers. Eventually they'll be moved
out of libgfs2 and into the applications.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/libgfs2/fs_ops.c | 8 +++++---
gfs2/libgfs2/gfs1.c | 3 ++-
gfs2/libgfs2/libgfs2.h | 2 +-
gfs2/libgfs2/structures.c | 6 ++++--
4 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index f2d178a1..6559384a 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -376,7 +376,7 @@ unsigned int lgfs2_calc_tree_height(struct lgfs2_inode *ip, uint64_t
size)
return height;
}
-void lgfs2_build_height(struct lgfs2_inode *ip, int height)
+int lgfs2_build_height(struct lgfs2_inode *ip, int height)
{
struct lgfs2_sbd *sdp = ip->i_sbd;
struct lgfs2_buffer_head *bh;
@@ -401,7 +401,7 @@ void lgfs2_build_height(struct lgfs2_inode *ip, int height)
};
if (lgfs2_meta_alloc(ip, &block))
- exit(1);
+ return -1;
bh = lgfs2_bget(sdp, block);
memcpy(bh->b_data, &mh, sizeof(mh));
buffer_copy_tail(sdp, bh,
@@ -421,6 +421,7 @@ void lgfs2_build_height(struct lgfs2_inode *ip, int height)
ip->i_height++;
}
+ return 0;
}
void lgfs2_find_metapath(struct lgfs2_inode *ip, uint64_t block, struct lgfs2_metapath
*mp)
@@ -494,7 +495,8 @@ void lgfs2_block_map(struct lgfs2_inode *ip, uint64_t lblock, int
*new,
if (!create)
return;
- lgfs2_build_height(ip, height);
+ if (lgfs2_build_height(ip, height))
+ exit(1);
}
lgfs2_find_metapath(ip, lblock, &mp);
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c
index c6ad8dbe..93009500 100644
--- a/gfs2/libgfs2/gfs1.c
+++ b/gfs2/libgfs2/gfs1.c
@@ -100,7 +100,8 @@ void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int
*new,
if (!create)
return;
- lgfs2_build_height(ip, height);
+ if (lgfs2_build_height(ip, height))
+ exit(1);
}
lgfs2_find_metapath(ip, lblock, &mp);
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index 34c9dfa1..dc4a42e9 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -544,7 +544,7 @@ extern int lgfs2_dirent_first(struct lgfs2_inode *dip,
struct gfs2_dirent **dent);
extern int lgfs2_dirent_next(struct lgfs2_inode *dip, struct lgfs2_buffer_head *bh,
struct gfs2_dirent **dent);
-extern void lgfs2_build_height(struct lgfs2_inode *ip, int height);
+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 unsigned int lgfs2_calc_tree_height(struct lgfs2_inode *ip, uint64_t size);
extern uint32_t lgfs2_log_header_hash(char *buf);
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index 5a1b46d4..af7e2fa6 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -186,7 +186,8 @@ int lgfs2_write_journal(struct lgfs2_inode *jnl, unsigned bsize,
unsigned int bl
/* Build the height up so our journal blocks will be contiguous and */
/* not broken up by indirect block pages. */
height = lgfs2_calc_tree_height(jnl, (blocks + 1) * bsize);
- lgfs2_build_height(jnl, height);
+ if (lgfs2_build_height(jnl, height))
+ exit(1);
for (x = 0; x < blocks; x++) {
struct lgfs2_buffer_head *bh = lgfs2_get_file_buf(jnl, x, 1);
@@ -334,7 +335,8 @@ struct lgfs2_inode *lgfs2_build_quota_change(struct lgfs2_inode
*per_node, unsig
return NULL;
hgt = lgfs2_calc_tree_height(ip, (blocks + 1) * sdp->sd_bsize);
- lgfs2_build_height(ip, hgt);
+ if (lgfs2_build_height(ip, hgt))
+ exit(1);
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.