From: "David S. Miller" <davem@redhat.com>
Date: Mon, 26 Nov 2001 15:53:47 -0800 (PST)
There are other problems remaining, this function is a logical
mess.
Replying to myself, I'd suggest a patch like the following to clear up
all the issues discovered:
--- fs/nfsd/vfs.c.~1~ Sun Oct 21 02:47:53 2001
+++ fs/nfsd/vfs.c Mon Nov 26 16:03:40 2001
@@ -545,32 +545,43 @@
static inline struct raparms *
nfsd_get_raparms(dev_t dev, ino_t ino)
{
- struct raparms *ra, **rap, **frap = NULL;
+ struct raparms *ra, *fra;
int depth = 0;
- for (rap = &raparm_cache; (ra = *rap); rap = &ra->p_next) {
+ ra = raparm_cache;
+ fra = NULL;
+ do {
if (ra->p_ino == ino && ra->p_dev == dev)
goto found;
+
depth++;
+
if (ra->p_count == 0)
- frap = rap;
- }
- depth = nfsdstats.ra_size*11/10;
- if (!frap)
+ fra = ra;
+
+ ra = ra->p_next;
+ } while (ra != raparm_cache);
+
+ if (!fra)
return NULL;
- rap = frap;
- ra = *frap;
- memset(ra, 0, sizeof(*ra));
+
+ ra = fra;
ra->p_dev = dev;
ra->p_ino = ino;
+ ra->p_reada = 0;
+ ra->p_ramax = 0;
+ ra->p_raend = 0;
+ ra->p_ralen = 0;
+ ra->p_rawin = 0;
+
found:
- if (rap != &raparm_cache) {
- *rap = ra->p_next;
- ra->p_next = raparm_cache;
+ if (ra != raparm_cache)
raparm_cache = ra;
- }
+
ra->p_count++;
- nfsdstats.ra_depth[depth*10/nfsdstats.ra_size]++;
+
+ nfsdstats.ra_depth[(depth <= 10 ? depth : 10)]++;
+
return ra;
}
@@ -1576,9 +1587,13 @@
dprintk("nfsd: allocating %d readahead buffers.\n",
cache_size);
memset(raparml, 0, sizeof(struct raparms) * cache_size);
+
+ /* Circular list. */
for (i = 0; i < cache_size - 1; i++) {
raparml[i].p_next = raparml + i + 1;
}
+ raparml[i].p_next = raparml;
+
raparm_cache = raparml;
} else {
printk(KERN_WARNING
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Nov 30 2001 - 21:00:24 EST