diff options
author | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 1999-06-13 16:29:25 +0000 |
commit | db7d4daea91e105e3859cf461d7e53b9b77454b2 (patch) | |
tree | 9bb65b95440af09e8aca63abe56970dd3360cc57 /fs/lockd | |
parent | 9c1c01ead627bdda9211c9abd5b758d6c687d8ac (diff) |
Merge with Linux 2.2.8.
Diffstat (limited to 'fs/lockd')
-rw-r--r-- | fs/lockd/clntproc.c | 46 | ||||
-rw-r--r-- | fs/lockd/host.c | 2 | ||||
-rw-r--r-- | fs/lockd/svc.c | 3 | ||||
-rw-r--r-- | fs/lockd/svclock.c | 25 | ||||
-rw-r--r-- | fs/lockd/svcproc.c | 2 | ||||
-rw-r--r-- | fs/lockd/svcsubs.c | 9 | ||||
-rw-r--r-- | fs/lockd/xdr.c | 50 |
7 files changed, 91 insertions, 46 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c index d50df7eac..8df091923 100644 --- a/fs/lockd/clntproc.c +++ b/fs/lockd/clntproc.c @@ -30,6 +30,14 @@ static int nlm_stat_to_errno(u32 stat); */ static u32 nlm_cookie = 0x1234; +static inline void nlmclnt_next_cookie(struct nlm_cookie *c) +{ + memcpy(c->data, &nlm_cookie, 4); + memset(c->data+4, 0, 4); + c->len=4; + nlm_cookie++; +} + /* * Initialize arguments for TEST/LOCK/UNLOCK/CANCEL calls */ @@ -40,7 +48,7 @@ nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) struct nlm_lock *lock = &argp->lock; memset(argp, 0, sizeof(*argp)); - argp->cookie = nlm_cookie++; + nlmclnt_next_cookie(&argp->cookie); argp->state = nsm_local_state; lock->fh = *NFS_FH(fl->fl_file->f_dentry); lock->caller = system_utsname.nodename; @@ -57,7 +65,7 @@ nlmclnt_setlockargs(struct nlm_rqst *req, struct file_lock *fl) int nlmclnt_setgrantargs(struct nlm_rqst *call, struct nlm_lock *lock) { - call->a_args.cookie = nlm_cookie++; + nlmclnt_next_cookie(&call->a_args.cookie); call->a_args.lock = *lock; call->a_args.lock.caller = system_utsname.nodename; @@ -230,9 +238,24 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc) /* Perform the RPC call. If an error occurs, try again */ if ((status = rpc_call(clnt, proc, argp, resp, 0)) < 0) { dprintk("lockd: rpc_call returned error %d\n", -status); - if (status == -ERESTARTSYS) - return status; - nlm_rebind_host(host); + switch (status) { + case -EPROTONOSUPPORT: + status = -EINVAL; + break; + case -ECONNREFUSED: + case -ETIMEDOUT: + case -ENOTCONN: + status = -EAGAIN; + break; + case -ERESTARTSYS: + return signalled () ? -EINTR : status; + default: + break; + } + if (req->a_args.block) + nlm_rebind_host(host); + else + break; } else if (resp->status == NLM_LCK_DENIED_GRACE_PERIOD) { dprintk("lockd: server in grace period\n"); @@ -248,9 +271,18 @@ nlmclnt_call(struct nlm_rqst *req, u32 proc) /* Back off a little and try again */ interruptible_sleep_on_timeout(&host->h_gracewait, 15*HZ); - } while (!signalled()); - return -ERESTARTSYS; + /* When the lock requested by F_SETLKW isn't available, + we will wait until the request can be satisfied. If + a signal is received during wait, we should return + -EINTR. */ + if (signalled ()) { + status = -EINTR; + break; + } + } while (1); + + return status; } /* diff --git a/fs/lockd/host.c b/fs/lockd/host.c index 2bbc005ce..4072221af 100644 --- a/fs/lockd/host.c +++ b/fs/lockd/host.c @@ -134,7 +134,7 @@ nlm_lookup_host(struct svc_client *clnt, struct sockaddr_in *sin, host->h_addr.sin_port = 0; /* ouch! */ host->h_version = version; host->h_proto = proto; - host->h_authflavor = RPC_AUTH_NULL; + host->h_authflavor = RPC_AUTH_UNIX; host->h_rpcclnt = NULL; host->h_sema = MUTEX; host->h_nextrebind = jiffies + NLM_HOST_REBIND; diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index be9e0a5f3..d61db4302 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c @@ -64,6 +64,7 @@ lockd(struct svc_rqst *rqstp) { struct svc_serv *serv = rqstp->rq_server; int err = 0; + unsigned long grace_period_expire; /* Lock module and set up kernel thread */ MOD_INC_USE_COUNT; @@ -111,7 +112,7 @@ lockd(struct svc_rqst *rqstp) } #endif - nlmsvc_grace_period += jiffies; + grace_period_expire = nlmsvc_grace_period + jiffies; nlmsvc_timeout = nlm_timeout * HZ; /* diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c index b1f1f5588..10c66ed4d 100644 --- a/fs/lockd/svclock.c +++ b/fs/lockd/svclock.c @@ -111,16 +111,25 @@ nlmsvc_lookup_block(struct nlm_file *file, struct nlm_lock *lock, int remove) return NULL; } +static inline int nlm_cookie_match(struct nlm_cookie *a, struct nlm_cookie *b) +{ + if(a->len != b->len) + return 0; + if(memcmp(a->data,b->data,a->len)) + return 0; + return 1; +} + /* * Find a block with a given NLM cookie. */ static inline struct nlm_block * -nlmsvc_find_block(u32 cookie) +nlmsvc_find_block(struct nlm_cookie *cookie) { struct nlm_block *block; for (block = nlm_blocked; block; block = block->b_next) { - if (block->b_call.a_args.cookie == cookie) + if (nlm_cookie_match(&block->b_call.a_args.cookie,cookie)) break; } @@ -139,7 +148,7 @@ nlmsvc_find_block(u32 cookie) */ static inline struct nlm_block * nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file, - struct nlm_lock *lock, u32 cookie) + struct nlm_lock *lock, struct nlm_cookie *cookie) { struct nlm_block *block; struct nlm_host *host; @@ -160,7 +169,7 @@ nlmsvc_create_block(struct svc_rqst *rqstp, struct nlm_file *file, lock->fl.fl_notify = nlmsvc_notify_blocked; if (!nlmclnt_setgrantargs(&block->b_call, lock)) goto failed_free; - block->b_call.a_args.cookie = cookie; /* see above */ + block->b_call.a_args.cookie = *cookie; /* see above */ dprintk("lockd: created block %p...\n", block); @@ -267,7 +276,7 @@ nlmsvc_traverse_blocks(struct nlm_host *host, struct nlm_file *file, int action) */ u32 nlmsvc_lock(struct svc_rqst *rqstp, struct nlm_file *file, - struct nlm_lock *lock, int wait, u32 cookie) + struct nlm_lock *lock, int wait, struct nlm_cookie *cookie) { struct file_lock *conflock; struct nlm_block *block; @@ -529,8 +538,8 @@ nlmsvc_grant_callback(struct rpc_task *task) unsigned long timeout; dprintk("lockd: GRANT_MSG RPC callback\n"); - if (!(block = nlmsvc_find_block(call->a_args.cookie))) { - dprintk("lockd: no block for cookie %x\n", call->a_args.cookie); + if (!(block = nlmsvc_find_block(&call->a_args.cookie))) { + dprintk("lockd: no block for cookie %x\n", *(u32 *)(call->a_args.cookie.data)); return; } @@ -560,7 +569,7 @@ nlmsvc_grant_callback(struct rpc_task *task) * block. */ void -nlmsvc_grant_reply(u32 cookie, u32 status) +nlmsvc_grant_reply(struct nlm_cookie *cookie, u32 status) { struct nlm_block *block; struct nlm_file *file; diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c index 2077752f4..0e59754f3 100644 --- a/fs/lockd/svcproc.c +++ b/fs/lockd/svcproc.c @@ -151,7 +151,7 @@ nlmsvc_proc_lock(struct svc_rqst *rqstp, struct nlm_args *argp, /* Now try to lock the file */ resp->status = nlmsvc_lock(rqstp, file, &argp->lock, - argp->block, argp->cookie); + argp->block, &argp->cookie); dprintk("lockd: LOCK status %ld\n", ntohl(resp->status)); nlm_release_host(host); diff --git a/fs/lockd/svcsubs.c b/fs/lockd/svcsubs.c index 0c3306d43..4cac77aec 100644 --- a/fs/lockd/svcsubs.c +++ b/fs/lockd/svcsubs.c @@ -52,8 +52,6 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, struct nlm_file *file; unsigned int hash; u32 nfserr; - uid_t saved_cr_uid; - struct svc_cred *cred; dprintk("lockd: nlm_file_lookup(%s/%u)\n", kdevname(u32_to_kdev_t(fh->fh_dev)), fh->fh_ino); @@ -86,15 +84,10 @@ nlm_lookup_file(struct svc_rqst *rqstp, struct nlm_file **result, * We have to make sure we have the right credential to open * the file. */ - cred = &rqstp->rq_cred; - saved_cr_uid = cred->cr_uid; - cred->cr_uid = 0; if ((nfserr = nlmsvc_ops->fopen(rqstp, fh, &file->f_file)) != 0) { dprintk("lockd: open failed (nfserr %ld)\n", ntohl(nfserr)); - cred->cr_uid = saved_cr_uid; goto out_free; } - cred->cr_uid = saved_cr_uid; file->f_next = nlm_files[hash]; nlm_files[hash] = file; @@ -134,7 +127,7 @@ nlm_delete_file(struct nlm_file *file) kfree(file); return; } - fp = &file->f_next; + fp = &f->f_next; } printk(KERN_WARNING "lockd: attempt to release unknown file!\n"); diff --git a/fs/lockd/xdr.c b/fs/lockd/xdr.c index 7d41c8a66..85fb7c729 100644 --- a/fs/lockd/xdr.c +++ b/fs/lockd/xdr.c @@ -53,28 +53,38 @@ nlmxdr_init(void) /* * XDR functions for basic NLM types */ -static inline u32 * -nlm_decode_cookie(u32 *p, u32 *c) +static inline u32 *nlm_decode_cookie(u32 *p, struct nlm_cookie *c) { unsigned int len; - if ((len = ntohl(*p++)) == 4) { - *c = ntohl(*p++); - } else if (len == 0) { /* hockeypux brain damage */ - *c = 0; - } else { + len = ntohl(*p++); + + if(len==0) + { + c->len=4; + memset(c->data, 0, 4); /* hockeypux brain damage */ + } + else if(len<=8) + { + c->len=len; + memcpy(c->data, p, len); + p+=(len+3)>>2; + } + else + { printk(KERN_NOTICE - "lockd: bad cookie size %d (should be 4)\n", len); + "lockd: bad cookie size %d (only cookies under 8 bytes are supported.)\n", len); return NULL; } return p; } static inline u32 * -nlm_encode_cookie(u32 *p, u32 c) +nlm_encode_cookie(u32 *p, struct nlm_cookie *c) { - *p++ = htonl(sizeof(c)); - *p++ = htonl(c); + *p++ = htonl(c->len); + memcpy(p, c->data, c->len); + p+=(c->len+3)>>2; return p; } @@ -168,7 +178,7 @@ nlm_encode_lock(u32 *p, struct nlm_lock *lock) static u32 * nlm_encode_testres(u32 *p, struct nlm_res *resp) { - if (!(p = nlm_encode_cookie(p, resp->cookie))) + if (!(p = nlm_encode_cookie(p, &resp->cookie))) return 0; *p++ = resp->status; @@ -308,7 +318,7 @@ nlmsvc_decode_shareargs(struct svc_rqst *rqstp, u32 *p, nlm_args *argp) int nlmsvc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) { - if (!(p = nlm_encode_cookie(p, resp->cookie))) + if (!(p = nlm_encode_cookie(p, &resp->cookie))) return 0; *p++ = resp->status; *p++ = xdr_zero; /* sequence argument */ @@ -318,7 +328,7 @@ nlmsvc_encode_shareres(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) int nlmsvc_encode_res(struct svc_rqst *rqstp, u32 *p, struct nlm_res *resp) { - if (!(p = nlm_encode_cookie(p, resp->cookie))) + if (!(p = nlm_encode_cookie(p, &resp->cookie))) return 0; *p++ = resp->status; return xdr_ressize_check(rqstp, p); @@ -388,7 +398,7 @@ nlmclt_encode_testargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) { struct nlm_lock *lock = &argp->lock; - if (!(p = nlm_encode_cookie(p, argp->cookie))) + if (!(p = nlm_encode_cookie(p, &argp->cookie))) return -EIO; *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero; if (!(p = nlm_encode_lock(p, lock))) @@ -429,7 +439,7 @@ nlmclt_encode_lockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) { struct nlm_lock *lock = &argp->lock; - if (!(p = nlm_encode_cookie(p, argp->cookie))) + if (!(p = nlm_encode_cookie(p, &argp->cookie))) return -EIO; *p++ = argp->block? xdr_one : xdr_zero; *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero; @@ -446,7 +456,7 @@ nlmclt_encode_cancargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) { struct nlm_lock *lock = &argp->lock; - if (!(p = nlm_encode_cookie(p, argp->cookie))) + if (!(p = nlm_encode_cookie(p, &argp->cookie))) return -EIO; *p++ = argp->block? xdr_one : xdr_zero; *p++ = (lock->fl.fl_type == F_WRLCK)? xdr_one : xdr_zero; @@ -461,7 +471,7 @@ nlmclt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) { struct nlm_lock *lock = &argp->lock; - if (!(p = nlm_encode_cookie(p, argp->cookie))) + if (!(p = nlm_encode_cookie(p, &argp->cookie))) return -EIO; if (!(p = nlm_encode_lock(p, lock))) return -EIO; @@ -472,7 +482,7 @@ nlmclt_encode_unlockargs(struct rpc_rqst *req, u32 *p, nlm_args *argp) static int nlmclt_encode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) { - if (!(p = nlm_encode_cookie(p, resp->cookie))) + if (!(p = nlm_encode_cookie(p, &resp->cookie))) return -EIO; *p++ = resp->status; req->rq_slen = xdr_adjust_iovec(req->rq_svec, p); @@ -501,7 +511,7 @@ nlmclt_decode_res(struct rpc_rqst *req, u32 *p, struct nlm_res *resp) * Buffer requirements for NLM */ #define NLM_void_sz 0 -#define NLM_cookie_sz 2 +#define NLM_cookie_sz 3 /* 1 len , 2 data */ #define NLM_caller_sz 1+QUADLEN(sizeof(system_utsname.nodename)) #define NLM_netobj_sz 1+QUADLEN(XDR_MAX_NETOBJ) /* #define NLM_owner_sz 1+QUADLEN(NLM_MAXOWNER) */ |