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 <tomasz.zawadzki@intel.com>
Change-Id: I742e1a50b14d456ae1e6de13b5111caec3e8322c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7641
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Tomasz Zawadzki 2021-04-27 09:54:55 -04:00
parent d0b4deab2b
commit 958364b4a0
2 changed files with 5 additions and 6 deletions

View File

@ -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;

View File

@ -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();