Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4774402rwb; Mon, 8 Aug 2022 06:55:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR4BlZyTjhsn0QSykhjKN7kFlJptXMYntc7I0O2oKZOOtdtLlaik0IY/tF0s4rU8u+pBUUyB X-Received: by 2002:a17:90b:3a8b:b0:1f5:2048:cbab with SMTP id om11-20020a17090b3a8b00b001f52048cbabmr20766325pjb.196.1659966925422; Mon, 08 Aug 2022 06:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659966925; cv=none; d=google.com; s=arc-20160816; b=Xs8MIss9IO0TYKQINWfKHiVx95IXBieX310AmKEkob3Q1w6JFzjItWgHMyKdvZ2Evt zMXAIyS7p3fbhIvlF7sf8i9i3msPL7YVfbC/iQZizu6Vel+/Cp8dO3eVGrEB+gxlOMnD SOW004iDDzlYi8dl0nc/iE00pO+JFCOsLqiIlYsXeHdFXTs+08TMXcevYbMyaAGnXG5G lh4ufdUS0fspSJDffR+HGvxBP4G5af7c09iAKn7531G0HMeL4WPGM0fuYofVRvJvx3ao oqczN/dTa9s3Iu3liOyHH5+jgKRZo52FCrWTJTZ+cnb73K2nJ+am4M2hWtJ3/AQH9Jdp uRgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject; bh=nN7W6qy7M+XWAjZkauwOBpqntEsVg+I9d3cMK2LI2Co=; b=rknVR/eFSTqa4epax5SFYasGSld19WuIWAcqPaEXRSkj1iuRLw3bskZyQMw4TgLPE8 wH7wb+eC+lL0FE/3vEaFjkGQgRXs7ARbgMuc9mafU6Uov5CQh9aw9dehGpJwvP3WLxEQ 0MXHhGsotuRXO7Y0RY2VDFfMtsMiWLmETY1QIQcjYk821C04BV167B6dDmb6QGWFu2p1 RrhiwXIhQJ0kl/imoIfXg/e8AO2fOIYMHzQcQlU/aSAjBzbzniJ/SLPm0e73ezuT97h/ KeLeNqtaV6l+n9FyngoHw6htlgpC25iFT2dpwBp0xZascKT9yMxIKezE2rwbV2hTkg7F v/4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y33-20020a634961000000b0041ccbc553d9si11629549pgk.485.2022.08.08.06.55.08; Mon, 08 Aug 2022 06:55:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232257AbiHHNwl (ORCPT + 99 others); Mon, 8 Aug 2022 09:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242879AbiHHNwj (ORCPT ); Mon, 8 Aug 2022 09:52:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A9CBE05 for ; Mon, 8 Aug 2022 06:52:38 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A9AF8B80E9C for ; Mon, 8 Aug 2022 13:52:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5861DC43470 for ; Mon, 8 Aug 2022 13:52:36 +0000 (UTC) Subject: [PATCH v3 1/7] NFSD: Instrument fh_verify() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 08 Aug 2022 09:52:35 -0400 Message-ID: <165996675523.2637.1380887920205977074.stgit@manet.1015granger.net> In-Reply-To: <165996657035.2637.4745479232455341597.stgit@manet.1015granger.net> References: <165996657035.2637.4745479232455341597.stgit@manet.1015granger.net> User-Agent: StGit/1.5.dev2+g9ce680a5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Capture file handles and how they map to local inodes. In particular, NFSv4 PUTFH uses fh_verify() so we can now observe which file handles are the target of OPEN, LOOKUP, RENAME, and so on. Signed-off-by: Chuck Lever --- fs/nfsd/nfsfh.c | 5 +++-- fs/nfsd/trace.h | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index c29baa03dfaf..5e2ed4b2a925 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -331,8 +331,6 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access) struct dentry *dentry; __be32 error; - dprintk("nfsd: fh_verify(%s)\n", SVCFH_fmt(fhp)); - if (!fhp->fh_dentry) { error = nfsd_set_fh_dentry(rqstp, fhp); if (error) @@ -340,6 +338,9 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access) } dentry = fhp->fh_dentry; exp = fhp->fh_export; + + trace_nfsd_fh_verify(rqstp, fhp, type, access); + /* * We still have to do all these permission checks, even when * fh_dentry is already set: diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index a60ead3b227a..8467fd8f94c2 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -171,6 +171,52 @@ TRACE_EVENT(nfsd_compound_encode_err, __entry->opnum, __entry->status) ); +#define show_fs_file_type(x) \ + __print_symbolic(x, \ + { S_IFLNK, "LNK" }, \ + { S_IFREG, "REG" }, \ + { S_IFDIR, "DIR" }, \ + { S_IFCHR, "CHR" }, \ + { S_IFBLK, "BLK" }, \ + { S_IFIFO, "FIFO" }, \ + { S_IFSOCK, "SOCK" }) + +TRACE_EVENT(nfsd_fh_verify, + TP_PROTO( + const struct svc_rqst *rqstp, + const struct svc_fh *fhp, + umode_t type, + int access + ), + TP_ARGS(rqstp, fhp, type, access), + TP_STRUCT__entry( + __field(unsigned int, netns_ino) + __sockaddr(server, rqstp->rq_xprt->xpt_remotelen) + __sockaddr(client, rqstp->rq_xprt->xpt_remotelen) + __field(u32, xid) + __field(u32, fh_hash) + __field(void *, inode) + __field(unsigned long, type) + __field(unsigned long, access) + ), + TP_fast_assign( + __entry->netns_ino = SVC_NET(rqstp)->ns.inum; + __assign_sockaddr(server, &rqstp->rq_xprt->xpt_local, + rqstp->rq_xprt->xpt_locallen); + __assign_sockaddr(client, &rqstp->rq_xprt->xpt_remote, + rqstp->rq_xprt->xpt_remotelen); + __entry->xid = be32_to_cpu(rqstp->rq_xid); + __entry->fh_hash = knfsd_fh_hash(&fhp->fh_handle); + __entry->inode = d_inode(fhp->fh_dentry); + __entry->type = type; + __entry->access = access; + ), + TP_printk("xid=0x%08x fh_hash=0x%08x inode=%p type=%s access=%s", + __entry->xid, __entry->fh_hash, __entry->inode, + show_fs_file_type(__entry->type), + show_nfsd_may_flags(__entry->access) + ) +); DECLARE_EVENT_CLASS(nfsd_fh_err_class, TP_PROTO(struct svc_rqst *rqstp,