]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Fix readahead handling in knfsd
authorAndrew Morton <akpm@osdl.org>
Tue, 1 Jun 2004 01:51:07 +0000 (18:51 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Tue, 1 Jun 2004 01:51:07 +0000 (18:51 -0700)
From: NeilBrown <neilb@cse.unsw.edu.au>

The read-ahead structures were not being initialised properly, and were not
having the use-count decremented after use, making them fairly useless
(since Apr 2002!).

From: Colin Gibbs <colin@gibbsonline.net>
Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
fs/nfsd/vfs.c

index a252cac5a6f32dceaa8b169a6e2d4508fb8b4cdc..3c57bc31f5213c3bb6a5317ff3badb2029ef5d85 100644 (file)
@@ -567,7 +567,7 @@ nfsd_sync_dir(struct dentry *dp)
 static spinlock_t ra_lock = SPIN_LOCK_UNLOCKED;
 
 static inline struct raparms *
-nfsd_get_raparms(dev_t dev, ino_t ino)
+nfsd_get_raparms(dev_t dev, ino_t ino, struct address_space *mapping)
 {
        struct raparms  *ra, **rap, **frap = NULL;
        int depth = 0;
@@ -589,7 +589,7 @@ nfsd_get_raparms(dev_t dev, ino_t ino)
        ra = *frap;
        ra->p_dev = dev;
        ra->p_ino = ino;
-       memset(&ra->p_ra, 0, sizeof(ra->p_ra));
+       file_ra_state_init(&ra->p_ra, mapping);
 found:
        if (rap != &raparm_cache) {
                *rap = ra->p_next;
@@ -661,7 +661,8 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
 #endif
 
        /* Get readahead parameters */
-       ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino);
+       ra = nfsd_get_raparms(inode->i_sb->s_dev, inode->i_ino,
+                             inode->i_mapping->host->i_mapping);
        if (ra)
                file.f_ra = ra->p_ra;
 
@@ -677,9 +678,12 @@ nfsd_read(struct svc_rqst *rqstp, struct svc_fh *fhp, loff_t offset,
        }
 
        /* Write back readahead params */
-       if (ra)
+       if (ra) {
+               spin_lock(&ra_lock);
                ra->p_ra = file.f_ra;
-
+               ra->p_count--;
+               spin_unlock(&ra_lock);
+       }
        if (err >= 0) {
                nfsdstats.io_read += err;
                *count = err;