• J
    scsi: lpfc: Rework remote port ref counting and node freeing · 307e3380
    James Smart 提交于
    When a remote port is disconnected and disappears, its node structure
    (ndlp) stays allocated and on a vport node list. While on the list it can
    be matched, thus requires validation checks on state to be added in
    numerous code paths. If the node comes back, its possible for there to be
    multiple node structures for the same device on the vport node list. There
    is no reason to keep the node structure around after it is no longer in
    existence, and the current implementation creates problems for itself
    (multiple nodes) and lots of unnecessary code for state validation.
    
    Additionally, the reference taking on the node structure didn't follow the
    normal model used by the kernel kref api. It included lots of odd logic to
    match state with reference count.  The combination of this odd logic plus
    the way it was implicitly used in the discovery engine made its reference
    taking implementation suspect and extremely hard to follow.
    
    Change the driver such that the reference taking routines are now normal
    ref increments/decrements and callout on refcount=0.
    
    With this in place, the rework can be done such that the node structure is
    fully removed and deallocated when the remote port no longer exists and all
    references are removed.  This removal logic, and the basic ref counting are
    intrically tied, thus in a single patch.
    
    Link: https://lore.kernel.org/r/20201115192646.12977-2-james.smart@broadcom.comCo-developed-by: NDick Kennedy <dick.kennedy@broadcom.com>
    Signed-off-by: NDick Kennedy <dick.kennedy@broadcom.com>
    Signed-off-by: NJames Smart <james.smart@broadcom.com>
    Signed-off-by: NMartin K. Petersen <martin.petersen@oracle.com>
    307e3380
lpfc_crtn.h 29.7 KB