Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / fs / lockd / clntproc.c
index 782f4c9..f8509ee 100644 (file)
@@ -6,6 +6,7 @@
  * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/errno.h>
@@ -456,7 +457,7 @@ static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *ho
        fl->fl_ops = &nlmclnt_lock_ops;
 }
 
-static int do_vfs_lock(struct file_lock *fl)
+static void do_vfs_lock(struct file_lock *fl)
 {
        int res = 0;
        switch (fl->fl_flags & (FL_POSIX|FL_FLOCK)) {
@@ -469,7 +470,9 @@ static int do_vfs_lock(struct file_lock *fl)
                default:
                        BUG();
        }
-       return res;
+       if (res < 0)
+               printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n",
+                               __FUNCTION__);
 }
 
 /*
@@ -498,7 +501,6 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
        struct nlm_host *host = req->a_host;
        struct nlm_res  *resp = &req->a_res;
        struct nlm_wait *block = NULL;
-       unsigned char fl_flags = fl->fl_flags;
        int status = -ENOLCK;
 
        if (!host->h_monitored && nsm_monitor(host) < 0) {
@@ -506,16 +508,9 @@ nlmclnt_lock(struct nlm_rqst *req, struct file_lock *fl)
                                        host->h_name);
                goto out;
        }
-       fl->fl_flags |= FL_ACCESS;
-       status = do_vfs_lock(fl);
-       if (status < 0)
-               goto out;
 
        block = nlmclnt_prepare_block(host, fl);
-again:
        for(;;) {
-               /* Reboot protection */
-               fl->fl_u.nfs_fl.state = host->h_state;
                status = nlmclnt_call(req, NLMPROC_LOCK);
                if (status < 0)
                        goto out_unblock;
@@ -538,17 +533,10 @@ again:
        }
 
        if (resp->status == NLM_LCK_GRANTED) {
-               down_read(&host->h_rwsem);
-               /* Check whether or not the server has rebooted */
-               if (fl->fl_u.nfs_fl.state != host->h_state) {
-                       up_read(&host->h_rwsem);
-                       goto again;
-               }
+               fl->fl_u.nfs_fl.state = host->h_state;
+               fl->fl_flags |= FL_SLEEP;
                /* Ensure the resulting lock will get added to granted list */
-               fl->fl_flags = fl_flags | FL_SLEEP;
-               if (do_vfs_lock(fl) < 0)
-                       printk(KERN_WARNING "%s: VFS is out of sync with lock manager!\n", __FUNCTION__);
-               up_read(&host->h_rwsem);
+               do_vfs_lock(fl);
        }
        status = nlm_stat_to_errno(resp->status);
 out_unblock:
@@ -558,7 +546,6 @@ out_unblock:
                nlmclnt_cancel(host, req->a_args.block, fl);
 out:
        nlm_release_call(req);
-       fl->fl_flags = fl_flags;
        return status;
 }
 
@@ -611,22 +598,15 @@ nlmclnt_reclaim(struct nlm_host *host, struct file_lock *fl)
 static int
 nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
 {
-       struct nlm_host *host = req->a_host;
        struct nlm_res  *resp = &req->a_res;
-       int status = 0;
+       int             status;
 
        /*
         * Note: the server is supposed to either grant us the unlock
         * request, or to deny it with NLM_LCK_DENIED_GRACE_PERIOD. In either
         * case, we want to unlock.
         */
-       fl->fl_flags |= FL_EXISTS;
-       down_read(&host->h_rwsem);
-       if (do_vfs_lock(fl) == -ENOENT) {
-               up_read(&host->h_rwsem);
-               goto out;
-       }
-       up_read(&host->h_rwsem);
+       do_vfs_lock(fl);
 
        if (req->a_flags & RPC_TASK_ASYNC)
                return nlm_async_call(req, NLMPROC_UNLOCK, &nlmclnt_unlock_ops);
@@ -635,6 +615,7 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
        if (status < 0)
                goto out;
 
+       status = 0;
        if (resp->status == NLM_LCK_GRANTED)
                goto out;