]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
nvmet: add transport discovery change op
authorJames Smart <jsmart2021@gmail.com>
Tue, 14 May 2019 21:58:02 +0000 (14:58 -0700)
committerChristoph Hellwig <hch@lst.de>
Fri, 21 Jun 2019 09:08:37 +0000 (11:08 +0200)
Some transports, such as FC-NVME, support discovery controller change
events without the use of a persistent discovery controller. FC receives
events via RSCN from the FC Fabric Controller or subsystem FC port.

This patch adds a nvmet transport op that is called whenever a
discovery change event occurs in the nvmet layer.

To facilitate the callback without adding another layer to cross into
core.c to reference the transport ops, the port structure snapshots
the transport ops when the port is enabled and clears them when disabled.

Signed-off-by: James Smart <jsmart2021@gmail.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/nvme/target/core.c
drivers/nvme/target/discovery.c
drivers/nvme/target/nvmet.h

index 7734a6acff85182feade6f394f1cb2829c9397c7..43e8c4adc1f4d09f8bdaef4ef607bfbd9f46510f 100644 (file)
@@ -311,6 +311,7 @@ int nvmet_enable_port(struct nvmet_port *port)
                port->inline_data_size = 0;
 
        port->enabled = true;
+       port->tr_ops = ops;
        return 0;
 }
 
@@ -321,6 +322,7 @@ void nvmet_disable_port(struct nvmet_port *port)
        lockdep_assert_held(&nvmet_config_sem);
 
        port->enabled = false;
+       port->tr_ops = NULL;
 
        ops = nvmet_transports[port->disc_addr.trtype];
        ops->remove_port(port);
index 5baf269f3f8a055705357f190127e3649f9026e8..8efca26b47764e3681c238d44a70abcbb84e1ad4 100644 (file)
@@ -41,6 +41,10 @@ void nvmet_port_disc_changed(struct nvmet_port *port,
                __nvmet_disc_changed(port, ctrl);
        }
        mutex_unlock(&nvmet_disc_subsys->lock);
+
+       /* If transport can signal change, notify transport */
+       if (port->tr_ops && port->tr_ops->discovery_chg)
+               port->tr_ops->discovery_chg(port);
 }
 
 static void __nvmet_subsys_disc_changed(struct nvmet_port *port,
index c25d88fc9dec82ade67859fc35df33260ce4f35f..dc270944bb25253e629700dc696d1aa342f05443 100644 (file)
@@ -140,6 +140,7 @@ struct nvmet_port {
        void                            *priv;
        bool                            enabled;
        int                             inline_data_size;
+       const struct nvmet_fabrics_ops  *tr_ops;
 };
 
 static inline struct nvmet_port *to_nvmet_port(struct config_item *item)
@@ -277,6 +278,7 @@ struct nvmet_fabrics_ops {
        void (*disc_traddr)(struct nvmet_req *req,
                        struct nvmet_port *port, char *traddr);
        u16 (*install_queue)(struct nvmet_sq *nvme_sq);
+       void (*discovery_chg)(struct nvmet_port *port);
 };
 
 #define NVMET_MAX_INLINE_BIOVEC        8