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 6022da55ba625739bdfb13bcbe29ac76b25d8a67
Author: Andrew Price <anprice(a)redhat.com>
AuthorDate: Tue Jan 10 15:15:18 2023 +0000
Add error checking to lgfs2_block_map()
Propagate errors from lgfs2_build_height() back to the callers instead
of exiting.
Signed-off-by: Andrew Price <anprice(a)redhat.com>
---
gfs2/edit/journal.c | 4 ++--
gfs2/fsck/fs_recovery.c | 6 +++++-
gfs2/fsck/rgrepair.c | 6 +++++-
gfs2/libgfs2/fs_ops.c | 19 ++++++++++---------
gfs2/libgfs2/libgfs2.h | 4 ++--
gfs2/libgfs2/recovery.c | 6 ++++--
gfs2/libgfs2/structures.c | 3 ++-
7 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/gfs2/edit/journal.c b/gfs2/edit/journal.c
index f5dc0518..b3756469 100644
--- a/gfs2/edit/journal.c
+++ b/gfs2/edit/journal.c
@@ -144,8 +144,8 @@ static int fsck_readi(struct lgfs2_inode *ip, void *rbuf, uint64_t
roffset,
if (amount > sdp->sd_bsize - o)
amount = sdp->sd_bsize - o;
if (!extlen)
- lgfs2_block_map(ip, lblock, ¬_new, &dblock, &extlen,
- FALSE);
+ if (lgfs2_block_map(ip, lblock, ¬_new, &dblock, &extlen, FALSE))
+ exit(1);
if (dblock) {
lbh = lgfs2_bread(sdp, dblock);
if (*abs_block == 0)
diff --git a/gfs2/fsck/fs_recovery.c b/gfs2/fsck/fs_recovery.c
index 03a2b7ca..a8385f7e 100644
--- a/gfs2/fsck/fs_recovery.c
+++ b/gfs2/fsck/fs_recovery.c
@@ -427,7 +427,11 @@ static int check_journal_seq_no(struct lgfs2_inode *ip, int fix)
highest_seq++;
prev_seq = highest_seq;
log_warn(_("Renumbering it as 0x%"PRIx64"\n"), highest_seq);
- lgfs2_block_map(ip, blk, &new, &dblock, NULL, 0);
+ if (lgfs2_block_map(ip, blk, &new, &dblock, NULL, 0)) {
+ log_crit(_("Failed to map block 0x%"PRIx32" in journal at
0x%"PRIx64": %s\n"),
+ blk, ip->i_num.in_addr, strerror(errno));
+ exit(1);
+ }
bh = lgfs2_bread(ip->i_sbd, dblock);
((struct gfs2_log_header *)bh->b_data)->lh_sequence = cpu_to_be64(highest_seq);
lgfs2_bmodified(bh);
diff --git a/gfs2/fsck/rgrepair.c b/gfs2/fsck/rgrepair.c
index 7c98bec6..83782e5d 100644
--- a/gfs2/fsck/rgrepair.c
+++ b/gfs2/fsck/rgrepair.c
@@ -64,7 +64,11 @@ static void find_journaled_rgs(struct lgfs2_sbd *sdp)
jblocks = ip->i_size / sdp->sd_bsize;
false_count = 0;
for (b = 0; b < jblocks; b++) {
- lgfs2_block_map(ip, b, &new, &dblock, NULL, 0);
+ if (lgfs2_block_map(ip, b, &new, &dblock, NULL, 0)) {
+ log_crit(_("Failed to map block 0x%"PRIu64" in journal at
0x%"PRIu64": %s\n"),
+ b, ip->i_num.in_addr, strerror(errno));
+ exit(1);
+ }
if (!dblock)
break;
bh = lgfs2_bread(sdp, dblock);
diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index 6559384a..d114c8ed 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -462,7 +462,7 @@ void lgfs2_lookup_block(struct lgfs2_inode *ip, struct
lgfs2_buffer_head *bh,
*new = 1;
}
-void lgfs2_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new,
+int lgfs2_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;
@@ -485,7 +485,7 @@ void lgfs2_block_map(struct lgfs2_inode *ip, uint64_t lblock, int
*new,
if (extlen)
*extlen = 1;
}
- return;
+ return 0;
}
bsize = (S_ISDIR(ip->i_mode)) ? sdp->sd_jbsize : sdp->sd_bsize;
@@ -493,10 +493,10 @@ void lgfs2_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);
@@ -509,7 +509,7 @@ void lgfs2_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 = {
@@ -555,6 +555,7 @@ void lgfs2_block_map(struct lgfs2_inode *ip, uint64_t lblock, int
*new,
if (bh != ip->i_bh)
lgfs2_brelse(bh);
+ return 0;
}
static void
@@ -616,9 +617,8 @@ int lgfs2_readi(struct lgfs2_inode *ip, void *buf, uint64_t offset,
unsigned int
if (sdp->gfs1)
lgfs2_gfs1_block_map(ip, lblock, ¬_new, &dblock,
&extlen, 0);
- else
- lgfs2_block_map(ip, lblock, ¬_new, &dblock,
- &extlen, 0);
+ else if (lgfs2_block_map(ip, lblock, ¬_new, &dblock, &extlen, 0))
+ exit(1);
}
if (dblock) {
@@ -699,7 +699,8 @@ int __lgfs2_writei(struct lgfs2_inode *ip, void *buf,
if (!extlen) {
new = 1;
- lgfs2_block_map(ip, lblock, &new, &dblock, &extlen, 0);
+ if (lgfs2_block_map(ip, lblock, &new, &dblock, &extlen, 0))
+ exit(1);
}
if (new) {
diff --git a/gfs2/libgfs2/libgfs2.h b/gfs2/libgfs2/libgfs2.h
index dc4a42e9..c6247031 100644
--- a/gfs2/libgfs2/libgfs2.h
+++ b/gfs2/libgfs2/libgfs2.h
@@ -530,8 +530,8 @@ extern int lgfs2_lookupi(struct lgfs2_inode *dip, const char
*filename, int len,
extern int lgfs2_dir_add(struct lgfs2_inode *dip, const char *filename, int len,
struct lgfs2_inum *inum, unsigned int type);
extern int lgfs2_dirent_del(struct lgfs2_inode *dip, const char *filename, int
name_len);
-extern void lgfs2_block_map(struct lgfs2_inode *ip, uint64_t lblock, int *new,
- uint64_t *dblock, uint32_t *extlen, int prealloc);
+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);
diff --git a/gfs2/libgfs2/recovery.c b/gfs2/libgfs2/recovery.c
index 56aa2478..7d5057e7 100644
--- a/gfs2/libgfs2/recovery.c
+++ b/gfs2/libgfs2/recovery.c
@@ -28,7 +28,8 @@ int lgfs2_replay_read_block(struct lgfs2_inode *ip, unsigned int blk,
int new = 0;
uint64_t dblock;
- lgfs2_block_map(ip, blk, &new, &dblock, NULL, 0);
+ if (lgfs2_block_map(ip, blk, &new, &dblock, NULL, 0))
+ exit(1);
if (!dblock)
return -EIO;
@@ -241,7 +242,8 @@ int lgfs2_clean_journal(struct lgfs2_inode *ip, struct
lgfs2_log_header *head)
lblock = head->lh_blkno;
lgfs2_replay_incr_blk(ip, &lblock);
- lgfs2_block_map(ip, lblock, &new, &dblock, NULL, 0);
+ if (lgfs2_block_map(ip, lblock, &new, &dblock, NULL, 0))
+ exit(1);
if (!dblock)
return -EIO;
diff --git a/gfs2/libgfs2/structures.c b/gfs2/libgfs2/structures.c
index af7e2fa6..45c3a5ce 100644
--- a/gfs2/libgfs2/structures.c
+++ b/gfs2/libgfs2/structures.c
@@ -160,7 +160,8 @@ static struct lgfs2_buffer_head *lgfs2_get_file_buf(struct lgfs2_inode
*ip, uint
if (ip->i_height == 0)
lgfs2_unstuff_dinode(ip);
- lgfs2_block_map(ip, lbn, &new, &dbn, NULL, prealloc);
+ if (lgfs2_block_map(ip, lbn, &new, &dbn, NULL, prealloc))
+ exit(1);
if (!dbn)
return NULL;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.