X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=fs%2Fjfs%2Fjfs_xtree.c;h=19913fcd4c332a48d8b4f49594d4eb66e1a6a26c;hb=9bf4aaab3e101692164d49b7ca357651eb691cb6;hp=fab2bbcfe09b49d44df97d4faa7fc13a03e48cfc;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/fs/jfs/jfs_xtree.c b/fs/jfs/jfs_xtree.c index fab2bbcfe..19913fcd4 100644 --- a/fs/jfs/jfs_xtree.c +++ b/fs/jfs/jfs_xtree.c @@ -1071,8 +1071,10 @@ xtSplitUp(tid_t tid, */ /* get/pin the parent page */ XT_GETPAGE(ip, parent->bn, smp, PSIZE, sp, rc); - if (rc) - goto errout2; + if (rc) { + XT_PUTPAGE(rcmp); + return rc; + } /* * The new key entry goes ONE AFTER the index of parent entry, @@ -1106,8 +1108,10 @@ xtSplitUp(tid_t tid, rc = (sp->header.flag & BT_ROOT) ? xtSplitRoot(tid, ip, split, &rmp) : xtSplitPage(tid, ip, split, &rmp, &rbn); - if (rc) - goto errout1; + if (rc) { + XT_PUTPAGE(smp); + return rc; + } XT_PUTPAGE(smp); /* keep new child page pinned */ @@ -1170,19 +1174,6 @@ xtSplitUp(tid_t tid, XT_PUTPAGE(rmp); return 0; - - /* - * If something fails in the above loop we were already walking back - * up the tree and the tree is now inconsistent. - * release all pages we're holding. - */ - errout1: - XT_PUTPAGE(smp); - - errout2: - XT_PUTPAGE(rcmp); - - return rc; } @@ -1222,7 +1213,7 @@ xtSplitPage(tid_t tid, struct inode *ip, struct pxdlist *pxdlist; pxd_t *pxd; struct tlock *tlck; - struct xtlock *sxtlck = 0, *rxtlck = 0; + struct xtlock *sxtlck = NULL, *rxtlck = NULL; smp = split->mp; sp = XT_PAGE(ip, smp); @@ -1603,7 +1594,7 @@ int xtExtend(tid_t tid, /* transaction id */ xad_t *xad; s64 xaddr; struct tlock *tlck; - struct xtlock *xtlck = 0; + struct xtlock *xtlck = NULL; int rootsplit = 0; jfs_info("xtExtend: nxoff:0x%lx nxlen:0x%x", (ulong) xoff, xlen); @@ -1957,7 +1948,7 @@ int xtUpdate(tid_t tid, struct inode *ip, xad_t * nxad) int nxlen, xlen, lxlen, rxlen; s64 nxaddr, xaddr; struct tlock *tlck; - struct xtlock *xtlck = 0; + struct xtlock *xtlck = NULL; int rootsplit = 0, newpage = 0; /* there must exist extent to be tailgated */ @@ -3416,9 +3407,9 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) int xlen, len, freexlen; struct btstack btstack; struct btframe *parent; - struct tblock *tblk = 0; - struct tlock *tlck = 0; - struct xtlock *xtlck = 0; + struct tblock *tblk = NULL; + struct tlock *tlck = NULL; + struct xtlock *xtlck = NULL; struct xdlistlock xadlock; /* maplock for COMMIT_WMAP */ struct pxd_lock *pxdlock; /* maplock for COMMIT_WMAP */ s64 nfreed; @@ -3504,7 +3495,17 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) * a page that was formerly to the right, let's make sure that the * next pointer is zero. */ - p->header.next = 0; + if (p->header.next) { + if (log) + /* + * Make sure this change to the header is logged. + * If we really truncate this leaf, the flag + * will be changed to tlckTRUNCATE + */ + tlck = txLock(tid, ip, mp, tlckXTREE|tlckGROW); + BT_MARK_DIRTY(mp, ip); + p->header.next = 0; + } freed = 0; @@ -3614,7 +3615,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) pxdlock->flag = mlckFREEPXD; PXDaddress(&pxdlock->pxd, xaddr); PXDlength(&pxdlock->pxd, freexlen); - txFreeMap(ip, pxdlock, 0, COMMIT_WMAP); + txFreeMap(ip, pxdlock, NULL, COMMIT_WMAP); /* reset map lock */ xadlock.flag = mlckFREEXADLIST; @@ -3642,8 +3643,8 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) xadlock.count = le16_to_cpu(p->header.nextindex) - nextindex; - txFreeMap(ip, (struct maplock *) & xadlock, 0, - COMMIT_WMAP); + txFreeMap(ip, (struct maplock *) & xadlock, + NULL, COMMIT_WMAP); } p->header.nextindex = cpu_to_le16(nextindex); } @@ -3672,7 +3673,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) xadlock.xdlist = &p->xad[XTENTRYSTART]; xadlock.count = le16_to_cpu(p->header.nextindex) - XTENTRYSTART; - txFreeMap(ip, (struct maplock *) & xadlock, 0, COMMIT_WMAP); + txFreeMap(ip, (struct maplock *) & xadlock, NULL, COMMIT_WMAP); } if (p->header.flag & BT_ROOT) { @@ -3747,8 +3748,8 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) xadlock.count = le16_to_cpu(p->header.nextindex) - index - 1; - txFreeMap(ip, (struct maplock *) & xadlock, 0, - COMMIT_WMAP); + txFreeMap(ip, (struct maplock *) & xadlock, + NULL, COMMIT_WMAP); } BT_MARK_DIRTY(mp, ip); @@ -3819,7 +3820,7 @@ s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int flag) xadlock.count = le16_to_cpu(p->header.nextindex) - XTENTRYSTART; - txFreeMap(ip, (struct maplock *) & xadlock, 0, + txFreeMap(ip, (struct maplock *) & xadlock, NULL, COMMIT_WMAP); } BT_MARK_DIRTY(mp, ip); @@ -3956,11 +3957,11 @@ s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size) struct btframe *parent; int rc; struct tblock *tblk; - struct tlock *tlck = 0; + struct tlock *tlck = NULL; xad_t *xad; int xlen; s64 xoff; - struct xtlock *xtlck = 0; + struct xtlock *xtlck = NULL; /* save object truncation type */ tblk = tid_to_tblock(tid);