]> git.hungrycats.org Git - linux/commitdiff
[PATCH] PATCH 6/16: BKL removal: Lock read-ahead cache
authorNeil Brown <neilb@cse.unsw.edu.au>
Tue, 26 Feb 2002 06:23:11 +0000 (22:23 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Tue, 26 Feb 2002 06:23:11 +0000 (22:23 -0800)
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.

fs/nfsd/vfs.c

index 2ff38d02efd2752221ccc43c1f8480b3eda943e1..dc5232ebc20a832f957520bb19aba2211a810ed6 100644 (file)
@@ -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 @@ found:
        }
        ra->p_count++;
        nfsdstats.ra_depth[depth*10/nfsdstats.ra_size]++;
+       spin_unlock(&ra_lock);
        return ra;
 }