aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@austin.ibm.com>2005-10-11 10:06:59 -0400
committerDave Kleikamp <shaggy@austin.ibm.com>2005-10-11 10:06:59 -0400
commitb6a47fd8ff08a9d5cd279cdb8d97a619983575fa (patch)
tree5e946b5a7c3f224d181525ca475fd3f29508c47d /fs
parentac17b8b57013a3e38d1958f66a218f15659e5752 (diff)
JFS: Corrupted block map should not cause trap
Replace assert statements with better error handling. Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/jfs/jfs_dmap.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c
index 51c02bf07878..68000a50ceb6 100644
--- a/fs/jfs/jfs_dmap.c
+++ b/fs/jfs/jfs_dmap.c
@@ -74,7 +74,7 @@
74static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno, 74static void dbAllocBits(struct bmap * bmp, struct dmap * dp, s64 blkno,
75 int nblocks); 75 int nblocks);
76static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval); 76static void dbSplit(dmtree_t * tp, int leafno, int splitsz, int newval);
77static void dbBackSplit(dmtree_t * tp, int leafno); 77static int dbBackSplit(dmtree_t * tp, int leafno);
78static int dbJoin(dmtree_t * tp, int leafno, int newval); 78static int dbJoin(dmtree_t * tp, int leafno, int newval);
79static void dbAdjTree(dmtree_t * tp, int leafno, int newval); 79static void dbAdjTree(dmtree_t * tp, int leafno, int newval);
80static int dbAdjCtl(struct bmap * bmp, s64 blkno, int newval, int alloc, 80static 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 * that it is at the front of a binary buddy system. 2466 * that it is at the front of a binary buddy system.
2467 */ 2467 */
2468 if (oldval == NOFREE) { 2468 if (oldval == NOFREE) {
2469 dbBackSplit((dmtree_t *) dcp, leafno); 2469 rc = dbBackSplit((dmtree_t *) dcp, leafno);
2470 if (rc)
2471 return rc;
2470 oldval = dcp->stree[ti]; 2472 oldval = dcp->stree[ti];
2471 } 2473 }
2472 dbSplit((dmtree_t *) dcp, leafno, dcp->budmin, newval); 2474 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 * 2628 *
2627 * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit; 2629 * serialization: IREAD_LOCK(ipbmap) or IWRITE_LOCK(ipbmap) held on entry/exit;
2628 */ 2630 */
2629static void dbBackSplit(dmtree_t * tp, int leafno) 2631static int dbBackSplit(dmtree_t * tp, int leafno)
2630{ 2632{
2631 int budsz, bud, w, bsz, size; 2633 int budsz, bud, w, bsz, size;
2632 int cursz; 2634 int cursz;
@@ -2661,7 +2663,10 @@ static void dbBackSplit(dmtree_t * tp, int leafno)
2661 */ 2663 */
2662 for (w = leafno, bsz = budsz;; bsz <<= 1, 2664 for (w = leafno, bsz = budsz;; bsz <<= 1,
2663 w = (w < bud) ? w : bud) { 2665 w = (w < bud) ? w : bud) {
2664 assert(bsz < le32_to_cpu(tp->dmt_nleafs)); 2666 if (bsz >= le32_to_cpu(tp->dmt_nleafs)) {
2667 jfs_err("JFS: block map error in dbBackSplit");
2668 return -EIO;
2669 }
2665 2670
2666 /* determine the buddy. 2671 /* determine the buddy.
2667 */ 2672 */
@@ -2680,7 +2685,11 @@ static void dbBackSplit(dmtree_t * tp, int leafno)
2680 } 2685 }
2681 } 2686 }
2682 2687
2683 assert(leaf[leafno] == size); 2688 if (leaf[leafno] != size) {
2689 jfs_err("JFS: wrong leaf value in dbBackSplit");
2690 return -EIO;
2691 }
2692 return 0;
2684} 2693}
2685 2694
2686 2695