lib/blob: add _spdk_bs_claim/release_md_page()

Functions to claim and release md pages were added.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: I1c8ddc13c8a5806fb874e5c34dae2a327e1ff248
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/482011
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Tomasz Zawadzki 2020-01-17 11:31:24 -05:00
parent 1b23560fcd
commit cb44fa06f9

View File

@ -84,6 +84,24 @@ _spdk_bs_get_snapshot_entry(struct spdk_blob_store *bs, spdk_blob_id blobid)
return snapshot_entry;
}
static void
_spdk_bs_claim_md_page(struct spdk_blob_store *bs, uint32_t page)
{
assert(page < spdk_bit_array_capacity(bs->used_md_pages));
assert(spdk_bit_array_get(bs->used_md_pages, page) == false);
spdk_bit_array_set(bs->used_md_pages, page);
}
static void
_spdk_bs_release_md_page(struct spdk_blob_store *bs, uint32_t page)
{
assert(page < spdk_bit_array_capacity(bs->used_md_pages));
assert(spdk_bit_array_get(bs->used_md_pages, page) == true);
spdk_bit_array_clear(bs->used_md_pages, page);
}
static void
_spdk_bs_claim_cluster(struct spdk_blob_store *bs, uint32_t cluster_num)
{
@ -1435,14 +1453,14 @@ _spdk_blob_persist_zero_pages_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bse
* so any pages in the clean list must be zeroed.
*/
for (i = 1; i < blob->clean.num_pages; i++) {
spdk_bit_array_clear(bs->used_md_pages, blob->clean.pages[i]);
_spdk_bs_release_md_page(bs, blob->clean.pages[i]);
}
if (blob->active.num_pages == 0) {
uint32_t page_num;
page_num = _spdk_bs_blobid_to_page(blob->id);
spdk_bit_array_clear(bs->used_md_pages, page_num);
_spdk_bs_release_md_page(bs, page_num);
}
/* Move on to clearing clusters */
@ -1698,7 +1716,7 @@ _spdk_blob_persist_generate_new_md(struct spdk_blob_persist_ctx *ctx)
/* Now that previous metadata page is complete, calculate the crc for it. */
ctx->pages[i - 1].crc = _spdk_blob_md_page_calc_crc(&ctx->pages[i - 1]);
blob->active.pages[i] = page_num;
spdk_bit_array_set(bs->used_md_pages, page_num);
_spdk_bs_claim_md_page(bs, page_num);
SPDK_DEBUGLOG(SPDK_LOG_BLOB, "Claiming page %u for blob %lu\n", page_num, blob->id);
page_num++;
}
@ -3440,7 +3458,7 @@ _spdk_bs_load_replay_md_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
page_num = ctx->cur_page;
if (_spdk_bs_load_cur_md_page_valid(ctx) == true) {
if (ctx->page->sequence_num == 0 || ctx->in_page_chain == true) {
spdk_bit_array_set(ctx->bs->used_md_pages, page_num);
_spdk_bs_claim_md_page(ctx->bs, page_num);
if (ctx->page->sequence_num == 0) {
spdk_bit_array_set(ctx->bs->used_blobids, page_num);
}
@ -4608,7 +4626,7 @@ _spdk_bs_create_blob(struct spdk_blob_store *bs,
return;
}
spdk_bit_array_set(bs->used_blobids, page_idx);
spdk_bit_array_set(bs->used_md_pages, page_idx);
_spdk_bs_claim_md_page(bs, page_idx);
id = _spdk_bs_page_to_blobid(page_idx);