Lines Matching +full:segment +full:- +full:no +full:- +full:remap

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 * ---------------------------------
207 TxAnchor.tlocksInUse--; in txLockFree()
209 jfs_info("txLockFree jfs_tlocks_low no more"); in txLockFree()
232 if (nTxLock == -1) { in txInit()
233 if (nTxBlock == -1) { in txInit()
245 if (nTxBlock == -1) in txInit()
250 nTxBlock = 16; /* No one should set it this low */ in txInit()
254 nTxLock = 256; /* No one should set it this low */ in txInit()
273 return -ENOMEM; in txInit()
275 for (k = 1; k < nTxBlock - 1; k++) { in txInit()
299 return -ENOMEM; in txInit()
303 for (k = 1; k < nTxLock - 1; k++) 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()
366 if (test_bit(log_SYNCBARRIER, &log->flag) || in txBegin()
367 test_bit(log_QUIESCE, &log->flag)) { in txBegin()
369 TXN_SLEEP(&log->syncwait); in txBegin()
398 if ((tblk->next == 0) && !(flag & COMMIT_FORCE)) { in txBegin()
399 /* Don't let a non-forced transaction take the last tblk */ in txBegin()
406 TxAnchor.freetid = tblk->next; in txBegin()
414 * awakened after sleeping on tblk->waitor in txBegin()
418 tblk->next = tblk->last = tblk->xflag = tblk->flag = tblk->lsn = 0; in txBegin()
420 tblk->sb = sb; in txBegin()
421 ++log->logtid; in txBegin()
422 tblk->logtid = log->logtid; in txBegin()
424 ++log->active; in txBegin()
443 * PARAMETER: sb - superblock
451 log = JFS_SBI(sb)->log; in txBeginAnon()
460 if (test_bit(log_SYNCBARRIER, &log->flag) || in txBeginAnon()
461 test_bit(log_QUIESCE, &log->flag)) { in txBeginAnon()
463 TXN_SLEEP(&log->syncwait); in txBeginAnon()
499 TXN_WAKEUP(&tblk->waitor); in txEnd()
501 log = JFS_SBI(tblk->sb)->log; in txEnd()
511 if (tblk->flag & tblkGC_LAZY) { in txEnd()
515 spin_lock_irq(&log->gclock); // LOGGC_LOCK in txEnd()
516 tblk->flag |= tblkGC_UNLOCKED; in txEnd()
517 spin_unlock_irq(&log->gclock); // LOGGC_UNLOCK in txEnd()
523 assert(tblk->next == 0); in txEnd()
528 tblk->next = TxAnchor.freetid; in txEnd()
534 if (--log->active == 0) { in txEnd()
535 clear_bit(log_FLUSH, &log->flag); in txEnd()
540 if (test_bit(log_SYNCBARRIER, &log->flag)) { in txEnd()
546 jfs_info("log barrier off: 0x%x", log->lsn); in txEnd()
549 clear_bit(log_SYNCBARRIER, &log->flag); in txEnd()
552 TXN_WAKEUP(&log->syncwait); in txEnd()
592 if (S_ISDIR(ip->i_mode) && (type & tlckXTREE) && in txLock()
593 !(mp->xflag & COMMIT_PAGE)) { in txLock()
599 lid = jfs_ip->xtlid; in txLock()
601 lid = mp->lid; in txLock()
611 if ((xtid = tlck->tid) == tid) { in txLock()
628 tlck->tid = tid; in txLock()
641 if (jfs_ip->atlhead == lid) { in txLock()
642 if (jfs_ip->atltail == lid) { in txLock()
647 list_del_init(&jfs_ip->anon_inode_list); in txLock()
650 jfs_ip->atlhead = tlck->next; in txLock()
653 for (last = jfs_ip->atlhead; in txLock()
654 lid_to_tlock(last)->next != lid; in txLock()
655 last = lid_to_tlock(last)->next) { in txLock()
658 lid_to_tlock(last)->next = tlck->next; in txLock()
659 if (jfs_ip->atltail == lid) in txLock()
660 jfs_ip->atltail = last; in txLock()
665 if (tblk->next) in txLock()
666 lid_to_tlock(tblk->last)->next = lid; in txLock()
668 tblk->next = lid; in txLock()
669 tlck->next = 0; in txLock()
670 tblk->last = lid; in txLock()
687 tlck->tid = tid; in txLock()
691 /* mark tlock for meta-data page */ in txLock()
692 if (mp->xflag & COMMIT_PAGE) { in txLock()
694 tlck->flag = tlckPAGELOCK; in txLock()
700 mp, mp->nohomeok, tid, tlck); in txLock()
707 if ((tid == 0) && mp->lsn) in txLock()
710 /* mark tlock for in-memory inode */ in txLock()
712 tlck->flag = tlckINODELOCK; in txLock()
714 if (S_ISDIR(ip->i_mode)) in txLock()
715 tlck->flag |= tlckDIRECTORY; in txLock()
717 tlck->type = 0; in txLock()
720 tlck->ip = ip; in txLock()
721 tlck->mp = mp; in txLock()
723 jfs_ip->xtlid = lid; in txLock()
725 mp->lid = lid; in txLock()
733 if (tblk->next) in txLock()
734 lid_to_tlock(tblk->last)->next = lid; in txLock()
736 tblk->next = lid; in txLock()
737 tlck->next = 0; in txLock()
738 tblk->last = lid; in txLock()
744 tlck->next = jfs_ip->atlhead; in txLock()
745 jfs_ip->atlhead = lid; in txLock()
746 if (tlck->next == 0) { in txLock()
748 jfs_ip->atltail = lid; in txLock()
750 list_add_tail(&jfs_ip->anon_inode_list, in txLock()
757 linelock = (struct linelock *) & tlck->lock; in txLock()
758 linelock->next = 0; in txLock()
759 linelock->flag = tlckLINELOCK; in txLock()
760 linelock->maxcnt = TLOCKSHORT; in txLock()
761 linelock->index = 0; in txLock()
765 linelock->l2linesize = L2DTSLOTSIZE; in txLock()
769 linelock->l2linesize = L2XTSLOTSIZE; in txLock()
772 xtlck->header.offset = 0; in txLock()
773 xtlck->header.length = 2; in txLock()
776 xtlck->lwm.offset = XTENTRYSTART; in txLock()
778 if (mp->xflag & COMMIT_PAGE) in txLock()
779 p = (xtpage_t *) mp->data; in txLock()
781 p = &jfs_ip->i_xtroot; in txLock()
782 xtlck->lwm.offset = in txLock()
783 le16_to_cpu(p->header.nextindex); in txLock()
785 xtlck->lwm.length = 0; /* ! */ in txLock()
786 xtlck->twm.offset = 0; in txLock()
787 xtlck->hwm.offset = 0; in txLock()
789 xtlck->index = 2; in txLock()
793 linelock->l2linesize = L2INODESLOTSIZE; in txLock()
797 linelock->l2linesize = L2DATASLOTSIZE; in txLock()
808 tlck->type |= type; in txLock()
817 /* assert(jfs_ip->fileset == AGGREGATE_I); */ in txLock()
818 if (jfs_ip->fileset != AGGREGATE_I) { in txLock()
835 xtid = tlck->tid; /* reacquire after dropping TXN_LOCK */ in txLock()
841 if (xtid && (tlck->mp == mp) && (mp->lid == lid)) in txLock()
842 TXN_SLEEP_DROP_LOCK(&tid_to_tblock(xtid)->waitor); in txLock()
859 * tblk -
871 for (lid = tblk->next; lid; lid = tlck->next) { in txRelease()
873 if ((mp = tlck->mp) != NULL && in txRelease()
874 (tlck->type & tlckBTROOT) == 0) { in txRelease()
875 assert(mp->xflag & COMMIT_PAGE); in txRelease()
876 mp->lid = 0; in txRelease()
884 TXN_WAKEUP(&tblk->waitor); in txRelease()
906 log = JFS_SBI(tblk->sb)->log; in txUnlock()
911 for (lid = tblk->next; lid; lid = next) { in txUnlock()
913 next = tlck->next; in txUnlock()
918 if ((mp = tlck->mp) != NULL && in txUnlock()
919 (tlck->type & tlckBTROOT) == 0) { in txUnlock()
920 assert(mp->xflag & COMMIT_PAGE); in txUnlock()
926 assert(mp->nohomeok > 0); in txUnlock()
931 if (mp->clsn) { in txUnlock()
932 logdiff(difft, tblk->clsn, log); in txUnlock()
933 logdiff(diffp, mp->clsn, log); in txUnlock()
935 mp->clsn = tblk->clsn; in txUnlock()
937 mp->clsn = tblk->clsn; in txUnlock()
940 assert(!(tlck->flag & tlckFREEPAGE)); in txUnlock()
950 llid = ((struct linelock *) & tlck->lock)->next; in txUnlock()
953 k = linelock->next; in txUnlock()
961 tblk->next = tblk->last = 0; in txUnlock()
968 if (tblk->lsn) { in txUnlock()
970 log->count--; in txUnlock()
971 list_del(&tblk->synclist); in txUnlock()
1001 tlck->tid = tid; in txMaplock()
1004 tlck->flag = tlckINODELOCK; in txMaplock()
1005 if (S_ISDIR(ip->i_mode)) in txMaplock()
1006 tlck->flag |= tlckDIRECTORY; in txMaplock()
1007 tlck->ip = ip; in txMaplock()
1008 tlck->mp = NULL; in txMaplock()
1010 tlck->type = type; in txMaplock()
1018 if (tblk->next) in txMaplock()
1019 lid_to_tlock(tblk->last)->next = lid; in txMaplock()
1021 tblk->next = lid; in txMaplock()
1022 tlck->next = 0; in txMaplock()
1023 tblk->last = lid; in txMaplock()
1029 tlck->next = jfs_ip->atlhead; in txMaplock()
1030 jfs_ip->atlhead = lid; in txMaplock()
1031 if (tlck->next == 0) { in txMaplock()
1033 jfs_ip->atltail = lid; in txMaplock()
1034 list_add_tail(&jfs_ip->anon_inode_list, in txMaplock()
1042 maplock = (struct maplock *) & tlck->lock; in txMaplock()
1043 maplock->next = 0; in txMaplock()
1044 maplock->maxcnt = 0; in txMaplock()
1045 maplock->index = 0; in txMaplock()
1071 linelock->next = 0; in txLinelock()
1072 linelock->flag = tlckLINELOCK; in txLinelock()
1073 linelock->maxcnt = TLOCKLONG; in txLinelock()
1074 linelock->index = 0; in txLinelock()
1075 if (tlck->flag & tlckDIRECTORY) in txLinelock()
1076 linelock->flag |= tlckDIRECTORY; in txLinelock()
1079 linelock->next = tlock->next; in txLinelock()
1080 tlock->next = lid; in txLinelock()
1087 * -----------------------------
1096 * for non-journalled segments the data are flushed to
1099 * segment will be made a part of the segment atomically).
1102 * one file system. no more than 6 segments are needed
1117 * on entry the inode lock on each segment is assumed
1139 /* is read-only file system ? */ in txCommit()
1141 rc = -EROFS; in txCommit()
1145 sb = cd.sb = iplist[0]->i_sb; in txCommit()
1155 log = JFS_SBI(sb)->log; in txCommit()
1160 lrd->logtid = cpu_to_le32(tblk->logtid); in txCommit()
1161 lrd->backchain = 0; in txCommit()
1163 tblk->xflag |= flag; in txCommit()
1166 tblk->xflag |= COMMIT_LAZY; in txCommit()
1168 * prepare non-journaled objects for commit in txCommit()
1170 * flush data pages of non-journaled file in txCommit()
1171 * to prevent the file getting non-initialized disk blocks in txCommit()
1173 * (new blocks - ) in txCommit()
1179 * acquire transaction lock on (on-disk) inodes in txCommit()
1181 * update on-disk inode from in-memory inode in txCommit()
1183 * on the on-disk inode of file object in txCommit()
1187 * of on-disk inodes on multiple on-disk inode pages by in txCommit()
1191 top = (cd.iplist[k])->i_ino; in txCommit()
1194 if (ip->i_ino > top) { in txCommit()
1195 top = ip->i_ino; in txCommit()
1205 * BUGBUG - This code has temporarily been removed. The in txCommit()
1222 * if ((!S_ISDIR(ip->i_mode)) in txCommit()
1223 * && (tblk->flag & COMMIT_DELETE) == 0) in txCommit()
1224 * filemap_write_and_wait(ip->i_mapping); in txCommit()
1235 if (jfs_ip->atlhead) { in txCommit()
1236 lid_to_tlock(jfs_ip->atltail)->next = tblk->next; in txCommit()
1237 tblk->next = jfs_ip->atlhead; in txCommit()
1238 if (!tblk->last) in txCommit()
1239 tblk->last = jfs_ip->atltail; in txCommit()
1240 jfs_ip->atlhead = jfs_ip->atltail = 0; in txCommit()
1242 list_del_init(&jfs_ip->anon_inode_list); in txCommit()
1247 * acquire transaction lock on on-disk inode page in txCommit()
1265 if (tblk->xflag & COMMIT_DELETE) { in txCommit()
1266 ihold(tblk->u.ip); in txCommit()
1278 * I believe this code is no longer needed. Splitting I_LOCK in txCommit()
1284 if (tblk->u.ip->i_state & I_SYNC) in txCommit()
1285 tblk->xflag &= ~COMMIT_LAZY; in txCommit()
1288 ASSERT((!(tblk->xflag & COMMIT_DELETE)) || in txCommit()
1289 ((tblk->u.ip->i_nlink == 0) && in txCommit()
1290 !test_cflag(COMMIT_Nolink, tblk->u.ip))); in txCommit()
1295 lrd->type = cpu_to_le16(LOG_COMMIT); in txCommit()
1296 lrd->length = 0; in txCommit()
1302 * - transaction is now committed - in txCommit()
1321 if (tblk->xflag & COMMIT_FORCE) in txCommit()
1329 if ((tblk->flag & tblkGC_LAZY) == 0) in txCommit()
1334 * reset in-memory object state in txCommit()
1341 * reset in-memory inode state in txCommit()
1343 jfs_ip->bxflag = 0; in txCommit()
1344 jfs_ip->blid = 0; in txCommit()
1372 struct lrd *lrd = &cd->lrd; in txLog()
1377 for (lid = tblk->next; lid; lid = tlck->next) { in txLog()
1380 tlck->flag |= tlckLOG; in txLog()
1383 ip = tlck->ip; in txLog()
1384 lrd->aggregate = cpu_to_le32(JFS_SBI(ip->i_sb)->aggregate); in txLog()
1385 lrd->log.redopage.fileset = cpu_to_le32(JFS_IP(ip)->fileset); in txLog()
1386 lrd->log.redopage.inode = cpu_to_le32(ip->i_ino); in txLog()
1389 switch (tlck->type & tlckTYPE) { in txLog()
1430 mp = tlck->mp; in diLog()
1433 lrd->log.redopage.type = cpu_to_le16(LOG_INODE); in diLog()
1434 lrd->log.redopage.l2linesize = cpu_to_le16(L2INODESLOTSIZE); in diLog()
1436 pxd = &lrd->log.redopage.pxd; in diLog()
1441 if (tlck->type & tlckENTRY) { in diLog()
1442 /* log after-image for logredo(): */ in diLog()
1443 lrd->type = cpu_to_le16(LOG_REDOPAGE); in diLog()
1444 PXDaddress(pxd, mp->index); in diLog()
1446 mp->logical_size >> tblk->sb->s_blocksize_bits); in diLog()
1447 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in diLog()
1450 tlck->flag |= tlckWRITEPAGE; in diLog()
1451 } else if (tlck->type & tlckFREE) { in diLog()
1469 lrd->type = cpu_to_le16(LOG_NOREDOINOEXT); in diLog()
1477 lrd->log.noredoinoext.iagnum = in diLog()
1478 cpu_to_le32((u32) (size_t) cd->iplist[1]); in diLog()
1479 lrd->log.noredoinoext.inoext_idx = in diLog()
1480 cpu_to_le32((u32) (size_t) cd->iplist[2]); in diLog()
1482 pxdlock = (struct pxd_lock *) & tlck->lock; in diLog()
1483 *pxd = pxdlock->pxd; in diLog()
1484 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in diLog()
1487 tlck->flag |= tlckUPDATEMAP; in diLog()
1490 tlck->flag |= tlckWRITEPAGE; in diLog()
1507 mp = tlck->mp; in dataLog()
1510 lrd->log.redopage.type = cpu_to_le16(LOG_DATA); in dataLog()
1511 lrd->log.redopage.l2linesize = cpu_to_le16(L2DATASLOTSIZE); in dataLog()
1513 pxd = &lrd->log.redopage.pxd; in dataLog()
1515 /* log after-image for logredo(): */ in dataLog()
1516 lrd->type = cpu_to_le16(LOG_REDOPAGE); in dataLog()
1518 if (jfs_dirtable_inline(tlck->ip)) { in dataLog()
1523 mp->lid = 0; in dataLog()
1527 tlck->mp = NULL; in dataLog()
1531 PXDaddress(pxd, mp->index); in dataLog()
1532 PXDlength(pxd, mp->logical_size >> tblk->sb->s_blocksize_bits); in dataLog()
1534 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in dataLog()
1537 tlck->flag |= tlckWRITEPAGE; in dataLog()
1554 mp = tlck->mp; in dtLog()
1557 lrd->log.redopage.type = cpu_to_le16(LOG_DTREE); in dtLog()
1558 lrd->log.redopage.l2linesize = cpu_to_le16(L2DTSLOTSIZE); in dtLog()
1560 pxd = &lrd->log.redopage.pxd; in dtLog()
1562 if (tlck->type & tlckBTROOT) in dtLog()
1563 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); in dtLog()
1567 * page extension in-place: entry insertion; in dtLog()
1568 * new right page from page split, reinitialized in-line in dtLog()
1571 if (tlck->type & (tlckNEW | tlckEXTEND)) { in dtLog()
1572 /* log after-image of the new page for logredo(): in dtLog()
1576 lrd->type = cpu_to_le16(LOG_REDOPAGE); in dtLog()
1577 if (tlck->type & tlckEXTEND) in dtLog()
1578 lrd->log.redopage.type |= cpu_to_le16(LOG_EXTEND); in dtLog()
1580 lrd->log.redopage.type |= cpu_to_le16(LOG_NEW); in dtLog()
1581 PXDaddress(pxd, mp->index); in dtLog()
1583 mp->logical_size >> tblk->sb->s_blocksize_bits); in dtLog()
1584 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in dtLog()
1589 if (tlck->type & tlckBTROOT) in dtLog()
1591 tlck->flag |= tlckUPDATEMAP; in dtLog()
1592 pxdlock = (struct pxd_lock *) & tlck->lock; in dtLog()
1593 pxdlock->flag = mlckALLOCPXD; in dtLog()
1594 pxdlock->pxd = *pxd; in dtLog()
1596 pxdlock->index = 1; in dtLog()
1599 tlck->flag |= tlckWRITEPAGE; in dtLog()
1607 if (tlck->type & (tlckENTRY | tlckRELINK)) { in dtLog()
1608 /* log after-image for logredo(): */ in dtLog()
1609 lrd->type = cpu_to_le16(LOG_REDOPAGE); in dtLog()
1610 PXDaddress(pxd, mp->index); in dtLog()
1612 mp->logical_size >> tblk->sb->s_blocksize_bits); in dtLog()
1613 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in dtLog()
1616 tlck->flag |= tlckWRITEPAGE; in dtLog()
1627 if (tlck->type & (tlckFREE | tlckRELOCATE)) { in dtLog()
1632 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); in dtLog()
1633 pxdlock = (struct pxd_lock *) & tlck->lock; in dtLog()
1634 *pxd = pxdlock->pxd; in dtLog()
1635 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in dtLog()
1640 tlck->flag |= tlckUPDATEMAP; in dtLog()
1663 ip = tlck->ip; in xtLog()
1664 mp = tlck->mp; in xtLog()
1667 lrd->log.redopage.type = cpu_to_le16(LOG_XTREE); in xtLog()
1668 lrd->log.redopage.l2linesize = cpu_to_le16(L2XTSLOTSIZE); in xtLog()
1670 page_pxd = &lrd->log.redopage.pxd; in xtLog()
1672 if (tlck->type & tlckBTROOT) { in xtLog()
1673 lrd->log.redopage.type |= cpu_to_le16(LOG_BTROOT); in xtLog()
1674 p = &JFS_IP(ip)->i_xtroot; in xtLog()
1675 if (S_ISDIR(ip->i_mode)) in xtLog()
1676 lrd->log.redopage.type |= in xtLog()
1679 p = (xtpage_t *) mp->data; in xtLog()
1680 next = le16_to_cpu(p->header.nextindex); in xtLog()
1682 xtlck = (struct xtlock *) & tlck->lock; in xtLog()
1684 maplock = (struct maplock *) & tlck->lock; in xtLog()
1691 if (tlck->type & (tlckNEW | tlckGROW | tlckRELINK)) { in xtLog()
1692 /* log after-image for logredo(): in xtLog()
1695 * after-image of XADlist; in xtLog()
1697 * applying the after-image to the meta-data page. in xtLog()
1699 lrd->type = cpu_to_le16(LOG_REDOPAGE); in xtLog()
1700 PXDaddress(page_pxd, mp->index); in xtLog()
1702 mp->logical_size >> tblk->sb->s_blocksize_bits); in xtLog()
1703 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in xtLog()
1710 lwm = xtlck->lwm.offset; in xtLog()
1720 tlck->flag |= tlckUPDATEMAP; in xtLog()
1721 xadlock->flag = mlckALLOCXADLIST; in xtLog()
1722 xadlock->count = next - lwm; in xtLog()
1723 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) { in xtLog()
1733 xadlock->flag = mlckALLOCPXDLIST; in xtLog()
1734 pxd = xadlock->xdlist = &xtlck->pxdlock; in xtLog()
1735 for (i = 0; i < xadlock->count; i++) { in xtLog()
1736 PXDaddress(pxd, addressXAD(&p->xad[lwm + i])); in xtLog()
1737 PXDlength(pxd, lengthXAD(&p->xad[lwm + i])); in xtLog()
1738 p->xad[lwm + i].flag &= in xtLog()
1747 xadlock->flag = mlckALLOCXADLIST; in xtLog()
1748 xadlock->xdlist = &p->xad[lwm]; in xtLog()
1749 tblk->xflag &= ~COMMIT_LAZY; in xtLog()
1752 tlck->ip, mp, tlck, lwm, xadlock->count); in xtLog()
1754 maplock->index = 1; in xtLog()
1758 tlck->flag |= tlckWRITEPAGE; in xtLog()
1769 if (tlck->type & tlckFREE) { in xtLog()
1786 if (tblk->xflag & COMMIT_TRUNCATE) { in xtLog()
1788 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); in xtLog()
1789 PXDaddress(page_pxd, mp->index); in xtLog()
1791 mp->logical_size >> tblk->sb-> in xtLog()
1793 lrd->backchain = in xtLog()
1796 if (tlck->type & tlckBTROOT) { in xtLog()
1798 lrd->type = cpu_to_le16(LOG_REDOPAGE); in xtLog()
1799 lrd->backchain = in xtLog()
1808 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in xtLog()
1809 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEXADLIST); in xtLog()
1810 xtlck = (struct xtlock *) & tlck->lock; in xtLog()
1811 hwm = xtlck->hwm.offset; in xtLog()
1812 lrd->log.updatemap.nxd = in xtLog()
1813 cpu_to_le16(hwm - XTENTRYSTART + 1); in xtLog()
1815 xtlck->header.offset = XTENTRYSTART; in xtLog()
1816 xtlck->header.length = hwm - XTENTRYSTART + 1; in xtLog()
1817 xtlck->index = 1; in xtLog()
1818 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in xtLog()
1824 tlck->flag |= tlckUPDATEMAP; in xtLog()
1825 xadlock->count = hwm - XTENTRYSTART + 1; in xtLog()
1826 if ((xadlock->count <= 4) && (tblk->xflag & COMMIT_LAZY)) { in xtLog()
1836 xadlock->flag = mlckFREEPXDLIST; in xtLog()
1837 pxd = xadlock->xdlist = &xtlck->pxdlock; in xtLog()
1838 for (i = 0; i < xadlock->count; i++) { in xtLog()
1840 addressXAD(&p->xad[XTENTRYSTART + i])); in xtLog()
1842 lengthXAD(&p->xad[XTENTRYSTART + i])); in xtLog()
1850 xadlock->flag = mlckFREEXADLIST; in xtLog()
1851 xadlock->xdlist = &p->xad[XTENTRYSTART]; in xtLog()
1852 tblk->xflag &= ~COMMIT_LAZY; in xtLog()
1855 tlck->ip, mp, xadlock->count); in xtLog()
1857 maplock->index = 1; in xtLog()
1860 if (((tblk->xflag & COMMIT_PWMAP) || S_ISDIR(ip->i_mode)) in xtLog()
1861 && !(tlck->type & tlckBTROOT)) in xtLog()
1862 tlck->flag |= tlckFREEPAGE; in xtLog()
1864 else (tblk->xflag & COMMIT_PMAP) in xtLog()
1873 * |----------+------+------+---------------| in xtLog()
1875 * | | hwm - hwm before truncation in xtLog()
1876 * | next - truncation point in xtLog()
1877 * lwm - lwm before truncation in xtLog()
1880 if (tlck->type & tlckTRUNCATE) { in xtLog()
1891 tblk->xflag &= ~COMMIT_LAZY; in xtLog()
1892 lwm = xtlck->lwm.offset; in xtLog()
1895 hwm = xtlck->hwm.offset; in xtLog()
1896 twm = xtlck->twm.offset; in xtLog()
1901 /* log after-image for logredo(): in xtLog()
1905 * after-image of XADlist; in xtLog()
1907 * applying the after-image to the meta-data page. in xtLog()
1909 lrd->type = cpu_to_le16(LOG_REDOPAGE); in xtLog()
1910 PXDaddress(page_pxd, mp->index); in xtLog()
1912 mp->logical_size >> tblk->sb->s_blocksize_bits); in xtLog()
1913 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, tlck)); in xtLog()
1916 * truncate entry XAD[twm == next - 1]: in xtLog()
1918 if (twm == next - 1) { in xtLog()
1921 * entry XAD[next - 1]: in xtLog()
1922 * (xtlck->pxdlock = truncated delta extent); in xtLog()
1924 pxdlock = (struct pxd_lock *) & xtlck->pxdlock; in xtLog()
1925 /* assert(pxdlock->type & tlckTRUNCATE); */ in xtLog()
1926 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in xtLog()
1927 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD); in xtLog()
1928 lrd->log.updatemap.nxd = cpu_to_le16(1); in xtLog()
1929 lrd->log.updatemap.pxd = pxdlock->pxd; in xtLog()
1930 pxd = pxdlock->pxd; /* save to format maplock */ in xtLog()
1931 lrd->backchain = in xtLog()
1943 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in xtLog()
1944 lrd->log.updatemap.type = in xtLog()
1946 xtlck = (struct xtlock *) & tlck->lock; in xtLog()
1947 hwm = xtlck->hwm.offset; in xtLog()
1948 lrd->log.updatemap.nxd = in xtLog()
1949 cpu_to_le16(hwm - next + 1); in xtLog()
1951 xtlck->header.offset = next; in xtLog()
1952 xtlck->header.length = hwm - next + 1; in xtLog()
1953 xtlck->index = 1; in xtLog()
1954 lrd->backchain = in xtLog()
1961 maplock->index = 0; in xtLog()
1972 tlck->flag |= tlckUPDATEMAP; in xtLog()
1973 xadlock->flag = mlckALLOCXADLIST; in xtLog()
1974 xadlock->count = next - lwm; in xtLog()
1975 xadlock->xdlist = &p->xad[lwm]; in xtLog()
1978 tlck->ip, mp, xadlock->count, lwm, next); in xtLog()
1979 maplock->index++; in xtLog()
1984 * truncate entry XAD[twm == next - 1]: in xtLog()
1986 if (twm == next - 1) { in xtLog()
1989 * entry XAD[next - 1]; in xtLog()
1990 * (xtlck->pxdlock = truncated delta extent); in xtLog()
1992 tlck->flag |= tlckUPDATEMAP; in xtLog()
1994 pxdlock->flag = mlckFREEPXD; in xtLog()
1995 pxdlock->count = 1; in xtLog()
1996 pxdlock->pxd = pxd; in xtLog()
1999 ip, mp, pxdlock->count, hwm); in xtLog()
2000 maplock->index++; in xtLog()
2012 tlck->flag |= tlckUPDATEMAP; in xtLog()
2013 xadlock->flag = mlckFREEXADLIST; in xtLog()
2014 xadlock->count = hwm - next + 1; in xtLog()
2015 xadlock->xdlist = &p->xad[next]; in xtLog()
2018 tlck->ip, mp, xadlock->count, next, hwm); in xtLog()
2019 maplock->index++; in xtLog()
2023 tlck->flag |= tlckWRITEPAGE; in xtLog()
2047 if (tlck->type & tlckRELOCATE) { in mapLog()
2051 lrd->type = cpu_to_le16(LOG_NOREDOPAGE); in mapLog()
2052 pxdlock = (struct pxd_lock *) & tlck->lock; in mapLog()
2053 pxd = &lrd->log.redopage.pxd; in mapLog()
2054 *pxd = pxdlock->pxd; in mapLog()
2055 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in mapLog()
2067 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in mapLog()
2068 lrd->log.updatemap.type = cpu_to_le16(LOG_FREEPXD); in mapLog()
2069 lrd->log.updatemap.nxd = cpu_to_le16(1); in mapLog()
2070 lrd->log.updatemap.pxd = pxdlock->pxd; in mapLog()
2071 lrd->backchain = cpu_to_le32(lmLog(log, tblk, lrd, NULL)); in mapLog()
2076 tlck->flag |= tlckUPDATEMAP; in mapLog()
2090 lrd->type = cpu_to_le16(LOG_UPDATEMAP); in mapLog()
2091 pxdlock = (struct pxd_lock *) & tlck->lock; in mapLog()
2092 nlock = pxdlock->index; in mapLog()
2094 if (pxdlock->flag & mlckALLOCPXD) in mapLog()
2095 lrd->log.updatemap.type = in mapLog()
2098 lrd->log.updatemap.type = in mapLog()
2100 lrd->log.updatemap.nxd = cpu_to_le16(1); in mapLog()
2101 lrd->log.updatemap.pxd = pxdlock->pxd; in mapLog()
2102 lrd->backchain = in mapLog()
2105 (ulong) addressPXD(&pxdlock->pxd), in mapLog()
2106 lengthPXD(&pxdlock->pxd)); in mapLog()
2110 tlck->flag |= tlckUPDATEMAP; in mapLog()
2133 if (newea->flag & DXD_EXTENT) { in txEA()
2135 maplock = (struct pxd_lock *) & tlck->lock; in txEA()
2137 pxdlock->flag = mlckALLOCPXD; in txEA()
2138 PXDaddress(&pxdlock->pxd, addressDXD(newea)); in txEA()
2139 PXDlength(&pxdlock->pxd, lengthDXD(newea)); in txEA()
2141 maplock->index = 1; in txEA()
2142 } else if (newea->flag & DXD_INLINE) { in txEA()
2152 if (!test_cflag(COMMIT_Nolink, ip) && oldea->flag & DXD_EXTENT) { in txEA()
2155 maplock = (struct pxd_lock *) & tlck->lock; in txEA()
2157 maplock->index = 0; in txEA()
2159 pxdlock->flag = mlckFREEPXD; in txEA()
2160 PXDaddress(&pxdlock->pxd, addressDXD(oldea)); in txEA()
2161 PXDlength(&pxdlock->pxd, lengthDXD(oldea)); in txEA()
2162 maplock->index++; in txEA()
2183 tlck = lid_to_tlock(tblk->next); in txForce()
2184 lid = tlck->next; in txForce()
2185 tlck->next = 0; in txForce()
2188 next = tlck->next; in txForce()
2189 tlck->next = tblk->next; in txForce()
2190 tblk->next = lid; in txForce()
2198 for (lid = tblk->next; lid; lid = next) { in txForce()
2200 next = tlck->next; in txForce()
2202 if ((mp = tlck->mp) != NULL && in txForce()
2203 (tlck->type & tlckBTROOT) == 0) { in txForce()
2204 assert(mp->xflag & COMMIT_PAGE); in txForce()
2206 if (tlck->flag & tlckWRITEPAGE) { in txForce()
2207 tlck->flag &= ~tlckWRITEPAGE; in txForce()
2217 * us to kunmap & remap the page. If we in txForce()
2223 assert(mp->nohomeok); in txForce()
2224 set_bit(META_dirty, &mp->flag); in txForce()
2225 set_bit(META_sync, &mp->flag); in txForce()
2252 ipimap = JFS_SBI(tblk->sb)->ipimap; in txUpdateMap()
2254 maptype = (tblk->xflag & COMMIT_PMAP) ? COMMIT_PMAP : COMMIT_PWMAP; in txUpdateMap()
2269 for (lid = tblk->next; lid; lid = tlck->next) { in txUpdateMap()
2272 if ((tlck->flag & tlckUPDATEMAP) == 0) in txUpdateMap()
2275 if (tlck->flag & tlckFREEPAGE) { in txUpdateMap()
2283 mp = tlck->mp; in txUpdateMap()
2284 ASSERT(mp->xflag & COMMIT_PAGE); in txUpdateMap()
2290 * . in-line PXD list: in txUpdateMap()
2291 * . out-of-line XAD list: in txUpdateMap()
2293 maplock = (struct maplock *) & tlck->lock; in txUpdateMap()
2294 nlock = maplock->index; in txUpdateMap()
2302 if (maplock->flag & mlckALLOC) { in txUpdateMap()
2319 else { /* (maplock->flag & mlckFREE) */ in txUpdateMap()
2321 if (tlck->flag & tlckDIRECTORY) in txUpdateMap()
2329 if (tlck->flag & tlckFREEPAGE) { in txUpdateMap()
2330 if (!(tblk->flag & tblkGC_LAZY)) { in txUpdateMap()
2332 ASSERT(mp->lid == lid); in txUpdateMap()
2333 tlck->mp->lid = 0; in txUpdateMap()
2335 assert(mp->nohomeok == 1); in txUpdateMap()
2338 tlck->mp = NULL; in txUpdateMap()
2346 * update in-memory inode flag/state in txUpdateMap()
2350 if (tblk->xflag & COMMIT_CREATE) { in txUpdateMap()
2351 diUpdatePMap(ipimap, tblk->ino, false, tblk); in txUpdateMap()
2356 pxdlock.pxd = tblk->u.ixpxd; in txUpdateMap()
2359 } else if (tblk->xflag & COMMIT_DELETE) { in txUpdateMap()
2360 ip = tblk->u.ip; in txUpdateMap()
2361 diUpdatePMap(ipimap, ip->i_ino, true, tblk); in txUpdateMap()
2372 * ipbmap -
2373 * malock -
2377 * maptype -
2380 * (e.g., tmp file - free from working map at releae
2384 * lsn - log sequence number;
2389 struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap; in txAllocPMap()
2402 if (maplock->flag & mlckALLOCXADLIST) { in txAllocPMap()
2404 xad = xadlistlock->xdlist; in txAllocPMap()
2405 for (n = 0; n < xadlistlock->count; n++, xad++) { in txAllocPMap()
2406 if (xad->flag & (XAD_NEW | XAD_EXTENDED)) { in txAllocPMap()
2411 xad->flag &= ~(XAD_NEW | XAD_EXTENDED); in txAllocPMap()
2416 } else if (maplock->flag & mlckALLOCPXD) { in txAllocPMap()
2418 xaddr = addressPXD(&pxdlock->pxd); in txAllocPMap()
2419 xlen = lengthPXD(&pxdlock->pxd); in txAllocPMap()
2422 } else { /* (maplock->flag & mlckALLOCPXDLIST) */ in txAllocPMap()
2425 pxd = pxdlistlock->xdlist; in txAllocPMap()
2426 for (n = 0; n < pxdlistlock->count; n++, pxd++) { in txAllocPMap()
2447 struct inode *ipbmap = JFS_SBI(ip->i_sb)->ipbmap; in txFreeMap()
2464 if (maplock->flag & mlckFREEXADLIST) { in txFreeMap()
2466 xad = xadlistlock->xdlist; in txFreeMap()
2467 for (n = 0; n < xadlistlock->count; n++, xad++) { in txFreeMap()
2468 if (!(xad->flag & XAD_NEW)) { in txFreeMap()
2477 } else if (maplock->flag & mlckFREEPXD) { in txFreeMap()
2479 xaddr = addressPXD(&pxdlock->pxd); in txFreeMap()
2480 xlen = lengthPXD(&pxdlock->pxd); in txFreeMap()
2485 } else { /* (maplock->flag & mlckALLOCPXDLIST) */ in txFreeMap()
2488 pxd = pxdlistlock->xdlist; in txFreeMap()
2489 for (n = 0; n < pxdlistlock->count; n++, pxd++) { in txFreeMap()
2504 if (maplock->flag & mlckFREEXADLIST) { in txFreeMap()
2506 xad = xadlistlock->xdlist; in txFreeMap()
2507 for (n = 0; n < xadlistlock->count; n++, xad++) { in txFreeMap()
2511 xad->flag = 0; in txFreeMap()
2515 } else if (maplock->flag & mlckFREEPXD) { in txFreeMap()
2517 xaddr = addressPXD(&pxdlock->pxd); in txFreeMap()
2518 xlen = lengthPXD(&pxdlock->pxd); in txFreeMap()
2522 } else { /* (maplock->flag & mlckFREEPXDLIST) */ in txFreeMap()
2525 pxd = pxdlistlock->xdlist; in txFreeMap()
2526 for (n = 0; n < pxdlistlock->count; n++, pxd++) { in txFreeMap()
2548 if (!jfs_ip->atlhead) in txFreelock()
2552 xtlck = (struct tlock *) &jfs_ip->atlhead; in txFreelock()
2554 while ((lid = xtlck->next) != 0) { in txFreelock()
2556 if (tlck->flag & tlckFREELOCK) { in txFreelock()
2557 xtlck->next = tlck->next; in txFreelock()
2565 if (jfs_ip->atlhead) in txFreelock()
2566 jfs_ip->atltail = xlid; in txFreelock()
2568 jfs_ip->atltail = 0; in txFreelock()
2572 list_del_init(&jfs_ip->anon_inode_list); in txFreelock()
2582 * frees line-locks and segment locks for all
2584 * Optionally sets state of file-system to FM_DIRTY in super-block.
2585 * log age of page-frames in memory for which caller has
2598 for (lid = tblk->next; lid; lid = next) { in txAbort()
2600 next = tlck->next; in txAbort()
2601 mp = tlck->mp; in txAbort()
2602 JFS_IP(tlck->ip)->xtlid = 0; in txAbort()
2605 mp->lid = 0; in txAbort()
2615 if (mp->xflag & COMMIT_PAGE && mp->lsn) in txAbort()
2626 tblk->next = tblk->last = 0; in txAbort()
2632 jfs_error(tblk->sb, "\n"); in txAbort()
2649 while (((tblk->flag & tblkGC_READY) == 0) && in txLazyCommit()
2650 ((tblk->flag & tblkGC_UNLOCKED) == 0)) { in txLazyCommit()
2661 log = (struct jfs_log *) JFS_SBI(tblk->sb)->log; in txLazyCommit()
2663 spin_lock_irq(&log->gclock); // LOGGC_LOCK in txLazyCommit()
2665 tblk->flag |= tblkGC_COMMITTED; in txLazyCommit()
2667 if (tblk->flag & tblkGC_READY) in txLazyCommit()
2668 log->gcrtc--; in txLazyCommit()
2670 wake_up_all(&tblk->gcwait); // LOGGC_WAKEUP in txLazyCommit()
2673 * Can't release log->gclock until we've tested tblk->flag in txLazyCommit()
2675 if (tblk->flag & tblkGC_LAZY) { in txLazyCommit()
2676 spin_unlock_irq(&log->gclock); // LOGGC_UNLOCK in txLazyCommit()
2678 tblk->flag &= ~tblkGC_LAZY; in txLazyCommit()
2679 txEnd(tblk - TxBlock); /* Convert back to tid */ in txLazyCommit()
2681 spin_unlock_irq(&log->gclock); // LOGGC_UNLOCK in txLazyCommit()
2708 sbi = JFS_SBI(tblk->sb); in jfs_lazycommit()
2715 if (sbi->commit_state & IN_LAZYCOMMIT) in jfs_lazycommit()
2718 sbi->commit_state |= IN_LAZYCOMMIT; in jfs_lazycommit()
2724 list_del(&tblk->cqueue); in jfs_lazycommit()
2730 sbi->commit_state &= ~IN_LAZYCOMMIT; in jfs_lazycommit()
2773 list_add_tail(&tblk->cqueue, &TxAnchor.unlock_queue); in txLazyUnlock()
2778 if (!(JFS_SBI(tblk->sb)->commit_state & IN_LAZYCOMMIT) && in txLazyUnlock()
2788 struct jfs_log *log = mp->log; in LogSyncRelease()
2790 assert(mp->nohomeok); in LogSyncRelease()
2809 struct jfs_log *log = JFS_SBI(sb)->log; in txQuiesce()
2812 set_bit(log_QUIESCE, &log->flag); in txQuiesce()
2820 ip = &jfs_ip->vfs_inode; in txQuiesce()
2827 tid = txBegin(ip->i_sb, COMMIT_INODE | COMMIT_FORCE); in txQuiesce()
2828 mutex_lock(&jfs_ip->commit_mutex); in txQuiesce()
2831 mutex_unlock(&jfs_ip->commit_mutex); in txQuiesce()
2863 struct jfs_log *log = JFS_SBI(sb)->log; in txResume()
2865 clear_bit(log_QUIESCE, &log->flag); in txResume()
2866 TXN_WAKEUP(&log->syncwait); in txResume()
2891 ip = &jfs_ip->vfs_inode; in jfs_sync()
2897 list_del_init(&jfs_ip->anon_inode_list); in jfs_sync()
2898 } else if (mutex_trylock(&jfs_ip->commit_mutex)) { in jfs_sync()
2904 tid = txBegin(ip->i_sb, COMMIT_INODE); in jfs_sync()
2907 mutex_unlock(&jfs_ip->commit_mutex); in jfs_sync()
2924 list_move(&jfs_ip->anon_inode_list, in jfs_sync()
2995 "txBegin blocked by no free tid = %d\n" in jfs_txstats_proc_show()
3000 "tLockAlloc blocked by no free lock = %d\n", in jfs_txstats_proc_show()