• James Smart's avatar
    nvmet_fc: support target port removal with nvmet layer · ea96d649
    James Smart authored
    Currently, if a targetport has been connected to via the nvmet config
    (in other words, the add_port() transport routine called, and the nvmet
    port pointer stored for using in upcalls on new io), and if the
    targetport is then removed (say the lldd driver decides to unload or
    fully reset its hardware) and then re-added (the lldd driver reloads or
    reinits its hardware), the port pointer has been lost so there's no way
    to continue to post commands up to nvmet via the transport port.
    
    Correct by allocating a small "port context" structure that will be
    linked to by the targetport. The context will save the targetport WWN's
    and the nvmet port pointer to use for it.  Initial allocation will occur
    when the targetport is bound to via add_port.  The context will be
    deallocated when remove_port() is called.  If a targetport is removed
    while nvmet has the active port context, the targetport will be unlinked
    from the port context before removal.  If a new targetport is registered,
    the port contexts without a binding are looked through and if the WWN's
    match (so it's the same as nvmet's port context) the port context is
    linked to the new target port.  Thus new io can be received on the new
    targetport and operation resumes with nvmet.
    
    Additionally, this also resolves nvmet configuration changing out from
    underneath of the nvme-fc target port (for example: a nvmetcli clear).
    Signed-off-by: default avatarJames Smart <james.smart@broadcom.com>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    ea96d649
fc.c 70.4 KB