From patchwork Thu Mar 31 16:02:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dai Ngo X-Patchwork-Id: 12797430 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 A9D30C433F5 for ; Thu, 31 Mar 2022 16:02:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239584AbiCaQEb (ORCPT ); Thu, 31 Mar 2022 12:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239524AbiCaQEN (ORCPT ); Thu, 31 Mar 2022 12:04:13 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1181C1D59D8; Thu, 31 Mar 2022 09:02:26 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 22VEnEPZ030446; Thu, 31 Mar 2022 16:02:23 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=yXkzRvCCOyJCq1tKDVIr7B3B4D/r6zkFivpwB4GHS0Y=; b=Myp7JGFnd//iEBwVLnyE9e4uvb3wRCBleMdoPWPHVQo6vOw84wkcCwVb+8AMFPT8dGSX VFf23OPjqIGKy+csV9SI+GflpL3T4ztNOy7ucwkYou+X8IA4or77ML7q3GCrmGSyd6iU jD7RUoEw1XMk1XMn6WSF8u4dj1CgSmpUaLgvi5MkwwnO0hn16fokG8D0fuc/1cfLapjC Wyjhpkj//3iEZpZN7wlBKhTRJaI0nBDqeliYKIv6tPkbij8yRaigRgiv03WDWLt5cYAQ G/KTOt4C7lDvv2noaQ07VBN76OYYv1ndqMMimpGQJ3eQNvbUL8q5KYBiLsCTBBTxbkHl cQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com with ESMTP id 3f1se0mtms-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Mar 2022 16:02:21 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.16.1.2/8.16.1.2) with SMTP id 22VFvMRV029519; Thu, 31 Mar 2022 16:02:20 GMT Received: from pps.reinject (localhost [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3f1s95hxph-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 31 Mar 2022 16:02:20 +0000 Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by pps.reinject (8.16.0.36/8.16.0.36) with SMTP id 22VG10KH003132; Thu, 31 Mar 2022 16:02:19 GMT Received: from ca-common-hq.us.oracle.com (ca-common-hq.us.oracle.com [10.211.9.209]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com with ESMTP id 3f1s95hxf8-12; Thu, 31 Mar 2022 16:02:19 +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 v19 11/11] NFSD: Show state of courtesy clients in client info Date: Thu, 31 Mar 2022 09:02:09 -0700 Message-Id: <1648742529-28551-12-git-send-email-dai.ngo@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1648742529-28551-1-git-send-email-dai.ngo@oracle.com> References: <1648742529-28551-1-git-send-email-dai.ngo@oracle.com> X-Proofpoint-ORIG-GUID: 9YZ7YcNfNLXPNHZ0uPmPlAJRpAz720KS X-Proofpoint-GUID: 9YZ7YcNfNLXPNHZ0uPmPlAJRpAz720KS Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@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 b56c23fb6ba1..7b4c7b15a99b 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -2486,7 +2486,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) @@ -2494,10 +2495,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);