From 958364b4a0c11c8a2fe792653ed7d5a58e94ce4a Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Tue, 27 Apr 2021 09:54:55 -0400 Subject: [PATCH] lib/blob: only verify cluster allocation when I/O is not frozen During snapshot creation the original blob becomes a thin provisioned blob that will only the diff of data after snapshot creation. Despite the comment in the UT the number of polls before issuing blob write was hitting blob BEFORE it swapped with new one. Issuing I/O during this period shall check for io freeze before checking cluster allocation. Otherwise bs_io_unit_is_allocated() hits assert for thin provisioned blob. This is because cluster map of blob is empty, but properties have not been updated yet. Signed-off-by: Tomasz Zawadzki Change-Id: I742e1a50b14d456ae1e6de13b5111caec3e8322c Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7641 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- lib/blob/blobstore.c | 4 ++-- test/unit/lib/blob/blob.c/blob_ut.c | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 0278eab80..d7e3bbb03 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -2612,8 +2612,6 @@ blob_request_submit_op_single(struct spdk_io_channel *_ch, struct spdk_blob *blo cpl.u.blob_basic.cb_fn = cb_fn; cpl.u.blob_basic.cb_arg = cb_arg; - is_allocated = blob_calculate_lba_and_lba_count(blob, offset, length, &lba, &lba_count); - if (blob->frozen_refcnt) { /* This blob I/O is frozen */ spdk_bs_user_op_t *op; @@ -2630,6 +2628,8 @@ blob_request_submit_op_single(struct spdk_io_channel *_ch, struct spdk_blob *blo return; } + is_allocated = blob_calculate_lba_and_lba_count(blob, offset, length, &lba, &lba_count); + switch (op_type) { case SPDK_BLOB_READ: { spdk_bs_batch_t *batch; diff --git a/test/unit/lib/blob/blob.c/blob_ut.c b/test/unit/lib/blob/blob.c/blob_ut.c index a63031bac..1494de29c 100644 --- a/test/unit/lib/blob/blob.c/blob_ut.c +++ b/test/unit/lib/blob/blob.c/blob_ut.c @@ -821,7 +821,7 @@ blob_snapshot_freeze_io(void) /* This is implementation specific. * Flag 'frozen_io' is set in _spdk_bs_snapshot_freeze_cpl callback. * Four async I/O operations happen before that. */ - poll_thread_times(0, 3); + poll_thread_times(0, 4); CU_ASSERT(TAILQ_EMPTY(&bs_channel->queued_io)); @@ -833,9 +833,8 @@ blob_snapshot_freeze_io(void) /* Verify that I/O is queued */ CU_ASSERT(!TAILQ_EMPTY(&bs_channel->queued_io)); - /* Verify that payload is not written to disk */ - CU_ASSERT(memcmp(payload_zero, &g_dev_buffer[blob->active.clusters[0]*SPDK_BS_PAGE_SIZE], - SPDK_BS_PAGE_SIZE) == 0); + /* Verify that payload is not written to disk, at this point the blobs already switched */ + CU_ASSERT(blob->active.clusters[0] == 0); /* Finish all operations including spdk_bs_create_snapshot */ poll_threads();