From 6ced60152638431a89c8418b44d95f5b7449fa3b Mon Sep 17 00:00:00 2001 From: Tomasz Zawadzki Date: Fri, 5 Jul 2019 06:33:53 -0400 Subject: [PATCH] lib/blob: only validate blobid of first page during bs_load Blob id only is matched to the very first page of md for that particular blob. During loading blobstore, we shouldn't verify further pages in chain against the blobid. Signed-off-by: Tomasz Zawadzki Change-Id: Ifc7863ddcb403aedc264c14e6b4c3915bd30dc41 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460607 Tested-by: SPDK CI Jenkins Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto Reviewed-by: Darek Stojaczyk Reviewed-by: Paul Luse --- lib/blob/blobstore.c | 3 ++- test/unit/lib/blob/blob.c/blob_ut.c | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index 90dda67ae..394654e68 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -3073,7 +3073,8 @@ static bool _spdk_bs_load_cur_md_page_valid(struct spdk_bs_load_ctx *ctx) return false; } - if (_spdk_bs_page_to_blobid(ctx->cur_page) != ctx->page->id) { + if (ctx->page->sequence_num == 0 && + _spdk_bs_page_to_blobid(ctx->cur_page) != ctx->page->id) { return false; } return true; diff --git a/test/unit/lib/blob/blob.c/blob_ut.c b/test/unit/lib/blob/blob.c/blob_ut.c index 4df6b4aa3..1516174ab 100644 --- a/test/unit/lib/blob/blob.c/blob_ut.c +++ b/test/unit/lib/blob/blob.c/blob_ut.c @@ -3664,6 +3664,19 @@ blob_dirty_shutdown(void) rc = spdk_blob_set_xattr(blob, "length", &length, sizeof(length)); CU_ASSERT(rc == 0); + /* Put xattr that fits exactly single page. + * This results in adding additional pages to MD. + * First is flags and smaller xattr, second the large xattr, + * third are just the extents. + */ + size_t xattr_length = 4072 - sizeof(struct spdk_blob_md_descriptor_xattr) - + strlen("large_xattr"); + char *xattr = calloc(xattr_length, sizeof(char)); + SPDK_CU_ASSERT_FATAL(xattr != NULL); + rc = spdk_blob_set_xattr(blob, "large_xattr", xattr, xattr_length); + free(xattr); + SPDK_CU_ASSERT_FATAL(rc == 0); + /* Resize the blob */ spdk_blob_resize(blob, 10, blob_op_complete, NULL); poll_threads();