gfs2-utils: master - libgfs2: dir_split_leaf needs to check for allocation failure

Bob Peterson rpeterso at fedoraproject.org
Tue Jan 26 21:09:34 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/gfs2-utils.git?p=gfs2-utils.git;a=commitdiff;h=d2219d1eba01d8c1b8d48fe188fc21dcc325cbfe
Commit:        d2219d1eba01d8c1b8d48fe188fc21dcc325cbfe
Parent:        04dc9d7c78ab9a72f99438be8cb0765374235f21
Author:        Bob Peterson <bob at ganesha.peterson>
AuthorDate:    Thu Jan 21 17:22:55 2010 -0600
Committer:     Bob Peterson <rpeterso at redhat.com>
CommitterDate: Tue Jan 26 15:09:46 2010 -0600

libgfs2: dir_split_leaf needs to check for allocation failure

When splitting directory leaf blocks, if an allocation fails
for some reason (e.g. corruption) it should throw an error
rather than plowing forward.

rhbz#455300
---
 gfs2/libgfs2/fs_ops.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gfs2/libgfs2/fs_ops.c b/gfs2/libgfs2/fs_ops.c
index e552321..81637c2 100644
--- a/gfs2/libgfs2/fs_ops.c
+++ b/gfs2/libgfs2/fs_ops.c
@@ -901,7 +901,8 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
 		    be32_to_cpu(dent->de_hash) < divider) {
 			name_len = be16_to_cpu(dent->de_name_len);
 
-			dirent_alloc(dip, nbh, name_len, &new);
+			if (dirent_alloc(dip, nbh, name_len, &new))
+				die("dir_split_leaf (3)\n");
 
 			new->de_inum = dent->de_inum;
 			new->de_hash = dent->de_hash;
@@ -927,7 +928,8 @@ static void dir_split_leaf(struct gfs2_inode *dip, uint32_t lindex,
 	} while (dent);
 
 	if (!moved) {
-		dirent_alloc(dip, nbh, 0, &new);
+		if (dirent_alloc(dip, nbh, 0, &new))
+			die("dir_split_leaf (4)\n");
 		new->de_inum.no_formal_ino = 0;
 	}
 
@@ -1107,7 +1109,8 @@ restart:
 				nleaf->lf_depth = leaf->lf_depth;
 				nleaf->lf_dirent_format = cpu_to_be32(GFS2_FORMAT_DE);
 
-				dirent_alloc(dip, nbh, len, &dent);
+				if (dirent_alloc(dip, nbh, len, &dent))
+					die("dir_split_leaf (3)\n");
 				dip->i_di.di_blocks++;
 				bmodified(dip->i_bh);
 				bmodified(bh);


More information about the cluster-commits mailing list