Commit b6a47fd8 authored by Dave Kleikamp's avatar Dave Kleikamp

JFS: Corrupted block map should not cause trap

Replace assert statements with better error handling.
Signed-off-by: default avatarDave Kleikamp <shaggy@austin.ibm.com>
parent ac17b8b5
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno, static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
int nblocks); int nblocks);
static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval); static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval);
static void dbBackSplit(dmtree_t * tp, int leafno); static int dbBackSplit(dmtree_t * tp, int leafno);
static int dbJoin(dmtree_t * tp, int leafno, int newval); static int dbJoin(dmtree_t * tp, int leafno, int newval);
static void dbAdjTree(dmtree_t * tp, int leafno, int newval); static void dbAdjTree(dmtree_t * tp, int leafno, int newval);
static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc,
...@@ -2466,7 +2466,9 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level) ...@@ -2466,7 +2466,9 @@ dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, int level)
* that it is at the front of a binary buddy system. * that it is at the front of a binary buddy system.
*/ */
if (oldval == NOFREE) { if (oldval == NOFREE) {
dbBackSplit((dmtree_t *) dcp, leafno); rc = dbBackSplit((dmtree_t *) dcp, leafno);
if (rc)
return rc;
oldval = dcp->stree[ti]; oldval = dcp->stree[ti];
} }
dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval); dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval);
...@@ -2626,7 +2628,7 @@ static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval) ...@@ -2626,7 +2628,7 @@ static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval)
* *
* serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit; * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit;
*/ */
static void dbBackSplit(dmtree_t * tp, int leafno) static int dbBackSplit(dmtree_t * tp, int leafno)
{ {
int budsz, bud, w, bsz, size; int budsz, bud, w, bsz, size;
int cursz; int cursz;
...@@ -2661,7 +2663,10 @@ static void dbBackSplit(dmtree_t * tp, int leafno) ...@@ -2661,7 +2663,10 @@ static void dbBackSplit(dmtree_t * tp, int leafno)
*/ */
for (w = leafno, bsz = budsz;; bsz <<= 1, for (w = leafno, bsz = budsz;; bsz <<= 1,
w = (w < bud) ? w : bud) { w = (w < bud) ? w : bud) {
assert(bsz < le32_to_cpu(tp->dmt_nleafs)); if (bsz >= le32_to_cpu(tp->dmt_nleafs)) {
jfs_err("JFS: block map error in dbBackSplit");
return -EIO;
}
/* determine the buddy. /* determine the buddy.
*/ */
...@@ -2680,7 +2685,11 @@ static void dbBackSplit(dmtree_t * tp, int leafno) ...@@ -2680,7 +2685,11 @@ static void dbBackSplit(dmtree_t * tp, int leafno)
} }
} }
assert(leaf[leafno] == size); if (leaf[leafno] != size) {
jfs_err("JFS: wrong leaf value in dbBackSplit");
return -EIO;
}
return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment