OSDN Git Service

target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling
authorNicholas Bellinger <nab@linux-iscsi.org>
Tue, 7 Apr 2015 21:53:27 +0000 (21:53 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 May 2015 20:03:53 +0000 (22:03 +0200)
commitca7767a3f859d6e5487ddcf7a23515e19188b922
tree2faa44db6b6f1f01e5969589917d3fbfa26e96a8
parent7f61df07930dae7b1a94f088365362a191d2f4ec
target: Fix COMPARE_AND_WRITE with SG_TO_MEM_NOALLOC handling

commit c8e639852ad720499912acedfd6b072325fd2807 upstream.

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: Christoph Hellwig <hch@lst.de>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/target/target_core_sbc.c
drivers/target/target_core_transport.c
include/target/target_core_base.h