Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2521561rwi; Fri, 28 Oct 2022 08:03:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YgwKECrioqF3AymfFPQmsnDTKih2d41CyRHV4wRdQa95pbIdYZ7Mlz6jOU1JtU/lnvBiK X-Received: by 2002:a17:902:6bc5:b0:183:4bef:1b20 with SMTP id m5-20020a1709026bc500b001834bef1b20mr55121487plt.158.1666969399228; Fri, 28 Oct 2022 08:03:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666969399; cv=none; d=google.com; s=arc-20160816; b=lgUoHmCPRsW+yQ2Iue2//cdO5bE4+Pf+WZl5cITFYRAaMb/nPvwwkRcWYdNSxiV4/V fb8+vJViG/5bMT3rMoeuEkv5X/Hod9hPFMqMQmK/0Jb01eEN4qPQ7YyPBVmfhjHxTXXb 6YOcaExrIRll6UOwqRcSTfPaMXoMisLkh4K/tEfxjOF81pwUkELRc379006Ya9GO6rBX uuRx0D9nIv7K5qaVbj6QWv1bckYaCy4ktidan8H7y/jTqc2+1Ubf9NgPDcCcpxXPjaaD ChjzpmJvYxZ2kC2C+2aCRjNsehhwvMhjDcG7TaNlb65O7V0bPS1K79IxJu5rhjGsW5vB z6Ng== 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:cc:to:from :subject; bh=3xv+FoUBecQSAQwSgRPVErLe8hrSLl7OCxjteBqnZM0=; b=E7ed25QuDulH9leXQ8YyGNI70/mTXltHcuv7/tnPQl4ww5UmI4TVtqFIQg7fB4RQSj zTS7JLi2y8BC1iZgXw4v6EfSFAWWXkima6CgSY4onbaooeyKnHvlerxGWijFOyJrfk54 1u93ulgLtzEJc2YV1uGp8+VIryjkrds5HjXNyaE4zm/E4BIyANwtwPu4zrGzU3vZNvyW 6UfVSDFXCmhaP8rYMAjSM+YZcbDVQMdsp9DOYXUclRRSNZSD1aeVi7zENQjuGbgYexnR JXcuTmCrIXn+HK0cz7vBCPNK+SriqTfngSBLdlD9PETKtV73aLrd4S7IjbMyaLRoDfR7 2mlg== 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 g15-20020a056a000b8f00b00563ad44ddf9si6136091pfj.380.2022.10.28.08.02.39; Fri, 28 Oct 2022 08:03:19 -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 S230383AbiJ1Osd (ORCPT + 99 others); Fri, 28 Oct 2022 10:48:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231223AbiJ1OsT (ORCPT ); Fri, 28 Oct 2022 10:48:19 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B1BA203577 for ; Fri, 28 Oct 2022 07:47:14 -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 A9DFDCE2BD4 for ; Fri, 28 Oct 2022 14:47:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBBA1C433D7; Fri, 28 Oct 2022 14:47:10 +0000 (UTC) Subject: [PATCH v7 06/14] NFSD: Trace delegation revocations From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de, jlayton@redhat.com Date: Fri, 28 Oct 2022 10:47:09 -0400 Message-ID: <166696842987.106044.10527746299775159505.stgit@klimt.1015granger.net> In-Reply-To: <166696812922.106044.679812521105874329.stgit@klimt.1015granger.net> References: <166696812922.106044.679812521105874329.stgit@klimt.1015granger.net> User-Agent: StGit/1.5.dev3+g9561319 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 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 Delegation revocation is an exceptional event that is not otherwise visible externally (eg, no network traffic is emitted). Generate a trace record when it occurs so that revocation can be observed or other activity can be triggered. Example: nfsd-1104 [005] 1912.002544: nfsd_stid_revoke: client 633c9343:4e82788d stateid 00000003:00000001 ref=2 type=DELEG Trace infrastructure is provided for subsequent additional tracing related to nfs4_stid activity. Signed-off-by: Chuck Lever Tested-by: Jeff Layton Reviewed-by: Jeff Layton --- fs/nfsd/nfs4state.c | 2 ++ fs/nfsd/trace.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 93cfae7cd391..2e6e1ee096b5 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1355,6 +1355,8 @@ static void revoke_delegation(struct nfs4_delegation *dp) WARN_ON(!list_empty(&dp->dl_recall_lru)); + trace_nfsd_stid_revoke(&dp->dl_stid); + if (clp->cl_minorversion) { dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; refcount_inc(&dp->dl_stid.sc_count); diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h index 477c2b035872..b09ab4f92d43 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -634,6 +634,61 @@ DEFINE_EVENT(nfsd_stateseqid_class, nfsd_##name, \ DEFINE_STATESEQID_EVENT(preprocess); DEFINE_STATESEQID_EVENT(open_confirm); +TRACE_DEFINE_ENUM(NFS4_OPEN_STID); +TRACE_DEFINE_ENUM(NFS4_LOCK_STID); +TRACE_DEFINE_ENUM(NFS4_DELEG_STID); +TRACE_DEFINE_ENUM(NFS4_CLOSED_STID); +TRACE_DEFINE_ENUM(NFS4_REVOKED_DELEG_STID); +TRACE_DEFINE_ENUM(NFS4_CLOSED_DELEG_STID); +TRACE_DEFINE_ENUM(NFS4_LAYOUT_STID); + +#define show_stid_type(x) \ + __print_flags(x, "|", \ + { NFS4_OPEN_STID, "OPEN" }, \ + { NFS4_LOCK_STID, "LOCK" }, \ + { NFS4_DELEG_STID, "DELEG" }, \ + { NFS4_CLOSED_STID, "CLOSED" }, \ + { NFS4_REVOKED_DELEG_STID, "REVOKED" }, \ + { NFS4_CLOSED_DELEG_STID, "CLOSED_DELEG" }, \ + { NFS4_LAYOUT_STID, "LAYOUT" }) + +DECLARE_EVENT_CLASS(nfsd_stid_class, + TP_PROTO( + const struct nfs4_stid *stid + ), + TP_ARGS(stid), + TP_STRUCT__entry( + __field(unsigned long, sc_type) + __field(int, sc_count) + __field(u32, cl_boot) + __field(u32, cl_id) + __field(u32, si_id) + __field(u32, si_generation) + ), + TP_fast_assign( + const stateid_t *stp = &stid->sc_stateid; + + __entry->sc_type = stid->sc_type; + __entry->sc_count = refcount_read(&stid->sc_count); + __entry->cl_boot = stp->si_opaque.so_clid.cl_boot; + __entry->cl_id = stp->si_opaque.so_clid.cl_id; + __entry->si_id = stp->si_opaque.so_id; + __entry->si_generation = stp->si_generation; + ), + TP_printk("client %08x:%08x stateid %08x:%08x ref=%d type=%s", + __entry->cl_boot, __entry->cl_id, + __entry->si_id, __entry->si_generation, + __entry->sc_count, show_stid_type(__entry->sc_type) + ) +); + +#define DEFINE_STID_EVENT(name) \ +DEFINE_EVENT(nfsd_stid_class, nfsd_stid_##name, \ + TP_PROTO(const struct nfs4_stid *stid), \ + TP_ARGS(stid)) + +DEFINE_STID_EVENT(revoke); + DECLARE_EVENT_CLASS(nfsd_clientid_class, TP_PROTO(const clientid_t *clid), TP_ARGS(clid),