Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6478769rwi; Tue, 18 Oct 2022 13:00:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4pp4FIOYYESKsoOsA4rugtaTXSpnYY1kyPuqHIa3if9pd1gZE+IUhz+B+cFLYV9GBtyy7/ X-Received: by 2002:a17:906:5dcc:b0:78d:e77d:e66f with SMTP id p12-20020a1709065dcc00b0078de77de66fmr3780387ejv.102.1666123249611; Tue, 18 Oct 2022 13:00:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666123249; cv=none; d=google.com; s=arc-20160816; b=GzWN5soLo+TNJxtKJMu7wMhxknw594X3pQpcMz5WJ2+uBTonRT6zh7qNXvuK6PzIqY xGXAGYAKlqPFwUcZzv/BKEiOtZjzHOVfIbF/JLpf13YtaE2WnEREEaqNpJhlLM2u0DvH 5YIa5HCi5f/tfTTn+Gbe+wOboFETp5CSZgV8Z7YXVhd95m3EJMBi+HGIdj5Yr9Ke0atk nOu6vTPBs/tjaVBs//eSGDCj4NiBpElCMBeeAHDF3lnSea7q/grLVmxkGcL8zpUbmTfS OPLWKX9gks2vCCr788wdSEGYwBQUFayZiWh6lQ1hc633/ADdF7EpNkZUx4YvnxFeI/w5 2RYA== 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=mO+rf8fGx0dV7lx8rh6CHIJldLHWN4bsiyo3Iy9Ta+U=; b=LTm/j9jo/wUQCrWMGd5MQ9G3+6FG10oHDrO1TKI6/Uk3oOsVZc5rzPKHniSLmNo0Af hap48kEfkjqvBW5vUDvNRIq+Y8apTilneJpjJyajcTsFeoGErR1RJ3sjhE+hiB2buz0N 9PYSN2Qa+p6g7eJ9FjOOfosDZBAHwCDmNa+QdsplzAgNC1ptUNhhHcc13HDr8A8Lur+7 Af9mKXgOF0PnVNZoXcAI1zhNspvz4gQI0eOqAt6fVodfo/yuk/wxg1W+12WIJ+Mx/o+j PbwYfnJW3joCJpfYgzqHecorsvYcHKpZxTuqzqE56ZdYI0oyjTgWOHwO17TZPE7Don9C cLnQ== 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 j20-20020a05640211d400b0045d3ed38ae1si10903024edw.16.2022.10.18.13.00.23; Tue, 18 Oct 2022 13:00:49 -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 S229947AbiJRT7Q (ORCPT + 99 others); Tue, 18 Oct 2022 15:59:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230097AbiJRT7I (ORCPT ); Tue, 18 Oct 2022 15:59:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CE20915CF for ; Tue, 18 Oct 2022 12:59:07 -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 AD878B82103 for ; Tue, 18 Oct 2022 19:59:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57CEEC433C1; Tue, 18 Oct 2022 19:59:04 +0000 (UTC) Subject: [PATCH v4 7/7] NFSD: Trace delegation revocations From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: neilb@suse.de Date: Tue, 18 Oct 2022 15:59:03 -0400 Message-ID: <166612314338.1291.6816037057097504104.stgit@manet.1015granger.net> In-Reply-To: <166612295223.1291.11761205673682408148.stgit@manet.1015granger.net> References: <166612295223.1291.11761205673682408148.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 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. Reviewed-by: Jeff Layton Tested-by: Jeff Layton Signed-off-by: Chuck Lever --- 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 a63334ad61f6..c37f07bb874d 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1401,6 +1401,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 4921144880d3..23fb39c957af 100644 --- a/fs/nfsd/trace.h +++ b/fs/nfsd/trace.h @@ -561,6 +561,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),