Fix knfsd readahead cache in 2.4.15
Hi Neil,
The following patch fixes a bug in the knfsd readahead code. Thememset() that is referenced in the patch below is clobbering the pointer to the next list element (ra->p_next), thus reducing the inode readahead cache to 1 entry upon the very first call to nfsd_get_raparms().
BTW: looking at the choice of cache size. Why is this set to number
of threads * 2? Isn't it better to have a minimum cache size? After all, the fact that I have 8 threads running does not at all reflect the number of inodes that I might have open on my various clients...
Cheers,
Trond
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c.orig +5 -1
@@ -560,9 +560,13 @@return NULL ; rap = frap; ra = *frap; -memset (ra,0 ,sizeof (*ra)); 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;
Quoted 2 lines · David S. Miller
There are other problems remaining, this function is a logical mess.
Hint: readahead via the page cache is the way to go...
-ben
Signature · 1 line
Fish.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
" " == Benjamin LaHaise <[email protected]> writes:
> Hint: readahead via the page cache is the way to go...
That's not the problem: knfsd has always done readahead via the page cache.
The problem is that the generic_file_read() stuff caches info about the status of readaheads in the 'struct file', which is a volatile object in NFS (it is released after the NFS request has been serviced). To work around that, knfsd copies that readahead status data from the struct file into a private cache, and trots it out again upon the next READ call to reference that particular inode.
Cheers,
Trond
Quoted 6 lines · Trond Myklebust
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
" " == Benjamin LaHaise <[email protected]> writes:
> Hint: readahead via the page cache is the way to go...
That's not the problem: knfsd has always done readahead via the page cache.
Sorry for not being clear, but what I was referring to is making the decision about how to read ahead by what is already in the page cache. It has a number of benefits that database people are after as it allows multiple threads using pread/pwrite to obtain the benefits of readahead.
-ben
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
" " == Benjamin LaHaise <[email protected]> writes:
> Sorry for not being clear, but what I was referring to is > making the decision about how to read ahead by what is already > in the page cache. It has a number of benefits that database > people are after as it allows multiple threads using > pread/pwrite to obtain the benefits of readahead.
Ah, OK. Sorry for being so dense ;-)
Yeah, that would be an improvement for knfsd too. The current scheme can only manage readahead for 1 reader per inode.
Are there any records of a more detailed discussion of how to go about implementing such a readahead strategy for Linux?
Cheers,
Trond
Quoted 6 lines · Trond Myklebust
Ah, OK. Sorry for being so dense ;-)
Yeah, that would be an improvement for knfsd too. The current scheme can only manage readahead for 1 reader per inode.
Are there any records of a more detailed discussion of how to go about implementing such a readahead strategy for Linux?
Not yet. I'm hoping to write such a patch in the next couple of months for 2.5.
-ben
Signature · 1 line
Fish.