[gfs2-utils] 03/12: Add error checking to lgfs2_gfs1_block_map()
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 470e64f511781c8e0657a7eb2d718212a952e2e7
Author: Andrew Price <anprice(a)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(a)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);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 3 months
[gfs2-utils] 02/12: Add error checking to lgfs2_block_map()
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 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.
1 year, 3 months
[gfs2-utils] 01/12: Add error checking to lgfs2_build_height()
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 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.
1 year, 3 months
[gfs2-utils] branch andyp-removeexit created (now 95cd681c)
by pagure@pagure.io
This is an automated email from the git hooks/post-receive script.
andyp pushed a change to branch andyp-removeexit
in repository gfs2-utils.
at 95cd681c libgfs2: Remove the remaining exit() calls
This branch includes the following new commits:
new 5f2ac440 Add error checking to lgfs2_build_height()
new 6022da55 Add error checking to lgfs2_block_map()
new 470e64f5 Add error checking to lgfs2_gfs1_block_map()
new a48fbe6b Don't call exit() in lgfs2_write_journal
new 27012088 Don't call exit() in lgfs2_build_quota_change
new c30414ee Remove lgfs2_breadm()
new ed0113b6 Add error checking to lgfs2_unstuff_dinode()
new 4ec44027 Remove some exit() calls
new a142c7c5 Add error checking to lgfs2_dir_split_leaf()
new 39d9de94 Add error checking to dir_make_exhash()
new b53325e1 Add error checking to dir_double_exhash()
new 95cd681c libgfs2: Remove the remaining exit() calls
The 12 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
1 year, 3 months