aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-12 16:06:31 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-08-22 08:58:16 -0400
commit1264a2f053a32376696e51184f086d35113e75ff (patch)
tree3753683f3c47273e616c4221faf2eba7829ace89
parentc2dd1378fa3b52ab1705f1ce0bd46d1b91eb1d58 (diff)
NFS: refactor code for calculating the crc32 hash of a filehandle
We want to be able to display the crc32 hash of the filehandle in tracepoints. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/inode.c3
-rw-r--r--fs/nfs/internal.h20
2 files changed, 21 insertions, 2 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index af6e806044d7..9a98b04c4445 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -38,7 +38,6 @@
38#include <linux/slab.h> 38#include <linux/slab.h>
39#include <linux/compat.h> 39#include <linux/compat.h>
40#include <linux/freezer.h> 40#include <linux/freezer.h>
41#include <linux/crc32.h>
42 41
43#include <asm/uaccess.h> 42#include <asm/uaccess.h>
44 43
@@ -1190,7 +1189,7 @@ u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh)
1190{ 1189{
1191 /* wireshark uses 32-bit AUTODIN crc and does a bitwise 1190 /* wireshark uses 32-bit AUTODIN crc and does a bitwise
1192 * not on the result */ 1191 * not on the result */
1193 return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size); 1192 return nfs_fhandle_hash(fh);
1194} 1193}
1195 1194
1196/* 1195/*
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 9b694f1e06c5..50f7068903b9 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -5,6 +5,7 @@
5#include "nfs4_fs.h" 5#include "nfs4_fs.h"
6#include <linux/mount.h> 6#include <linux/mount.h>
7#include <linux/security.h> 7#include <linux/security.h>
8#include <linux/crc32.h>
8 9
9#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS) 10#define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS)
10 11
@@ -574,3 +575,22 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts)
574{ 575{
575 return ((u64)ts->tv_sec << 30) + ts->tv_nsec; 576 return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
576} 577}
578
579#ifdef CONFIG_CRC32
580/**
581 * nfs_fhandle_hash - calculate the crc32 hash for the filehandle
582 * @fh - pointer to filehandle
583 *
584 * returns a crc32 hash for the filehandle that is compatible with
585 * the one displayed by "wireshark".
586 */
587static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
588{
589 return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
590}
591#else
592static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
593{
594 return 0;
595}
596#endif