bdev: cleanup child iov rewind code
When we run out of bdev_io's child iovs and we had to round down I/O size to nearest block size boundary, we used to decrease the existing child_iovcnt and set a new "child_iov_run_out" flag to terminate the uppermost splitting loop. We can get rid of that new flag by just not decreasing child_iovcnt when rewinding the last few iovs - it will make the uppermost loop naturally terminate using the existing checks. Change-Id: Ie40c7ce135e7fb8fe284afdf7beeebd10af85cb7 Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/459911 Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
5926236661
commit
fcbbcf4905
@ -1601,7 +1601,6 @@ _spdk_bdev_io_split(void *_bdev_io)
|
|||||||
uint64_t parent_iov_offset, iov_len;
|
uint64_t parent_iov_offset, iov_len;
|
||||||
uint32_t parent_iovpos, parent_iovcnt, child_iovcnt, iovcnt;
|
uint32_t parent_iovpos, parent_iovcnt, child_iovcnt, iovcnt;
|
||||||
void *md_buf = NULL;
|
void *md_buf = NULL;
|
||||||
bool child_iov_run_out = false;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
remaining = bdev_io->u.bdev.split_remaining_num_blocks;
|
remaining = bdev_io->u.bdev.split_remaining_num_blocks;
|
||||||
@ -1657,16 +1656,19 @@ _spdk_bdev_io_split(void *_bdev_io)
|
|||||||
* size and then adjust to_next_boundary before starting the
|
* size and then adjust to_next_boundary before starting the
|
||||||
* child I/O.
|
* child I/O.
|
||||||
*/
|
*/
|
||||||
|
assert(child_iovcnt == BDEV_IO_NUM_CHILD_IOV);
|
||||||
to_last_block_bytes = to_next_boundary_bytes % blocklen;
|
to_last_block_bytes = to_next_boundary_bytes % blocklen;
|
||||||
if (to_last_block_bytes != 0) {
|
if (to_last_block_bytes != 0) {
|
||||||
to_next_boundary_bytes += _to_next_boundary(to_next_boundary_bytes, blocklen);;
|
uint32_t child_iovpos = child_iovcnt - 1;
|
||||||
|
/* don't decrease child_iovcnt so the loop will naturally end */
|
||||||
|
|
||||||
|
to_next_boundary_bytes += _to_next_boundary(to_next_boundary_bytes, blocklen);
|
||||||
while (to_last_block_bytes > 0 && iovcnt > 0) {
|
while (to_last_block_bytes > 0 && iovcnt > 0) {
|
||||||
iov_len = spdk_min(to_last_block_bytes,
|
iov_len = spdk_min(to_last_block_bytes,
|
||||||
bdev_io->child_iov[child_iovcnt - 1].iov_len);
|
bdev_io->child_iov[child_iovpos].iov_len);
|
||||||
bdev_io->child_iov[child_iovcnt - 1].iov_len -= iov_len;
|
bdev_io->child_iov[child_iovpos].iov_len -= iov_len;
|
||||||
if (bdev_io->child_iov[child_iovcnt - 1].iov_len == 0) {
|
if (bdev_io->child_iov[child_iovpos].iov_len == 0) {
|
||||||
child_iovcnt--;
|
child_iovpos--;
|
||||||
iovcnt--;
|
iovcnt--;
|
||||||
}
|
}
|
||||||
to_last_block_bytes -= iov_len;
|
to_last_block_bytes -= iov_len;
|
||||||
@ -1674,7 +1676,6 @@ _spdk_bdev_io_split(void *_bdev_io)
|
|||||||
|
|
||||||
assert(to_last_block_bytes == 0);
|
assert(to_last_block_bytes == 0);
|
||||||
}
|
}
|
||||||
child_iov_run_out = true;
|
|
||||||
to_next_boundary -= to_next_boundary_bytes / blocklen;
|
to_next_boundary -= to_next_boundary_bytes / blocklen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1699,10 +1700,6 @@ _spdk_bdev_io_split(void *_bdev_io)
|
|||||||
remaining -= to_next_boundary;
|
remaining -= to_next_boundary;
|
||||||
bdev_io->u.bdev.split_current_offset_blocks = current_offset;
|
bdev_io->u.bdev.split_current_offset_blocks = current_offset;
|
||||||
bdev_io->u.bdev.split_remaining_num_blocks = remaining;
|
bdev_io->u.bdev.split_remaining_num_blocks = remaining;
|
||||||
/* stop splitting until child_iov is available */
|
|
||||||
if (spdk_unlikely(child_iov_run_out)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bdev_io->u.bdev.split_outstanding--;
|
bdev_io->u.bdev.split_outstanding--;
|
||||||
if (rc == -ENOMEM) {
|
if (rc == -ENOMEM) {
|
||||||
|
Loading…
Reference in New Issue
Block a user