mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
RDMA/core: Pass the net namespace to the device name lookups
Prepare for per-netns RDMA device names by passing the target net namespace through the name lookup and allocation helpers. Keep current global uniqueness behaviour. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Link: https://patch.msgid.link/20260716132316.1495242-2-jiri@resnulli.us Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
aac287f4f1
commit
8d01029384
|
|
@ -351,7 +351,8 @@ void ib_device_put(struct ib_device *device)
|
|||
}
|
||||
EXPORT_SYMBOL(ib_device_put);
|
||||
|
||||
static struct ib_device *__ib_device_get_by_name(const char *name)
|
||||
static struct ib_device *__ib_device_get_by_name(const char *name,
|
||||
const struct net *net)
|
||||
{
|
||||
struct ib_device *device;
|
||||
unsigned long index;
|
||||
|
|
@ -395,7 +396,7 @@ int ib_device_rename(struct ib_device *ibdev, const char *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (__ib_device_get_by_name(name)) {
|
||||
if (__ib_device_get_by_name(name, rdma_dev_net(ibdev))) {
|
||||
up_write(&devices_rwsem);
|
||||
return -EEXIST;
|
||||
}
|
||||
|
|
@ -435,7 +436,8 @@ int ib_device_set_dim(struct ib_device *ibdev, u8 use_dim)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int alloc_name(struct ib_device *ibdev, const char *name)
|
||||
/* Pick a free index for the '%d' style @name pattern. */
|
||||
static int alloc_name_id(struct net *net, const char *name)
|
||||
{
|
||||
struct ib_device *device;
|
||||
unsigned long index;
|
||||
|
|
@ -462,15 +464,22 @@ static int alloc_name(struct ib_device *ibdev, const char *name)
|
|||
}
|
||||
|
||||
rc = ida_alloc(&inuse, GFP_KERNEL);
|
||||
if (rc < 0)
|
||||
goto out;
|
||||
|
||||
rc = dev_set_name(&ibdev->dev, name, rc);
|
||||
out:
|
||||
ida_destroy(&inuse);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int alloc_name(struct ib_device *ibdev, const char *name)
|
||||
{
|
||||
int id;
|
||||
|
||||
id = alloc_name_id(rdma_dev_net(ibdev), name);
|
||||
if (id < 0)
|
||||
return id;
|
||||
|
||||
return dev_set_name(&ibdev->dev, name, id);
|
||||
}
|
||||
|
||||
static void ib_device_release(struct device *device)
|
||||
{
|
||||
struct ib_device *dev = container_of(device, struct ib_device, dev);
|
||||
|
|
@ -1223,7 +1232,8 @@ static int assign_name(struct ib_device *device, const char *name)
|
|||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (__ib_device_get_by_name(dev_name(&device->dev))) {
|
||||
if (__ib_device_get_by_name(dev_name(&device->dev),
|
||||
rdma_dev_net(device))) {
|
||||
ret = -ENFILE;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user