linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org,
	target-devel <target-devel@vger.kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Lance Gropper <lance.gropper@qosserver.com>,
	Stefan Priebe <s.priebe@profihost.ag>,
	Christoph Hellwig <hch@lst.de>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Roland Dreier <roland@purestorage.com>,
	Nicholas Bellinger <nab@linux-iscsi.org>
Subject: [PATCH 3.10 51/51] target: Drop arbitrary maximum I/O size limit
Date: Tue,  3 Feb 2015 15:17:33 -0800	[thread overview]
Message-ID: <20150203231726.142383380@linuxfoundation.org> (raw)
In-Reply-To: <20150203231724.582537862@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------


From: Nicholas Bellinger <nab@linux-iscsi.org>

commit 046ba64285a4389ae5e9a7dfa253c6bff3d7c341 upstream.

This patch drops the arbitrary maximum I/O size limit in sbc_parse_cdb(),
which currently for fabric_max_sectors is hardcoded to 8192 (4 MB for 512
byte sector devices), and for hw_max_sectors is a backend driver dependent
value.

This limit is problematic because Linux initiators have only recently
started to honor block limits MAXIMUM TRANSFER LENGTH, and other non-Linux
based initiators (eg: MSFT Fibre Channel) can also generate I/Os larger
than 4 MB in size.

Currently when this happens, the following message will appear on the
target resulting in I/Os being returned with non recoverable status:

  SCSI OP 28h with too big sectors 16384 exceeds fabric_max_sectors: 8192

Instead, drop both [fabric,hw]_max_sector checks in sbc_parse_cdb(),
and convert the existing hw_max_sectors into a purely informational
attribute used to represent the granuality that backend driver and/or
subsystem code is splitting I/Os upon.

Also, update FILEIO with an explicit FD_MAX_BYTES check in fd_execute_rw()
to deal with the one special iovec limitiation case.

v2 changes:
  - Drop hw_max_sectors check in sbc_parse_cdb()

Reported-by: Lance Gropper <lance.gropper@qosserver.com>
Reported-by: Stefan Priebe <s.priebe@profihost.ag>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/target/target_core_device.c |    8 ++++----
 drivers/target/target_core_file.c   |   11 ++++++++++-
 drivers/target/target_core_iblock.c |    2 +-
 drivers/target/target_core_sbc.c    |   15 ---------------
 drivers/target/target_core_spc.c    |    5 +----
 5 files changed, 16 insertions(+), 25 deletions(-)

--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -1037,10 +1037,10 @@ int se_dev_set_optimal_sectors(struct se
 				" changed for TCM/pSCSI\n", dev);
 		return -EINVAL;
 	}
-	if (optimal_sectors > dev->dev_attrib.fabric_max_sectors) {
+	if (optimal_sectors > dev->dev_attrib.hw_max_sectors) {
 		pr_err("dev[%p]: Passed optimal_sectors %u cannot be"
-			" greater than fabric_max_sectors: %u\n", dev,
-			optimal_sectors, dev->dev_attrib.fabric_max_sectors);
+			" greater than hw_max_sectors: %u\n", dev,
+			optimal_sectors, dev->dev_attrib.hw_max_sectors);
 		return -EINVAL;
 	}
 
@@ -1442,7 +1442,6 @@ struct se_device *target_alloc_device(st
 				DA_UNMAP_GRANULARITY_ALIGNMENT_DEFAULT;
 	dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN;
 	dev->dev_attrib.fabric_max_sectors = DA_FABRIC_MAX_SECTORS;
-	dev->dev_attrib.optimal_sectors = DA_FABRIC_MAX_SECTORS;
 
 	return dev;
 }
@@ -1475,6 +1474,7 @@ int target_configure_device(struct se_de
 	dev->dev_attrib.hw_max_sectors =
 		se_dev_align_max_sectors(dev->dev_attrib.hw_max_sectors,
 					 dev->dev_attrib.hw_block_size);
+	dev->dev_attrib.optimal_sectors = dev->dev_attrib.hw_max_sectors;
 
 	dev->dev_index = scsi_get_new_index(SCSI_DEVICE_INDEX);
 	dev->creation_time = get_jiffies_64();
--- a/drivers/target/target_core_file.c
+++ b/drivers/target/target_core_file.c
@@ -554,7 +554,16 @@ fd_execute_rw(struct se_cmd *cmd)
 	enum dma_data_direction data_direction = cmd->data_direction;
 	struct se_device *dev = cmd->se_dev;
 	int ret = 0;
-
+	/*
+	 * We are currently limited by the number of iovecs (2048) per
+	 * single vfs_[writev,readv] call.
+	 */
+	if (cmd->data_length > FD_MAX_BYTES) {
+		pr_err("FILEIO: Not able to process I/O of %u bytes due to"
+		       "FD_MAX_BYTES: %u iovec count limitiation\n",
+			cmd->data_length, FD_MAX_BYTES);
+		return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
+	}
 	/*
 	 * Call vectorized fileio functions to map struct scatterlist
 	 * physical memory addresses to struct iovec virtual memory.
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -122,7 +122,7 @@ static int iblock_configure_device(struc
 	q = bdev_get_queue(bd);
 
 	dev->dev_attrib.hw_block_size = bdev_logical_block_size(bd);
-	dev->dev_attrib.hw_max_sectors = UINT_MAX;
+	dev->dev_attrib.hw_max_sectors = queue_max_hw_sectors(q);
 	dev->dev_attrib.hw_queue_depth = q->nr_requests;
 
 	/*
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -561,21 +561,6 @@ sbc_parse_cdb(struct se_cmd *cmd, struct
 	if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
 		unsigned long long end_lba;
 
-		if (sectors > dev->dev_attrib.fabric_max_sectors) {
-			printk_ratelimited(KERN_ERR "SCSI OP %02xh with too"
-				" big sectors %u exceeds fabric_max_sectors:"
-				" %u\n", cdb[0], sectors,
-				dev->dev_attrib.fabric_max_sectors);
-			return TCM_INVALID_CDB_FIELD;
-		}
-		if (sectors > dev->dev_attrib.hw_max_sectors) {
-			printk_ratelimited(KERN_ERR "SCSI OP %02xh with too"
-				" big sectors %u exceeds backend hw_max_sectors:"
-				" %u\n", cdb[0], sectors,
-				dev->dev_attrib.hw_max_sectors);
-			return TCM_INVALID_CDB_FIELD;
-		}
-
 		end_lba = dev->transport->get_blocks(dev) + 1;
 		if (cmd->t_task_lba + sectors > end_lba) {
 			pr_err("cmd exceeds last lba %llu "
--- a/drivers/target/target_core_spc.c
+++ b/drivers/target/target_core_spc.c
@@ -444,7 +444,6 @@ static sense_reason_t
 spc_emulate_evpd_b0(struct se_cmd *cmd, unsigned char *buf)
 {
 	struct se_device *dev = cmd->se_dev;
-	u32 max_sectors;
 	int have_tp = 0;
 
 	/*
@@ -469,9 +468,7 @@ spc_emulate_evpd_b0(struct se_cmd *cmd,
 	/*
 	 * Set MAXIMUM TRANSFER LENGTH
 	 */
-	max_sectors = min(dev->dev_attrib.fabric_max_sectors,
-			  dev->dev_attrib.hw_max_sectors);
-	put_unaligned_be32(max_sectors, &buf[8]);
+	put_unaligned_be32(dev->dev_attrib.hw_max_sectors, &buf[8]);
 
 	/*
 	 * Set OPTIMAL TRANSFER LENGTH



  parent reply	other threads:[~2015-02-03 23:31 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 23:16 [PATCH 3.10 00/51] 3.10.68-stable review Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 01/51] spi: dw-mid: fix FIFO size Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 02/51] ASoC: wm8960: Fix capture sample rate from 11250 to 11025 Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 03/51] can: kvaser_usb: Do not sleep in atomic context Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 04/51] can: kvaser_usb: Send correct context to URB completion Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 05/51] can: kvaser_usb: Retry the first bulk transfer on -ETIMEDOUT Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 06/51] can: kvaser_usb: Fix state handling upon BUS_ERROR events Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 07/51] powerpc/xmon: Fix another endiannes issue in RTAS call from xmon Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 08/51] ALSA: seq-dummy: remove deadlock-causing events on close Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 09/51] Input: i8042 - add noloop quirk for Medion Akoya E7225 (MD98857) Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 10/51] nfs: fix dio deadlock when O_DIRECT flag is flipped Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 11/51] NFSv4.1: Fix an Oops in nfs41_walk_client_list Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 12/51] nl80211: fix per-station group key get/del and memory leak Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 13/51] dm thin: dont allow messages to be sent to a pool target in READ_ONLY or FAIL mode Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 14/51] dm cache: fix missing ERR_PTR returns and handling Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 15/51] spi/pxa2xx: Clear cur_chip pointer before starting next message Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 16/51] regulator: core: fix race condition in regulator_put() Greg Kroah-Hartman
2015-02-03 23:16 ` [PATCH 3.10 17/51] drivers: net: cpsw: discard dual emac default vlan configuration Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 18/51] ARM: 7829/1: Add ".text.unlikely" and ".text.hot" to arm unwind tables Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 19/51] ARM: mm: correct pte_same behaviour for LPAE Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 20/51] ARM: LPAE: use signed arithmetic for mask definitions Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 21/51] ARM: LPAE: use phys_addr_t in alloc_init_pud() Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 22/51] ARM: fix type of PHYS_PFN_OFFSET to unsigned long Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 23/51] ARM: lpae: fix definition of PTE_HWTABLE_PTRS Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 24/51] ARM: 7866/1: include: asm: use long long instead of u64 within atomic.h Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 25/51] ARM: 7867/1: include: asm: use int instead of unsigned long for oldval in atomic_cmpxchg() Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 26/51] ARM: fix asm/memory.h build error Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 27/51] ARM: 7931/1: Correct virt_addr_valid Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 28/51] ARM: DMA: ensure that old section mappings are flushed from the TLB Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 29/51] ARM: 8108/1: mm: Introduce {pte,pmd}_isset and {pte,pmd}_isclear Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 30/51] ARM: 8109/1: mm: Modify pte_write and pmd_write logic for LPAE Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 31/51] pstore: Fail to unlink if a driver has not defined pstore_erase Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 32/51] pstore: d_alloc_name() doesnt return an ERR_PTR Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 33/51] pstore: clarify clearing of _read_cnt in ramoops_context Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 34/51] pstore: skip zero size persistent ram buffer in traverse Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 35/51] pstore: Fix NULL pointer fault if get NULL prz in ramoops_get_next_prz Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 36/51] pstore/ram: avoid atomic accesses for ioremapped regions Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 37/51] efi-pstore: Make efi-pstore return a unique id Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 38/51] gpio: squelch a compiler warning Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 39/51] workqueue: fix subtle pool management issue which can stall whole worker_pool Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 40/51] IB/isert: Adjust CQ size to HW limits Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 41/51] ib_isert: Add max_send_sge=2 minimum for control PDU responses Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 42/51] vhost-scsi: Take configfs group dependency during VHOST_SCSI_SET_ENDPOINT Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 43/51] tcm_loop: Fix wrong I_T nexus association Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 44/51] vhost-scsi: Add missing virtio-scsi -> TCM attribute conversion Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 45/51] iscsi,iser-target: Initiate termination only once Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 46/51] iser-target: Fix flush + disconnect completion handling Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 47/51] iser-target: Parallelize CM connection establishment Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 48/51] iser-target: Fix connected_handler + teardown flow race Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 49/51] iser-target: Handle ADDR_CHANGE event for listener cm_id Greg Kroah-Hartman
2015-02-03 23:17 ` [PATCH 3.10 50/51] iser-target: Fix implicit termination of connections Greg Kroah-Hartman
2015-02-03 23:17 ` Greg Kroah-Hartman [this message]
2015-02-04 14:01 ` [PATCH 3.10 00/51] 3.10.68-stable review Guenter Roeck
2015-02-04 17:30 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150203231726.142383380@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=lance.gropper@qosserver.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=nab@linux-iscsi.org \
    --cc=roland@purestorage.com \
    --cc=s.priebe@profihost.ag \
    --cc=stable@vger.kernel.org \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).