• Nicholas Bellinger's avatar
    target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling · c8e63985
    Nicholas Bellinger authored
    This patch fixes a bug for COMPARE_AND_WRITE handling with
    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>
target_core_sbc.c 38 KB