Commit 8b43ced6 authored by Prabhakar Kushwaha's avatar Prabhakar Kushwaha Committed by Christoph Hellwig

nvme-tcp: use __dev_get_by_name instead dev_get_by_name for OPT_HOST_IFACE

dev_get_by_name() finds network device by name but it also increases the
reference count.

If a nvme-tcp queue is present and the network device driver is removed
before nvme_tcp, we will face the following continuous log:

  "kernel:unregister_netdevice: waiting for <eth> to become free. Usage count = 2"

And rmmod further halts. Similar case arises during reboot/shutdown
with nvme-tcp queue present and both never completes.

To fix this, use __dev_get_by_name() which finds network device by
name without increasing any reference counter.

Fixes: 3ede8f72 ("nvme-tcp: allow selecting the network interface for connections")
Signed-off-by: default avatarOmkar Kulkarni <okulkarni@marvell.com>
Signed-off-by: default avatarShai Malin <smalin@marvell.com>
Signed-off-by: default avatarPrabhakar Kushwaha <pkushwaha@marvell.com>
Reviewed-by: default avatarSagi Grimberg <sagi@grimberg.me>
[hch: remove the ->ndev member entirely]
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent a731763f
...@@ -123,7 +123,6 @@ struct nvme_tcp_ctrl { ...@@ -123,7 +123,6 @@ struct nvme_tcp_ctrl {
struct blk_mq_tag_set admin_tag_set; struct blk_mq_tag_set admin_tag_set;
struct sockaddr_storage addr; struct sockaddr_storage addr;
struct sockaddr_storage src_addr; struct sockaddr_storage src_addr;
struct net_device *ndev;
struct nvme_ctrl ctrl; struct nvme_ctrl ctrl;
struct work_struct err_work; struct work_struct err_work;
...@@ -2533,8 +2532,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, ...@@ -2533,8 +2532,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev,
} }
if (opts->mask & NVMF_OPT_HOST_IFACE) { if (opts->mask & NVMF_OPT_HOST_IFACE) {
ctrl->ndev = dev_get_by_name(&init_net, opts->host_iface); if (!__dev_get_by_name(&init_net, opts->host_iface)) {
if (!ctrl->ndev) {
pr_err("invalid interface passed: %s\n", pr_err("invalid interface passed: %s\n",
opts->host_iface); opts->host_iface);
ret = -ENODEV; ret = -ENODEV;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment