Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] NFS: add filehandle crc for debug display
@ 2012-03-07  1:46 Weston Andros Adamson
  2012-03-20 13:53 ` Bryan Schumaker
  0 siblings, 1 reply; 3+ messages in thread
From: Weston Andros Adamson @ 2012-03-07  1:46 UTC (permalink / raw)
  To: Trond.Myklebust; +Cc: chuck.lever, linux-nfs, Weston Andros Adamson

Match wireshark's CRC-32 hash for easier debugging

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
---
Reposted with Trond's suggestion of splitting out hash calculation to a 
separate function.  Now dprintks can use a fh's CRC instead of the 
multiline nfs_display_fhandle() when it makes sense.

 fs/nfs/inode.c         |   23 ++++++++++++++++++++---
 include/linux/nfs_fs.h |    8 ++++++++
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 99a4f52..3919ceb 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>
@@ -1045,7 +1046,23 @@ struct nfs_fh *nfs_alloc_fhandle(void)
 	return fh;
 }
 
-/**
+#ifdef RPC_DEBUG
+/*
+ * _nfs_display_fhandle_hash - calculate the crc32 hash for the filehandle
+ *                             in the same way that wireshark does
+ *
+ * @fh: file handle
+ *
+ * For debugging only.
+ */
+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);
+}
+
+/*
  * _nfs_display_fhandle - display an NFS file handle on the console
  *
  * @fh: file handle to display
@@ -1053,7 +1070,6 @@ struct nfs_fh *nfs_alloc_fhandle(void)
  *
  * For debugging only.
  */
-#ifdef RPC_DEBUG
 void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
 {
 	unsigned short i;
@@ -1063,7 +1079,8 @@ void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
 		return;
 	}
 
-	printk(KERN_DEFAULT "%s at %p is %u bytes:\n", caption, fh, fh->size);
+	printk(KERN_DEFAULT "%s at %p is %u bytes, crc: 0x%08x:\n",
+	       caption, fh, fh->size, _nfs_display_fhandle_hash(fh));
 	for (i = 0; i < fh->size; i += 16) {
 		__be32 *pos = (__be32 *)&fh->data[i];
 
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index c07a757..ce8e436 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)
 }
 
 #ifdef RPC_DEBUG
+extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
+static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
+{
+	return _nfs_display_fhandle_hash(fh);
+}
 extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
 #define nfs_display_fhandle(fh, caption)			\
 	do {							\
@@ -403,6 +408,9 @@ extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
 			_nfs_display_fhandle(fh, caption);	\
 	} while (0)
 #else
+static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
+{
+}
 static inline void nfs_display_fhandle(const struct nfs_fh *fh,
 				       const char *caption)
 {
-- 
1.7.4.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFS: add filehandle crc for debug display
  2012-03-07  1:46 [PATCH] NFS: add filehandle crc for debug display Weston Andros Adamson
@ 2012-03-20 13:53 ` Bryan Schumaker
  2012-03-20 13:55   ` Myklebust, Trond
  0 siblings, 1 reply; 3+ messages in thread
From: Bryan Schumaker @ 2012-03-20 13:53 UTC (permalink / raw)
  To: Weston Andros Adamson; +Cc: Trond.Myklebust, chuck.lever, linux-nfs

Hi Dros,

On 03/06/2012 08:46 PM, Weston Andros Adamson wrote:

> Match wireshark's CRC-32 hash for easier debugging
> 
> Signed-off-by: Weston Andros Adamson <dros@netapp.com>
> ---
> Reposted with Trond's suggestion of splitting out hash calculation to a 
> separate function.  Now dprintks can use a fh's CRC instead of the 
> multiline nfs_display_fhandle() when it makes sense.
> 
>  fs/nfs/inode.c         |   23 ++++++++++++++++++++---
>  include/linux/nfs_fs.h |    8 ++++++++
>  2 files changed, 28 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 99a4f52..3919ceb 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>
> @@ -1045,7 +1046,23 @@ struct nfs_fh *nfs_alloc_fhandle(void)
>  	return fh;
>  }
>  
> -/**
> +#ifdef RPC_DEBUG
> +/*
> + * _nfs_display_fhandle_hash - calculate the crc32 hash for the filehandle
> + *                             in the same way that wireshark does
> + *
> + * @fh: file handle
> + *
> + * For debugging only.
> + */
> +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);
> +}
> +
> +/*
>   * _nfs_display_fhandle - display an NFS file handle on the console
>   *
>   * @fh: file handle to display
> @@ -1053,7 +1070,6 @@ struct nfs_fh *nfs_alloc_fhandle(void)
>   *
>   * For debugging only.
>   */
> -#ifdef RPC_DEBUG
>  void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
>  {
>  	unsigned short i;
> @@ -1063,7 +1079,8 @@ void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption)
>  		return;
>  	}
>  
> -	printk(KERN_DEFAULT "%s at %p is %u bytes:\n", caption, fh, fh->size);
> +	printk(KERN_DEFAULT "%s at %p is %u bytes, crc: 0x%08x:\n",
> +	       caption, fh, fh->size, _nfs_display_fhandle_hash(fh));
>  	for (i = 0; i < fh->size; i += 16) {
>  		__be32 *pos = (__be32 *)&fh->data[i];
>  
> diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
> index c07a757..ce8e436 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)
>  }
>  
>  #ifdef RPC_DEBUG
> +extern u32 _nfs_display_fhandle_hash(const struct nfs_fh *fh);
> +static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
> +{
> +	return _nfs_display_fhandle_hash(fh);
> +}
>  extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
>  #define nfs_display_fhandle(fh, caption)			\
>  	do {							\
> @@ -403,6 +408,9 @@ extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption);
>  			_nfs_display_fhandle(fh, caption);	\
>  	} while (0)
>  #else
> +static inline u32 nfs_display_fhandle_hash(const struct nfs_fh *fh)
> +{


This function should return something... maybe 0?

- Bryan

> +}
>  static inline void nfs_display_fhandle(const struct nfs_fh *fh,
>  				       const char *caption)
>  {



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] NFS: add filehandle crc for debug display
  2012-03-20 13:53 ` Bryan Schumaker
@ 2012-03-20 13:55   ` Myklebust, Trond
  0 siblings, 0 replies; 3+ messages in thread
From: Myklebust, Trond @ 2012-03-20 13:55 UTC (permalink / raw)
  To: Schumaker, Bryan
  Cc: Adamson, Dros, chuck.lever@oracle.com, linux-nfs@vger.kernel.org

T24gVHVlLCAyMDEyLTAzLTIwIGF0IDA5OjUzIC0wNDAwLCBCcnlhbiBTY2h1bWFrZXIgd3JvdGU6
DQo+IEhpIERyb3MsDQo+IA0KPiBPbiAwMy8wNi8yMDEyIDA4OjQ2IFBNLCBXZXN0b24gQW5kcm9z
IEFkYW1zb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WxlICgwKQ0KPiA+ICAjZWxzZQ0KPiA+ICtzdGF0aWMgaW5saW5lIHUzMiBuZnNfZGlzcGxh
eV9maGFuZGxlX2hhc2goY29uc3Qgc3RydWN0IG5mc19maCAqZmgpDQo+ID4gK3sNCj4gDQo+IA0K
PiBUaGlzIGZ1bmN0aW9uIHNob3VsZCByZXR1cm4gc29tZXRoaW5nLi4uIG1heWJlIDA/DQo+IA0K
PiAtIEJyeWFuDQo+IA0KPiA+ICt9DQo+ID4gIHN0YXRpYyBpbmxpbmUgdm9pZCBuZnNfZGlzcGxh
eV9maGFuZGxlKGNvbnN0IHN0cnVjdCBuZnNfZmggKmZoLA0KPiA+ICAJCQkJICAgICAgIGNvbnN0
IGNoYXIgKmNhcHRpb24pDQo+ID4gIHsNCj4gDQoNClllcy4gU3RlcGhlbiBSb3Rod2VsbCBwb2lu
dGVkIG91dCB0aGUgc2FtZSwgYW5kIHNvIEkndmUgYXBwbGllZCBoaXMNCnBhdGNoIHRvIHRoZSAn
dGVzdGluZycgYnJhbmNoIGFscmVhZHkuDQoNCkhlIGFsc28gZm91bmQgYSBidW5jaCBvZiAnc3Ry
dWN0IHJwY190YXNrJyBpbiB0aGUgc3VucnBjIGFuZCBsb2NrZCBjb2RlDQp0aGF0IHdlcmUgbWFy
a2VkIGFzICd1bnVzZWQgdmFyaWFibGUnLCBhbmQgc28gdGhlcmUgaXMgYSBwYXRjaCB0byBmaXgN
CnRoYXQgdG9vLi4uDQoNCi0tIA0KVHJvbmQgTXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1h
aW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5NeWtsZWJ1c3RAbmV0YXBwLmNvbQ0Kd3d3Lm5ldGFw
cC5jb20NCg0K

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-20 13:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07  1:46 [PATCH] NFS: add filehandle crc for debug display Weston Andros Adamson
2012-03-20 13:53 ` Bryan Schumaker
2012-03-20 13:55   ` Myklebust, Trond

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox