From patchwork Thu Mar 17 07:43:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dai Ngo X-Patchwork-Id: 12783627 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8733BC433FE for ; Thu, 17 Mar 2022 07:44:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbiCQHpy (ORCPT ); Thu, 17 Mar 2022 03:45:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229447AbiCQHpn (ORCPT ); Thu, 17 Mar 2022 03:45:43 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0072C12E7; Thu, 17 Mar 2022 00:44:07 -0700 (PDT) Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22H3W24d001976; Thu, 17 Mar 2022 07:44:05 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2021-07-09; bh=sGLHwlXW4JJkK+NaiBRn1/20D/aBsY2DOOTzDkUli40=; b=YXSj0KKVxL0rmRXMv4+tniAx4xy9HLb87KHrXvBK831yjMePwdq4X+wpPD5j83MJm5/H 5iQSsi4G7O/GFm2zJJKSvi7qZgFPDyabLtlGknieQnXxi1PxQW6Rws3DbKHE/MzSD8lr DoXv+v+K066OnUEO38+AlJoy/WLsZB6oB7+IX8yrITbCqvXA82a7/EpmPKR4MoJeQvOp d6+fpAGoFXpRRk/lsIF7pK6n/gUUzKsqUlQ+aSLLrZG1E87S255WQJngyHuIiGHPLlP5 pMR/5XmRPZnocRZpyUo1U9HxgyMIVQKaDHPLrDubeR1mUiprfHXU9ml7EAbkxRm2mC2+ lA== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com with ESMTP id 3et5xwr5ea-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Mar 2022 07:44:04 +0000 Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 22H7fnaV034963; Thu, 17 Mar 2022 07:44:03 GMT Received: from pps.reinject (localhost [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3erhy2wr1h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Mar 2022 07:44:03 +0000 Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 22H7hoGx038783; Thu, 17 Mar 2022 07:44:03 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com with ESMTP id 3erhy2wqv5-12; Thu, 17 Mar 2022 07:44:03 +0000 From: Dai Ngo To: chuck.lever@oracle.com, bfields@fieldses.org Cc: jlayton@redhat.com, viro@zeniv.linux.org.uk, linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH RFC v17 11/11] NFSD: Show state of courtesy clients in client info Date: Thu, 17 Mar 2022 00:43:48 -0700 Message-Id: <1647503028-11966-12-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1647503028-11966-1-git-send-email-dai.ngo@oracle.com> References: <1647503028-11966-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-GUID: nz9pNEjQvZ2uPcJuxRzZJlfZUC90HKLr X-Proofpoint-ORIG-GUID: nz9pNEjQvZ2uPcJuxRzZJlfZUC90HKLr Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Update client_info_show to show state of courtesy client and time since last renew. Signed-off-by: Dai Ngo --- fs/nfsd/nfs4state.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index d5758c7101dc..21dd8265bef8 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2411,7 +2411,8 @@ static int client_info_show(struct seq_file *m, void *v) { struct inode *inode = m->private; struct nfs4_client *clp; - u64 clid; + u64 clid, hrs; + u32 mins, secs; clp = get_nfsdfs_clp(inode); if (!clp) @@ -2419,10 +2420,17 @@ static int client_info_show(struct seq_file *m, void *v) memcpy(&clid, &clp->cl_clientid, sizeof(clid)); seq_printf(m, "clientid: 0x%llx\n", clid); seq_printf(m, "address: \"%pISpc\"\n", (struct sockaddr *)&clp->cl_addr); - if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags)) + + if (clp->cl_cs_client_state == NFSD4_CLIENT_COURTESY) + seq_puts(m, "status: courtesy\n"); + else if (clp->cl_cs_client_state == NFSD4_CLIENT_CONFIRMED) seq_puts(m, "status: confirmed\n"); else seq_puts(m, "status: unconfirmed\n"); + hrs = div_u64_rem(ktime_get_boottime_seconds() - clp->cl_time, + 3600, &secs); + mins = div_u64_rem((u64)secs, 60, &secs); + seq_printf(m, "time since last renew: %llu:%02u:%02u\n", hrs, mins, secs); seq_printf(m, "name: "); seq_quote_mem(m, clp->cl_name.data, clp->cl_name.len); seq_printf(m, "\nminor version: %d\n", clp->cl_minorversion);