linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
To: steved@redhat.com
Cc: cel@kernel.org, jlayton@kernel.org, linux-nfs@vger.kernel.org,
	Prabhakar Pujeri <prabhakar.pujeri@dell.com>
Subject: [PATCH v1 1/3] nfsdctl: report NFSv4 grace state
Date: Tue, 25 Aug 2026 06:52:13 +0000	[thread overview]
Message-ID: <ae1cdff0e22ee34415b416adf91c40976cafdd82.1787639206.git.prabhakar.pujeri@dell.com> (raw)
In-Reply-To: <cover.1787639206.git.prabhakar.pujeri@dell.com>

The threads command reports the server's thread configuration, but an
operator also needs to know whether the NFSv4 server is accepting normal
state operations or only recovery requests.

Display the kernel's new in-grace value when the attribute is present.
Checking its presence prevents a new nfsdctl from reporting an older
kernel's lack of the attribute as "no".

Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
---
 configure.ac                   | 2 +-
 support/include/nfsd_netlink.h | 1 +
 utils/nfsdctl/nfsdctl.8        | 3 ++-
 utils/nfsdctl/nfsdctl.adoc     | 3 ++-
 utils/nfsdctl/nfsdctl.c        | 8 ++++++++
 5 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index 2ce1e12..96aa82c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,7 +259,7 @@ AC_CHECK_HEADERS(linux/nfsd_netlink.h)
 
 # ensure the system netlink headers have the latest features
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]],
-			                   [[int foo = NFSD_CMD_SERVER_STATS_GET;]])],
+			                   [[int foo = NFSD_A_SERVER_IN_GRACE;]])],
 			   [AC_DEFINE([USE_SYSTEM_NFSD_NETLINK_H], 1,
 				      ["Use system's linux/nfsd_netlink.h"])])
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/lockd_netlink.h>]],
diff --git a/support/include/nfsd_netlink.h b/support/include/nfsd_netlink.h
index 87da1d0..e1fc2db 100644
--- a/support/include/nfsd_netlink.h
+++ b/support/include/nfsd_netlink.h
@@ -84,6 +84,7 @@ enum {
 	NFSD_A_SERVER_SCOPE,
 	NFSD_A_SERVER_MIN_THREADS,
 	NFSD_A_SERVER_FH_KEY,
+	NFSD_A_SERVER_IN_GRACE,
 
 	__NFSD_A_SERVER_MAX,
 	NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX - 1)
diff --git a/utils/nfsdctl/nfsdctl.8 b/utils/nfsdctl/nfsdctl.8
index 1f526e7..58d5cd9 100644
--- a/utils/nfsdctl/nfsdctl.8
+++ b/utils/nfsdctl/nfsdctl.8
@@ -144,7 +144,8 @@ takes no arguments.
 Get/set the number of running nfsd threads in each pool. Pass a list of
 integers to change the currently active number of threads. Passing it a
 value of 0 will shut down the NFS server. Run this without arguments to
-get the current number of running threads in each pool.
+get the current number of running threads in each pool and whether the
+NFSv4 server is in its recovery grace period.
 .RE
 .sp
 .if n .RS 4
diff --git a/utils/nfsdctl/nfsdctl.adoc b/utils/nfsdctl/nfsdctl.adoc
index e85348e..7e03933 100644
--- a/utils/nfsdctl/nfsdctl.adoc
+++ b/utils/nfsdctl/nfsdctl.adoc
@@ -82,7 +82,8 @@ Each subcommand can also accept its own set of options and arguments. The
   Get/set the number of running nfsd threads in each pool. Pass a list of
   integers to change the currently active number of threads. Passing it a
   value of 0 will shut down the NFS server. Run this without arguments to
-  get the current number of running threads in each pool.
+  get the current number of running threads in each pool and whether the
+  NFSv4 server is in its recovery grace period.
 
 [source,bash]
 ----
diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c
index c712674..2b1faef 100644
--- a/utils/nfsdctl/nfsdctl.c
+++ b/utils/nfsdctl/nfsdctl.c
@@ -311,6 +311,8 @@ static void parse_threads_get(struct genlmsghdr *gnlh)
 	struct nlattr *attr;
 	int rem, pools = 0, i = 0;
 	uint32_t *pool_threads = NULL;
+	bool in_grace = false;
+	bool have_in_grace = false;
 
 	nla_for_each_attr(attr, genlmsg_attrdata(gnlh, 0),
 			  genlmsg_attrlen(gnlh, 0), rem)
@@ -337,6 +339,10 @@ static void parse_threads_get(struct genlmsghdr *gnlh)
 		case NFSD_A_SERVER_MIN_THREADS:
 			printf("min-threads: %u\n", nla_get_u32(attr));
 			break;
+		case NFSD_A_SERVER_IN_GRACE:
+			in_grace = nla_get_u8(attr);
+			have_in_grace = true;
+			break;
 		default:
 			break;
 		}
@@ -346,6 +352,8 @@ static void parse_threads_get(struct genlmsghdr *gnlh)
 	for (i = 0; i < pools; ++i)
 		printf(" %d", pool_threads[i]);
 	putchar('\n');
+	if (have_in_grace)
+		printf("in-grace: %s\n", in_grace ? "yes" : "no");
 }
 
 static void parse_pool_mode_get(struct genlmsghdr *gnlh)
-- 
2.54.0


  reply	other threads:[~2026-08-25  6:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  6:52 [PATCH v1 0/3] nfsdctl: list NFSv4 clients Prabhakar Pujeri
2026-08-25  6:52 ` Prabhakar Pujeri [this message]
2026-08-25  6:52 ` [PATCH v1 2/3] nfsdctl: add a command to " Prabhakar Pujeri
2026-08-25  6:52 ` [PATCH v1 3/3] nfsdctl: display per-client NFSv4 state usage Prabhakar Pujeri
2026-08-28 14:37 ` [PATCH v1 0/3] nfsdctl: list NFSv4 clients Jeff Layton
2026-08-29 21:28   ` Steve Dickson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae1cdff0e22ee34415b416adf91c40976cafdd82.1787639206.git.prabhakar.pujeri@dell.com \
    --to=prabhakar.pujeri@dell.com \
    --cc=cel@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).