Commit fd5cdcf8 authored by Neil Brown's avatar Neil Brown Committed by Linus Torvalds

[PATCH] PATCH 6/16: BKL removal: Lock read-ahead cache

Protect read-ahead cache with SMP safe locking

As another step to removing the BKL from nfsd, this patch
protects the read-ahead cache with a spinlock.
parent 322eddbd
...@@ -549,12 +549,15 @@ nfsd_sync_dir(struct dentry *dp) ...@@ -549,12 +549,15 @@ nfsd_sync_dir(struct dentry *dp)
* Obtain the readahead parameters for the file * Obtain the readahead parameters for the file
* specified by (dev, ino). * specified by (dev, ino).
*/ */
static spinlock_t ra_lock = SPIN_LOCK_UNLOCKED;
static inline struct raparms * static inline struct raparms *
nfsd_get_raparms(kdev_t dev, ino_t ino) nfsd_get_raparms(kdev_t dev, ino_t ino)
{ {
struct raparms *ra, **rap, **frap = NULL; struct raparms *ra, **rap, **frap = NULL;
int depth = 0; int depth = 0;
spin_lock(&ra_lock);
for (rap = &raparm_cache; (ra = *rap); rap = &ra->p_next) { for (rap = &raparm_cache; (ra = *rap); rap = &ra->p_next) {
if (ra->p_ino == ino && kdev_same(ra->p_dev, dev)) if (ra->p_ino == ino && kdev_same(ra->p_dev, dev))
goto found; goto found;
...@@ -563,8 +566,10 @@ nfsd_get_raparms(kdev_t dev, ino_t ino) ...@@ -563,8 +566,10 @@ nfsd_get_raparms(kdev_t dev, ino_t ino)
frap = rap; frap = rap;
} }
depth = nfsdstats.ra_size*11/10; depth = nfsdstats.ra_size*11/10;
if (!frap) if (!frap) {
spin_unlock(&ra_lock);
return NULL; return NULL;
}
rap = frap; rap = frap;
ra = *frap; ra = *frap;
ra->p_dev = dev; ra->p_dev = dev;
...@@ -582,6 +587,7 @@ nfsd_get_raparms(kdev_t dev, ino_t ino) ...@@ -582,6 +587,7 @@ nfsd_get_raparms(kdev_t dev, ino_t ino)
} }
ra->p_count++; ra->p_count++;
nfsdstats.ra_depth[depth*10/nfsdstats.ra_size]++; nfsdstats.ra_depth[depth*10/nfsdstats.ra_size]++;
spin_unlock(&ra_lock);
return ra; return ra;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment