On 06/14/2013 12:28 PM, Marek Skuczynski wrote: > >> Values passed to bread are: vol: 0, pxd: len: 1, addr1: 0, addr2: 0 >> >> The p->header.flag is equal 0 after returning from bread(). >> >> >> Any idea how to handle this problem ? >> It looks like the function needs to do a better job of sanity checking. >> > > I guess that a pxdAddress couldn't be equal to zero. > If this is the case, rXtree() should return MINOR_ERROR, as in the case > when bread fails. > Am I correct?
Something like this would probably fix it. A corrupt node may have any kind of data, so just keeping it from infinitely recursing would probably catch any problem where bread() doesn't fail. Index: libfs/log_map.c =================================================================== RCS file: /cvsroot/jfs/jfsutils/libfs/log_map.c,v retrieving revision 1.21 diff -u -p -r1.21 log_map.c --- libfs/log_map.c 11 May 2012 13:02:04 -0000 1.21 +++ libfs/log_map.c 14 Jun 2013 21:37:56 -0000 @@ -1682,6 +1682,7 @@ int rXtree(int32_t vol, /* index in vop xtpage_t *p; caddr_t buf_ptr; pxd_t pxd; + int max_depth; /* start from root in dinode */ p = (xtpage_t *) & dp->di_btroot; @@ -1696,6 +1697,13 @@ int rXtree(int32_t vol, /* index in vop /* * traverse down leftmost child node to the leftmost leaf of xtree */ + + /* + * Overkill, but I don't know the practical limit for the xtree + * depth + */ + max_depth = 100; + do { /* read in the leftmost child page */ if (bread(vol, pxd, (void **) &buf_ptr, PB_READ) != 0) { @@ -1711,7 +1719,12 @@ int rXtree(int32_t vol, /* index in vop PXDlength(&pxd, vopen[vol].lbperpage); PXDaddress(&pxd, addressXAD(&p->xad[XTENTRYSTART])); } - } while (!(p->header.flag & BT_LEAF)); + } while (--max_depth); + + if (!(p->header.flag & BT_LEAF)) { + fsck_send_msg(lrdo_RXTREADLFFAIL); + return(MINOR_ERROR); + } out: *first_leaf = p; ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Jfs-discussion mailing list Jfs-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jfs-discussion