Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1672565ybf; Sun, 1 Mar 2020 15:25:42 -0800 (PST) X-Google-Smtp-Source: ADFU+vs7pBv4fISyiOuppFUXjSq13fPQ760UI8wr1cz1JwWIKLqZ0qdV1MzF8/aEvxNa6F3XTt/G X-Received: by 2002:a9d:70d5:: with SMTP id w21mr4094805otj.65.1583105141879; Sun, 01 Mar 2020 15:25:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583105141; cv=none; d=google.com; s=arc-20160816; b=0RKVTqLVI1GcWaiC0+jrI5Nh+yUEeFjoVzMaspZ3Mo2yVKzbOdJd9Cc3hyM49dfGbr 2cLStN3WrEhH+aH2KEqeDvAOIwaWfkaQ8eQcH5egAOD8nVGobOR1/8P5wIQWzuCww3XE rQz2aHhIxWi7tp56UW+/wIhXQo2Uf1/gedl0TuIMU7RHLD2fRGgxJo5eLJAW6ZStwCgz Ib6lVdsrB7FELELdbSFrSAGNFPgvPDhmWqWebbfLep4zAodyFpuGtWLZXdFGqBgVwjdI 4dXW7arunicOjmJKWYKDpNdIo4fiMrznoQ+4NLHvzQX4GCxFjKxd9L/7fVIVC3XWOVGE J8/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ds3vP0pr/vApQsOppNkATvBSjNkIOcY6j7wOViIDBOE=; b=Tch/uT3kMaO3jFDT0KwMxZu9UGBzssdkNgGCzV2UZ1FtTT9oFlz1wefoNUJCirVssC XWtv5NIs8m6wH5QH0Ztnin3mdd98zP3BRXV5Rs8s9AfDfXt9YZifuowY9B+3axv7f3Rb fZNv0DjaBBJF8icdcVrZbhiWAoMAlAkoKhNfieoub9ojxeucdrjIcJgMCem8KpH/2mcR YrTDftNs/7p+EnYViT4pOypFBAssXJqP7SF7wAuQ3kHW+SyEL9iLfjxQ79X7iRofx1Zd UoGjm8KLeHUlqRXPMudWrRGkAwYkOo7mwnUiJ+a5fpF0ueb9IHQuZhX2O2I4/kHfAvff ddfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H26CeLc0; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d4si664266otp.214.2020.03.01.15.25.23; Sun, 01 Mar 2020 15:25:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=H26CeLc0; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726592AbgCAXZR (ORCPT + 99 others); Sun, 1 Mar 2020 18:25:17 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:43719 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgCAXZQ (ORCPT ); Sun, 1 Mar 2020 18:25:16 -0500 Received: by mail-yw1-f67.google.com with SMTP id u78so4672619ywf.10 for ; Sun, 01 Mar 2020 15:25:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ds3vP0pr/vApQsOppNkATvBSjNkIOcY6j7wOViIDBOE=; b=H26CeLc0sUsga0syMXZMYXJ92gaZFBIxooXue+sTXJvM5DSd8YLkpmU3qvU2nxU+2e KHwfdmv1EMPdfYMUUX78a0kDxkuHI6XOtNlzJz8ZotM3FcDtMSk9d+JDI4HPj2b6mMpI eBh2+P9wWHo/iTyZ0Cglmn2ZT8C7eTp1SluvLL0O+iiopipTfpXcUlWFYgiKbm02CIu0 M1vrMhalgdRaZ8TA/f1XEVL+KBUb6MEtRIJ+Q/XaF4pMwwz4j+Hd/2RKtrp9Kyr5zPyd KSA+xqRFcnnMMDsKUlVtTvRJkatg9FeIV6LUA55qiKmLKhNx84BA/oikh9X1pvig/N+D yw+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ds3vP0pr/vApQsOppNkATvBSjNkIOcY6j7wOViIDBOE=; b=PskLJIqy/IcBsElVCaPclJwWKbJxsh1BsSu9tIxhUZonxmZeb5/7qXFlqwmovewfRf o2UG8b9yFFPfQWV+v7l3SRwDlgdIzFoOZGBqPFBPsg2jWZFcXoGJVQw89QFlo1Y+0Bf8 DhsAe6KcmwgBv5wVOGzZ+a2RkHAAbhkgTOJzFbup5G6IBimliR3VFn6LV0chVNM/59nD OTRqzgKx/6FDAeE38LnELYFDfA5F6X39A/wBWGxI7zoG4NTblaoxkX6lQexN4ztnz1sF uvwkRJqvyoXVpeP7O/MCbjZKogXo6mTXJUq94XWrhc1IgUJXVxpTQxB8aJHegNG0Iqty 5r4A== X-Gm-Message-State: APjAAAUt7pHqNkBJiB5GM7qwfoZkDjTFVCYdhf0K/5Est7hfm9wsKTub J55MygE6odkXepaTYZfPnQ== X-Received: by 2002:a0d:ebc9:: with SMTP id u192mr14379842ywe.360.1583105115924; Sun, 01 Mar 2020 15:25:15 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id u4sm7167301ywu.26.2020.03.01.15.25.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Mar 2020 15:25:15 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: "J. Bruce Fields" Cc: linux-nfs@vger.kernel.org Subject: [PATCH 2/8] nfsd: Add tracing to nfsd_set_fh_dentry() Date: Sun, 1 Mar 2020 18:21:39 -0500 Message-Id: <20200301232145.1465430-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200301232145.1465430-2-trond.myklebust@hammerspace.com> References: <20200301232145.1465430-1-trond.myklebust@hammerspace.com> <20200301232145.1465430-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Add tracing to allow us to figure out where any stale filehandle issues may be originating from. Signed-off-by: Trond Myklebust --- fs/nfsd/nfsfh.c | 13 ++++++++++--- fs/nfsd/trace.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index b319080288c3..37bc8f5f4514 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -14,6 +14,7 @@ #include "nfsd.h" #include "vfs.h" #include "auth.h" +#include "trace.h" #define NFSDDBG_FACILITY NFSDDBG_FH @@ -209,11 +210,14 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) } error = nfserr_stale; - if (PTR_ERR(exp) == -ENOENT) - return error; + if (IS_ERR(exp)) { + trace_nfsd_set_fh_dentry_badexport(rqstp, fhp, PTR_ERR(exp)); + + if (PTR_ERR(exp) == -ENOENT) + return error; - if (IS_ERR(exp)) return nfserrno(PTR_ERR(exp)); + } if (exp->ex_flags & NFSEXP_NOSUBTREECHECK) { /* Elevate privileges so that the lack of 'r' or 'x' @@ -267,6 +271,9 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp) dentry = exportfs_decode_fh(exp->ex_path.mnt, fid, data_left, fileid_type, nfsd_acceptable, exp); + if (IS_ERR_OR_NULL(dentry)) + trace_nfsd_set_fh_dentry_badhandle(rqstp, fhp, + dentry ? PTR_ERR(dentry) : -ESTALE); } if (dentry == NULL) goto out; diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 06dd0d337049..9abd1591a841 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -50,6 +50,36 @@ TRACE_EVENT(nfsd_compound_status, __get_str(name), __entry->status) ) +DECLARE_EVENT_CLASS(nfsd_fh_err_class, + TP_PROTO(struct svc_rqst *rqstp, + struct svc_fh *fhp, + int status), + TP_ARGS(rqstp, fhp, status), + TP_STRUCT__entry( + __field(u32, xid) + __field(u32, fh_hash) + __field(int, status) + ), + TP_fast_assign( + __entry->xid = be32_to_cpu(rqstp->rq_xid); + __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle); + __entry->status = status; + ), + TP_printk("xid=0x%08x fh_hash=0x%08x status=%d", + __entry->xid, __entry->fh_hash, + __entry->status) +) + +#define DEFINE_NFSD_FH_ERR_EVENT(name) \ +DEFINE_EVENT(nfsd_fh_err_class, nfsd_##name, \ + TP_PROTO(struct svc_rqst *rqstp, \ + struct svc_fh *fhp, \ + int status), \ + TP_ARGS(rqstp, fhp, status)) + +DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badexport); +DEFINE_NFSD_FH_ERR_EVENT(set_fh_dentry_badhandle); + DECLARE_EVENT_CLASS(nfsd_io_class, TP_PROTO(struct svc_rqst *rqstp, struct svc_fh *fhp, -- 2.24.1