Re: [PATCH v2 3/5] sunrpc: Add a sysfs files for rpc_clnt information

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

 



On 27 Jan 2025, at 16:50, Anna Schumaker wrote:

> From: Anna Schumaker <anna.schumaker@xxxxxxxxxx>
>
> These files display useful information about the RPC client, such as the
> rpc version number, program name, and maximum number of connections
> allowed.
>
> Signed-off-by: Anna Schumaker <anna.schumaker@xxxxxxxxxx>
> ---
>  net/sunrpc/sysfs.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 73 insertions(+)
>
> diff --git a/net/sunrpc/sysfs.c b/net/sunrpc/sysfs.c
> index dc3b7cd70000..0d382ab24f1f 100644
> --- a/net/sunrpc/sysfs.c
> +++ b/net/sunrpc/sysfs.c
> @@ -59,6 +59,16 @@ static struct kobject *rpc_sysfs_object_alloc(const char *name,
>  	return NULL;
>  }
>
> +static inline struct rpc_clnt *
> +rpc_sysfs_client_kobj_get_clnt(struct kobject *kobj)
> +{
> +	struct rpc_sysfs_client *c = container_of(kobj,
> +		struct rpc_sysfs_client, kobject);
> +	struct rpc_clnt *ret = c->clnt;
> +
> +	return refcount_inc_not_zero(&ret->cl_count) ? ret : NULL;
> +}
> +
>  static inline struct rpc_xprt *
>  rpc_sysfs_xprt_kobj_get_xprt(struct kobject *kobj)
>  {
> @@ -86,6 +96,51 @@ rpc_sysfs_xprt_switch_kobj_get_xprt(struct kobject *kobj)
>  	return xprt_switch_get(x->xprt_switch);
>  }
>
> +static ssize_t rpc_sysfs_clnt_version_show(struct kobject *kobj,
> +					   struct kobj_attribute *attr,
> +					   char *buf)
> +{
> +	struct rpc_clnt *clnt = rpc_sysfs_client_kobj_get_clnt(kobj);
> +	ssize_t ret;
> +
> +	if (!clnt)
> +		return sprintf(buf, "<closed>\n");
> +
> +	ret = sprintf(buf, "%u", clnt->cl_vers);
> +	refcount_dec(&clnt->cl_count);
> +	return ret;
> +}
> +
> +static ssize_t rpc_sysfs_clnt_program_show(struct kobject *kobj,
> +					   struct kobj_attribute *attr,
> +					   char *buf)
> +{
> +	struct rpc_clnt *clnt = rpc_sysfs_client_kobj_get_clnt(kobj);
> +	ssize_t ret;
> +
> +	if (!clnt)
> +		return sprintf(buf, "<closed>\n");
> +
> +	ret = sprintf(buf, "%s", clnt->cl_program->name);
> +	refcount_dec(&clnt->cl_count);
> +	return ret;
> +}
> +
> +static ssize_t rpc_sysfs_clnt_max_connect_show(struct kobject *kobj,
> +					       struct kobj_attribute *attr,
> +					       char *buf)
> +{
> +	struct rpc_clnt *clnt = rpc_sysfs_client_kobj_get_clnt(kobj);
> +	ssize_t ret;
> +
> +	if (!clnt)
> +		return sprintf(buf, "<closed>\n");
> +
> +	ret = sprintf(buf, "%u\n", clnt->cl_max_connect);
> +	refcount_dec(&clnt->cl_count);
> +	return ret;
> +}
> +
>  static ssize_t rpc_sysfs_xprt_dstaddr_show(struct kobject *kobj,
>  					   struct kobj_attribute *attr,
>  					   char *buf)
> @@ -423,6 +478,23 @@ static const void *rpc_sysfs_xprt_namespace(const struct kobject *kobj)
>  			    kobject)->xprt->xprt_net;
>  }
>
> +static struct kobj_attribute rpc_sysfs_clnt_version = __ATTR(rpc_version,
> +	0444, rpc_sysfs_clnt_version_show, NULL);
> +
> +static struct kobj_attribute rpc_sysfs_clnt_program = __ATTR(program,
> +	0444, rpc_sysfs_clnt_program_show, NULL);
> +
> +static struct kobj_attribute rpc_sysfs_clnt_max_connect = __ATTR(max_connect,
> +	0644, rpc_sysfs_clnt_max_connect_show, NULL);

Wants 0444 here.

Ben






[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