提交 9ce1f2e1 编写于 作者: J James Smart 提交者: Christoph Hellwig

nvmet-fc: cleanup nvmet add_port/remove_port

The current fc transport add_port routine validates that there is a
matching port to the target port config. It then takes a reference
on the targetport. The del_port removes the reference.

Unfortunately, if the LLDD undergoes a hw reset or driver unload and
wants to unreg the targetport, due to the reference, the targetport
effectively can't be removed. It requires the admin to remove the
port from the nvmet config first, which calls the del_port.
Note: it appears nvmetcli clear skips over the del_port call (I'm
not attempting to change that).

There's no real reason to take the reference. With FC, there is nothing
to enable or disable as the presence of the FC targetport implicitly
means its enabled, and removal of the targtport means its disabled.

Change add_port to simply validate and change remove_port to a noop.
No references are taken on the targetport.
Signed-off-by: NJames Smart <james.smart@broadcom.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
上级 b6f80773
...@@ -2490,14 +2490,8 @@ nvmet_fc_add_port(struct nvmet_port *port) ...@@ -2490,14 +2490,8 @@ nvmet_fc_add_port(struct nvmet_port *port)
list_for_each_entry(tgtport, &nvmet_fc_target_list, tgt_list) { list_for_each_entry(tgtport, &nvmet_fc_target_list, tgt_list) {
if ((tgtport->fc_target_port.node_name == traddr.nn) && if ((tgtport->fc_target_port.node_name == traddr.nn) &&
(tgtport->fc_target_port.port_name == traddr.pn)) { (tgtport->fc_target_port.port_name == traddr.pn)) {
/* a FC port can only be 1 nvmet port id */ tgtport->port = port;
if (!tgtport->port) { ret = 0;
tgtport->port = port;
port->priv = tgtport;
nvmet_fc_tgtport_get(tgtport);
ret = 0;
} else
ret = -EALREADY;
break; break;
} }
} }
...@@ -2508,19 +2502,7 @@ nvmet_fc_add_port(struct nvmet_port *port) ...@@ -2508,19 +2502,7 @@ nvmet_fc_add_port(struct nvmet_port *port)
static void static void
nvmet_fc_remove_port(struct nvmet_port *port) nvmet_fc_remove_port(struct nvmet_port *port)
{ {
struct nvmet_fc_tgtport *tgtport = port->priv; /* nothing to do */
unsigned long flags;
bool matched = false;
spin_lock_irqsave(&nvmet_fc_tgtlock, flags);
if (tgtport->port == port) {
matched = true;
tgtport->port = NULL;
}
spin_unlock_irqrestore(&nvmet_fc_tgtlock, flags);
if (matched)
nvmet_fc_tgtport_put(tgtport);
} }
static struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = { static struct nvmet_fabrics_ops nvmet_fc_tgt_fcp_ops = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册