Merge to kernel-2.6.20-1.2949.fc6.vs2.2.0.1
[linux-2.6.git] / fs / nfsd / lockd.c
index 479835b..221acd1 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/types.h>
 #include <linux/fs.h>
+#include <linux/file.h>
 #include <linux/mount.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/svc.h>
 /*
  * Note: we hold the dentry use count while the file is open.
  */
-static u32
-nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file *filp)
+static __be32
+nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp)
 {
-       u32             nfserr;
+       __be32          nfserr;
        struct svc_fh   fh;
 
        /* must initialize before using! but maxsize doesn't matter */
@@ -35,37 +36,33 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file *filp)
 
        exp_readlock();
        nfserr = nfsd_open(rqstp, &fh, S_IFREG, MAY_LOCK, filp);
-       if (!nfserr) {
-               dget(filp->f_dentry);
-               mntget(filp->f_vfsmnt);
-       }
        fh_put(&fh);
        rqstp->rq_client = NULL;
        exp_readunlock();
-       /* nlm and nfsd don't share error codes.
-        * we invent: 0 = no error
-        *            1 = stale file handle
-        *            2 = other error
+       /* We return nlm error codes as nlm doesn't know
+        * about nfsd, but nfsd does know about nlm..
         */
        switch (nfserr) {
        case nfs_ok:
                return 0;
+       case nfserr_dropit:
+               return nlm_drop_reply;
+#ifdef CONFIG_LOCKD_V4
        case nfserr_stale:
-               return 1;
+               return nlm4_stale_fh;
+#endif
        default:
-               return 2;
+               return nlm_lck_denied;
        }
 }
 
 static void
 nlm_fclose(struct file *filp)
 {
-       nfsd_close(filp);
-       dput(filp->f_dentry);
-       mntput(filp->f_vfsmnt);
+       fput(filp);
 }
 
-struct nlmsvc_binding          nfsd_nlm_ops = {
+static struct nlmsvc_binding   nfsd_nlm_ops = {
        .fopen          = nlm_fopen,            /* open file for locking */
        .fclose         = nlm_fclose,           /* close file */
 };