diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-14 22:23:16 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2015-07-14 22:23:16 +0200 |
commit | 2e85e328864c215c2efa228f129ce3fa6aa1db1f (patch) | |
tree | 0cff25891d80c72978e16c5784b07923b0b1017e /sys/src/cmd/9660srv/iobuf.c | |
parent | f5688dd6c9bfb6cee00f2c5e5f190d7a2ffaa6c6 (diff) |
9660srv: keep data and metadata separate in the cache with a tag
data on the disk is layed out sequentially and directory information
is at the end of the disk. we want to keep data and metadata separated
so that reading large sequential files will not evict the directory
information from the cache causing long seeks.
for that, we tag the clusters (an 8th for metadata, and the rest
for data) and getbuf() will only evict clusters of the same tag.
Diffstat (limited to 'sys/src/cmd/9660srv/iobuf.c')
-rw-r--r-- | sys/src/cmd/9660srv/iobuf.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sys/src/cmd/9660srv/iobuf.c b/sys/src/cmd/9660srv/iobuf.c index 6bba533e8..a617483e6 100644 --- a/sys/src/cmd/9660srv/iobuf.c +++ b/sys/src/cmd/9660srv/iobuf.c @@ -31,7 +31,7 @@ int nclust = NCLUST; static Ioclust* iohead; static Ioclust* iotail; -static Ioclust* getclust(Xdata*, long); +static Ioclust* getclust(Xdata*, long, ulong); static void putclust(Ioclust*); static void xread(Ioclust*); @@ -53,6 +53,16 @@ iobuf_init(void) for(i=0; i<nclust; i++){ c = (Ioclust*)mem; mem += sizeof(Ioclust); + + /* + * on a iso filesystem, data is usually layed out sequentially + * but directory information is at the end of the disk. to avoid + * evicting directory information when reading large sequential + * files, we keep them tagged in the cache. for now, we use + * an 8th of the clusters for meta data. + */ + c->tag = i <= (nclust/8); + c->addr = -1; c->prev = iotail; if(iotail) @@ -87,13 +97,13 @@ purgebuf(Xdata *dev) } static Ioclust* -getclust(Xdata *dev, long addr) +getclust(Xdata *dev, long addr, ulong tag) { Ioclust *c, *f; f = nil; for(c=iohead; c; c=c->next){ - if(!c->busy) + if(!c->busy && c->tag == tag) f = c; if(c->addr == addr && c->dev == dev){ c->busy++; @@ -141,13 +151,13 @@ putclust(Ioclust *c) } Iobuf* -getbuf(Xdata *dev, ulong addr) +getbuf(Xdata *dev, ulong addr, ulong tag) { int off; Ioclust *c; off = addr%BUFPERCLUST; - c = getclust(dev, addr - off); + c = getclust(dev, addr - off, tag); if(c->nbuf < off){ c->busy--; error("I/O read error"); |