]> git.hungrycats.org Git - linux/commitdiff
[PATCH] PATCH 5/16: NFSD: BKL removal: add BKL where needed in filehandle lookup
authorNeil Brown <neilb@cse.unsw.edu.au>
Tue, 26 Feb 2002 06:23:05 +0000 (22:23 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Tue, 26 Feb 2002 06:23:05 +0000 (22:23 -0800)
Protect dentry attachement from BKL

The process of attaching a dentry into the dcache
still needs the BKL I think.
When all the other BKL changes in the VFS settle down, I
will revisit this.  But as it is not a very frequent
operation, the BKL wont hurt.

Also add a down/up of i_sem when doing a lookup(".."),
as it is down for all other lookups.

fs/nfsd/nfsfh.c

index 301c167f97a6b244684e64b00cd3776f1acad03d..97242a262dc6c38562439fdb45277d4481c3c1ec 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/sched.h>
 #include <linux/slab.h>
+#include <linux/smp_lock.h>
 #include <linux/fs.h>
 #include <linux/unistd.h>
 #include <linux/string.h>
@@ -273,7 +274,9 @@ struct dentry *nfsd_findparent(struct dentry *child)
        /* I'm going to assume that if the returned dentry is different, then
         * it is well connected.  But nobody returns different dentrys do they?
         */
+       down(&child->d_inode->i_sem);
        pdentry = child->d_inode->i_op->lookup(child->d_inode, tdentry);
+       up(&child->d_inode->i_sem);
        d_drop(tdentry); /* we never want ".." hashed */
        if (!pdentry && tdentry->d_inode == NULL) {
                /* File system cannot find ".." ... sad but possible */
@@ -426,6 +429,7 @@ find_fh_dentry(struct super_block *sb, __u32 *datap, int len, int fhtype, int ne
         */
        dprintk("nfs_fh: need to look harder for %s/%d\n", sb->s_id, datap[0]);
 
+       lock_kernel();
        if (!S_ISDIR(result->d_inode->i_mode)) {
                nfsdstats.fh_nocache_nondir++;
                        /* need to iget dirino and make sure this inode is in that directory */
@@ -499,6 +503,7 @@ find_fh_dentry(struct super_block *sb, __u32 *datap, int len, int fhtype, int ne
                        dput(dentry);
                        dput(result);   /* this will discard the whole free path, so we can up the semaphore */
                        up(&sb->s_nfsd_free_path_sem);
+                       unlock_kernel();
                        goto retry;
                }
                dput(dentry);
@@ -506,6 +511,7 @@ find_fh_dentry(struct super_block *sb, __u32 *datap, int len, int fhtype, int ne
        }
        dput(dentry);
        up(&sb->s_nfsd_free_path_sem);
+       unlock_kernel();
        return result;
 
 err_dentry:
@@ -513,6 +519,7 @@ err_dentry:
 err_result:
        dput(result);
        up(&sb->s_nfsd_free_path_sem);
+       unlock_kernel();
 err_out:
        if (err == -ESTALE)
                nfsdstats.fh_stale++;