Re: [RFC PATCH rdma-next v1] RDMA/srp: Rename SRP sysfs name after IB device rename trigger

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

 



On 5/15/19 3:20 PM, Leon Romanovsky wrote:
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index a67aaf0e1f76..64f777e757f6 100644
> --- a/drivers/infiniband/core/device.c
> +++ b/drivers/infiniband/core/device.c
> @@ -410,6 +410,9 @@ static int rename_compat_devs(struct ib_device *device)
> 
>  int ib_device_rename(struct ib_device *ibdev, const char *name)
>  {
> +	struct ib_client *client;
> +	unsigned long index;
> +	void *client_data;
>  	int ret;
> 
>  	down_write(&devices_rwsem);
> @@ -428,6 +431,19 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)
>  		goto out;
>  	strlcpy(ibdev->name, name, IB_DEVICE_NAME_MAX);
>  	ret = rename_compat_devs(ibdev);
> +
> +	downgrade_write(&devices_rwsem);
> +	down_read(&clients_rwsem);
> +	xa_for_each_marked (&clients, index, client, CLIENT_REGISTERED) {
> +		if (client->rename) {
> +			client_data =
> +				xa_load(&ibdev->client_data, client->client_id);
> +			client->rename(ibdev, client_data);
> +		}
> +	}
> +	up_read(&clients_rwsem);
> +	up_read(&devices_rwsem);
> +	return 0;
>  out:
>  	up_write(&devices_rwsem);
>  	return ret;
> diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
> index be9ddcad8f28..2edd014e62db 100644
> --- a/drivers/infiniband/ulp/srp/ib_srp.c
> +++ b/drivers/infiniband/ulp/srp/ib_srp.c
> @@ -148,6 +148,7 @@ MODULE_PARM_DESC(ch_count,
> 
>  static void srp_add_one(struct ib_device *device);
>  static void srp_remove_one(struct ib_device *device, void *client_data);
> +static void srp_rename_dev(struct ib_device *device, void *client_data);
>  static void srp_recv_done(struct ib_cq *cq, struct ib_wc *wc);
>  static void srp_handle_qp_err(struct ib_cq *cq, struct ib_wc *wc,
>  		const char *opname);
> @@ -162,7 +163,8 @@ static struct workqueue_struct *srp_remove_wq;
>  static struct ib_client srp_client = {
>  	.name   = "srp",
>  	.add    = srp_add_one,
> -	.remove = srp_remove_one
> +	.remove = srp_remove_one,
> +	.rename = srp_rename_dev
>  };
> 
>  static struct ib_sa_client srp_sa_client;
> @@ -4112,6 +4114,20 @@ static struct srp_host *srp_add_port(struct srp_device *device, u8 port)
>  	return NULL;
>  }
> 
> +static void srp_rename_dev(struct ib_device *device, void *client_data)
> +{
> +	struct srp_device *srp_dev = client_data;
> +	struct srp_host *host, *tmp_host;
> +
> +	list_for_each_entry_safe (host, tmp_host, &srp_dev->dev_list, list) {
> +		char name[IB_DEVICE_NAME_MAX * 2] = {};
> +
> +		snprintf(name, IB_DEVICE_NAME_MAX * 2, "srp-%s-%d",
> +			 dev_name(&device->dev), host->port);
> +		device_rename(&host->dev, name);
> +	}
> +}
> +
>  static void srp_add_one(struct ib_device *device)
>  {
>  	struct srp_device *srp_dev;
> diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h
> index e9fffa55426b..59d0fffbf192 100644
> --- a/include/rdma/ib_verbs.h
> +++ b/include/rdma/ib_verbs.h
> @@ -2727,6 +2727,7 @@ struct ib_client {
>  	const char *name;
>  	void (*add)   (struct ib_device *);
>  	void (*remove)(struct ib_device *, void *client_data);
> +	void (*rename)(struct ib_device *, void *client_data);
> 
>  	/* Returns the net_dev belonging to this ib_client and matching the
>  	 * given parameters.

Hi Leon,

Thanks for having shared this patch early. The approach of this patch
looks good to me but please fix the checkpatch warnings triggered by
this patch:

WARNING: space prohibited between function name and open parenthesis '('
#203: FILE: drivers/infiniband/core/device.c:437:
+       xa_for_each_marked (&clients, index, client, CLIENT_REGISTERED) {

WARNING: space prohibited between function name and open parenthesis '('
#247: FILE: drivers/infiniband/ulp/srp/ib_srp.c:4122:
+       list_for_each_entry_safe (host, tmp_host, &srp_dev->dev_list,
list) {

WARNING: function definition argument 'struct ib_device *' should also
have an identifier name
#267: FILE: include/rdma/ib_verbs.h:2730:
+       void (*rename)(struct ib_device *, void *client_data);

Thanks,

Bart.




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux