mfs: improve & simplify secondary cache logic
. fixes "!" errors when booting from cd
This commit is contained in:
parent
05341dfeb0
commit
49532259e5
@ -28,7 +28,7 @@
|
|||||||
FORWARD _PROTOTYPE( void rm_lru, (struct buf *bp) );
|
FORWARD _PROTOTYPE( void rm_lru, (struct buf *bp) );
|
||||||
FORWARD _PROTOTYPE( void rw_block, (struct buf *, int) );
|
FORWARD _PROTOTYPE( void rw_block, (struct buf *, int) );
|
||||||
|
|
||||||
PRIVATE int vmcache_avail = -1; /* 0 if not available, >0 if available. */
|
PRIVATE int vmcache = 0; /* are we using vm's secondary cache? (initially not) */
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
* get_block *
|
* get_block *
|
||||||
@ -57,27 +57,11 @@ PUBLIC struct buf *get_block(
|
|||||||
int b;
|
int b;
|
||||||
static struct buf *bp, *prev_ptr;
|
static struct buf *bp, *prev_ptr;
|
||||||
u64_t yieldid = VM_BLOCKID_NONE, getid = make64(dev, block);
|
u64_t yieldid = VM_BLOCKID_NONE, getid = make64(dev, block);
|
||||||
int vmcache = 0;
|
|
||||||
|
|
||||||
assert(buf_hash);
|
assert(buf_hash);
|
||||||
assert(buf);
|
assert(buf);
|
||||||
assert(nr_bufs > 0);
|
assert(nr_bufs > 0);
|
||||||
|
|
||||||
if(vmcache_avail < 0) {
|
|
||||||
/* Test once for the availability of the vm yield block feature. */
|
|
||||||
if(vm_forgetblock(VM_BLOCKID_NONE) == ENOSYS) {
|
|
||||||
vmcache_avail = 0;
|
|
||||||
} else {
|
|
||||||
vmcache_avail = 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* use vmcache if it's available, and allowed, and we're not doing
|
|
||||||
* i/o on a ram disk device.
|
|
||||||
*/
|
|
||||||
if(vmcache_avail && may_use_vmcache && major(dev) != MEMORY_MAJOR)
|
|
||||||
vmcache = 1;
|
|
||||||
|
|
||||||
ASSERT(fs_block_size > 0);
|
ASSERT(fs_block_size > 0);
|
||||||
|
|
||||||
/* Search the hash chain for (dev, block). Do_read() can use
|
/* Search the hash chain for (dev, block). Do_read() can use
|
||||||
@ -586,6 +570,19 @@ PUBLIC void set_blocksize(struct super_block *sp)
|
|||||||
cache_resize(sp->s_block_size, MINBUFS);
|
cache_resize(sp->s_block_size, MINBUFS);
|
||||||
bufs = bufs_heuristic(sp);
|
bufs = bufs_heuristic(sp);
|
||||||
cache_resize(sp->s_block_size, bufs);
|
cache_resize(sp->s_block_size, bufs);
|
||||||
|
|
||||||
|
/* Decide whether to use seconday cache or not.
|
||||||
|
* Only do this if
|
||||||
|
* - it's available, and
|
||||||
|
* - use of it hasn't been disabled for this fs, and
|
||||||
|
* - our main FS device isn't a memory device
|
||||||
|
*/
|
||||||
|
|
||||||
|
vmcache = 0;
|
||||||
|
if(vm_forgetblock(VM_BLOCKID_NONE) != ENOSYS &&
|
||||||
|
may_use_vmcache && major(sp->s_dev) != MEMORY_MAJOR) {
|
||||||
|
vmcache = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*
|
/*===========================================================================*
|
||||||
|
@ -412,7 +412,7 @@ PUBLIC void read_ahead()
|
|||||||
rdahed_inode = NULL; /* turn off read ahead */
|
rdahed_inode = NULL; /* turn off read ahead */
|
||||||
if ( (b = read_map(rip, rdahedpos)) == NO_BLOCK) return; /* at EOF */
|
if ( (b = read_map(rip, rdahedpos)) == NO_BLOCK) return; /* at EOF */
|
||||||
|
|
||||||
assert(rdahedpos > 0); /* So we can safely cast it to unsigned below */
|
assert(rdahedpos >= 0); /* So we can safely cast it to unsigned below */
|
||||||
|
|
||||||
bp = rahead(rip, b, cvul64( (unsigned long) rdahedpos), block_size);
|
bp = rahead(rip, b, cvul64( (unsigned long) rdahedpos), block_size);
|
||||||
put_block(bp, PARTIAL_DATA_BLOCK);
|
put_block(bp, PARTIAL_DATA_BLOCK);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user