Skip to content

Commit

Permalink
target/file: Update hw_max_sectors based on current block_size
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: <[email protected]> #3.5+
Signed-off-by: Nicholas Bellinger <[email protected]>
  • Loading branch information
Nicholas Bellinger committed Dec 19, 2013
1 parent 2853c2b commit 95cadac
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions drivers/target/target_core_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,11 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size)
dev->dev_attrib.block_size = block_size;
pr_debug("dev[%p]: SE Device block_size changed to %u\n",
dev, block_size);

if (dev->dev_attrib.max_bytes_per_io)
dev->dev_attrib.hw_max_sectors =
dev->dev_attrib.max_bytes_per_io / block_size;

return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/target/target_core_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,8 @@ static int fd_attach_hba(struct se_hba *hba, u32 host_id)
pr_debug("CORE_HBA[%d] - TCM FILEIO HBA Driver %s on Generic"
" Target Core Stack %s\n", hba->hba_id, FD_VERSION,
TARGET_CORE_MOD_VERSION);
pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic"
" MaxSectors: %u\n",
hba->hba_id, fd_host->fd_host_id, FD_MAX_SECTORS);
pr_debug("CORE_HBA[%d] - Attached FILEIO HBA: %u to Generic\n",
hba->hba_id, fd_host->fd_host_id);

return 0;
}
Expand Down Expand Up @@ -220,7 +219,8 @@ static int fd_configure_device(struct se_device *dev)
}

dev->dev_attrib.hw_block_size = fd_dev->fd_block_size;
dev->dev_attrib.hw_max_sectors = FD_MAX_SECTORS;
dev->dev_attrib.max_bytes_per_io = FD_MAX_BYTES;
dev->dev_attrib.hw_max_sectors = FD_MAX_BYTES / fd_dev->fd_block_size;
dev->dev_attrib.hw_queue_depth = FD_MAX_DEVICE_QUEUE_DEPTH;

if (fd_dev->fbd_flags & FDBD_HAS_BUFFERED_IO_WCE) {
Expand Down
5 changes: 4 additions & 1 deletion drivers/target/target_core_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
#define FD_DEVICE_QUEUE_DEPTH 32
#define FD_MAX_DEVICE_QUEUE_DEPTH 128
#define FD_BLOCKSIZE 512
#define FD_MAX_SECTORS 2048
/*
* Limited by the number of iovecs (2048) per vfs_[writev,readv] call
*/
#define FD_MAX_BYTES 8388608

#define RRF_EMULATE_CDB 0x01
#define RRF_GOT_LBA 0x02
Expand Down
1 change: 1 addition & 0 deletions include/target/target_core_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ struct se_dev_attrib {
u32 unmap_granularity;
u32 unmap_granularity_alignment;
u32 max_write_same_len;
u32 max_bytes_per_io;
struct se_device *da_dev;
struct config_group da_group;
};
Expand Down

0 comments on commit 95cadac

Please sign in to comment.