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.