diff --git a/include/spdk_internal/bdev.h b/include/spdk_internal/bdev.h index fd91e6f84..4db50225c 100644 --- a/include/spdk_internal/bdev.h +++ b/include/spdk_internal/bdev.h @@ -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. */ diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index eb3dcdc49..934bf59f6 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -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); }