Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4772576rwb; Mon, 8 Aug 2022 06:53:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4rTOe0bW31l4tsfvZei9VNzTYGLksBrgs8uD1wO2NKnfxG4agqh19BZOAxgdjhRh0zUnGo X-Received: by 2002:a50:ec0c:0:b0:43c:fd26:404d with SMTP id g12-20020a50ec0c000000b0043cfd26404dmr18148956edr.359.1659966798357; Mon, 08 Aug 2022 06:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659966798; cv=none; d=google.com; s=arc-20160816; b=XKxJtoBEwfQnPsMDjvm/ZqlNyIxUWWA6N0biANyQyu0Tvlski0J4+7KfSST17nH5tk 4gzdVWMiSBq1OHPKJSzUcNYAUqocvZ98j3QTPGCsbMSuvtfLETmc7j8zwlAW+wTQxS0H iNGqhtaMS71TysZ7sG1x7FOjwCChf8+Dj3xr0D0MWOTJD0j6CJhcXy1Uyt5EvZKMdB2h DCFqsgz2BZbteIBkAjeiVpbMRlTaLvfUISUrmC0wzVMsHvRt0gft31hvp1HfHWuQMAid XHra6NDJOE9Cs+7OlylNS8rzIG9puTNwHbWsQotzH2sY7XHyUqbAH5fQXQqwsW35kmk0 MwfA== 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:message-id:date:to:from:subject; bh=nN7W6qy7M+XWAjZkauwOBpqntEsVg+I9d3cMK2LI2Co=; b=vH9EqltJeGcwrDd5SQfj5tSzR+856LI+i7vx5kQmWJQ9yd+XCt9GiespXDZHerUoQc 3mLfwTUkwE1Tkkq02BCJgTe/ebWJYm7Z9IHq3zExHhJfRg5UIPEPKngRU8AcdhVFzHXh fupCra6YuvhbQUKRIsn3hZ7aLrxKR9hvQL+9Hktd8/bv7/PxA+7ukoOfaIiN0Pt5mcU0 wwwOkPNXcCdvH5kd217WBMeL3tpGPsoLRoEs6E9PYjTeM+pMRYKuNpmfL36UPMpYBUrI lfhfj5RQOhF2Jmflj+j6f9dTdZsntf3QUuiY8HuSc9xAqAUzVUQ3eu4I0C55bbsMJUXM kLOw== 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 m19-20020a056402431300b0043d2f04a703si7596353edc.40.2022.08.08.06.52.42; Mon, 08 Aug 2022 06:53:18 -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 S232602AbiHHNtQ (ORCPT + 99 others); Mon, 8 Aug 2022 09:49:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235611AbiHHNtQ (ORCPT ); Mon, 8 Aug 2022 09:49:16 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 113B9B1F8 for ; Mon, 8 Aug 2022 06:49:15 -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 sin.source.kernel.org (Postfix) with ESMTPS id 5ECCCCE10B3 for ; Mon, 8 Aug 2022 13:49:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96191C433C1 for ; Mon, 8 Aug 2022 13:49:11 +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:49:10 -0400 Message-ID: <165996655005.2613.3803552076018199850.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,