From fc29938dabf736b88f7f2ae3e18efbb01b1fbcb8 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Tue, 19 Oct 2004 18:40:45 -0700 Subject: [PATCH] lockd: remove hardcoded maximum NLM cookie length At the moment, the NLM cookie length is fixed to 8 bytes, while 1024 is the theoretical maximum. FreeBSD uses 16 bytes, Mac OS X uses 20 bytes. Therefore we need to make the length dynamic (which I set to 32 bytes). This patch is based on an old patch for Linux 2.4.23-pre9, which I changed to patch properly (also added some stylish NIPQUAD fixes). From: Neil Brown Further lockd tidyups. - NIPQUAD everywhere that is appropriate - use XDR_QUADLEN in more places as appropriate - discard QUADLEN which is a lockd-specific version of XDR_QUADLEN Signed-off-by: Neil Brown Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/lockd/debug.h | 9 +++++++++ include/linux/lockd/xdr.h | 10 +++++----- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'include/linux') diff --git a/include/linux/lockd/debug.h b/include/linux/lockd/debug.h index 5b6961d739d4..34b2b7f33c3b 100644 --- a/include/linux/lockd/debug.h +++ b/include/linux/lockd/debug.h @@ -45,4 +45,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 */ diff --git a/include/linux/lockd/xdr.h b/include/linux/lockd/xdr.h index ef14dbd2a67c..d7a5cc4cfa97 100644 --- a/include/linux/lockd/xdr.h +++ b/include/linux/lockd/xdr.h @@ -13,10 +13,9 @@ #include #include +#define NLM_MAXCOOKIELEN 32 #define NLM_MAXSTRLEN 1024 -#define QUADLEN(len) (((len) + 3) >> 2) - #define nlm_granted __constant_htonl(NLM_LCK_GRANTED) #define nlm_lck_denied __constant_htonl(NLM_LCK_DENIED) #define nlm_lck_denied_nolocks __constant_htonl(NLM_LCK_DENIED_NOLOCKS) @@ -33,13 +32,14 @@ struct nlm_lock { }; /* - * NLM cookies. Technically they can be 1K, Nobody uses over 8 bytes - * however. + * NLM cookies. Technically they can be 1K, but Linux only uses 8 bytes. + * FreeBSD uses 16, Apple Mac OS X 10.3 uses 20. Therefore we set it to + * 32 bytes. */ struct nlm_cookie { - unsigned char data[8]; + unsigned char data[NLM_MAXCOOKIELEN]; unsigned int len; }; -- cgit v1.2.3