Re: [PATCH] NFS: add crc hash to nfs_display_fhandle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2012-03-06 at 18:17 -0500, Weston Andros Adamson wrote:
> Match wireshark's CRC-32 hash for easier debugging.
> 
> Signed-off-by: Weston Andros Adamson <dros@xxxxxxxxxx>
> ---
> Requested by Chuck and others.
> 
> Nothing in trond/nfs-for-next uses nfs_display_fhandle() yet.
> I tested by calling it in nfs4xdr.c:encode_putfh().
> 
>  fs/nfs/inode.c |    8 +++++++-
>  1 files changed, 7 insertions(+), 1 deletions(-)
> 
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 99a4f52..c1f44e9 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -39,6 +39,7 @@
>  #include <linux/slab.h>
>  #include <linux/compat.h>
>  #include <linux/freezer.h>
> +#include <linux/crc32.h>
>  
>  #include <asm/system.h>
>  #include <asm/uaccess.h>
> @@ -1057,13 +1058,18 @@ struct nfs_fh *nfs_alloc_fhandle(void)
>  void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
>  {
>  	unsigned short i;
> +	u32 crc;
>  
>  	if (fh->size == 0 || fh == NULL) {
>  		printk(KERN_DEFAULT "%s at %p is empty\n", caption, fh);
>  		return;
>  	}
>  
> -	printk(KERN_DEFAULT "%s at %p is %u bytes:\n", caption, fh, fh->size);
> +	/* match wireshark's CRC-32 hash */
> +	crc = ~crc32(0xFFFFFFFF, &fh->data[0], fh->size);
> +
> +	printk(KERN_DEFAULT "%s at %p is %u bytes, crc: 0x%08x:\n",
> +	                    caption, fh, fh->size, crc);
>  	for (i = 0; i < fh->size; i += 16) {
>  		__be32 *pos = (__be32 *)&fh->data[i];
Could we split this into 2 functions:

nfs_display_fhandle_hash() and nfs_display_fhandle(), with the latter
calling the former?

That will allow us to select both a short form and a full form. I can
see the former being used in something like nfs_fhget(), or the
revalidation functions, while the latter would be useful in
*_proc_lookup() or nfs_instantiate()...

-- 
Trond Myklebust
Linux NFS client maintainer

NetApp
Trond.Myklebust@xxxxxxxxxx
www.netapp.com

��.n��������+%������w��{.n�����{��w���jg��������ݢj����G�������j:+v���w�m������w�������h�����٥



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux