--- linux/fs/lockd/svclock.c_1.11 Wed Nov 5 16:38:26 2003 +++ linux/fs/lockd/svclock.c Wed Nov 5 16:35:39 2003 @@ -113,11 +113,11 @@ (long long)lock->fl.fl_end, lock->fl.fl_type); for (head = &nlm_blocked; (block = *head); head = &block->b_next) { fl = &block->b_call.a_args.lock.fl; - dprintk("lockd: check f=%p pd=%d %Ld-%Ld ty=%d cookie=%x\n", + dprintk("lockd: check f=%p pd=%d %Ld-%Ld ty=%d cookie=%s\n", block->b_file, fl->fl_pid, (long long)fl->fl_start, (long long)fl->fl_end, fl->fl_type, - *(unsigned int*)(block->b_call.a_args.cookie.data)); + nlmdbg_cookie2a(&block->b_call.a_args.cookie)); if (block->b_file == file && nlm_compare_locks(fl, &lock->fl)) { if (remove) { *head = block->b_next; @@ -574,10 +574,10 @@ unsigned long timeout; dprintk("lockd: GRANT_MSG RPC callback\n"); - dprintk("callback: looking for cookie %x \n", - *(unsigned int *)(call->a_args.cookie.data)); + dprintk("callback: looking for cookie %s \n", + nlmdbg_cookie2a(&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)); + dprintk("lockd: no block for cookie %s\n", nlmdbg_cookie2a(&call->a_args.cookie)); return; } --- linux/fs/lockd/xdr.c_1.12 Wed Nov 5 16:38:26 2003 +++ linux/fs/lockd/xdr.c Wed Nov 5 16:35:39 2003 @@ -55,7 +55,7 @@ c->len=4; memset(c->data, 0, 4); /* hockeypux brain damage */ } - else if(len<=8) + else if(len<=NLM_MAXCOOKIELEN) { c->len=len; memcpy(c->data, p, len); @@ -64,7 +64,7 @@ else { printk(KERN_NOTICE - "lockd: bad cookie size %d (only cookies under 8 bytes are supported.)\n", len); + "lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN); return NULL; } return p; @@ -86,7 +86,7 @@ if ((len = ntohl(*p++)) != NFS2_FHSIZE) { printk(KERN_NOTICE - "lockd: bad fhandle size %x (should be %d)\n", + "lockd: bad fhandle size %d (should be %d)\n", len, NFS2_FHSIZE); return NULL; } @@ -534,7 +534,7 @@ * Buffer requirements for NLM */ #define NLM_void_sz 0 -#define NLM_cookie_sz 3 /* 1 len , 2 data */ +#define NLM_cookie_sz 1+QUADLEN(NLM_MAXCOOKIELEN) #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) */ @@ -643,3 +643,32 @@ } #endif +#ifdef RPC_DEBUG +const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie) +{ + /* + * We can get away with a static buffer because we're only + * called with BKL held. + */ + static char buf[2*NLM_MAXCOOKIELEN+1]; + int i; + int len = sizeof(buf); + char *p = buf; + + len--; /* allow for trailing \0 */ + if (len < 3) + return "???"; + for (i = 0 ; i < cookie->len ; i++) { + if (len < 2) { + strcpy(p-3, "..."); + break; + } + sprintf(p, "%02x", cookie->data[i]); + p += 2; + len -= 2; + } + *p = '\0'; + + return buf; +} +#endif --- linux/fs/lockd/xdr4.c_1.8 Wed Nov 5 16:38:26 2003 +++ linux/fs/lockd/xdr4.c Wed Nov 5 16:35:39 2003 @@ -56,7 +56,7 @@ c->len=4; memset(c->data, 0, 4); /* hockeypux brain damage */ } - else if(len<=8) + else if(len<=NLM_MAXCOOKIELEN) { c->len=len; memcpy(c->data, p, len); @@ -65,7 +65,7 @@ else { printk(KERN_NOTICE - "lockd: bad cookie size %d (only cookies under 8 bytes are supported.)\n", len); + "lockd: bad cookie size %d (only cookies under %d bytes are supported.)\n", len, NLM_MAXCOOKIELEN); return NULL; } return p; @@ -540,7 +540,7 @@ * Buffer requirements for NLM */ #define NLM4_void_sz 0 -#define NLM4_cookie_sz 3 /* 1 len , 2 data */ +#define NLM4_cookie_sz 1+XDR_QUADLEN(NLM_MAXCOOKIELEN) #define NLM4_caller_sz 1+XDR_QUADLEN(NLM_MAXSTRLEN) #define NLM4_netobj_sz 1+XDR_QUADLEN(XDR_MAX_NETOBJ) /* #define NLM4_owner_sz 1+XDR_QUADLEN(NLM4_MAXOWNER) */ --- linux/include/linux/lockd/debug.h_1.3 Wed Nov 5 16:38:26 2003 +++ linux/include/linux/lockd/debug.h Wed Nov 5 16:35:39 2003 @@ -49,4 +49,13 @@ #define NLMDBG_ALL 0x7fff +/* + * Support for printing NLM cookies in dprintk() + */ +#ifdef RPC_DEBUG +struct nlm_cookie; +/* Call this function with the BKL held (it uses a static buffer) */ +extern const char *nlmdbg_cookie2a(const struct nlm_cookie *); +#endif + #endif /* LINUX_LOCKD_DEBUG_H */ --- linux/include/linux/lockd/xdr.h_1.4 Wed Nov 5 16:38:26 2003 +++ linux/include/linux/lockd/xdr.h Wed Nov 5 16:35:39 2003 @@ -33,14 +33,15 @@ }; /* - * NLM cookies. Technically they can be 1K, Nobody uses over 8 bytes - * however. + * NLM cookies. Technically they can be 1K, Few people use over 8 bytes, + * FreeBSD uses 16, Apple Mac OS-X 10.3 uses 20. */ struct nlm_cookie { - unsigned char data[8]; unsigned int len; +#define NLM_MAXCOOKIELEN 32 + unsigned char data[NLM_MAXCOOKIELEN]; }; /*