]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
target: do not submit a zero-bio I/O request
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Sep 2012 15:30:41 +0000 (17:30 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 7 Sep 2012 19:08:19 +0000 (12:08 -0700)
scsi_setup_fs_cmnd does not like to receive requests with no
bios attached to it.  Special-case zero-length reads and writes,
by not submitting any bio.

Testcase: sg_raw /dev/sdb 28 00 00 00 00 00 00 00 00 00
    should not fail
    panics with the rest of the series but not this patch
    behaves correctly without or with this series

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_iblock.c

index 1fac95f8c22a81d155b07b1e76bd38821ce5c38b..a87e3c4f188efd5f3e5f7f729ddaebc0ee7dbb0b 100644 (file)
@@ -641,6 +641,12 @@ static int iblock_execute_rw(struct se_cmd *cmd)
                goto fail;
        cmd->priv = ibr;
 
+       if (!sgl_nents) {
+               atomic_set(&ibr->pending, 1);
+               iblock_complete_cmd(cmd);
+               return 0;
+       }
+
        bio = iblock_get_bio(cmd, block_lba, sgl_nents);
        if (!bio)
                goto fail_free_ibr;