target/file: Fix SG table for prot_buf initialization
authorAkinobu Mita <akinobu.mita@gmail.com>
Mon, 13 Apr 2015 14:21:57 +0000 (23:21 +0900)
committerSasha Levin <sasha.levin@oracle.com>
Sun, 17 May 2015 23:12:12 +0000 (19:12 -0400)
commit5e64371411f83fdf6626162b28f07aaf29ee48cc
tree50c22ea723c27ea28012a1b0644bd2f084e47f75
parent606105af942168c1ba9424d0c9378a23ceab52f3
target/file: Fix SG table for prot_buf initialization

[ Upstream commit c836777830428372074d5129ac513e1472c99791 ]

In fd_do_prot_rw(), it allocates prot_buf which is used to copy from
se_cmd->t_prot_sg by sbc_dif_copy_prot().  The SG table for prot_buf
is also initialized by allocating 'se_cmd->t_prot_nents' entries of
scatterlist and setting the data length of each entry to PAGE_SIZE
at most.

However if se_cmd->t_prot_sg contains a clustered entry (i.e.
sg->length > PAGE_SIZE), the SG table for prot_buf can't be
initialized correctly and sbc_dif_copy_prot() can't copy to prot_buf.
(This actually happened with TCM loopback fabric module)

As prot_buf is allocated by kzalloc() and it's physically contiguous,
we only need a single scatterlist entry.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
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: <stable@vger.kernel.org> # v3.14+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
drivers/target/target_core_file.c