blob: fix bs recovery
Recovery code did not claim clusters taken by metadata. Signed-off-by: Maciej Szwed <maciej.szwed@intel.com> Change-Id: If6726eddd22f4e1a3f9814b2348243155fb0fdb9 Reviewed-on: https://review.gerrithub.io/394173 Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
This commit is contained in:
parent
60c1cd75dc
commit
2a8d46cece
@ -1982,6 +1982,8 @@ static void
|
||||
_spdk_bs_load_replay_md_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
{
|
||||
struct spdk_bs_load_ctx *ctx = cb_arg;
|
||||
uint64_t num_md_clusters;
|
||||
uint64_t i;
|
||||
uint32_t page_num;
|
||||
|
||||
if (bserrno != 0) {
|
||||
@ -2019,6 +2021,11 @@ _spdk_bs_load_replay_md_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
||||
ctx->cur_page = ctx->page_index;
|
||||
_spdk_bs_load_replay_cur_md_page(seq, cb_arg);
|
||||
} else {
|
||||
/* Claim all of the clusters used by the metadata */
|
||||
num_md_clusters = divide_round_up(ctx->super->md_len, ctx->bs->pages_per_cluster);
|
||||
for (i = 0; i < num_md_clusters; i++) {
|
||||
_spdk_bs_claim_cluster(ctx->bs, i);
|
||||
}
|
||||
spdk_dma_free(ctx->page);
|
||||
_spdk_bs_load_write_used_md(seq, ctx, bserrno);
|
||||
}
|
||||
|
@ -1918,6 +1918,7 @@ blob_dirty_shutdown(void)
|
||||
spdk_blob_id blobid1, blobid2, blobid3;
|
||||
struct spdk_blob *blob;
|
||||
uint64_t length;
|
||||
uint64_t free_clusters;
|
||||
const void *value;
|
||||
size_t value_len;
|
||||
uint32_t page_num;
|
||||
@ -1954,6 +1955,8 @@ blob_dirty_shutdown(void)
|
||||
rc = spdk_blob_resize(blob, 10);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
free_clusters = spdk_bs_free_cluster_count(g_bs);
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
blob = NULL;
|
||||
g_blob = NULL;
|
||||
@ -1973,6 +1976,8 @@ blob_dirty_shutdown(void)
|
||||
CU_ASSERT(g_blob != NULL);
|
||||
blob = g_blob;
|
||||
|
||||
CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs));
|
||||
|
||||
/* Get the xattrs */
|
||||
value = NULL;
|
||||
rc = spdk_blob_get_xattr_value(blob, "length", &value, &value_len);
|
||||
@ -1986,6 +1991,8 @@ blob_dirty_shutdown(void)
|
||||
rc = spdk_blob_resize(blob, 20);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
free_clusters = spdk_bs_free_cluster_count(g_bs);
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
blob = NULL;
|
||||
@ -2007,6 +2014,7 @@ blob_dirty_shutdown(void)
|
||||
CU_ASSERT(g_blob != NULL);
|
||||
blob = g_blob;
|
||||
CU_ASSERT(spdk_blob_get_num_clusters(blob) == 20);
|
||||
CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs));
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
@ -2037,6 +2045,8 @@ blob_dirty_shutdown(void)
|
||||
rc = spdk_blob_resize(blob, 10);
|
||||
CU_ASSERT(rc == 0);
|
||||
|
||||
free_clusters = spdk_bs_free_cluster_count(g_bs);
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
blob = NULL;
|
||||
g_blob = NULL;
|
||||
@ -2064,12 +2074,15 @@ blob_dirty_shutdown(void)
|
||||
CU_ASSERT(*(uint64_t *)value == length);
|
||||
CU_ASSERT(value_len == 8);
|
||||
CU_ASSERT(spdk_blob_get_num_clusters(blob) == 10);
|
||||
CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs));
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
spdk_bs_delete_blob(g_bs, blobid2, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
||||
free_clusters = spdk_bs_free_cluster_count(g_bs);
|
||||
|
||||
/* Dirty shutdown */
|
||||
_spdk_bs_free(g_bs);
|
||||
/* reload the blobstore */
|
||||
@ -2085,6 +2098,7 @@ blob_dirty_shutdown(void)
|
||||
spdk_bs_open_blob(g_bs, blobid1, blob_op_with_handle_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
CU_ASSERT(g_blob != NULL);
|
||||
CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs));
|
||||
spdk_blob_close(g_blob, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
||||
@ -2154,6 +2168,8 @@ blob_dirty_shutdown(void)
|
||||
page->sequence_num = 1;
|
||||
page->crc = _spdk_blob_md_page_calc_crc(page);
|
||||
|
||||
free_clusters = spdk_bs_free_cluster_count(g_bs);
|
||||
|
||||
/* Dirty shutdown */
|
||||
_spdk_bs_free(g_bs);
|
||||
/* reload the blobstore */
|
||||
@ -2171,6 +2187,8 @@ blob_dirty_shutdown(void)
|
||||
CU_ASSERT(g_blob != NULL);
|
||||
blob = g_blob;
|
||||
|
||||
CU_ASSERT(free_clusters == spdk_bs_free_cluster_count(g_bs));
|
||||
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
blob = NULL;
|
||||
g_blob = NULL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user