From patchwork Mon May 9 19:37:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 770402 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p49JZt5x031503 for ; Mon, 9 May 2011 19:37:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754135Ab1EIThN (ORCPT ); Mon, 9 May 2011 15:37:13 -0400 Received: from mail-yx0-f174.google.com ([209.85.213.174]:58964 "EHLO mail-yx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754072Ab1EIThM (ORCPT ); Mon, 9 May 2011 15:37:12 -0400 Received: by mail-yx0-f174.google.com with SMTP id 7so1914279yxs.19 for ; Mon, 09 May 2011 12:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:from:subject:to:cc:date:message-id :in-reply-to:references:user-agent:mime-version:content-type :content-transfer-encoding; bh=oeKUEk5iLIsfilrqxaqfe5db9HV+LlgRS7AY2hHzacI=; b=A4gb+80PdWRIECGO88YmwhVyFD0CPjMrmqC95XEdn1fvApyf2G5altTzJQwDVeYD3O yRQCPMk/B9eM77V9IvxGumtgh09FpCXpkNbMBoAMgfqOVFTBKjKE/yJ0Od2JPb4ftX2R jrn0JNHJiufr9+N8ntl9GE5JZi/9dBeyxH7rw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:from:subject:to:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding; b=XEjz5qY3+e6sNlO2XcwWtPsVzfVTLEiYItDfr5OuFHJufiLEgmgYwQ35xX5DcA8mCs /s94SM+6o0J9G3P1J/l43dHl6wRVFXlXEnoKYai9iZigiZ8K2IEuU3+Xmx/wgFOA6XOA 8K8UdAl43muc7JPWEKg6evFnKasm9n7Xh+Fyo= Received: by 10.101.81.4 with SMTP id i4mr2094557anl.15.1304969832533; Mon, 09 May 2011 12:37:12 -0700 (PDT) Received: from matisse.1015granger.net (adsl-99-26-161-222.dsl.sfldmi.sbcglobal.net [99.26.161.222]) by mx.google.com with ESMTPS id v1sm6639038anh.25.2011.05.09.12.37.11 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 09 May 2011 12:37:11 -0700 (PDT) From: Chuck Lever Subject: [PATCH 06/16] NFS: Add a client-side function to display file handles To: trond.myklebust@netapp.com Cc: linux-nfs@vger.kernel.org Date: Mon, 09 May 2011 15:37:10 -0400 Message-ID: <20110509193710.16568.68115.stgit@matisse.1015granger.net> In-Reply-To: <20110509192522.16568.59082.stgit@matisse.1015granger.net> References: <20110509192522.16568.59082.stgit@matisse.1015granger.net> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 09 May 2011 19:37:14 +0000 (UTC) For debugging, introduce a simplistic function to print file handles on the system console. It's hooked into the dprintk debugging facility, but you can call _nfs_display_fhandle() directly if you want to print a handle unconditionally. Signed-off-by: Chuck Lever --- fs/nfs/inode.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ include/linux/nfs_fs.h | 14 ++++++++++++++ 2 files changed, 59 insertions(+), 0 deletions(-) -- 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 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 57bb31a..9a444d0 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -1039,6 +1039,51 @@ struct nfs_fh *nfs_alloc_fhandle(void) } /** + * _nfs_display_fhandle - display an NFS file handle on the console + * + * @fh: file handle to display + * @caption: display caption + * + * For debugging only. + */ +#ifdef RPC_DEBUG +void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption) +{ + unsigned short i; + + if (fh->size == 0 || fh == NULL) { + printk(KERN_NOTICE "%s at %p is empty\n", caption, fh); + return; + } + + printk(KERN_NOTICE "%s at %p is %u bytes:\n", caption, fh, fh->size); + for (i = 0; i < fh->size; i += 16) { + __be32 *pos = (__be32 *)&fh->data[i]; + + switch ((fh->size - i - 1) >> 2) { + case 0: + printk(KERN_NOTICE " %08x", + be32_to_cpup(pos)); + break; + case 1: + printk(KERN_NOTICE " %08x %08x\n", + be32_to_cpup(pos), be32_to_cpup(pos + 1)); + break; + case 2: + printk(KERN_NOTICE " %08x %08x %08x\n", + be32_to_cpup(pos), be32_to_cpup(pos + 1), + be32_to_cpup(pos + 2)); + break; + default: + printk(KERN_NOTICE " %08x %08x %08x %08x\n", + be32_to_cpup(pos), be32_to_cpup(pos + 1), + be32_to_cpup(pos + 2), be32_to_cpup(pos + 3)); + } + } +} +#endif + +/** * nfs_inode_attrs_need_update - check if the inode attributes need updating * @inode - pointer to inode * @fattr - attributes diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h index 1b93b9c..0e3eb70 100644 --- a/include/linux/nfs_fs.h +++ b/include/linux/nfs_fs.h @@ -394,6 +394,20 @@ static inline void nfs_free_fhandle(const struct nfs_fh *fh) kfree(fh); } +#ifdef RPC_DEBUG +extern void _nfs_display_fhandle(const struct nfs_fh *fh, const char *caption); +#define nfs_display_fhandle(fh, caption) \ + do { \ + if (unlikely(nfs_debug & NFSDBG_FACILITY)) \ + _nfs_display_fhandle(fh, caption); \ + } while (0) +#else +static inline void nfs_display_fhandle(const struct nfs_fh *fh, + const char *caption) +{ +} +#endif + /* * linux/fs/nfs/nfsroot.c */