• Nicholas Bellinger's avatar
    target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling · d71c65f4
    Nicholas Bellinger authored
    [ Upstream commit c8e63985 ]
    
    This patch fixes a bug for COMPARE_AND_WRITE handling with
    fabrics using SCF_PASSTHROUGH_SG_TO_MEM_NOALLOC.
    
    It adds the missing allocation for cmd->t_bidi_data_sg within
    transport_generic_new_cmd() that is used by COMPARE_AND_WRITE
    for the initial READ payload, even if the fabric is already
    providing a pre-allocated buffer for cmd->t_data_sg.
    
    Also, fix zero-length COMPARE_AND_WRITE handling within the
    compare_and_write_callback() and target_complete_ok_work()
    to queue the response, skipping the initial READ.
    
    This fixes COMPARE_AND_WRITE emulation with loopback, vhost,
    and xen-backend fabric drivers using SG_TO_MEM_NOALLOC.
    Reported-by: default avatarChristoph Hellwig <hch@lst.de>
    Cc: Christoph Hellwig <hch@lst.de>
    Cc: <stable@vger.kernel.org> # v3.12+
    Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
    Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
    d71c65f4
target_core_sbc.c 35.3 KB