]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
target: ensure se_cmd->t_prot_sg is allocated when required
authorAkinobu Mita <akinobu.mita@gmail.com>
Fri, 1 May 2015 06:23:49 +0000 (15:23 +0900)
committerNicholas Bellinger <nab@linux-iscsi.org>
Sun, 31 May 2015 05:42:24 +0000 (22:42 -0700)
commit5835812f13e56483f2c4907664bb43b0a78546b6
tree229ed3b47ab6f80936c063b5b92bfe6bf7c736e5
parent57636388af32c2c7db3919e8d53f4979b7c7c307
target: ensure se_cmd->t_prot_sg is allocated when required

Even if the device backend is initialized with protection info is
enabled, some requests don't have the protection info attached for
WRITE SAME command issued by block device helpers, WRITE command with
WRPROTECT=0 by SG_IO ioctl, etc.

So when TCM loopback fabric module is used, se_cmd->t_prot_sg is NULL
for these requests and performing WRITE_INSERT of PI using software
emulation by sbc_dif_generate() causes kernel crash.

To fix this, introduce SCF_PASSTHROUGH_PROT_SG_TO_MEM_NOALLOC for
se_cmd_flags, which is used to determine that se_cmd->t_prot_sg needs
to be allocated or use pre-allocated protection information by scsi
mid-layer.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Nicholas Bellinger <nab@linux-iscsi.org>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>
Cc: target-devel@vger.kernel.org
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_transport.c
include/target/target_core_base.h