diff options
author | Frans Kaashoek <[email protected]> | 2019-07-29 17:33:16 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2019-07-29 17:33:16 -0400 |
commit | 530431045237d7ccbbc0bb65ed83309845c19893 (patch) | |
tree | 6617b13b8e63bb0fd19ff04ac21b8d5e5d9da6b0 /kernel/log.c | |
parent | 34980381bd75ce28ffea2113559aefa1b02c64f0 (diff) | |
download | xv6-labs-530431045237d7ccbbc0bb65ed83309845c19893.tar.gz xv6-labs-530431045237d7ccbbc0bb65ed83309845c19893.tar.bz2 xv6-labs-530431045237d7ccbbc0bb65ed83309845c19893.zip |
Remove B_DIRTY
Use refcnt to pin blocks into the cache
Replace flags/B_VALID with a boolean field valid
Use info[id].status to signal completion of disk interrupt
Pass a read/write flag to virtio_disk_rw
Diffstat (limited to 'kernel/log.c')
-rw-r--r-- | kernel/log.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/kernel/log.c b/kernel/log.c index c8f7e62..5aea267 100644 --- a/kernel/log.c +++ b/kernel/log.c @@ -77,6 +77,7 @@ install_trans(void) struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst bwrite(dbuf); // write dst to disk + dbuf->refcnt--; // unpin buffer from cache brelse(lbuf); brelse(dbuf); } @@ -203,7 +204,7 @@ commit() } // Caller has modified b->data and is done with the buffer. -// Record the block number and pin in the cache with B_DIRTY. +// Record the block number and pin in the cache by increasing refcnt. // commit()/write_log() will do the disk write. // // log_write() replaces bwrite(); a typical use is: @@ -227,9 +228,10 @@ log_write(struct buf *b) break; } log.lh.block[i] = b->blockno; - if (i == log.lh.n) + if (i == log.lh.n) { // Add new block to log? + b->refcnt++; // Pin block in cache log.lh.n++; - b->flags |= B_DIRTY; // prevent eviction + } release(&log.lock); } |