Lines Matching +full:xlen +full:- +full:1
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) International Business Machines Corp., 2000-2005
4 * Portions Copyright (C) Christoph Hellwig, 2001-2002
17 * (no hashlist for mp -> tlock).
20 * tlock on in-memory inode:
21 * in-place tlock in the in-memory inode itself;
84 static int nTxBlock = -1; /* number of transaction blocks */
89 static int nTxLock = -1; /* number of transaction locks */
172 * ---------------------------------
195 jfs_tlocks_low = 1; in txLockAlloc()
207 TxAnchor.tlocksInUse--; in txLockFree()
232 if (nTxLock == -1) { in txInit()
233 if (nTxBlock == -1) { in txInit()
236 if (si.totalram > (256 * 1024)) /* 1 GB */ in txInit()
245 if (nTxBlock == -1) in txInit()
273 return -ENOMEM; in txInit()
275 for (k = 1; k < nTxBlock - 1; k++) { in txInit()
276 TxBlock[k].next = k + 1; in txInit()
284 TxAnchor.freetid = 1; in txInit()
287 stattx.maxtid = 1; /* statistics */ in txInit()
299 return -ENOMEM; in txInit()
303 for (k = 1; k < nTxLock - 1; k++) in txInit()
304 TxLock[k].next = k + 1; in txInit()
309 TxAnchor.freelock = 1; in txInit()
317 stattx.maxlid = 1; /* statistics */ in txInit()
340 * PARAMETER: sb - superblock
341 * flag - force for nested tx;
343 * RETURN: tid - transaction id
355 log = JFS_SBI(sb)->log; in txBegin()
358 jfs_error(sb, "read-only filesystem\n"); in txBegin()
371 if (test_bit(log_SYNCBARRIER, &log->flag) || in txBegin()
372 test_bit(log_QUIESCE, &log->flag)) { in txBegin()
374 TXN_SLEEP(&log->syncwait); in txBegin()
403 if ((tblk->next == 0) && !(flag & COMMIT_FORCE)) { in txBegin()
404 /* Don't let a non-forced transaction take the last tblk */ in txBegin()
411 TxAnchor.freetid = tblk->next; in txBegin()
419 * awakened after sleeping on tblk->waitor in txBegin()
423 tblk->next = tblk->last = tblk->xflag = tblk->flag = tblk->lsn = 0; in txBegin()
425 tblk->sb = sb; in txBegin()
426 ++log->logtid; in txBegin()
427 tblk->logtid = log->logtid; in txBegin()
429 ++log->active; in txBegin()
448 * PARAMETER: sb - superblock
456 log = JFS_SBI(sb)->log; in txBeginAnon()
465 if (test_bit(log_SYNCBARRIER, &log->flag) || in txBeginAnon()
466 test_bit(log_QUIESCE, &log->flag)) { in txBeginAnon()
468 TXN_SLEEP(&log->syncwait); in txBeginAnon()
504 TXN_WAKEUP(&tblk->waitor); in txEnd()
506 log = JFS_SBI(tblk->sb)->log; in txEnd()
516 if (tblk->flag & tblkGC_LAZY) { in txEnd()
520 spin_lock_irq(&log->gclock); // LOGGC_LOCK in txEnd()
521 tblk->flag |= tblkGC_UNLOCKED; in txEnd()
522 spin_unlock_irq(&log->gclock); // LOGGC_UNLOCK in txEnd()
528 assert(tblk->next == 0); in txEnd()
533 tblk->next = TxAnchor.freetid; in txEnd()
539 if (--log->active == 0) { in txEnd()
540 clear_bit(log_FLUSH, &log->flag); in txEnd()
545 if (test_bit(log_SYNCBARRIER, &log->flag)) { in txEnd()
549 jfs_syncpt(log, 1); in txEnd()
551 jfs_info("log barrier off: 0x%x", log->lsn); in txEnd()
554 clear_bit(log_SYNCBARRIER, &log->flag); in txEnd()
557 TXN_WAKEUP(&log->syncwait); in txEnd()
597 if (S_ISDIR(ip->i_mode) && (type & tlckXTREE) && in txLock()
598 !(mp->xflag & COMMIT_PAGE)) { in txLock()
603 dir_xtree = 1; in txLock()
604 lid = jfs_ip->xtlid; in txLock()
606 lid = mp->lid; in txLock()
616 if ((xtid = tlck->tid) == tid) { in txLock()
633 tlck->tid = tid; in txLock()
646 if (jfs_ip->atlhead == lid) { in txLock()
647 if (jfs_ip->atltail == lid) { in txLock()
652 list_del_init(&jfs_ip->anon_inode_list); in txLock()
655 jfs_ip->atlhead = tlck->next; in txLock()
658 for (last = jfs_ip->atlhead; in txLock()
659 lid_to_tlock(last)->next != lid; in txLock()
660 last = lid_to_tlock(last)->next) { in txLock()
663 lid_to_tlock(last)->next = tlck->next; in txLock()
664 if (jfs_ip->atltail == lid) in txLock()
665 jfs_ip->atltail = last; in txLock()
670 if (tblk->next) in txLock()
671 lid_to_tlock(tblk->last)->next = lid; in txLock()
673 tblk->next = lid; in txLock()
674 tlck->next = 0; in txLock()
675 tblk->last = lid; in txLock()
692 tlck->tid = tid; in txLock()
696 /* mark tlock for meta-data page */ in txLock()
697 if (mp->xflag & COMMIT_PAGE) { in txLock()
699 tlck->flag = tlckPAGELOCK; in txLock()
705 mp, mp->nohomeok, tid, tlck); in txLock()
712 if ((tid == 0) && mp->lsn) in txLock()
715 /* mark tlock for in-memory inode */ in txLock()
717 tlck->flag = tlckINODELOCK; in txLock()
719 if (S_ISDIR(ip->i_mode)) in txLock()
720 tlck->flag |= tlckDIRECTORY; in txLock()
722 tlck->type = 0; in txLock()
725 tlck->ip = ip; in txLock()
726 tlck->mp = mp; in txLock()
728 jfs_ip->xtlid = lid; in txLock()
730 mp->lid = lid; in txLock()
738 if (tblk->next) in txLock()
739 lid_to_tlock(tblk->last)->next = lid; in txLock()
741 tblk->next = lid; in txLock()
742 tlck->next = 0; in txLock()
743 tblk->last = lid; in txLock()
749 tlck->next = jfs_ip->atlhead; in txLock()
750 jfs_ip->atlhead = lid; in txLock()
751 if (tlck->next == 0) { in txLock()
753 jfs_ip->atltail = lid; in txLock()
755 list_add_tail(&jfs_ip->anon_inode_list, in txLock()
762 linelock = (struct linelock *) & tlck->lock; in txLock()
763 linelock->next = 0; in txLock()
764 linelock->flag = tlckLINELOCK; in txLock()
765 linelock->maxcnt = TLOCKSHORT; in txLock()
766 linelock->index = 0; in txLock()
770 linelock->l2linesize = L2DTSLOTSIZE; in txLock()
774 linelock->l2linesize = L2XTSLOTSIZE; in txLock()
777 xtlck->header.offset = 0; in txLock()
778 xtlck->header.length = 2; in txLock()
781 xtlck->lwm.offset = XTENTRYSTART; in txLock()
783 if (mp->xflag & COMMIT_PAGE) in txLock()
784 p = (xtpage_t *) mp->data; in txLock()
786 p = (xtpage_t *) &jfs_ip->i_xtroot; in txLock()
787 xtlck->lwm.offset = in txLock()
788 le16_to_cpu(p->header.nextindex); in txLock()
790 xtlck->lwm.length = 0; /* ! */ in txLock()
791 xtlck->twm.offset = 0; in txLock()
792 xtlck->hwm.offset = 0; in txLock()
794 xtlck->index = 2; in txLock()
798 linelock->l2linesize = L2INODESLOTSIZE; in txLock()
802 linelock->l2linesize = L2DATASLOTSIZE; in txLock()
813 tlck->type |= type; in txLock()
822 /* assert(jfs_ip->fileset == AGGREGATE_I); */ in txLock()
823 if (jfs_ip->fileset != AGGREGATE_I) { in txLock()
840 xtid = tlck->tid; /* reacquire after dropping TXN_LOCK */ in txLock()
846 if (xtid && (tlck->mp == mp) && (mp->lid == lid)) in txLock()
847 TXN_SLEEP_DROP_LOCK(&tid_to_tblock(xtid)->waitor); in txLock()
864 * tblk -
876 for (lid = tblk->next; lid; lid = tlck->next) { in txRelease()
878 if ((mp = tlck->mp) != NULL && in txRelease()
879 (tlck->type & tlckBTROOT) == 0) { in txRelease()
880 assert(mp->xflag & COMMIT_PAGE); in txRelease()
881 mp->lid = 0; in txRelease()
889 TXN_WAKEUP(&tblk->waitor); in txRelease()
911 log = JFS_SBI(tblk->sb)->log; in txUnlock()
916 for (lid = tblk->next; lid; lid = next) { in txUnlock()
918 next = tlck->next; in txUnlock()
923 if ((mp = tlck->mp) != NULL && in txUnlock()
924 (tlck->type & tlckBTROOT) == 0) { in txUnlock()
925 assert(mp->xflag & COMMIT_PAGE); in txUnlock()
931 assert(mp->nohomeok > 0); in txUnlock()
936 if (mp->clsn) { in txUnlock()
937 logdiff(difft, tblk->clsn, log); in txUnlock()
938 logdiff(diffp, mp->clsn, log); in txUnlock()
940 mp->clsn = tblk->clsn; in txUnlock()
942 mp->clsn = tblk->clsn; in txUnlock()
945 assert(!(tlck->flag & tlckFREEPAGE)); in txUnlock()
955 llid = ((struct linelock *) & tlck->lock)->next; in txUnlock()
958 k = linelock->next; in txUnlock()
966 tblk->next = tblk->last = 0; in txUnlock()
973 if (tblk->lsn) { in txUnlock()
975 log->count--; in txUnlock()
976 list_del(&tblk->synclist); in txUnlock()
1006 tlck->tid = tid; in txMaplock()
1009 tlck->flag = tlckINODELOCK; in txMaplock()
1010 if (S_ISDIR(ip->i_mode)) in txMaplock()
1011 tlck->flag |= tlckDIRECTORY; in txMaplock()
1012 tlck->ip = ip; in txMaplock()
1013 tlck->mp = NULL; in txMaplock()
1015 tlck->type = type; in txMaplock()
1023 if (tblk->next) in txMaplock()
1024 lid_to_tlock(tblk->last)->next = lid; in txMaplock()
1026 tblk->next = lid; in txMaplock()
1027 tlck->next = 0; in txMaplock()
1028 tblk->last = lid; in txMaplock()
1034 tlck->next = jfs_ip->atlhead; in txMaplock()
1035 jfs_ip->atlhead = lid; in txMaplock()
1036 if (tlck->next == 0) { in txMaplock()
1038 jfs_ip->atltail = lid; in txMaplock()
1039 list_add_tail(&jfs_ip->anon_inode_list, in txMaplock()
1047 maplock = (struct maplock *) & tlck->lock; in txMaplock()
1048 maplock->next = 0; in txMaplock()
1049 maplock->maxcnt = 0; in txMaplock()
1050 maplock->index = 0; in txMaplock()
1076 linelock->next = 0; in txLinelock()
1077 linelock->flag = tlckLINELOCK; in txLinelock()
1078 linelock->maxcnt = TLOCKLONG; in txLinelock()
1079 linelock->index = 0; in txLinelock()
1080 if (tlck->flag & tlckDIRECTORY) in txLinelock()
1081 linelock->flag |= tlckDIRECTORY; in txLinelock()
1084 linelock->next = tlock->next; in txLinelock()
1085 tlock->next = lid; in txLinelock()
1092 * -----------------------------
1101 * for non-journalled segments the data are flushed to
1144 /* is read-only file system ? */ in txCommit()
1146 rc = -EROFS; in txCommit()
1150 sb = cd.sb = iplist[0]->i_sb; in txCommit()
1160 log = JFS_SBI(sb)->log; in txCommit()
1165 lrd->logtid = cpu_to_le32(tblk->logtid); in txCommit()
1166 lrd->backchain = 0; in txCommit()
1168 tblk->xflag |= flag; in txCommit()
1171 tblk->xflag |= COMMIT_LAZY; in txCommit()
1173 * prepare non-journaled objects for commit in txCommit()
1175 * flush data pages of non-journaled file in txCommit()
1176 * to prevent the file getting non-initialized disk blocks in txCommit()
1178 * (new blocks - ) in txCommit()
1184 * acquire transaction lock on (on-disk) inodes in txCommit()
1186 * update on-disk inode from in-memory inode in txCommit()
1188 * on the on-disk inode of file object in txCommit()
1192 * of on-disk inodes on multiple on-disk inode pages by in txCommit()
1196 top = (cd.iplist[k])->i_ino; in txCommit()
1197 for (n = k + 1; n < cd.nip; n++) { in txCommit()
1199 if (ip->i_ino > top) { in txCommit()
1200 top = ip->i_ino; in txCommit()
1210 * BUGBUG - This code has temporarily been removed. The in txCommit()
1227 * if ((!S_ISDIR(ip->i_mode)) in txCommit()
1228 * && (tblk->flag & COMMIT_DELETE) == 0) in txCommit()
1229 * filemap_write_and_wait(ip->i_mapping); in txCommit()
1240 if (jfs_ip->atlhead) { in txCommit()
1241 lid_to_tlock(jfs_ip->atltail)->next = tblk->next; in txCommit()
1242 tblk->next = jfs_ip->atlhead; in txCommit()
1243 if (!tblk->last) in txCommit()
1244 tblk->last = jfs_ip->atltail; in txCommit()
1245 jfs_ip->atlhead = jfs_ip->atltail = 0; in txCommit()
1247 list_del_init(&jfs_ip->anon_inode_list); in txCommit()
1252 * acquire transaction lock on on-disk inode page in txCommit()
1270 if (tblk->xflag & COMMIT_DELETE) { in txCommit()
1271 ihold(tblk->u.ip); in txCommit()
1289 if (tblk->u.ip->i_state & I_SYNC) in txCommit()
1290 tblk->xflag &= ~COMMIT_LAZY; in txCommit()
1293 ASSERT((!(tblk->xflag & COMMIT_DELETE)) || in txCommit()
1294 ((tblk->u.ip->i_nlink == 0) && in txCommit()
1295 !test_cflag(COMMIT_Nolink, tblk->u.ip))); in txCommit()
1300 lrd->type = cpu_to_le16(LOG_COMMIT); in txCommit()
1301 lrd->length = 0; in txCommit()
1307 * - transaction is now committed - in txCommit()
1326 if (tblk->xflag & COMMIT_FORCE) in txCommit()
1334 if ((tblk->flag & tblkGC_LAZY) == 0) in txCommit()
1339 * reset in-memory object state in txCommit()
1346 * reset in-memory inode state in txCommit()
1348 jfs_ip->bxflag = 0; in txCommit()
1349 jfs_ip->blid = 0; in txCommit()
1354 txAbort(tid, 1); in txCommit()
1377 struct lrd *lrd = &cd->lrd; in txLog()
1382 for (lid = tblk->next; lid; lid = tlck->next) { in txLog()
1385 tlck->flag |= tlckLOG; in txLog()
1388 ip = tlck->ip; in txLog()
1389 lrd->aggregate = cpu_to_le32(JFS_SBI(ip->i_sb)->aggregate); in txLog()
1390 lrd->log.redopage.fileset = cpu_to_le32(JFS_IP(ip)->fileset); in txLog()
1391 lrd->log.redopage.inode = cpu_to_le32(ip->i_ino); in txLog()
1394 switch (tlck->type & tlckTYPE) { in txLog()
1435 mp = tlck->mp; in diLog()
1438 lrd->log.redopage.type = cpu_to_le16(LOG_INODE); in diLog()
1439 lrd->log.redopage.l2linesize = cpu_to_le16(L2INODESLOTSIZE); in diLog()
1441 pxd = &lrd->log.redopage.pxd; in diLog()
1446 if (tlck->type & tlckENTRY) { in diLog()
1447 /* log after-image for logredo(): */ in diLog()
1448 lrd->type = cpu_to_le16(LOG_REDOPAGE); in diLog()
1449 PXDaddress(pxd, mp->index); in diLog()
1451 mp->logical_size >> tblk->sb->s_blocksize_bits); in diLog()
1452 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in diLog()
1455 tlck->flag |= tlckWRITEPAGE; in diLog()
1456 } else if (tlck->type & tlckFREE) { in diLog()
1474 lrd->type = cpu_to_le16(LOG_NOREDOINOEXT); in diLog()
1480 * passed to us in the iplist[1] and iplist[2]. in diLog()
1482 lrd->log.noredoinoext.iagnum = in diLog()
1483 cpu_to_le32((u32) (size_t) cd->iplist[1]); in diLog()
1484 lrd->log.noredoinoext.inoext_idx = in diLog()
1485 cpu_to_le32((u32) (size_t) cd->iplist[2]); in diLog()
1487 pxdlock = (struct pxd_lock *) & tlck->lock; in diLog()
1488 *pxd = pxdlock->pxd; in diLog()
1489 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in diLog()
1492 tlck->flag |= tlckUPDATEMAP; in diLog()
1495 tlck->flag |= tlckWRITEPAGE; in diLog()
1512 mp = tlck->mp; in dataLog()
1515 lrd->log.redopage.type = cpu_to_le16(LOG_DATA); in dataLog()
1516 lrd->log.redopage.l2linesize = cpu_to_le16(L2DATASLOTSIZE); in dataLog()
1518 pxd = &lrd->log.redopage.pxd; in dataLog()
1520 /* log after-image for logredo(): */ in dataLog()
1521 lrd->type = cpu_to_le16(LOG_REDOPAGE); in dataLog()
1523 if (jfs_dirtable_inline(tlck->ip)) { in dataLog()
1528 mp->lid = 0; in dataLog()
1532 tlck->mp = NULL; in dataLog()
1536 PXDaddress(pxd, mp->index); in dataLog()
1537 PXDlength(pxd, mp->logical_size >> tblk->sb->s_blocksize_bits); in dataLog()
1539 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in dataLog()
1542 tlck->flag |= tlckWRITEPAGE; in dataLog()
1559 mp = tlck->mp; in dtLog()
1562 lrd->log.redopage.type = cpu_to_le16(LOG_DTREE); in dtLog()
1563 lrd->log.redopage.l2linesize = cpu_to_le16(L2DTSLOTSIZE); in dtLog()
1565 pxd = &lrd->log.redopage.pxd; in dtLog()
1567 if (tlck->type & tlckBTROOT) in dtLog()
1568 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); in dtLog()
1572 * page extension in-place: entry insertion; in dtLog()
1573 * new right page from page split, reinitialized in-line in dtLog()
1576 if (tlck->type & (tlckNEW | tlckEXTEND)) { in dtLog()
1577 /* log after-image of the new page for logredo(): in dtLog()
1581 lrd->type = cpu_to_le16(LOG_REDOPAGE); in dtLog()
1582 if (tlck->type & tlckEXTEND) in dtLog()
1583 lrd->log.redopage.type |= cpu_to_le16(LOG_EXTEND); in dtLog()
1585 lrd->log.redopage.type |= cpu_to_le16(LOG_NEW); in dtLog()
1586 PXDaddress(pxd, mp->index); in dtLog()
1588 mp->logical_size >> tblk->sb->s_blocksize_bits); in dtLog()
1589 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in dtLog()
1594 if (tlck->type & tlckBTROOT) in dtLog()
1596 tlck->flag |= tlckUPDATEMAP; in dtLog()
1597 pxdlock = (struct pxd_lock *) & tlck->lock; in dtLog()
1598 pxdlock->flag = mlckALLOCPXD; in dtLog()
1599 pxdlock->pxd = *pxd; in dtLog()
1601 pxdlock->index = 1; in dtLog()
1604 tlck->flag |= tlckWRITEPAGE; in dtLog()
1612 if (tlck->type & (tlckENTRY | tlckRELINK)) { in dtLog()
1613 /* log after-image for logredo(): */ in dtLog()
1614 lrd->type = cpu_to_le16(LOG_REDOPAGE); in dtLog()
1615 PXDaddress(pxd, mp->index); in dtLog()
1617 mp->logical_size >> tblk->sb->s_blocksize_bits); in dtLog()
1618 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in dtLog()
1621 tlck->flag |= tlckWRITEPAGE; in dtLog()
1632 if (tlck->type & (tlckFREE | tlckRELOCATE)) { in dtLog()
1637 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); in dtLog()
1638 pxdlock = (struct pxd_lock *) & tlck->lock; in dtLog()
1639 *pxd = pxdlock->pxd; in dtLog()
1640 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in dtLog()
1645 tlck->flag |= tlckUPDATEMAP; in dtLog()
1668 ip = tlck->ip; in xtLog()
1669 mp = tlck->mp; in xtLog()
1672 lrd->log.redopage.type = cpu_to_le16(LOG_XTREE); in xtLog()
1673 lrd->log.redopage.l2linesize = cpu_to_le16(L2XTSLOTSIZE); in xtLog()
1675 page_pxd = &lrd->log.redopage.pxd; in xtLog()
1677 if (tlck->type & tlckBTROOT) { in xtLog()
1678 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); in xtLog()
1679 p = (xtpage_t *) &JFS_IP(ip)->i_xtroot; in xtLog()
1680 if (S_ISDIR(ip->i_mode)) in xtLog()
1681 lrd->log.redopage.type |= in xtLog()
1684 p = (xtpage_t *) mp->data; in xtLog()
1685 next = le16_to_cpu(p->header.nextindex); in xtLog()
1687 xtlck = (struct xtlock *) & tlck->lock; in xtLog()
1689 maplock = (struct maplock *) & tlck->lock; in xtLog()
1696 if (tlck->type & (tlckNEW | tlckGROW | tlckRELINK)) { in xtLog()
1697 /* log after-image for logredo(): in xtLog()
1700 * after-image of XADlist; in xtLog()
1702 * applying the after-image to the meta-data page. in xtLog()
1704 lrd->type = cpu_to_le16(LOG_REDOPAGE); in xtLog()
1705 PXDaddress(page_pxd, mp->index); in xtLog()
1707 mp->logical_size >> tblk->sb->s_blocksize_bits); in xtLog()
1708 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in xtLog()
1715 lwm = xtlck->lwm.offset; in xtLog()
1725 tlck->flag |= tlckUPDATEMAP; in xtLog()
1726 xadlock->flag = mlckALLOCXADLIST; in xtLog()
1727 xadlock->count = next - lwm; in xtLog()
1728 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) { in xtLog()
1738 xadlock->flag = mlckALLOCPXDLIST; in xtLog()
1739 pxd = xadlock->xdlist = &xtlck->pxdlock; in xtLog()
1740 for (i = 0; i < xadlock->count; i++) { in xtLog()
1741 PXDaddress(pxd, addressXAD(&p->xad[lwm + i])); in xtLog()
1742 PXDlength(pxd, lengthXAD(&p->xad[lwm + i])); in xtLog()
1743 p->xad[lwm + i].flag &= in xtLog()
1752 xadlock->flag = mlckALLOCXADLIST; in xtLog()
1753 xadlock->xdlist = &p->xad[lwm]; in xtLog()
1754 tblk->xflag &= ~COMMIT_LAZY; in xtLog()
1757 tlck->ip, mp, tlck, lwm, xadlock->count); in xtLog()
1759 maplock->index = 1; in xtLog()
1763 tlck->flag |= tlckWRITEPAGE; in xtLog()
1774 if (tlck->type & tlckFREE) { in xtLog()
1791 if (tblk->xflag & COMMIT_TRUNCATE) { in xtLog()
1793 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); in xtLog()
1794 PXDaddress(page_pxd, mp->index); in xtLog()
1796 mp->logical_size >> tblk->sb-> in xtLog()
1798 lrd->backchain = in xtLog()
1801 if (tlck->type & tlckBTROOT) { in xtLog()
1803 lrd->type = cpu_to_le16(LOG_REDOPAGE); in xtLog()
1804 lrd->backchain = in xtLog()
1813 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in xtLog()
1814 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEXADLIST); in xtLog()
1815 xtlck = (struct xtlock *) & tlck->lock; in xtLog()
1816 hwm = xtlck->hwm.offset; in xtLog()
1817 lrd->log.updatemap.nxd = in xtLog()
1818 cpu_to_le16(hwm - XTENTRYSTART + 1); in xtLog()
1820 xtlck->header.offset = XTENTRYSTART; in xtLog()
1821 xtlck->header.length = hwm - XTENTRYSTART + 1; in xtLog()
1822 xtlck->index = 1; in xtLog()
1823 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in xtLog()
1829 tlck->flag |= tlckUPDATEMAP; in xtLog()
1830 xadlock->count = hwm - XTENTRYSTART + 1; in xtLog()
1831 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) { in xtLog()
1841 xadlock->flag = mlckFREEPXDLIST; in xtLog()
1842 pxd = xadlock->xdlist = &xtlck->pxdlock; in xtLog()
1843 for (i = 0; i < xadlock->count; i++) { in xtLog()
1845 addressXAD(&p->xad[XTENTRYSTART + i])); in xtLog()
1847 lengthXAD(&p->xad[XTENTRYSTART + i])); in xtLog()
1855 xadlock->flag = mlckFREEXADLIST; in xtLog()
1856 xadlock->xdlist = &p->xad[XTENTRYSTART]; in xtLog()
1857 tblk->xflag &= ~COMMIT_LAZY; in xtLog()
1860 tlck->ip, mp, xadlock->count); in xtLog()
1862 maplock->index = 1; in xtLog()
1865 if (((tblk->xflag & COMMIT_PWMAP) || S_ISDIR(ip->i_mode)) in xtLog()
1866 && !(tlck->type & tlckBTROOT)) in xtLog()
1867 tlck->flag |= tlckFREEPAGE; in xtLog()
1869 else (tblk->xflag & COMMIT_PMAP) in xtLog()
1878 * |----------+------+------+---------------| in xtLog()
1880 * | | hwm - hwm before truncation in xtLog()
1881 * | next - truncation point in xtLog()
1882 * lwm - lwm before truncation in xtLog()
1885 if (tlck->type & tlckTRUNCATE) { in xtLog()
1896 tblk->xflag &= ~COMMIT_LAZY; in xtLog()
1897 lwm = xtlck->lwm.offset; in xtLog()
1900 hwm = xtlck->hwm.offset; in xtLog()
1901 twm = xtlck->twm.offset; in xtLog()
1906 /* log after-image for logredo(): in xtLog()
1910 * after-image of XADlist; in xtLog()
1912 * applying the after-image to the meta-data page. in xtLog()
1914 lrd->type = cpu_to_le16(LOG_REDOPAGE); in xtLog()
1915 PXDaddress(page_pxd, mp->index); in xtLog()
1917 mp->logical_size >> tblk->sb->s_blocksize_bits); in xtLog()
1918 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in xtLog()
1921 * truncate entry XAD[twm == next - 1]: in xtLog()
1923 if (twm == next - 1) { in xtLog()
1926 * entry XAD[next - 1]: in xtLog()
1927 * (xtlck->pxdlock = truncated delta extent); in xtLog()
1929 pxdlock = (struct pxd_lock *) & xtlck->pxdlock; in xtLog()
1930 /* assert(pxdlock->type & tlckTRUNCATE); */ in xtLog()
1931 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in xtLog()
1932 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD); in xtLog()
1933 lrd->log.updatemap.nxd = cpu_to_le16(1); in xtLog()
1934 lrd->log.updatemap.pxd = pxdlock->pxd; in xtLog()
1935 pxd = pxdlock->pxd; /* save to format maplock */ in xtLog()
1936 lrd->backchain = in xtLog()
1948 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in xtLog()
1949 lrd->log.updatemap.type = in xtLog()
1951 xtlck = (struct xtlock *) & tlck->lock; in xtLog()
1952 hwm = xtlck->hwm.offset; in xtLog()
1953 lrd->log.updatemap.nxd = in xtLog()
1954 cpu_to_le16(hwm - next + 1); in xtLog()
1956 xtlck->header.offset = next; in xtLog()
1957 xtlck->header.length = hwm - next + 1; in xtLog()
1958 xtlck->index = 1; in xtLog()
1959 lrd->backchain = in xtLog()
1966 maplock->index = 0; in xtLog()
1977 tlck->flag |= tlckUPDATEMAP; in xtLog()
1978 xadlock->flag = mlckALLOCXADLIST; in xtLog()
1979 xadlock->count = next - lwm; in xtLog()
1980 xadlock->xdlist = &p->xad[lwm]; in xtLog()
1983 tlck->ip, mp, xadlock->count, lwm, next); in xtLog()
1984 maplock->index++; in xtLog()
1989 * truncate entry XAD[twm == next - 1]: in xtLog()
1991 if (twm == next - 1) { in xtLog()
1994 * entry XAD[next - 1]; in xtLog()
1995 * (xtlck->pxdlock = truncated delta extent); in xtLog()
1997 tlck->flag |= tlckUPDATEMAP; in xtLog()
1999 pxdlock->flag = mlckFREEPXD; in xtLog()
2000 pxdlock->count = 1; in xtLog()
2001 pxdlock->pxd = pxd; in xtLog()
2004 ip, mp, pxdlock->count, hwm); in xtLog()
2005 maplock->index++; in xtLog()
2017 tlck->flag |= tlckUPDATEMAP; in xtLog()
2018 xadlock->flag = mlckFREEXADLIST; in xtLog()
2019 xadlock->count = hwm - next + 1; in xtLog()
2020 xadlock->xdlist = &p->xad[next]; in xtLog()
2023 tlck->ip, mp, xadlock->count, next, hwm); in xtLog()
2024 maplock->index++; in xtLog()
2028 tlck->flag |= tlckWRITEPAGE; in xtLog()
2052 if (tlck->type & tlckRELOCATE) { in mapLog()
2056 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); in mapLog()
2057 pxdlock = (struct pxd_lock *) & tlck->lock; in mapLog()
2058 pxd = &lrd->log.redopage.pxd; in mapLog()
2059 *pxd = pxdlock->pxd; in mapLog()
2060 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in mapLog()
2072 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in mapLog()
2073 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD); in mapLog()
2074 lrd->log.updatemap.nxd = cpu_to_le16(1); in mapLog()
2075 lrd->log.updatemap.pxd = pxdlock->pxd; in mapLog()
2076 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in mapLog()
2081 tlck->flag |= tlckUPDATEMAP; in mapLog()
2095 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in mapLog()
2096 pxdlock = (struct pxd_lock *) & tlck->lock; in mapLog()
2097 nlock = pxdlock->index; in mapLog()
2099 if (pxdlock->flag & mlckALLOCPXD) in mapLog()
2100 lrd->log.updatemap.type = in mapLog()
2103 lrd->log.updatemap.type = in mapLog()
2105 lrd->log.updatemap.nxd = cpu_to_le16(1); in mapLog()
2106 lrd->log.updatemap.pxd = pxdlock->pxd; in mapLog()
2107 lrd->backchain = in mapLog()
2109 jfs_info("mapLog: xaddr:0x%lx xlen:0x%x", in mapLog()
2110 (ulong) addressPXD(&pxdlock->pxd), in mapLog()
2111 lengthPXD(&pxdlock->pxd)); in mapLog()
2115 tlck->flag |= tlckUPDATEMAP; in mapLog()
2138 if (newea->flag & DXD_EXTENT) { in txEA()
2140 maplock = (struct pxd_lock *) & tlck->lock; in txEA()
2142 pxdlock->flag = mlckALLOCPXD; in txEA()
2143 PXDaddress(&pxdlock->pxd, addressDXD(newea)); in txEA()
2144 PXDlength(&pxdlock->pxd, lengthDXD(newea)); in txEA()
2146 maplock->index = 1; in txEA()
2147 } else if (newea->flag & DXD_INLINE) { in txEA()
2157 if (!test_cflag(COMMIT_Nolink, ip) && oldea->flag & DXD_EXTENT) { in txEA()
2160 maplock = (struct pxd_lock *) & tlck->lock; in txEA()
2162 maplock->index = 0; in txEA()
2164 pxdlock->flag = mlckFREEPXD; in txEA()
2165 PXDaddress(&pxdlock->pxd, addressDXD(oldea)); in txEA()
2166 PXDlength(&pxdlock->pxd, lengthDXD(oldea)); in txEA()
2167 maplock->index++; in txEA()
2188 tlck = lid_to_tlock(tblk->next); in txForce()
2189 lid = tlck->next; in txForce()
2190 tlck->next = 0; in txForce()
2193 next = tlck->next; in txForce()
2194 tlck->next = tblk->next; in txForce()
2195 tblk->next = lid; in txForce()
2203 for (lid = tblk->next; lid; lid = next) { in txForce()
2205 next = tlck->next; in txForce()
2207 if ((mp = tlck->mp) != NULL && in txForce()
2208 (tlck->type & tlckBTROOT) == 0) { in txForce()
2209 assert(mp->xflag & COMMIT_PAGE); in txForce()
2211 if (tlck->flag & tlckWRITEPAGE) { in txForce()
2212 tlck->flag &= ~tlckWRITEPAGE; in txForce()
2228 assert(mp->nohomeok); in txForce()
2229 set_bit(META_dirty, &mp->flag); in txForce()
2230 set_bit(META_sync, &mp->flag); in txForce()
2257 ipimap = JFS_SBI(tblk->sb)->ipimap; in txUpdateMap()
2259 maptype = (tblk->xflag & COMMIT_PMAP) ? COMMIT_PMAP : COMMIT_PWMAP; in txUpdateMap()
2274 for (lid = tblk->next; lid; lid = tlck->next) { in txUpdateMap()
2277 if ((tlck->flag & tlckUPDATEMAP) == 0) in txUpdateMap()
2280 if (tlck->flag & tlckFREEPAGE) { in txUpdateMap()
2288 mp = tlck->mp; in txUpdateMap()
2289 ASSERT(mp->xflag & COMMIT_PAGE); in txUpdateMap()
2295 * . in-line PXD list: in txUpdateMap()
2296 * . out-of-line XAD list: in txUpdateMap()
2298 maplock = (struct maplock *) & tlck->lock; in txUpdateMap()
2299 nlock = maplock->index; in txUpdateMap()
2307 if (maplock->flag & mlckALLOC) { in txUpdateMap()
2324 else { /* (maplock->flag & mlckFREE) */ in txUpdateMap()
2326 if (tlck->flag & tlckDIRECTORY) in txUpdateMap()
2334 if (tlck->flag & tlckFREEPAGE) { in txUpdateMap()
2335 if (!(tblk->flag & tblkGC_LAZY)) { in txUpdateMap()
2337 ASSERT(mp->lid == lid); in txUpdateMap()
2338 tlck->mp->lid = 0; in txUpdateMap()
2340 assert(mp->nohomeok == 1); in txUpdateMap()
2343 tlck->mp = NULL; in txUpdateMap()
2351 * update in-memory inode flag/state in txUpdateMap()
2355 if (tblk->xflag & COMMIT_CREATE) { in txUpdateMap()
2356 diUpdatePMap(ipimap, tblk->ino, false, tblk); in txUpdateMap()
2361 pxdlock.pxd = tblk->u.ixpxd; in txUpdateMap()
2362 pxdlock.index = 1; in txUpdateMap()
2364 } else if (tblk->xflag & COMMIT_DELETE) { in txUpdateMap()
2365 ip = tblk->u.ip; in txUpdateMap()
2366 diUpdatePMap(ipimap, ip->i_ino, true, tblk); in txUpdateMap()
2377 * ipbmap -
2378 * malock -
2382 * maptype -
2385 * (e.g., tmp file - free from working map at releae
2389 * lsn - log sequence number;
2394 struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap; in txAllocPMap()
2398 int xlen; in txAllocPMap() local
2407 if (maplock->flag & mlckALLOCXADLIST) { in txAllocPMap()
2409 xad = xadlistlock->xdlist; in txAllocPMap()
2410 for (n = 0; n < xadlistlock->count; n++, xad++) { in txAllocPMap()
2411 if (xad->flag & (XAD_NEW | XAD_EXTENDED)) { in txAllocPMap()
2413 xlen = lengthXAD(xad); in txAllocPMap()
2415 (s64) xlen, tblk); in txAllocPMap()
2416 xad->flag &= ~(XAD_NEW | XAD_EXTENDED); in txAllocPMap()
2417 jfs_info("allocPMap: xaddr:0x%lx xlen:%d", in txAllocPMap()
2418 (ulong) xaddr, xlen); in txAllocPMap()
2421 } else if (maplock->flag & mlckALLOCPXD) { in txAllocPMap()
2423 xaddr = addressPXD(&pxdlock->pxd); in txAllocPMap()
2424 xlen = lengthPXD(&pxdlock->pxd); in txAllocPMap()
2425 dbUpdatePMap(ipbmap, false, xaddr, (s64) xlen, tblk); in txAllocPMap()
2426 jfs_info("allocPMap: xaddr:0x%lx xlen:%d", (ulong) xaddr, xlen); in txAllocPMap()
2427 } else { /* (maplock->flag & mlckALLOCPXDLIST) */ in txAllocPMap()
2430 pxd = pxdlistlock->xdlist; in txAllocPMap()
2431 for (n = 0; n < pxdlistlock->count; n++, pxd++) { in txAllocPMap()
2433 xlen = lengthPXD(pxd); in txAllocPMap()
2434 dbUpdatePMap(ipbmap, false, xaddr, (s64) xlen, in txAllocPMap()
2436 jfs_info("allocPMap: xaddr:0x%lx xlen:%d", in txAllocPMap()
2437 (ulong) xaddr, xlen); in txAllocPMap()
2452 struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap; in txFreeMap()
2456 int xlen; in txFreeMap() local
2469 if (maplock->flag & mlckFREEXADLIST) { in txFreeMap()
2471 xad = xadlistlock->xdlist; in txFreeMap()
2472 for (n = 0; n < xadlistlock->count; n++, xad++) { in txFreeMap()
2473 if (!(xad->flag & XAD_NEW)) { in txFreeMap()
2475 xlen = lengthXAD(xad); in txFreeMap()
2477 (s64) xlen, tblk); in txFreeMap()
2478 jfs_info("freePMap: xaddr:0x%lx xlen:%d", in txFreeMap()
2479 (ulong) xaddr, xlen); in txFreeMap()
2482 } else if (maplock->flag & mlckFREEPXD) { in txFreeMap()
2484 xaddr = addressPXD(&pxdlock->pxd); in txFreeMap()
2485 xlen = lengthPXD(&pxdlock->pxd); in txFreeMap()
2486 dbUpdatePMap(ipbmap, true, xaddr, (s64) xlen, in txFreeMap()
2488 jfs_info("freePMap: xaddr:0x%lx xlen:%d", in txFreeMap()
2489 (ulong) xaddr, xlen); in txFreeMap()
2490 } else { /* (maplock->flag & mlckALLOCPXDLIST) */ in txFreeMap()
2493 pxd = pxdlistlock->xdlist; in txFreeMap()
2494 for (n = 0; n < pxdlistlock->count; n++, pxd++) { in txFreeMap()
2496 xlen = lengthPXD(pxd); in txFreeMap()
2498 (s64) xlen, tblk); in txFreeMap()
2499 jfs_info("freePMap: xaddr:0x%lx xlen:%d", in txFreeMap()
2500 (ulong) xaddr, xlen); in txFreeMap()
2509 if (maplock->flag & mlckFREEXADLIST) { in txFreeMap()
2511 xad = xadlistlock->xdlist; in txFreeMap()
2512 for (n = 0; n < xadlistlock->count; n++, xad++) { in txFreeMap()
2514 xlen = lengthXAD(xad); in txFreeMap()
2515 dbFree(ip, xaddr, (s64) xlen); in txFreeMap()
2516 xad->flag = 0; in txFreeMap()
2517 jfs_info("freeWMap: xaddr:0x%lx xlen:%d", in txFreeMap()
2518 (ulong) xaddr, xlen); in txFreeMap()
2520 } else if (maplock->flag & mlckFREEPXD) { in txFreeMap()
2522 xaddr = addressPXD(&pxdlock->pxd); in txFreeMap()
2523 xlen = lengthPXD(&pxdlock->pxd); in txFreeMap()
2524 dbFree(ip, xaddr, (s64) xlen); in txFreeMap()
2525 jfs_info("freeWMap: xaddr:0x%lx xlen:%d", in txFreeMap()
2526 (ulong) xaddr, xlen); in txFreeMap()
2527 } else { /* (maplock->flag & mlckFREEPXDLIST) */ in txFreeMap()
2530 pxd = pxdlistlock->xdlist; in txFreeMap()
2531 for (n = 0; n < pxdlistlock->count; n++, pxd++) { in txFreeMap()
2533 xlen = lengthPXD(pxd); in txFreeMap()
2534 dbFree(ip, xaddr, (s64) xlen); in txFreeMap()
2535 jfs_info("freeWMap: xaddr:0x%lx xlen:%d", in txFreeMap()
2536 (ulong) xaddr, xlen); in txFreeMap()
2553 if (!jfs_ip->atlhead) in txFreelock()
2557 xtlck = (struct tlock *) &jfs_ip->atlhead; in txFreelock()
2559 while ((lid = xtlck->next) != 0) { in txFreelock()
2561 if (tlck->flag & tlckFREELOCK) { in txFreelock()
2562 xtlck->next = tlck->next; in txFreelock()
2570 if (jfs_ip->atlhead) in txFreelock()
2571 jfs_ip->atltail = xlid; in txFreelock()
2573 jfs_ip->atltail = 0; in txFreelock()
2577 list_del_init(&jfs_ip->anon_inode_list); in txFreelock()
2587 * frees line-locks and segment locks for all
2589 * Optionally sets state of file-system to FM_DIRTY in super-block.
2590 * log age of page-frames in memory for which caller has
2603 for (lid = tblk->next; lid; lid = next) { in txAbort()
2605 next = tlck->next; in txAbort()
2606 mp = tlck->mp; in txAbort()
2607 JFS_IP(tlck->ip)->xtlid = 0; in txAbort()
2610 mp->lid = 0; in txAbort()
2620 if (mp->xflag & COMMIT_PAGE && mp->lsn) in txAbort()
2631 tblk->next = tblk->last = 0; in txAbort()
2637 jfs_error(tblk->sb, "\n"); in txAbort()
2654 while (((tblk->flag & tblkGC_READY) == 0) && in txLazyCommit()
2655 ((tblk->flag & tblkGC_UNLOCKED) == 0)) { in txLazyCommit()
2666 log = (struct jfs_log *) JFS_SBI(tblk->sb)->log; in txLazyCommit()
2668 spin_lock_irq(&log->gclock); // LOGGC_LOCK in txLazyCommit()
2670 tblk->flag |= tblkGC_COMMITTED; in txLazyCommit()
2672 if (tblk->flag & tblkGC_READY) in txLazyCommit()
2673 log->gcrtc--; in txLazyCommit()
2675 wake_up_all(&tblk->gcwait); // LOGGC_WAKEUP in txLazyCommit()
2678 * Can't release log->gclock until we've tested tblk->flag in txLazyCommit()
2680 if (tblk->flag & tblkGC_LAZY) { in txLazyCommit()
2681 spin_unlock_irq(&log->gclock); // LOGGC_UNLOCK in txLazyCommit()
2683 tblk->flag &= ~tblkGC_LAZY; in txLazyCommit()
2684 txEnd(tblk - TxBlock); /* Convert back to tid */ in txLazyCommit()
2686 spin_unlock_irq(&log->gclock); // LOGGC_UNLOCK in txLazyCommit()
2714 sbi = JFS_SBI(tblk->sb); in jfs_lazycommit()
2721 if (sbi->commit_state & IN_LAZYCOMMIT) in jfs_lazycommit()
2724 sbi->commit_state |= IN_LAZYCOMMIT; in jfs_lazycommit()
2725 WorkDone = 1; in jfs_lazycommit()
2730 list_del(&tblk->cqueue); in jfs_lazycommit()
2736 sbi->commit_state &= ~IN_LAZYCOMMIT; in jfs_lazycommit()
2779 list_add_tail(&tblk->cqueue, &TxAnchor.unlock_queue); in txLazyUnlock()
2784 if (!(JFS_SBI(tblk->sb)->commit_state & IN_LAZYCOMMIT) && in txLazyUnlock()
2786 jfs_commit_thread_waking = 1; in txLazyUnlock()
2794 struct jfs_log *log = mp->log; in LogSyncRelease()
2796 assert(mp->nohomeok); in LogSyncRelease()
2815 struct jfs_log *log = JFS_SBI(sb)->log; in txQuiesce()
2818 set_bit(log_QUIESCE, &log->flag); in txQuiesce()
2826 ip = &jfs_ip->vfs_inode; in txQuiesce()
2833 tid = txBegin(ip->i_sb, COMMIT_INODE | COMMIT_FORCE); in txQuiesce()
2834 mutex_lock(&jfs_ip->commit_mutex); in txQuiesce()
2835 txCommit(tid, 1, &ip, 0); in txQuiesce()
2837 mutex_unlock(&jfs_ip->commit_mutex); in txQuiesce()
2869 struct jfs_log *log = JFS_SBI(sb)->log; in txResume()
2871 clear_bit(log_QUIESCE, &log->flag); in txResume()
2872 TXN_WAKEUP(&log->syncwait); in txResume()
2898 ip = &jfs_ip->vfs_inode; in jfs_sync()
2904 list_del_init(&jfs_ip->anon_inode_list); in jfs_sync()
2905 } else if (mutex_trylock(&jfs_ip->commit_mutex)) { in jfs_sync()
2911 tid = txBegin(ip->i_sb, COMMIT_INODE); in jfs_sync()
2912 txCommit(tid, 1, &ip, 0); in jfs_sync()
2914 mutex_unlock(&jfs_ip->commit_mutex); in jfs_sync()
2931 list_move(&jfs_ip->anon_inode_list, in jfs_sync()