From d77608212b6a01487e44697a488710fc1fcf51e1 Mon Sep 17 00:00:00 2001 From: Xiaodong Liu Date: Thu, 28 Feb 2019 21:00:11 +0800 Subject: [PATCH] bdev/raid: enable flush support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FLUSH io_type shares a same process with UNMAP, except that in the end, it calls spdk_bdev_flush_blocks function. Change-Id: I4529bf29b7cd9f16d10f2edc99a20d25213c9c71 Signed-off-by: Xiaodong Liu Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446492 Tested-by: SPDK CI Jenkins Reviewed-by: Piotr Pelpliński Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: wuzhouhui Reviewed-by: Changpeng Liu --- lib/bdev/raid/bdev_raid.c | 13 ++++++++----- test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c | 8 ++++++++ 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index 6e74baed8..995ee73db 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -742,6 +742,13 @@ _raid_bdev_submit_null_payload_request_next(void *_bdev_io) raid_bdev_base_io_completion, bdev_io); break; + case SPDK_BDEV_IO_TYPE_FLUSH: + ret = spdk_bdev_flush_blocks(raid_bdev->base_bdev_info[disk_idx].desc, + raid_ch->base_channel[disk_idx], + offset_in_disk, nblocks_in_disk, + raid_bdev_base_io_completion, bdev_io); + break; + default: SPDK_ERRLOG("submit request, invalid io type with null payload %u\n", bdev_io->type); assert(false); @@ -835,15 +842,11 @@ raid_bdev_submit_request(struct spdk_io_channel *ch, struct spdk_bdev_io *bdev_i raid_bdev_start_rw_request(ch, bdev_io); break; - case SPDK_BDEV_IO_TYPE_FLUSH: - /* TODO: support flush if requirement comes */ - spdk_bdev_io_complete(bdev_io, SPDK_BDEV_IO_STATUS_SUCCESS); - break; - case SPDK_BDEV_IO_TYPE_RESET: _raid_bdev_submit_reset_request(ch, bdev_io); break; + case SPDK_BDEV_IO_TYPE_FLUSH: case SPDK_BDEV_IO_TYPE_UNMAP: _raid_bdev_submit_null_payload_request(ch, bdev_io); break; diff --git a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c index eebfe2ce5..f84394a23 100644 --- a/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c +++ b/test/unit/lib/bdev/bdev_raid.c/bdev_raid_ut.c @@ -306,6 +306,14 @@ spdk_bdev_unmap_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, return g_bdev_io_submit_status; } +int +spdk_bdev_flush_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch, + uint64_t offset_blocks, uint64_t num_blocks, + spdk_bdev_io_completion_cb cb, void *cb_arg) +{ + return 0; +} + bool spdk_bdev_io_type_supported(struct spdk_bdev *bdev, enum spdk_bdev_io_type io_type) {