Message ID | 1376418952-12481-2-git-send-email-Trond.Myklebust@netapp.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
I think I was the last one to touch this. On Aug 13, 2013, at 2:35 PM, Trond Myklebust <Trond.Myklebust@netapp.com> wrote: > We want to be able to display the crc32 hash of the filehandle in > tracepoints. > > Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> > --- > fs/nfs/inode.c | 3 +-- > fs/nfs/internal.h | 20 ++++++++++++++++++++ > 2 files changed, 21 insertions(+), 2 deletions(-) > > diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c > index af6e806..9a98b04 100644 > --- a/fs/nfs/inode.c > +++ b/fs/nfs/inode.c > @@ -38,7 +38,6 @@ > #include <linux/slab.h> > #include <linux/compat.h> > #include <linux/freezer.h> > -#include <linux/crc32.h> > > #include <asm/uaccess.h> > > @@ -1190,7 +1189,7 @@ u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh) > { > /* wireshark uses 32-bit AUTODIN crc and does a bitwise > * not on the result */ > - return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size); > + return nfs_fhandle_hash(fh); > } > > /* > diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h > index 9b694f1..50f7068 100644 > --- a/fs/nfs/internal.h > +++ b/fs/nfs/internal.h > @@ -5,6 +5,7 @@ > #include "nfs4_fs.h" > #include <linux/mount.h> > #include <linux/security.h> > +#include <linux/crc32.h> > > #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS) > > @@ -574,3 +575,22 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts) > { > return ((u64)ts->tv_sec << 30) + ts->tv_nsec; > } > + > +#ifdef CONFIG_CRC32 Good catch! > +/** > + * nfs_fhandle_hash - calculate the crc32 hash for the filehandle > + * @fh - pointer to filehandle > + * > + * returns a crc32 hash for the filehandle that is compatible with > + * the one displayed by "wireshark". > + */ > +static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) > +{ > + return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size); Why the change to crc32_le? Is that what wireshark does? I don't remember exactly what I found when I looked at how wireshark made FH hashes. -dros > +} > +#else > +static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) > +{ > + return 0; > +} > +#endif > -- > 1.8.3.1 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Tue, 2013-08-13 at 19:52 +0000, Adamson, Dros wrote: > I think I was the last one to touch this. > > On Aug 13, 2013, at 2:35 PM, Trond Myklebust <Trond.Myklebust@netapp.com> wrote: > > > We want to be able to display the crc32 hash of the filehandle in > > tracepoints. > > > > Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> > > --- > > fs/nfs/inode.c | 3 +-- > > fs/nfs/internal.h | 20 ++++++++++++++++++++ > > 2 files changed, 21 insertions(+), 2 deletions(-) > > > > diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c > > index af6e806..9a98b04 100644 > > --- a/fs/nfs/inode.c > > +++ b/fs/nfs/inode.c > > @@ -38,7 +38,6 @@ > > #include <linux/slab.h> > > #include <linux/compat.h> > > #include <linux/freezer.h> > > -#include <linux/crc32.h> > > > > #include <asm/uaccess.h> > > > > @@ -1190,7 +1189,7 @@ u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh) > > { > > /* wireshark uses 32-bit AUTODIN crc and does a bitwise > > * not on the result */ > > - return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size); > > + return nfs_fhandle_hash(fh); > > } > > > > /* > > diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h > > index 9b694f1..50f7068 100644 > > --- a/fs/nfs/internal.h > > +++ b/fs/nfs/internal.h > > @@ -5,6 +5,7 @@ > > #include "nfs4_fs.h" > > #include <linux/mount.h> > > #include <linux/security.h> > > +#include <linux/crc32.h> > > > > #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS) > > > > @@ -574,3 +575,22 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts) > > { > > return ((u64)ts->tv_sec << 30) + ts->tv_nsec; > > } > > + > > +#ifdef CONFIG_CRC32 > > Good catch! > > > +/** > > + * nfs_fhandle_hash - calculate the crc32 hash for the filehandle > > + * @fh - pointer to filehandle > > + * > > + * returns a crc32 hash for the filehandle that is compatible with > > + * the one displayed by "wireshark". > > + */ > > +static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) > > +{ > > + return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size); > > Why the change to crc32_le? Is that what wireshark does? I don't remember exactly what I found when I looked at how wireshark made FH hashes. > > -dros If you look inside include/linux/crc32.h, you'll see that crc32 is just a macro that expands to a call to the function crc32_le(). So all I've done is to expand the macro. Cheers Trond -- Trond Myklebust Linux NFS client maintainer NetApp Trond.Myklebust@netapp.com www.netapp.com
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index af6e806..9a98b04 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -38,7 +38,6 @@ #include <linux/slab.h> #include <linux/compat.h> #include <linux/freezer.h> -#include <linux/crc32.h> #include <asm/uaccess.h> @@ -1190,7 +1189,7 @@ u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh) { /* wireshark uses 32-bit AUTODIN crc and does a bitwise * not on the result */ - return ~crc32(0xFFFFFFFF, &fh->data[0], fh->size); + return nfs_fhandle_hash(fh); } /* diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 9b694f1..50f7068 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -5,6 +5,7 @@ #include "nfs4_fs.h" #include <linux/mount.h> #include <linux/security.h> +#include <linux/crc32.h> #define NFS_MS_MASK (MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOEXEC|MS_SYNCHRONOUS) @@ -574,3 +575,22 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts) { return ((u64)ts->tv_sec << 30) + ts->tv_nsec; } + +#ifdef CONFIG_CRC32 +/** + * nfs_fhandle_hash - calculate the crc32 hash for the filehandle + * @fh - pointer to filehandle + * + * returns a crc32 hash for the filehandle that is compatible with + * the one displayed by "wireshark". + */ +static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) +{ + return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size); +} +#else +static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh) +{ + return 0; +} +#endif
We want to be able to display the crc32 hash of the filehandle in tracepoints. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com> --- fs/nfs/inode.c | 3 +-- fs/nfs/internal.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)