bdev: rearrange struct spdk_bdev_io
Move the commonly-accessed fields to the front so they end up in the same cache line where possible. Also tweak the types of type, status, error.nvme.sct, error.nvme.sc, error.scsi.sc, and error.scsi.sk (they can fit in 8 bits), and move the Write Zeroes splitting variables into u.bdev. This reduces sizeof(struct spdk_bdev_io) from 272 to 224, in addition to the better cache line usage. Change-Id: I4a91fd07f252e7add4a2db179df9c53268672198 Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com> Reviewed-on: https://review.gerrithub.io/404053 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
c0e926b203
commit
7fd3a82561
@ -311,29 +311,14 @@ struct spdk_bdev_io {
|
||||
/** The mgmt channel that this I/O was allocated from. */
|
||||
struct spdk_bdev_mgmt_channel *mgmt_ch;
|
||||
|
||||
/** bdev allocated memory associated with this request */
|
||||
void *buf;
|
||||
/** User function that will be called when this completes */
|
||||
spdk_bdev_io_completion_cb cb;
|
||||
|
||||
/** requested size of the buffer associated with this I/O */
|
||||
uint64_t buf_len;
|
||||
/** Context that will be passed to the completion callback */
|
||||
void *caller_ctx;
|
||||
|
||||
/** Callback for when buf is allocated */
|
||||
spdk_bdev_io_get_buf_cb get_buf_cb;
|
||||
|
||||
/** Entry to the list need_buf of struct spdk_bdev. */
|
||||
STAILQ_ENTRY(spdk_bdev_io) buf_link;
|
||||
|
||||
/** Enumerated value representing the I/O type. */
|
||||
int16_t type;
|
||||
|
||||
/** Status for the IO */
|
||||
int16_t status;
|
||||
|
||||
/** number of blocks remaining in a split i/o */
|
||||
uint64_t split_remaining_num_blocks;
|
||||
|
||||
/** current offset of the split I/O in the bdev */
|
||||
uint64_t split_current_offset_blocks;
|
||||
/** Current tsc at submit time. Used to calculate latency at completion. */
|
||||
uint64_t submit_tsc;
|
||||
|
||||
/**
|
||||
* Set to true while the bdev module submit_request function is in progress.
|
||||
@ -343,6 +328,34 @@ struct spdk_bdev_io {
|
||||
*/
|
||||
bool in_submit_request;
|
||||
|
||||
/** Status for the IO */
|
||||
int8_t status;
|
||||
|
||||
/** Error information from a device */
|
||||
union {
|
||||
/** Only valid when status is SPDK_BDEV_IO_STATUS_NVME_ERROR */
|
||||
struct {
|
||||
/** NVMe status code type */
|
||||
uint8_t sct;
|
||||
/** NVMe status code */
|
||||
uint8_t sc;
|
||||
} nvme;
|
||||
/** Only valid when status is SPDK_BDEV_IO_STATUS_SCSI_ERROR */
|
||||
struct {
|
||||
/** SCSI status code */
|
||||
uint8_t sc;
|
||||
/** SCSI sense key */
|
||||
uint8_t sk;
|
||||
/** SCSI additional sense code */
|
||||
uint8_t asc;
|
||||
/** SCSI additional sense code qualifier */
|
||||
uint8_t ascq;
|
||||
} scsi;
|
||||
} error;
|
||||
|
||||
/** Enumerated value representing the I/O type. */
|
||||
uint8_t type;
|
||||
|
||||
union {
|
||||
struct {
|
||||
/** For basic IO case, use our own iovec element. */
|
||||
@ -359,6 +372,15 @@ struct spdk_bdev_io {
|
||||
|
||||
/** Starting offset (in blocks) of the bdev for this I/O. */
|
||||
uint64_t offset_blocks;
|
||||
|
||||
/** stored user callback in case we split the I/O and use a temporary callback */
|
||||
spdk_bdev_io_completion_cb stored_user_cb;
|
||||
|
||||
/** number of blocks remaining in a split i/o */
|
||||
uint64_t split_remaining_num_blocks;
|
||||
|
||||
/** current offset of the split I/O in the bdev */
|
||||
uint64_t split_current_offset_blocks;
|
||||
} bdev;
|
||||
struct {
|
||||
/** Channel reference held while messages for this reset are in progress. */
|
||||
@ -382,36 +404,17 @@ struct spdk_bdev_io {
|
||||
} nvme_passthru;
|
||||
} u;
|
||||
|
||||
/** Error information from a device */
|
||||
union {
|
||||
/** Only valid when status is SPDK_BDEV_IO_STATUS_NVME_ERROR */
|
||||
struct {
|
||||
/** NVMe status code type */
|
||||
int sct;
|
||||
/** NVMe status code */
|
||||
int sc;
|
||||
} nvme;
|
||||
/** Only valid when status is SPDK_BDEV_IO_STATUS_SCSI_ERROR */
|
||||
struct {
|
||||
/** SCSI status code */
|
||||
enum spdk_scsi_status sc;
|
||||
/** SCSI sense key */
|
||||
enum spdk_scsi_sense sk;
|
||||
/** SCSI additional sense code */
|
||||
uint8_t asc;
|
||||
/** SCSI additional sense code qualifier */
|
||||
uint8_t ascq;
|
||||
} scsi;
|
||||
} error;
|
||||
/** bdev allocated memory associated with this request */
|
||||
void *buf;
|
||||
|
||||
/** User function that will be called when this completes */
|
||||
spdk_bdev_io_completion_cb cb;
|
||||
/** requested size of the buffer associated with this I/O */
|
||||
uint64_t buf_len;
|
||||
|
||||
/** stored user callback in case we split the I/O and use a temporary callback */
|
||||
spdk_bdev_io_completion_cb stored_user_cb;
|
||||
/** Callback for when buf is allocated */
|
||||
spdk_bdev_io_get_buf_cb get_buf_cb;
|
||||
|
||||
/** Context that will be passed to the completion callback */
|
||||
void *caller_ctx;
|
||||
/** Entry to the list need_buf of struct spdk_bdev. */
|
||||
STAILQ_ENTRY(spdk_bdev_io) buf_link;
|
||||
|
||||
/** Member used for linking child I/Os together. */
|
||||
TAILQ_ENTRY(spdk_bdev_io) link;
|
||||
@ -419,9 +422,6 @@ struct spdk_bdev_io {
|
||||
/** It may be used by modules to put the bdev_io into its own list. */
|
||||
TAILQ_ENTRY(spdk_bdev_io) module_link;
|
||||
|
||||
/** Current tsc at submit time. Used to calculate latency at completion. */
|
||||
uint64_t submit_tsc;
|
||||
|
||||
/**
|
||||
* Per I/O context for use by the bdev module.
|
||||
*/
|
||||
|
@ -1672,12 +1672,12 @@ spdk_bdev_write_zeroes_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channe
|
||||
bdev_io->u.bdev.iovs = &bdev_io->u.bdev.iov;
|
||||
bdev_io->u.bdev.iovcnt = 1;
|
||||
bdev_io->u.bdev.num_blocks = len / spdk_bdev_get_block_size(bdev);
|
||||
bdev_io->split_remaining_num_blocks = num_blocks - bdev_io->u.bdev.num_blocks;
|
||||
bdev_io->split_current_offset_blocks = offset_blocks + bdev_io->u.bdev.num_blocks;
|
||||
bdev_io->u.bdev.split_remaining_num_blocks = num_blocks - bdev_io->u.bdev.num_blocks;
|
||||
bdev_io->u.bdev.split_current_offset_blocks = offset_blocks + bdev_io->u.bdev.num_blocks;
|
||||
}
|
||||
|
||||
if (split_request) {
|
||||
bdev_io->stored_user_cb = cb;
|
||||
bdev_io->u.bdev.stored_user_cb = cb;
|
||||
spdk_bdev_io_init(bdev_io, bdev, cb_arg, spdk_bdev_write_zeroes_split);
|
||||
} else {
|
||||
spdk_bdev_io_init(bdev_io, bdev, cb_arg, cb);
|
||||
@ -2608,24 +2608,24 @@ spdk_bdev_write_zeroes_split(struct spdk_bdev_io *bdev_io, bool success, void *c
|
||||
uint64_t len;
|
||||
|
||||
if (!success) {
|
||||
bdev_io->cb = bdev_io->stored_user_cb;
|
||||
bdev_io->cb = bdev_io->u.bdev.stored_user_cb;
|
||||
_spdk_bdev_io_complete(bdev_io);
|
||||
return;
|
||||
}
|
||||
|
||||
/* no need to perform the error checking from write_zeroes_blocks because this request already passed those checks. */
|
||||
len = spdk_min(spdk_bdev_get_block_size(bdev_io->bdev) * bdev_io->split_remaining_num_blocks,
|
||||
len = spdk_min(spdk_bdev_get_block_size(bdev_io->bdev) * bdev_io->u.bdev.split_remaining_num_blocks,
|
||||
ZERO_BUFFER_SIZE);
|
||||
|
||||
bdev_io->u.bdev.offset_blocks = bdev_io->split_current_offset_blocks;
|
||||
bdev_io->u.bdev.offset_blocks = bdev_io->u.bdev.split_current_offset_blocks;
|
||||
bdev_io->u.bdev.iov.iov_len = len;
|
||||
bdev_io->u.bdev.num_blocks = len / spdk_bdev_get_block_size(bdev_io->bdev);
|
||||
bdev_io->split_remaining_num_blocks -= bdev_io->u.bdev.num_blocks;
|
||||
bdev_io->split_current_offset_blocks += bdev_io->u.bdev.num_blocks;
|
||||
bdev_io->u.bdev.split_remaining_num_blocks -= bdev_io->u.bdev.num_blocks;
|
||||
bdev_io->u.bdev.split_current_offset_blocks += bdev_io->u.bdev.num_blocks;
|
||||
|
||||
/* if this round completes the i/o, change the callback to be the original user callback */
|
||||
if (bdev_io->split_remaining_num_blocks == 0) {
|
||||
spdk_bdev_io_init(bdev_io, bdev_io->bdev, cb_arg, bdev_io->stored_user_cb);
|
||||
if (bdev_io->u.bdev.split_remaining_num_blocks == 0) {
|
||||
spdk_bdev_io_init(bdev_io, bdev_io->bdev, cb_arg, bdev_io->u.bdev.stored_user_cb);
|
||||
} else {
|
||||
spdk_bdev_io_init(bdev_io, bdev_io->bdev, cb_arg, spdk_bdev_write_zeroes_split);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user