Re: [PATCH RFC v24 7/7] NFSD: Show state of courtesy client in client info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, May 01, 2022 at 10:38:16AM -0700, Dai Ngo wrote:
> Update client_info_show to show state of courtesy client
> and time since last renew.

At this point I may be borderline woodshedding, but: for simplicity's
sake, let's just keep that time as a number of seconds.  I'm thinking
that'll make it marginally easier for people processing the output and
doing comparisons and such.

--b.

> 
> Signed-off-by: Dai Ngo <dai.ngo@xxxxxxxxxx>
> ---
>  fs/nfsd/nfs4state.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 4ab7dda44f38..9cff06fc3600 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -2473,7 +2473,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)
> @@ -2481,10 +2482,19 @@ 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_state == NFSD4_COURTESY)
> +		seq_puts(m, "status: courtesy\n");
> +	else if (clp->cl_state == NFSD4_EXPIRABLE)
> +		seq_puts(m, "status: expirable\n");
> +	else if (test_bit(NFSD4_CLIENT_CONFIRMED, &clp->cl_flags))
>  		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);
> -- 
> 2.9.5



[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux