netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@mellanox.com>
To: Leon Romanovsky <leon@kernel.org>
Cc: Doug Ledford <dledford@redhat.com>,
	Leon Romanovsky <leonro@mellanox.com>,
	RDMA mailing list <linux-rdma@vger.kernel.org>,
	linux-s390@vger.kernel.org, Ursula Braun <ubraun@linux.ibm.com>,
	"David S. Miller" <davem@davemloft.net>,
	netdev@vger.kernel.org,
	Selvin Xavier <selvin.xavier@broadcom.com>,
	Steve Wise <swise@chelsio.com>, Lijun Ou <oulijun@huawei.com>,
	Shiraz Saleem <shiraz.saleem@intel.com>,
	Ariel Elior <Ariel.Elior@cavium.com>,
	Christian Benvenuti <benve@cisco.com>,
	Adit Ranadive <aditr@vmware.com>,
	Dennis Dalessandro <dennis.dalessandro@intel.com>
Subject: Re: [PATCH rdma-next 1/5] RDMA/core: Provide getter and setter to access IB device name
Date: Thu, 20 Sep 2018 09:15:41 -0600	[thread overview]
Message-ID: <20180920151541.GC30219@mellanox.com> (raw)
In-Reply-To: <20180920112202.9181-2-leon@kernel.org>

On Thu, Sep 20, 2018 at 02:21:58PM +0300, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
> 
> Prepare IB device name field to rename operation by ensuring that all
> accesses to it are protected with lock and users don't see part of name.

Oh dear, no, that isn't going to work, there is too much stuff using
dev_name.. Did you read the comment on device_rename??

https://elixir.bootlin.com/linux/v4.19-rc4/source/drivers/base/core.c#L2715

> The protection is done with global device_lock because it is used in
> allocation and deallocation phases. At this stage, this lock is not
> busy and easily can be moved to be per-device, once it will be needed.
> 
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
>  drivers/infiniband/core/device.c | 24 +++++++++++++++++++++++-
>  include/rdma/ib_verbs.h          |  8 +++++++-
>  2 files changed, 30 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
> index 5a680a88aa87..3270cde6d806 100644
> +++ b/drivers/infiniband/core/device.c
> @@ -170,6 +170,14 @@ static struct ib_device *__ib_device_get_by_name(const char *name)
>  	return NULL;
>  }
> 
> +void ib_device_get_name(struct ib_device *ibdev, char *name)
> +{
> +	down_read(&lists_rwsem);
> +	strlcpy(name, ibdev->name, IB_DEVICE_NAME_MAX);
> +	up_read(&lists_rwsem);
> +}
> +EXPORT_SYMBOL(ib_device_get_name);

I think we have to follow netdev and just rely on device_rename()
being 'good enough'.  

Switch everything to use dev_name()/etc rather than try and do
something like this so the responsibility is on the device core to
keep this working, not us.

Turns out I have a series for that for unrelated reasons..

>  static int alloc_name(char *name)
>  {
>  	unsigned long *inuse;
> @@ -202,6 +210,21 @@ static int alloc_name(char *name)
>  	return 0;
>  }
> 
> +int ib_device_alloc_name(struct ib_device *ibdev, const char *pattern)
> +{
> +	int ret = 0;
> +
> +	mutex_lock(&device_mutex);
> +	strlcpy(ibdev->name, pattern, IB_DEVICE_NAME_MAX);
> +	if (strchr(ibdev->name, '%'))
> +		ret = alloc_name(ibdev->name);
> +
> +	mutex_unlock(&device_mutex);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(ib_device_alloc_name);

Can't call alloc_name() without also adding to the list, this will
allow duplicates.

Jason

  parent reply	other threads:[~2018-09-20 20:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 11:21 [PATCH rdma-next 0/5] IB device rename support Leon Romanovsky
2018-09-20 11:21 ` [PATCH rdma-next 1/5] RDMA/core: Provide getter and setter to access IB device name Leon Romanovsky
2018-09-20 14:32   ` Steve Wise
2018-09-20 15:15   ` Jason Gunthorpe [this message]
2018-09-20 16:40     ` Leon Romanovsky
2018-09-20 16:46       ` Jason Gunthorpe
2018-09-20 11:21 ` [PATCH rdma-next 2/5] net/smc: Use IB device index instead of name Leon Romanovsky
2018-09-20 11:22 ` [PATCH rdma-next 3/5] RDMA: Convert IB drivers to name allocation routine Leon Romanovsky
2018-09-20 11:22 ` [PATCH rdma-next 4/5] RDMA/core: Implement IB device rename function Leon Romanovsky
2018-09-20 11:22 ` [PATCH rdma-next 5/5] RDMA/nldev: Allow IB device rename through RDMA netlink Leon Romanovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180920151541.GC30219@mellanox.com \
    --to=jgg@mellanox.com \
    --cc=Ariel.Elior@cavium.com \
    --cc=aditr@vmware.com \
    --cc=benve@cisco.com \
    --cc=davem@davemloft.net \
    --cc=dennis.dalessandro@intel.com \
    --cc=dledford@redhat.com \
    --cc=leon@kernel.org \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oulijun@huawei.com \
    --cc=selvin.xavier@broadcom.com \
    --cc=shiraz.saleem@intel.com \
    --cc=swise@chelsio.com \
    --cc=ubraun@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).