Skip to content

Commit 95cadac

Browse files
author
Nicholas Bellinger
committed
target/file: Update hw_max_sectors based on current block_size
This patch allows FILEIO to update hw_max_sectors based on the current max_bytes_per_io. This is required because vfs_[writev,readv]() can accept a maximum of 2048 iovecs per call, so the enforced hw_max_sectors really needs to be calculated based on block_size. This addresses a >= v3.5 bug where block_size=512 was rejecting > 1M sized I/O requests, because FD_MAX_SECTORS was hardcoded to 2048 for the block_size=4096 case. (v2: Use max_bytes_per_io instead of ->update_hw_max_sectors) Reported-by: Henrik Goldman <hg@x-formation.com> Cc: <stable@vger.kernel.org> #3.5+ Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 2853c2b commit 95cadac

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

drivers/target/target_core_device.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,11 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size)
11061106
dev->dev_attrib.block_size = block_size;
11071107
pr_debug("dev[%p]: SE Device block_size changed to %u\n",
11081108
dev, block_size);
1109+
1110+
if (dev->dev_attrib.max_bytes_per_io)
1111+
dev->dev_attrib.hw_max_sectors =
1112+
dev->dev_attrib.max_bytes_per_io / block_size;
1113+
11091114
return 0;
11101115
}
11111116

drivers/target/target_core_file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id)
6666
pr_debug("CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic"
6767
" Target Core Stack %s\n", hba->hba_id, FD_VERSION,
6868
TARGET_CORE_MOD_VERSION);
69-
pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic"
70-
" MaxSectors: %u\n",
71-
hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS);
69+
pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic\n",
70+
hba->hba_id, fd_host->fd_host_id);
7271

7372
return 0;
7473
}
@@ -220,7 +219,8 @@ static int fd_configure_device(struct se_device *dev)
220219
}
221220

222221
dev->dev_attrib.hw_block_size = fd_dev->fd_block_size;
223-
dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
222+
dev->dev_attrib.max_bytes_per_io = FD_MAX_BYTES;
223+
dev->dev_attrib.hw_max_sectors = FD_MAX_BYTES / fd_dev->fd_block_size;
224224
dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH;
225225

226226
if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {

drivers/target/target_core_file.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
#define FD_DEVICE_QUEUE_DEPTH 32
88
#define FD_MAX_DEVICE_QUEUE_DEPTH 128
99
#define FD_BLOCKSIZE 512
10-
#define FD_MAX_SECTORS 2048
10+
/*
11+
* Limited by the number of iovecs (2048) per vfs_[writev,readv] call
12+
*/
13+
#define FD_MAX_BYTES 8388608
1114

1215
#define RRF_EMULATE_CDB 0x01
1316
#define RRF_GOT_LBA 0x02

include/target/target_core_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ struct se_dev_attrib {
620620
u32 unmap_granularity;
621621
u32 unmap_granularity_alignment;
622622
u32 max_write_same_len;
623+
u32 max_bytes_per_io;
623624
struct se_device *da_dev;
624625
struct config_group da_group;
625626
};

0 commit comments

Comments
 (0)