diff options
author | Frans Kaashoek <[email protected]> | 2015-04-03 08:22:02 -0400 |
---|---|---|
committer | Frans Kaashoek <[email protected]> | 2015-04-03 08:22:02 -0400 |
commit | c24ac5d76353d04955cc348f1cb5b95743c42b38 (patch) | |
tree | cd58ba052fc238fe7f47a495c22c65e7d4bcbd45 /bio.c | |
parent | 7443b9649a6d83443439ae95458434038313b42b (diff) | |
download | xv6-labs-c24ac5d76353d04955cc348f1cb5b95743c42b38.tar.gz xv6-labs-c24ac5d76353d04955cc348f1cb5b95743c42b38.tar.bz2 xv6-labs-c24ac5d76353d04955cc348f1cb5b95743c42b38.zip |
Disentangle block size from the disk's sector size. Set block size to 1024 to show
that they can be different. Clean up mkfs, simplifying specifying fs parameters,
remove some redundancy between fs and mkfs, and fix disk layout bugs. Call blocks
in the file system blocks instead of sectors. Passes usertests for different
block sizes.
Diffstat (limited to 'bio.c')
-rw-r--r-- | bio.c | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -24,6 +24,7 @@ #include "defs.h" #include "param.h" #include "spinlock.h" +#include "fs.h" #include "buf.h" struct { @@ -55,20 +56,20 @@ binit(void) } } -// Look through buffer cache for sector on device dev. +// Look through buffer cache for block on device dev. // If not found, allocate a buffer. // In either case, return B_BUSY buffer. static struct buf* -bget(uint dev, uint sector) +bget(uint dev, uint blockno) { struct buf *b; acquire(&bcache.lock); loop: - // Is the sector already cached? + // Is the block already cached? for(b = bcache.head.next; b != &bcache.head; b = b->next){ - if(b->dev == dev && b->sector == sector){ + if(b->dev == dev && b->blockno == blockno){ if(!(b->flags & B_BUSY)){ b->flags |= B_BUSY; release(&bcache.lock); @@ -85,7 +86,7 @@ bget(uint dev, uint sector) for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ if((b->flags & B_BUSY) == 0 && (b->flags & B_DIRTY) == 0){ b->dev = dev; - b->sector = sector; + b->blockno = blockno; b->flags = B_BUSY; release(&bcache.lock); return b; @@ -94,15 +95,16 @@ bget(uint dev, uint sector) panic("bget: no buffers"); } -// Return a B_BUSY buf with the contents of the indicated disk sector. +// Return a B_BUSY buf with the contents of the indicated block. struct buf* -bread(uint dev, uint sector) +bread(uint dev, uint blockno) { struct buf *b; - b = bget(dev, sector); - if(!(b->flags & B_VALID)) + b = bget(dev, blockno); + if(!(b->flags & B_VALID)) { iderw(b); + } return b; } |