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)
* Obtain the readahead parameters for the file
* specified by (dev, ino).
*/
static spinlock_t ra_lock = SPIN_LOCK_UNLOCKED;
static inline struct raparms *
nfsd_get_raparms(kdev_t dev, ino_t ino)
{
struct raparms *ra, **rap, **frap = NULL;
int depth = 0;
spin_lock(&ra_lock);
for (rap = &raparm_cache; (ra = *rap); rap = &ra->p_next) {
if (ra->p_ino == ino && kdev_same(ra->p_dev, dev))
goto found;
......@@ -563,8 +566,10 @@ nfsd_get_raparms(kdev_t dev, ino_t ino)
frap = rap;
}
depth = nfsdstats.ra_size*11/10;
if (!frap)
if (!frap) {
spin_unlock(&ra_lock);
return NULL;
}
rap = frap;
ra = *frap;
ra->p_dev = dev;
......@@ -582,6 +587,7 @@ nfsd_get_raparms(kdev_t dev, ino_t ino)
}
ra->p_count++;
nfsdstats.ra_depth[depth*10/nfsdstats.ra_size]++;
spin_unlock(&ra_lock);
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