]> git.neil.brown.name Git - history.git/commitdiff
NFSv2/v3 locking: Patch by Patrice Dumas to ensure that the server index blocks uniquely
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Sat, 13 Mar 2004 16:51:10 +0000 (11:51 -0500)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Sat, 13 Mar 2004 16:51:10 +0000 (11:51 -0500)
    by using the client address in addition to the value of the NLM cookie field.

fs/lockd/svc4proc.c
fs/lockd/svclock.c
fs/lockd/svcproc.c
include/linux/lockd/lockd.h

index 5d94583b1be20263a6963b60a5849eb9f6de4a25..a3d3b78f7ce3a865d6ac9608a679627471bfb4ef 100644 (file)
@@ -464,7 +464,7 @@ nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res  *argp,
 
         dprintk("lockd: GRANTED_RES   called\n");
 
-        nlmsvc_grant_reply(&argp->cookie, argp->status);
+        nlmsvc_grant_reply(rqstp, &argp->cookie, argp->status);
         return rpc_success;
 }
 
index dfb16a579c995f68ddfbe221faca821876926bfe..c4921266aee0d1f57d08e0bfeebebc29c3c2f1ed 100644 (file)
@@ -143,14 +143,15 @@ static inline int nlm_cookie_match(struct nlm_cookie *a, struct nlm_cookie *b)
  * Find a block with a given NLM cookie.
  */
 static inline struct nlm_block *
-nlmsvc_find_block(struct nlm_cookie *cookie)
+nlmsvc_find_block(struct nlm_cookie *cookie,  struct sockaddr_in *sin)
 {
        struct nlm_block *block;
 
        for (block = nlm_blocked; block; block = block->b_next) {
                dprintk("cookie: head of blocked queue %p, block %p\n", 
                        nlm_blocked, block);
-               if (nlm_cookie_match(&block->b_call.a_args.cookie,cookie))
+               if (nlm_cookie_match(&block->b_call.a_args.cookie,cookie)
+                               && nlm_cmp_addr(sin, &block->b_host->h_addr))
                        break;
        }
 
@@ -566,12 +567,16 @@ nlmsvc_grant_callback(struct rpc_task *task)
        struct nlm_rqst         *call = (struct nlm_rqst *) task->tk_calldata;
        struct nlm_block        *block;
        unsigned long           timeout;
+       struct sockaddr_in      *peer_addr = RPC_PEERADDR(task->tk_client);
 
        dprintk("lockd: GRANT_MSG RPC callback\n");
-       dprintk("callback: looking for cookie %x \n", 
-               *(unsigned int *)(call->a_args.cookie.data));
-       if (!(block = nlmsvc_find_block(&call->a_args.cookie))) {
-               dprintk("lockd: no block for cookie %x\n", *(u32 *)(call->a_args.cookie.data));
+       dprintk("callback: looking for cookie %x, host (%08x)\n", 
+               *(unsigned int *)(call->a_args.cookie.data),
+               ntohl(peer_addr->sin_addr.s_addr));
+       if (!(block = nlmsvc_find_block(&call->a_args.cookie, peer_addr))) {
+               dprintk("lockd: no block for cookie %x, host (%08x)\n",
+                       *(u32 *)(call->a_args.cookie.data),
+                       ntohl(peer_addr->sin_addr.s_addr));
                return;
        }
 
@@ -600,18 +605,21 @@ nlmsvc_grant_callback(struct rpc_task *task)
  * block.
  */
 void
-nlmsvc_grant_reply(struct nlm_cookie *cookie, u32 status)
+nlmsvc_grant_reply(struct svc_rqst *rqstp, struct nlm_cookie *cookie, u32 status)
 {
        struct nlm_block        *block;
        struct nlm_file         *file;
 
-       if (!(block = nlmsvc_find_block(cookie)))
+       dprintk("grant_reply: looking for cookie %x, host (%08x), s=%d \n", 
+               *(unsigned int *)(cookie->data), 
+               ntohl(rqstp->rq_addr.sin_addr.s_addr), status);
+       if (!(block = nlmsvc_find_block(cookie, &rqstp->rq_addr)))
                return;
        file = block->b_file;
 
        file->f_count++;
        down(&file->f_sema);
-       if ((block = nlmsvc_find_block(cookie)) != NULL) {
+       if ((block = nlmsvc_find_block(cookie,&rqstp->rq_addr)) != NULL) {
                if (status == NLM_LCK_DENIED_GRACE_PERIOD) {
                        /* Try again in a couple of seconds */
                        nlmsvc_insert_block(block, 10 * HZ);
index 4651f7b3f245942b534eb2e7520008d1b3886832..b676e8ccd8c8f4ac5e0f2ff6ef033131dc56afb2 100644 (file)
@@ -490,7 +490,7 @@ nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res  *argp,
 
        dprintk("lockd: GRANTED_RES   called\n");
 
-       nlmsvc_grant_reply(&argp->cookie, argp->status);
+       nlmsvc_grant_reply(rqstp, &argp->cookie, argp->status);
        return rpc_success;
 }
 
index cdfd42b56a50bb13fa4f6d3ad5a417103e22669d..e0db6e1d057e0bef7e2da007414a9503cedb6b0b 100644 (file)
@@ -165,7 +165,7 @@ u32           nlmsvc_cancel_blocked(struct nlm_file *, struct nlm_lock *);
 unsigned long    nlmsvc_retry_blocked(void);
 int              nlmsvc_traverse_blocks(struct nlm_host *, struct nlm_file *,
                                        int action);
-void     nlmsvc_grant_reply(struct nlm_cookie *cookie, u32 status);
+void     nlmsvc_grant_reply(struct svc_rqst *, struct nlm_cookie *, u32);
 
 /*
  * File handling for the server personality