clntproc.c (8990c1bc4be46473ad19bf2fa612ca57286f3df4) clntproc.c (7db836d4a427c3c64406b00b6d8d745d6335d72a)
1/*
2 * linux/fs/lockd/clntproc.c
3 *
4 * RPC procedures for the client side NLM implementation
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#include <linux/module.h>
1/*
2 * linux/fs/lockd/clntproc.c
3 *
4 * RPC procedures for the client side NLM implementation
5 *
6 * Copyright (C) 1996, Olaf Kirch <okir@monad.swb.de>
7 */
8
9#include <linux/module.h>
10#include <linux/smp_lock.h>
11#include <linux/slab.h>
12#include <linux/types.h>
13#include <linux/errno.h>
14#include <linux/fs.h>
15#include <linux/nfs_fs.h>
16#include <linux/utsname.h>
17#include <linux/freezer.h>
18#include <linux/sunrpc/clnt.h>

--- 188 unchanged lines hidden (view full) ---

207 break;
208 printk("nlm_alloc_call: failed, waiting for memory\n");
209 schedule_timeout_interruptible(5*HZ);
210 }
211 nlm_release_host(host);
212 return NULL;
213}
214
10#include <linux/slab.h>
11#include <linux/types.h>
12#include <linux/errno.h>
13#include <linux/fs.h>
14#include <linux/nfs_fs.h>
15#include <linux/utsname.h>
16#include <linux/freezer.h>
17#include <linux/sunrpc/clnt.h>

--- 188 unchanged lines hidden (view full) ---

206 break;
207 printk("nlm_alloc_call: failed, waiting for memory\n");
208 schedule_timeout_interruptible(5*HZ);
209 }
210 nlm_release_host(host);
211 return NULL;
212}
213
215void nlm_release_call(struct nlm_rqst *call)
214void nlmclnt_release_call(struct nlm_rqst *call)
216{
217 if (!atomic_dec_and_test(&call->a_count))
218 return;
219 nlm_release_host(call->a_host);
220 nlmclnt_release_lockargs(call);
221 kfree(call);
222}
223
224static void nlmclnt_rpc_release(void *data)
225{
215{
216 if (!atomic_dec_and_test(&call->a_count))
217 return;
218 nlm_release_host(call->a_host);
219 nlmclnt_release_lockargs(call);
220 kfree(call);
221}
222
223static void nlmclnt_rpc_release(void *data)
224{
226 nlm_release_call(data);
225 nlmclnt_release_call(data);
227}
228
229static int nlm_wait_on_grace(wait_queue_head_t *queue)
230{
231 DEFINE_WAIT(wait);
232 int status = -EINTR;
233
234 prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);

--- 197 unchanged lines hidden (view full) ---

432 fl->fl_end = req->a_res.lock.fl.fl_end;
433 fl->fl_type = req->a_res.lock.fl.fl_type;
434 fl->fl_pid = 0;
435 break;
436 default:
437 status = nlm_stat_to_errno(req->a_res.status);
438 }
439out:
226}
227
228static int nlm_wait_on_grace(wait_queue_head_t *queue)
229{
230 DEFINE_WAIT(wait);
231 int status = -EINTR;
232
233 prepare_to_wait(queue, &wait, TASK_INTERRUPTIBLE);

--- 197 unchanged lines hidden (view full) ---

431 fl->fl_end = req->a_res.lock.fl.fl_end;
432 fl->fl_type = req->a_res.lock.fl.fl_type;
433 fl->fl_pid = 0;
434 break;
435 default:
436 status = nlm_stat_to_errno(req->a_res.status);
437 }
438out:
440 nlm_release_call(req);
439 nlmclnt_release_call(req);
441 return status;
442}
443
444static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl)
445{
446 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
447 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state;
448 new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner);

--- 140 unchanged lines hidden (view full) ---

589 */
590 if (resp->status == nlm_lck_denied && (fl_flags & FL_SLEEP))
591 status = -ENOLCK;
592 else
593 status = nlm_stat_to_errno(resp->status);
594out_unblock:
595 nlmclnt_finish_block(block);
596out:
440 return status;
441}
442
443static void nlmclnt_locks_copy_lock(struct file_lock *new, struct file_lock *fl)
444{
445 spin_lock(&fl->fl_u.nfs_fl.owner->host->h_lock);
446 new->fl_u.nfs_fl.state = fl->fl_u.nfs_fl.state;
447 new->fl_u.nfs_fl.owner = nlm_get_lockowner(fl->fl_u.nfs_fl.owner);

--- 140 unchanged lines hidden (view full) ---

588 */
589 if (resp->status == nlm_lck_denied && (fl_flags & FL_SLEEP))
590 status = -ENOLCK;
591 else
592 status = nlm_stat_to_errno(resp->status);
593out_unblock:
594 nlmclnt_finish_block(block);
595out:
597 nlm_release_call(req);
596 nlmclnt_release_call(req);
598 return status;
599out_unlock:
600 /* Fatal error: ensure that we remove the lock altogether */
601 dprintk("lockd: lock attempt ended in fatal error.\n"
602 " Attempting to unlock.\n");
603 nlmclnt_finish_block(block);
604 fl_type = fl->fl_type;
605 fl->fl_type = F_UNLCK;

--- 84 unchanged lines hidden (view full) ---

690 if (resp->status == nlm_granted)
691 goto out;
692
693 if (resp->status != nlm_lck_denied_nolocks)
694 printk("lockd: unexpected unlock status: %d\n", resp->status);
695 /* What to do now? I'm out of my depth... */
696 status = -ENOLCK;
697out:
597 return status;
598out_unlock:
599 /* Fatal error: ensure that we remove the lock altogether */
600 dprintk("lockd: lock attempt ended in fatal error.\n"
601 " Attempting to unlock.\n");
602 nlmclnt_finish_block(block);
603 fl_type = fl->fl_type;
604 fl->fl_type = F_UNLCK;

--- 84 unchanged lines hidden (view full) ---

689 if (resp->status == nlm_granted)
690 goto out;
691
692 if (resp->status != nlm_lck_denied_nolocks)
693 printk("lockd: unexpected unlock status: %d\n", resp->status);
694 /* What to do now? I'm out of my depth... */
695 status = -ENOLCK;
696out:
698 nlm_release_call(req);
697 nlmclnt_release_call(req);
699 return status;
700}
701
702static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
703{
704 struct nlm_rqst *req = data;
705 u32 status = ntohl(req->a_res.status);
706

--- 44 unchanged lines hidden (view full) ---

751 nlmclnt_setlockargs(req, fl);
752 req->a_args.block = block;
753
754 atomic_inc(&req->a_count);
755 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
756 NLMPROC_CANCEL, &nlmclnt_cancel_ops);
757 if (status == 0 && req->a_res.status == nlm_lck_denied)
758 status = -ENOLCK;
698 return status;
699}
700
701static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
702{
703 struct nlm_rqst *req = data;
704 u32 status = ntohl(req->a_res.status);
705

--- 44 unchanged lines hidden (view full) ---

750 nlmclnt_setlockargs(req, fl);
751 req->a_args.block = block;
752
753 atomic_inc(&req->a_count);
754 status = nlmclnt_async_call(nfs_file_cred(fl->fl_file), req,
755 NLMPROC_CANCEL, &nlmclnt_cancel_ops);
756 if (status == 0 && req->a_res.status == nlm_lck_denied)
757 status = -ENOLCK;
759 nlm_release_call(req);
758 nlmclnt_release_call(req);
760 return status;
761}
762
763static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
764{
765 struct nlm_rqst *req = data;
766 u32 status = ntohl(req->a_res.status);
767

--- 76 unchanged lines hidden ---
759 return status;
760}
761
762static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
763{
764 struct nlm_rqst *req = data;
765 u32 status = ntohl(req->a_res.status);
766

--- 76 unchanged lines hidden ---