diff options
author | Robert Morris <[email protected]> | 2014-08-28 05:57:47 -0400 |
---|---|---|
committer | Robert Morris <[email protected]> | 2014-08-28 05:57:47 -0400 |
commit | 48aa917403de1599a02924e429a9f43ea31e9cc1 (patch) | |
tree | 037648a21b395eacdd2d716a33cfc95e14ff0a61 /log.c | |
parent | 71453f72f285a17ccf0520b9dbdafdc701ff2f4a (diff) | |
download | xv6-labs-48aa917403de1599a02924e429a9f43ea31e9cc1.tar.gz xv6-labs-48aa917403de1599a02924e429a9f43ea31e9cc1.tar.bz2 xv6-labs-48aa917403de1599a02924e429a9f43ea31e9cc1.zip |
i think this is a working concurrent logging scheme
Diffstat (limited to 'log.c')
-rw-r--r-- | log.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -52,6 +52,10 @@ struct log log; static void recover_from_log(void); static void commit(); +// statistics, delete eventually XXX. +static int maxsize; +static int maxoutstanding; + void initlog(void) { @@ -131,10 +135,15 @@ begin_op(void) while(1){ if(log.committing){ sleep(&log, &log.lock); + } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ + // this op might exhaust log space; wait for commit. + sleep(&log, &log.lock); } else { - // XXX wait (for a commit) if log is longish. - // need to reserve to avoid over-commit of log space. log.outstanding += 1; + if(log.outstanding > maxoutstanding){ + maxoutstanding = log.outstanding; + cprintf("%d outstanding\n", log.outstanding); + } release(&log.lock); break; } @@ -155,6 +164,9 @@ end_op(void) if(log.outstanding == 0){ do_commit = 1; log.committing = 1; + } else { + // begin_op() may be waiting for log space. + wakeup(&log); } release(&log.lock); @@ -208,6 +220,11 @@ log_write(struct buf *b) if (i == log.lh.n) log.lh.n++; b->flags |= B_DIRTY; // XXX prevent eviction + + if(log.lh.n > maxsize){ + maxsize = log.lh.n; + cprintf("log size %d/%d\n", log.lh.n, LOGSIZE); + } } //PAGEBREAK! |