aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWeston Andros Adamson <dros@netapp.com>2012-03-06 20:46:43 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-03-07 10:34:07 -0500
commitd8e0539ebdff5ff27fa7eb019715d9dfb5171a3b (patch)
treec85febe66a9527be703fd82fd9e017df740364b3
parentff2eb6818d0d5b2691c112f51c539a817fcc59fc (diff)
NFS: add filehandle crc for debug display
Match wireshark's CRC-32 hash for easier debugging Signed-off-by: Weston Andros Adamson <dros@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/inode.c23
-rw-r--r--include/linux/nfs_fs.h8
2 files changed, 28 insertions, 3 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index ba03b7908149..0337554f1561 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -39,6 +39,7 @@
39#include <linux/slab.h> 39#include <linux/slab.h>
40#include <linux/compat.h> 40#include <linux/compat.h>
41#include <linux/freezer.h> 41#include <linux/freezer.h>
42#include <linux/crc32.h>
42 43
43#include <asm/system.h> 44#include <asm/system.h>
44#include <asm/uaccess.h> 45#include <asm/uaccess.h>
@@ -1045,7 +1046,23 @@ struct nfs_fh *nfs_alloc_fhandle(void)
1045 return fh; 1046 return fh;
1046} 1047}
1047 1048
1048/** 1049#ifdef RPC_DEBUG
1050/*
1051 * _nfs_display_fhandle_hash - calculate the crc32 hash for the filehandle
1052 * in the same way that wireshark does
1053 *
1054 * @fh: file handle
1055 *
1056 * For debugging only.
1057 */
1058u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh)
1059{
1060 /* wireshark uses 32-bit AUTODIN crc and does a bitwise
1061 * not on the result */
1062 return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size);
1063}
1064
1065/*
1049 * _nfs_display_fhandle - display an NFS file handle on the console 1066 * _nfs_display_fhandle - display an NFS file handle on the console
1050 * 1067 *
1051 * @fh: file handle to display 1068 * @fh: file handle to display
@@ -1053,7 +1070,6 @@ struct nfs_fh *nfs_alloc_fhandle(void)
1053 * 1070 *
1054 * For debugging only. 1071 * For debugging only.
1055 */ 1072 */
1056#ifdef RPC_DEBUG
1057void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption) 1073void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
1058{ 1074{
1059 unsigned short i; 1075 unsigned short i;
@@ -1063,7 +1079,8 @@ void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
1063 return; 1079 return;
1064 } 1080 }
1065 1081
1066 printk(KERN_DEFAULT "%s at %p is %u bytes:\n", caption, fh, fh->size); 1082 printk(KERN_DEFAULT "%s at %p is %u bytes, crc: 0x%08x:\n",
1083 caption, fh, fh->size, _nfs_display_fhandle_hash(fh));
1067 for (i = 0; i < fh->size; i += 16) { 1084 for (i = 0; i < fh->size; i += 16) {
1068 __be32 *pos = (__be32 *)&fh->data[i]; 1085 __be32 *pos = (__be32 *)&fh->data[i];
1069 1086
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index c07a757649dc..ce8e4361ad14 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -396,6 +396,11 @@ static inline void nfs_free_fhandle(const struct nfs_fh *fh)
396} 396}
397 397
398#ifdef RPC_DEBUG 398#ifdef RPC_DEBUG
399extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
400static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
401{
402 return _nfs_display_fhandle_hash(fh);
403}
399extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption); 404extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
400#define nfs_display_fhandle(fh, caption) \ 405#define nfs_display_fhandle(fh, caption) \
401 do { \ 406 do { \
@@ -403,6 +408,9 @@ extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
403 _nfs_display_fhandle(fh, caption); \ 408 _nfs_display_fhandle(fh, caption); \
404 } while (0) 409 } while (0)
405#else 410#else
411static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
412{
413}
406static inline void nfs_display_fhandle(const struct nfs_fh *fh, 414static inline void nfs_display_fhandle(const struct nfs_fh *fh,
407 const char *caption) 415 const char *caption)
408{ 416{