From 6d4bf8d1ef2c785d7a056c528ea8ea3608fa9439 Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Mon, 31 May 2004 18:51:07 -0700 Subject: [PATCH] [PATCH] Fix readahead handling in knfsd From: NeilBrown 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 Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/nfsd/vfs.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index a252cac5a6f32..3c57bc31f5213 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -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; -- 2.53.0