Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp4772612rwb; Mon, 8 Aug 2022 06:53:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5NlseMD2erGWSakYflq3V3WWsvr7bDZ7MzYLtsLwdXpmVGXaMfPlSHcYkxUbpYGNyjAzKg X-Received: by 2002:a17:907:3f98:b0:730:cfce:9c0f with SMTP id hr24-20020a1709073f9800b00730cfce9c0fmr14355500ejc.475.1659966801623; Mon, 08 Aug 2022 06:53:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659966801; cv=none; d=google.com; s=arc-20160816; b=lzUa97yQiM6yp3VQol4ex78ZkfA/PM+sRsdZzTdrvfsa681Ik1KM2oHw297b+rnWao 8XfgiGtg9XQB9d+FucI/OEnintdD7oeRRpuQfntBiSUcSZD8OQ1tExsxOe6Z3zdVDu3B ASX6sCKYtoCy5Lgg6YpwTKZxN+7NpCUKqABD7UNXwuAxumqAFfVqzLK3KlIU9tjGx8Tb DOOE43ohIo3yRmb5RNulG9/JeqHTDEi77kxw6tIqMjRicDIPs8U4ZfqoS6F0orWRvKTt BpbNbuArYFTAKzLRb7D2X/+5xZ6ngeCpaldCV3Y8lI7lzFKbEPZcomT+ku+ezbotXq8+ twnw== 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=S/fMmjNEGhJZoMmn/phVW/czuG5Lmv8ApmuEJkg45tw=; b=bpabjhlSpVo3+XPlmXpjaz0jr/i3FT2iVcHePDWvGamfu/c5ADJKutVLiCagJX15M8 n5OZlEEp+BJUHkj+MfptVA0WxXEb5hfxXGnRhRs76u3cO7BWBQX31UyvYftc5yNtRA8L Nec8ryF5HePa3G6XRSNfc870ABJybxXNrWjUNsMUqV4Oiu2kmMVGu6qk74gVsUQCidsp oQLtOOwoOPSjioVSY1r+64HkDf+IPG5kre7Qdf4YYzPqBFjKm47z6iR9BJfqxptbadcA 8X5d2axDcNckuCCzrWWeGztwz1H1uAyc1W03Ea1u2yeud957/dAaDpBuFuYeyGITI63F ooxA== 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 mp22-20020a1709071b1600b00722e3682c3bsi10791323ejc.257.2022.08.08.06.52.48; Mon, 08 Aug 2022 06:53:21 -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 S237349AbiHHNtW (ORCPT + 99 others); Mon, 8 Aug 2022 09:49:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235611AbiHHNtV (ORCPT ); Mon, 8 Aug 2022 09:49:21 -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 6DD9BB1F8 for ; Mon, 8 Aug 2022 06:49:20 -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 180BCB80EA1 for ; Mon, 8 Aug 2022 13:49:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA381C433C1 for ; Mon, 8 Aug 2022 13:49:17 +0000 (UTC) Subject: [PATCH v3 2/7] NFSD: Replace dprintk() call site in fh_verify() From: Chuck Lever To: linux-nfs@vger.kernel.org Date: Mon, 08 Aug 2022 09:49:16 -0400 Message-ID: <165996655686.2613.13952702788417892616.stgit@manet.1015granger.net> In-Reply-To: <165996655005.2613.3803552076018199850.stgit@manet.1015granger.net> References: <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 Record permission errors in the trace log. Note that the new trace event is conditional, so it will only record non-zero return values from nfsd_permission(). Signed-off-by: Chuck Lever --- fs/nfsd/nfsfh.c | 8 +------- fs/nfsd/trace.h | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 5e2ed4b2a925..877da093ed2d 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -392,13 +392,7 @@ fh_verify(struct svc_rqst *rqstp, struct svc_fh *fhp, umode_t type, int access) skip_pseudoflavor_check: /* Finally, check access permissions. */ error = nfsd_permission(rqstp, exp, dentry, access); - - if (error) { - dprintk("fh_verify: %pd2 permission failure, " - "acc=%x, error=%d\n", - dentry, - access, ntohl(error)); - } + trace_nfsd_fh_verify_err(rqstp, fhp, type, access, error); out: if (error == nfserr_stale) nfsd_stats_fh_stale_inc(exp); diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 8467fd8f94c2..b6f3c1366a82 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -211,13 +211,55 @@ TRACE_EVENT(nfsd_fh_verify, __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, + TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s", + __entry->xid, __entry->fh_hash, show_fs_file_type(__entry->type), show_nfsd_may_flags(__entry->access) ) ); +TRACE_EVENT_CONDITION(nfsd_fh_verify_err, + TP_PROTO( + const struct svc_rqst *rqstp, + const struct svc_fh *fhp, + umode_t type, + int access, + __be32 error + ), + TP_ARGS(rqstp, fhp, type, access, error), + TP_CONDITION(error), + 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) + __field(int, error) + ), + 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; + __entry->error = be32_to_cpu(error); + ), + TP_printk("xid=0x%08x fh_hash=0x%08x type=%s access=%s error=%d", + __entry->xid, __entry->fh_hash, + show_fs_file_type(__entry->type), + show_nfsd_may_flags(__entry->access), + __entry->error + ) +); + DECLARE_EVENT_CLASS(nfsd_fh_err_class, TP_PROTO(struct svc_rqst *rqstp, struct svc_fh *fhp,