scsi: target/iscsi: Simplify iscsit_handle_text_cmd()
Treat text_in and padding as a single buffer instead of two buffers. Cc: Nicholas Bellinger <nab@linux-iscsi.org> Cc: Mike Christie <mchristi@redhat.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Bart Van Assche <bvanassche@acm.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
658c31224d
commit
47eefded1f
|
@ -2240,28 +2240,25 @@ iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
|
||||||
rx_size = payload_length;
|
rx_size = payload_length;
|
||||||
if (payload_length) {
|
if (payload_length) {
|
||||||
u32 checksum = 0, data_crc = 0;
|
u32 checksum = 0, data_crc = 0;
|
||||||
u32 padding = 0, pad_bytes = 0;
|
u32 padding = 0;
|
||||||
int niov = 0, rx_got;
|
int niov = 0, rx_got;
|
||||||
struct kvec iov[3];
|
struct kvec iov[2];
|
||||||
|
|
||||||
text_in = kzalloc(payload_length, GFP_KERNEL);
|
rx_size = ALIGN(payload_length, 4);
|
||||||
|
text_in = kzalloc(rx_size, GFP_KERNEL);
|
||||||
if (!text_in)
|
if (!text_in)
|
||||||
goto reject;
|
goto reject;
|
||||||
|
|
||||||
cmd->text_in_ptr = text_in;
|
cmd->text_in_ptr = text_in;
|
||||||
|
|
||||||
memset(iov, 0, 3 * sizeof(struct kvec));
|
memset(iov, 0, sizeof(iov));
|
||||||
iov[niov].iov_base = text_in;
|
iov[niov].iov_base = text_in;
|
||||||
iov[niov++].iov_len = payload_length;
|
iov[niov++].iov_len = rx_size;
|
||||||
|
|
||||||
padding = ((-payload_length) & 3);
|
padding = rx_size - payload_length;
|
||||||
if (padding != 0) {
|
if (padding)
|
||||||
iov[niov].iov_base = &pad_bytes;
|
|
||||||
iov[niov++].iov_len = padding;
|
|
||||||
rx_size += padding;
|
|
||||||
pr_debug("Receiving %u additional bytes"
|
pr_debug("Receiving %u additional bytes"
|
||||||
" for padding.\n", padding);
|
" for padding.\n", padding);
|
||||||
}
|
|
||||||
if (conn->conn_ops->DataDigest) {
|
if (conn->conn_ops->DataDigest) {
|
||||||
iov[niov].iov_base = &checksum;
|
iov[niov].iov_base = &checksum;
|
||||||
iov[niov++].iov_len = ISCSI_CRC_LEN;
|
iov[niov++].iov_len = ISCSI_CRC_LEN;
|
||||||
|
@ -2273,9 +2270,9 @@ iscsit_handle_text_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
|
||||||
goto reject;
|
goto reject;
|
||||||
|
|
||||||
if (conn->conn_ops->DataDigest) {
|
if (conn->conn_ops->DataDigest) {
|
||||||
iscsit_do_crypto_hash_buf(conn->conn_rx_hash, text_in,
|
iscsit_do_crypto_hash_buf(conn->conn_rx_hash,
|
||||||
payload_length, padding,
|
text_in, rx_size, 0, NULL,
|
||||||
&pad_bytes, &data_crc);
|
&data_crc);
|
||||||
|
|
||||||
if (checksum != data_crc) {
|
if (checksum != data_crc) {
|
||||||
pr_err("Text data CRC32C DataDigest"
|
pr_err("Text data CRC32C DataDigest"
|
||||||
|
|
Loading…
Reference in New Issue