Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-or-later */
0002 /*
0003  *   Copyright (C) International Business Machines Corp., 2000-2004
0004  */
0005 #ifndef _H_JFS_TXNMGR
0006 #define _H_JFS_TXNMGR
0007 
0008 #include "jfs_logmgr.h"
0009 
0010 /*
0011  * Hide implementation of TxBlock and TxLock
0012  */
0013 #define tid_to_tblock(tid) (&TxBlock[tid])
0014 
0015 #define lid_to_tlock(lid) (&TxLock[lid])
0016 
0017 /*
0018  *  transaction block
0019  */
0020 struct tblock {
0021     /*
0022      * tblock and jbuf_t common area: struct logsyncblk
0023      *
0024      * the following 5 fields are the same as struct logsyncblk
0025      * which is common to tblock and jbuf to form logsynclist
0026      */
0027     u16 xflag;      /* tx commit type */
0028     u16 flag;       /* tx commit state */
0029     lid_t dummy;        /* Must keep structures common */
0030     s32 lsn;        /* recovery lsn */
0031     struct list_head synclist;  /* logsynclist link */
0032 
0033     /* lock management */
0034     struct super_block *sb; /* super block */
0035     lid_t next;     /* index of first tlock of tid */
0036     lid_t last;     /* index of last tlock of tid */
0037     wait_queue_head_t waitor;   /* tids waiting on this tid */
0038 
0039     /* log management */
0040     u32 logtid;     /* log transaction id */
0041 
0042     /* commit management */
0043     struct list_head cqueue;    /* commit queue list */
0044     s32 clsn;       /* commit lsn */
0045     struct lbuf *bp;
0046     s32 pn;         /* commit record log page number */
0047     s32 eor;        /* commit record eor */
0048     wait_queue_head_t gcwait;   /* group commit event list:
0049                      * ready transactions wait on this
0050                      * event for group commit completion.
0051                      */
0052     union {
0053         struct inode *ip; /* inode being deleted */
0054         pxd_t ixpxd;    /* pxd of inode extent for created inode */
0055     } u;
0056     u32 ino;        /* inode number being created */
0057 };
0058 
0059 extern struct tblock *TxBlock;  /* transaction block table */
0060 
0061 /* commit flags: tblk->xflag */
0062 #define COMMIT_SYNC 0x0001  /* synchronous commit */
0063 #define COMMIT_FORCE    0x0002  /* force pageout at end of commit */
0064 #define COMMIT_FLUSH    0x0004  /* init flush at end of commit */
0065 #define COMMIT_MAP  0x00f0
0066 #define COMMIT_PMAP 0x0010  /* update pmap */
0067 #define COMMIT_WMAP 0x0020  /* update wmap */
0068 #define COMMIT_PWMAP    0x0040  /* update pwmap */
0069 #define COMMIT_FREE 0x0f00
0070 #define COMMIT_DELETE   0x0100  /* inode delete */
0071 #define COMMIT_TRUNCATE 0x0200  /* file truncation */
0072 #define COMMIT_CREATE   0x0400  /* inode create */
0073 #define COMMIT_LAZY 0x0800  /* lazy commit */
0074 #define COMMIT_PAGE 0x1000  /* Identifies element as metapage */
0075 #define COMMIT_INODE    0x2000  /* Identifies element as inode */
0076 
0077 /* group commit flags tblk->flag: see jfs_logmgr.h */
0078 
0079 /*
0080  *  transaction lock
0081  */
0082 struct tlock {
0083     lid_t next;     /* 2: index next lockword on tid locklist
0084                  *      next lockword on freelist
0085                  */
0086     tid_t tid;      /* 2: transaction id holding lock */
0087 
0088     u16 flag;       /* 2: lock control */
0089     u16 type;       /* 2: log type */
0090 
0091     struct metapage *mp;    /* 4/8: object page buffer locked */
0092     struct inode *ip;   /* 4/8: object */
0093     /* (16) */
0094 
0095     s16 lock[24];       /* 48: overlay area */
0096 };              /* (64) */
0097 
0098 extern struct tlock *TxLock;    /* transaction lock table */
0099 
0100 /*
0101  * tlock flag
0102  */
0103 /* txLock state */
0104 #define tlckPAGELOCK        0x8000
0105 #define tlckINODELOCK       0x4000
0106 #define tlckLINELOCK        0x2000
0107 #define tlckINLINELOCK      0x1000
0108 /* lmLog state */
0109 #define tlckLOG         0x0800
0110 /* updateMap state */
0111 #define tlckUPDATEMAP       0x0080
0112 #define tlckDIRECTORY       0x0040
0113 /* freeLock state */
0114 #define tlckFREELOCK        0x0008
0115 #define tlckWRITEPAGE       0x0004
0116 #define tlckFREEPAGE        0x0002
0117 
0118 /*
0119  * tlock type
0120  */
0121 #define tlckTYPE        0xfe00
0122 #define tlckINODE       0x8000
0123 #define tlckXTREE       0x4000
0124 #define tlckDTREE       0x2000
0125 #define tlckMAP         0x1000
0126 #define tlckEA          0x0800
0127 #define tlckACL         0x0400
0128 #define tlckDATA        0x0200
0129 #define tlckBTROOT      0x0100
0130 
0131 #define tlckOPERATION       0x00ff
0132 #define tlckGROW        0x0001  /* file grow */
0133 #define tlckREMOVE      0x0002  /* file delete */
0134 #define tlckTRUNCATE        0x0004  /* file truncate */
0135 #define tlckRELOCATE        0x0008  /* file/directory relocate */
0136 #define tlckENTRY       0x0001  /* directory insert/delete */
0137 #define tlckEXTEND      0x0002  /* directory extend in-line */
0138 #define tlckSPLIT       0x0010  /* splited page */
0139 #define tlckNEW         0x0020  /* new page from split */
0140 #define tlckFREE        0x0040  /* free page */
0141 #define tlckRELINK      0x0080  /* update sibling pointer */
0142 
0143 /*
0144  *  linelock for lmLog()
0145  *
0146  * note: linelock and its variations are overlaid
0147  * at tlock.lock: watch for alignment;
0148  */
0149 struct lv {
0150     u8 offset;      /* 1: */
0151     u8 length;      /* 1: */
0152 };              /* (2) */
0153 
0154 #define TLOCKSHORT  20
0155 #define TLOCKLONG   28
0156 
0157 struct linelock {
0158     lid_t next;     /* 2: next linelock */
0159 
0160     s8 maxcnt;      /* 1: */
0161     s8 index;       /* 1: */
0162 
0163     u16 flag;       /* 2: */
0164     u8 type;        /* 1: */
0165     u8 l2linesize;      /* 1: log2 of linesize */
0166     /* (8) */
0167 
0168     struct lv lv[20];   /* 40: */
0169 };              /* (48) */
0170 
0171 #define dt_lock linelock
0172 
0173 struct xtlock {
0174     lid_t next;     /* 2: */
0175 
0176     s8 maxcnt;      /* 1: */
0177     s8 index;       /* 1: */
0178 
0179     u16 flag;       /* 2: */
0180     u8 type;        /* 1: */
0181     u8 l2linesize;      /* 1: log2 of linesize */
0182                 /* (8) */
0183 
0184     struct lv header;   /* 2: */
0185     struct lv lwm;      /* 2: low water mark */
0186     struct lv hwm;      /* 2: high water mark */
0187     struct lv twm;      /* 2: */
0188                 /* (16) */
0189 
0190     s32 pxdlock[8];     /* 32: */
0191 };              /* (48) */
0192 
0193 
0194 /*
0195  *  maplock for txUpdateMap()
0196  *
0197  * note: maplock and its variations are overlaid
0198  * at tlock.lock/linelock: watch for alignment;
0199  * N.B. next field may be set by linelock, and should not
0200  * be modified by maplock;
0201  * N.B. index of the first pxdlock specifies index of next
0202  * free maplock (i.e., number of maplock) in the tlock;
0203  */
0204 struct maplock {
0205     lid_t next;     /* 2: */
0206 
0207     u8 maxcnt;      /* 2: */
0208     u8 index;       /* 2: next free maplock index */
0209 
0210     u16 flag;       /* 2: */
0211     u8 type;        /* 1: */
0212     u8 count;       /* 1: number of pxd/xad */
0213                 /* (8) */
0214 
0215     pxd_t pxd;      /* 8: */
0216 };              /* (16): */
0217 
0218 /* maplock flag */
0219 #define mlckALLOC       0x00f0
0220 #define mlckALLOCXADLIST    0x0080
0221 #define mlckALLOCPXDLIST    0x0040
0222 #define mlckALLOCXAD        0x0020
0223 #define mlckALLOCPXD        0x0010
0224 #define mlckFREE        0x000f
0225 #define mlckFREEXADLIST     0x0008
0226 #define mlckFREEPXDLIST     0x0004
0227 #define mlckFREEXAD     0x0002
0228 #define mlckFREEPXD     0x0001
0229 
0230 #define pxd_lock    maplock
0231 
0232 struct xdlistlock {
0233     lid_t next;     /* 2: */
0234 
0235     u8 maxcnt;      /* 2: */
0236     u8 index;       /* 2: */
0237 
0238     u16 flag;       /* 2: */
0239     u8 type;        /* 1: */
0240     u8 count;       /* 1: number of pxd/xad */
0241                 /* (8) */
0242 
0243     /*
0244      * We need xdlist to be 64 bits (8 bytes), regardless of
0245      * whether void * is 32 or 64 bits
0246      */
0247     union {
0248         void *_xdlist;  /* pxd/xad list */
0249         s64 pad;    /* 8: Force 64-bit xdlist size */
0250     } union64;
0251 };              /* (16): */
0252 
0253 #define xdlist union64._xdlist
0254 
0255 /*
0256  *  commit
0257  *
0258  * parameter to the commit manager routines
0259  */
0260 struct commit {
0261     tid_t tid;      /* tid = index of tblock */
0262     int flag;       /* flags */
0263     struct jfs_log *log;    /* log */
0264     struct super_block *sb; /* superblock */
0265 
0266     int nip;        /* number of entries in iplist */
0267     struct inode **iplist;  /* list of pointers to inodes */
0268 
0269     /* log record descriptor on 64-bit boundary */
0270     struct lrd lrd;     /* : log record descriptor */
0271 };
0272 
0273 /*
0274  * external declarations
0275  */
0276 extern int jfs_tlocks_low;
0277 
0278 extern int txInit(void);
0279 extern void txExit(void);
0280 extern struct tlock *txLock(tid_t, struct inode *, struct metapage *, int);
0281 extern struct tlock *txMaplock(tid_t, struct inode *, int);
0282 extern int txCommit(tid_t, int, struct inode **, int);
0283 extern tid_t txBegin(struct super_block *, int);
0284 extern void txBeginAnon(struct super_block *);
0285 extern void txEnd(tid_t);
0286 extern void txAbort(tid_t, int);
0287 extern struct linelock *txLinelock(struct linelock *);
0288 extern void txFreeMap(struct inode *, struct maplock *, struct tblock *, int);
0289 extern void txEA(tid_t, struct inode *, dxd_t *, dxd_t *);
0290 extern void txFreelock(struct inode *);
0291 extern int lmLog(struct jfs_log *, struct tblock *, struct lrd *,
0292          struct tlock *);
0293 extern void txQuiesce(struct super_block *);
0294 extern void txResume(struct super_block *);
0295 extern void txLazyUnlock(struct tblock *);
0296 extern int jfs_lazycommit(void *);
0297 extern int jfs_sync(void *);
0298 #endif              /* _H_JFS_TXNMGR */