diff -ru V7EM/h/param.h V7JEM/h/param.h --- V7EM/h/param.h Tue Jan 29 18:15:02 2002 +++ V7JEM/h/param.h Sun Mar 3 01:43:53 2002 @@ -2,6 +2,8 @@ * tunable variables */ +#define JOURNALING + #define NBUF 29 /* size of buffer cache */ #define NINODE 200 /* number of in core inodes */ #define NFILE 175 /* number of in core file structures */ diff -ru V7EM/h/systm.h V7JEM/h/systm.h --- V7EM/h/systm.h Mon Jan 28 06:52:32 2002 +++ V7JEM/h/systm.h Sun Mar 3 03:01:14 2002 @@ -3,12 +3,12 @@ * used by more than one * routine. */ -char canonb[CANBSIZ]; /* buffer for erase and kill (#@) */ -struct inode *rootdir; /* pointer to inode of root directory */ -struct proc *runq; /* head of linked list of running processes */ -int cputype; /* type of cpu =40, 45, or 70 */ -int lbolt; /* time of day in 60th not in time */ -time_t time; /* time in sec from 1970 */ +extern char canonb[CANBSIZ]; /* buffer for erase and kill (#@) */ +extern struct inode *rootdir; /* pointer to inode of root directory */ +extern struct proc *runq; /* head of linked list of running processes */ +extern int cputype; /* type of cpu =40, 45, or 70 */ +extern int lbolt; /* time of day in 60th not in time */ +extern time_t time; /* time in sec from 1970 */ /* * Nblkdev is the number of entries @@ -18,58 +18,58 @@ * Used in bounds checking on major * device numbers. */ -int nblkdev; +extern int nblkdev; /* * Number of character switch entries. * Set by cinit/tty.c */ -int nchrdev; +extern int nchrdev; -int mpid; /* generic for unique process id's */ -char runin; /* scheduling flag */ -char runout; /* scheduling flag */ -char runrun; /* scheduling flag */ -char curpri; /* more scheduling */ -int maxmem; /* actual max memory per process */ -physadr lks; /* pointer to clock device */ -daddr_t swplo; /* block number of swap space */ -int nswap; /* size of swap space */ -int updlock; /* lock for sync */ -daddr_t rablock; /* block to be read ahead */ +extern int mpid; /* generic for unique process id's */ +extern char runin; /* scheduling flag */ +extern char runout; /* scheduling flag */ +extern char runrun; /* scheduling flag */ +extern char curpri; /* more scheduling */ +extern int maxmem; /* actual max memory per process */ +extern physadr lks; /* pointer to clock device */ +extern daddr_t swplo; /* block number of swap space */ +extern int nswap; /* size of swap space */ +extern int updlock; /* lock for sync */ +extern daddr_t rablock; /* block to be read ahead */ extern char regloc[]; /* locs. of saved user registers (trap.c) */ -char msgbuf[MSGBUFS]; /* saved "printf" characters */ -dev_t rootdev; /* device of the root */ -dev_t swapdev; /* swapping device */ -dev_t pipedev; /* pipe device */ +extern char msgbuf[MSGBUFS]; /* saved "printf" characters */ +extern dev_t rootdev; /* device of the root */ +extern dev_t swapdev; /* swapping device */ +extern dev_t pipedev; /* pipe device */ extern int icode[]; /* user init code */ extern int szicode; /* its size */ -dev_t getmdev(); -daddr_t bmap(); -struct inode *ialloc(); -struct inode *iget(); -struct inode *owner(); -struct inode *maknode(); -struct inode *namei(); -struct buf *alloc(); -struct buf *getblk(); -struct buf *geteblk(); -struct buf *bread(); -struct buf *breada(); -struct filsys *getfs(); -struct file *getf(); -struct file *falloc(); -int uchar(); +extern dev_t getmdev(); +extern daddr_t bmap(); +extern struct inode *ialloc(); +extern struct inode *iget(); +extern struct inode *owner(); +extern struct inode *maknode(); +extern struct inode *namei(); +extern struct buf *alloc(); +extern struct buf *getblk(); +extern struct buf *geteblk(); +extern struct buf *bread(); +extern struct buf *breada(); +extern struct filsys *getfs(); +extern struct file *getf(); +extern struct file *falloc(); +extern int uchar(); /* * Instrumentation */ -int dk_busy; -long dk_time[32]; -long dk_numb[3]; -long dk_wds[3]; -long tk_nin; -long tk_nout; +extern int dk_busy; +extern long dk_time[32]; +extern long dk_numb[3]; +extern long dk_wds[3]; +extern long tk_nin; +extern long tk_nout; /* * Structure of the system-entry table diff -ru V7EM/h/trans.h V7JEM/h/trans.h --- V7EM/h/trans.h Sun Mar 3 03:37:45 2002 +++ V7JEM/h/trans.h Sun Mar 3 01:01:43 2002 @@ -0,0 +1,11 @@ + +struct trans { + int t_gen; /* generation no : for test */ + int t_opcount; /* op serial : for test */ +}; + +#define TOP_USED 1 +#define TOP_SUPER 2 +#define TOP_FREE 3 +#define TOP_INODE 4 +#define TOP_ILIST 5 diff -ru V7EM/h/user.h V7JEM/h/user.h --- V7EM/h/user.h Mon Jan 28 07:02:49 2002 +++ V7JEM/h/user.h Sun Mar 3 01:43:12 2002 @@ -94,6 +94,7 @@ * extends from u + USIZE*64 * backward not to reach here */ + struct trans *u_tp; /* transaction pointer */ }; #define r_val1 u_rv.ur_val1 diff -ru V7EM/sys/Makefile V7JEM/sys/Makefile --- V7EM/sys/Makefile Tue Jan 29 19:04:01 2002 +++ V7JEM/sys/Makefile Sun Mar 3 01:02:35 2002 @@ -2,7 +2,8 @@ CFLAGS=-O -g -traditional -DFSEM SRCS= alloc.c bio.c fio.c iget.c nami.c pipe.c rdwri.c \ -setup.c subr.c c.c prf.c sys2.c sys3.c sys4.c mkdir.c rmdir.c pwd.c em.c +setup.c subr.c c.c prf.c sys2.c sys3.c sys4.c mkdir.c rmdir.c pwd.c em.c \ +trans.c OBJS=$(SRCS:.c=.o) diff -ru V7EM/sys/alloc.c V7JEM/sys/alloc.c --- V7EM/sys/alloc.c Tue Jan 29 18:01:20 2002 +++ V7JEM/sys/alloc.c Sun Mar 3 03:12:11 2002 @@ -9,6 +9,7 @@ #include "../h/ino.h" #include "../h/dir.h" #include "../h/user.h" +#include "../h/trans.h" typedef struct fblk *FBLKP; /* @@ -114,7 +115,12 @@ } } fp->s_nfree = 0; +#ifdef JOURNALING + trans_add(u.u_tp,bp,TOP_FREE,0,sizeof(fp->s_free)); + bdwrite(bp); +#else bwrite(bp); +#endif fp->s_flock = 0; wakeup((caddr_t)&fp->s_flock); } diff -ru V7EM/sys/c.c V7JEM/sys/c.c --- V7EM/sys/c.c Tue Jan 29 16:42:04 2002 +++ V7JEM/sys/c.c Sun Mar 3 03:05:03 2002 @@ -11,6 +11,63 @@ #include "../h/inode.h" #include "../h/acct.h" +/* h/systm.h common data */ +/* + * Random set of variables + * used by more than one + * routine. + */ +char canonb[CANBSIZ]; /* buffer for erase and kill (#@) */ +struct inode *rootdir; /* pointer to inode of root directory */ +struct proc *runq; /* head of linked list of running processes */ +int cputype; /* type of cpu =40, 45, or 70 */ +int lbolt; /* time of day in 60th not in time */ +time_t time; /* time in sec from 1970 */ + +/* + * Nblkdev is the number of entries + * (rows) in the block switch. It is + * set in binit/bio.c by making + * a pass over the switch. + * Used in bounds checking on major + * device numbers. + */ +int nblkdev; + +/* + * Number of character switch entries. + * Set by cinit/tty.c + */ +int nchrdev; + +int mpid; /* generic for unique process id's */ +char runin; /* scheduling flag */ +char runout; /* scheduling flag */ +char runrun; /* scheduling flag */ +char curpri; /* more scheduling */ +int maxmem; /* actual max memory per process */ +physadr lks; /* pointer to clock device */ +daddr_t swplo; /* block number of swap space */ +int nswap; /* size of swap space */ +int updlock; /* lock for sync */ +daddr_t rablock; /* block to be read ahead */ +char msgbuf[MSGBUFS]; /* saved "printf" characters */ +dev_t rootdev; /* device of the root */ +dev_t swapdev; /* swapping device */ +dev_t pipedev; /* pipe device */ + +/* + * Instrumentation + */ +int dk_busy; +long dk_time[32]; +long dk_numb[3]; +long dk_wds[3]; +long tk_nin; +long tk_nout; + +/* end systm definition */ + int nulldev(); int nodev(); int emstrategy(); diff -ru V7EM/sys/iget.c V7JEM/sys/iget.c --- V7EM/sys/iget.c Tue Jan 29 16:03:04 2002 +++ V7JEM/sys/iget.c Sun Mar 3 02:41:48 2002 @@ -8,6 +8,7 @@ #include "../h/filsys.h" #include "../h/conf.h" #include "../h/buf.h" +#include "../h/trans.h" /* * Look up an inode by device,inumber. @@ -217,6 +218,11 @@ CONV_TO_DISKORDER4(&(dp->di_ctime)); } ip->i_flag &= ~(IUPD|IACC|ICHG); +#ifdef JOURNALING + trans_add(u.u_tp, bp, TOP_INODE + , itoo(ip->i_number)*sizeof(struct dinode) + , (itoo(ip->i_number)+1)*sizeof(struct dinode)); +#endif bdwrite(bp); } } diff -ru V7EM/sys/subr.c V7JEM/sys/subr.c --- V7EM/sys/subr.c Tue Jan 29 17:53:45 2002 +++ V7JEM/sys/subr.c Sun Mar 3 03:06:50 2002 @@ -5,6 +5,7 @@ #include "../h/dir.h" #include "../h/user.h" #include "../h/buf.h" +#include "../h/trans.h" /* * Bmap defines the structure of file system storage @@ -42,9 +43,15 @@ if(rwflg==B_READ || (bp = alloc(dev))==NULL) return((daddr_t)-1); nb = bp->b_blkno; +#ifdef JOURNALING + trans_add(u.u_tp, bp, TOP_USED, 0, 0); +#endif bdwrite(bp); ip->i_un.i_addr[i] = nb; ip->i_flag |= IUPD|ICHG; +#ifdef JOURNALING + iupdat(ip, &time, &time); +#endif } if(i < NADDR-4) rablock = ip->i_un.i_addr[i+1]; @@ -83,6 +90,9 @@ bdwrite(bp); ip->i_un.i_addr[NADDR-j] = nb; ip->i_flag |= IUPD|ICHG; +#ifdef JOURNALING + iupdat(ip, &time, &time); +#endif } /* @@ -105,9 +115,15 @@ return((daddr_t)-1); } nb = nbp->b_blkno; +#ifdef JOURNALING + if (j==3) trans_add(u.u_tp, nbp, TOP_USED, 0, 0); +#endif bdwrite(nbp); bap[i] = nb; CONV_TO_DISKORDER4(bap+i); +#ifdef JOURNALING + trans_add(u.u_tp, bp, TOP_ILIST, sizeof(daddr_t)*i,sizeof(daddr_t)*(i+1)); +#endif bdwrite(bp); } else brelse(bp); diff -ru V7EM/sys/trans.c V7JEM/sys/trans.c --- V7EM/sys/trans.c Sun Mar 3 03:37:48 2002 +++ V7JEM/sys/trans.c Sun Mar 3 01:01:58 2002 @@ -0,0 +1,65 @@ +#include "../h/param.h" +#include "../h/systm.h" +#include "../h/seg.h" +#include "../h/buf.h" +#include "../h/conf.h" +#include "../h/trans.h" + +struct trans * trans_get(); +void trans_add(struct trans *tp,struct buf *bp,int op,int from,int to); +void trans_put(struct trans *tp); + +static int gen=1; + +extern void *kmemalloc(int size); +extern void kmemfree(void *p,int size); + +struct trans * trans_get() { + struct trans *tp; + tp = kmemalloc(sizeof(struct trans)); + tp->t_gen = gen++; + tp->t_opcount = 0; + return tp; +} + +void trans_put(struct trans *tp) { + kmemfree(tp, sizeof(struct trans)); +} + +void trans_add(struct trans *tp,struct buf *bp,int op,int from,int to) { + if (!tp) { +printf("%s: bno = %d %d - %d\n" + , (op == TOP_USED)?"TOP_USED" + :(op == TOP_SUPER)?"TOP_SUPER" + :(op == TOP_FREE)?"TOP_FREE" + :(op == TOP_INODE)?"TOP_INODE" + :(op == TOP_ILIST)?"TOP_ILIST" + :"TOP_ERROR" + ,bp->b_blkno,from,to); + return; + } + tp->t_opcount ++; +printf("%s: %d %d bno = %d %d - %d\n" + , (op == TOP_USED)?"TOP_USED" + :(op == TOP_SUPER)?"TOP_SUPER" + :(op == TOP_FREE)?"TOP_FREE" + :(op == TOP_INODE)?"TOP_INODE" + :(op == TOP_ILIST)?"TOP_ILIST" + :"TOP_ERROR" + ,tp->t_gen,tp->t_opcount,bp->b_blkno,from,to); +} + + +#undef free +#undef malloc + +void *kmemalloc(int size) { + extern void *malloc(); + return malloc(size); +} + +void kmemfree(void *p, int size) { + free(p); +} + +