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 470e64f511781c8e0657a7eb2d718212a952e2e7 Author: Andrew Price anprice@redhat.com AuthorDate: Tue Jan 10 15:24:59 2023 +0000
Add error checking to lgfs2_gfs1_block_map()
Signed-off-by: Andrew Price anprice@redhat.com --- gfs2/libgfs2/fs_ops.c | 8 ++++---- gfs2/libgfs2/gfs1.c | 14 ++++++++------ gfs2/libgfs2/libgfs2.h | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c index d114c8ed..d2dcc76d 100644 --- a/gfs2/libgfs2/fs_ops.c +++ b/gfs2/libgfs2/fs_ops.c @@ -614,10 +614,10 @@ int lgfs2_readi(struct lgfs2_inode *ip, void *buf, uint64_t offset, unsigned int amount = sdp->sd_bsize - o;
if (!extlen) { - if (sdp->gfs1) - lgfs2_gfs1_block_map(ip, lblock, ¬_new, &dblock, - &extlen, 0); - else if (lgfs2_block_map(ip, lblock, ¬_new, &dblock, &extlen, 0)) + if (sdp->gfs1) { + if (lgfs2_gfs1_block_map(ip, lblock, ¬_new, &dblock, &extlen, 0)) + exit(1); + } else if (lgfs2_block_map(ip, lblock, ¬_new, &dblock, &extlen, 0)) exit(1); }
diff --git a/gfs2/libgfs2/gfs1.c b/gfs2/libgfs2/gfs1.c index 93009500..53972d38 100644 --- a/gfs2/libgfs2/gfs1.c +++ b/gfs2/libgfs2/gfs1.c @@ -67,7 +67,7 @@ void lgfs2_gfs1_lookup_block(struct lgfs2_inode *ip, struct lgfs2_buffer_head *b *new = 1; }
-void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, +int lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, uint64_t *dblock, uint32_t *extlen, int prealloc) { struct lgfs2_sbd *sdp = ip->i_sbd; @@ -90,7 +90,7 @@ void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, if (extlen) *extlen = 1; } - return; + return 0; }
bsize = (fs_is_jdata(ip)) ? sdp->sd_jbsize : sdp->sd_bsize; @@ -98,10 +98,10 @@ void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, height = lgfs2_calc_tree_height(ip, (lblock + 1) * bsize); if (ip->i_height < height) { if (!create) - return; + return 0;
if (lgfs2_build_height(ip, height)) - exit(1); + return -1; }
lgfs2_find_metapath(ip, lblock, &mp); @@ -114,7 +114,7 @@ void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, if (bh != ip->i_bh) lgfs2_brelse(bh); if (!*dblock) - return; + return 0;
if (*new) { struct gfs2_meta_header mh = { @@ -162,6 +162,7 @@ void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new,
if (bh != ip->i_bh) lgfs2_brelse(bh); + return 0; }
int lgfs2_gfs1_writei(struct lgfs2_inode *ip, void *buf, uint64_t offset, @@ -204,7 +205,8 @@ int lgfs2_gfs1_writei(struct lgfs2_inode *ip, void *buf, uint64_t offset,
if (!extlen){ new = 1; - lgfs2_gfs1_block_map(ip, lblock, &new, &dblock, &extlen, 0); + if (lgfs2_gfs1_block_map(ip, lblock, &new, &dblock, &extlen, 0)) + exit(1); if (!dblock) return -1; } diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h index c6247031..5530ab2b 100644 --- a/gfs2/libgfs2/libgfs2.h +++ b/gfs2/libgfs2/libgfs2.h @@ -710,8 +710,8 @@ extern void lgfs2_gfs1_lookup_block(struct lgfs2_inode *ip, struct lgfs2_buffer_head *bh, unsigned int height, struct lgfs2_metapath *mp, int create, int *new, uint64_t *block); -extern void lgfs2_gfs1_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new, - uint64_t *dblock, uint32_t *extlen, int prealloc); +extern int lgfs2_gfs1_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_gfs1_writei(struct lgfs2_inode *ip, void *buf, uint64_t offset, unsigned int size); extern struct lgfs2_inode *lgfs2_gfs_inode_get(struct lgfs2_sbd *sdp, char *buf);
cluster-commits@lists.fedorahosted.org