Skip to contentSkip to conversation

Fix readahead handling in knfsd.

PATCH New NeilBrown 1 participant 1 message Jun 1, 2004 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20040601112157.28553.patches@notabene

NeilBrown

author
#1 lore raw

PATCH 1/1 Fix readahead handling in knfsd.

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 <[email protected]>

----------- Diffstat output ------------

 ./fs/nfsd/vfs.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
fs/nfsd/vfs.c renamed from fs/nfsd/vfs.c~current~ +9 -5
diff ./fs/nfsd/vfs.c~current~ ./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
 #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
 	}
 
 	/* 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;

-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
NFS maillist - [email protected]
https://lists.sourceforge.net/lists/listinfo/nfs