blob: don't try to claim cluster 0 in recovery code
Thin provisioned blobs mark unallocated clusters with cluster ID 0. During recovery from a dirty shutdown, we must not try to claim cluster 0 - we should ignore them instead. Fixes issue #291. Signed-off-by: Jim Harris <james.r.harris@intel.com> Change-Id: If0dd42416f5de8d9972073bf6ed44eb8bc655415 Reviewed-on: https://review.gerrithub.io/410065 Reviewed-by: Daniel Verkamp <daniel.verkamp@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
22898a91b9
commit
e8ddb060f8
@ -2648,16 +2648,24 @@ _spdk_bs_load_replay_md_parse_page(const struct spdk_blob_md_page *page, struct
|
||||
struct spdk_blob_md_descriptor_extent *desc_extent;
|
||||
unsigned int i, j;
|
||||
unsigned int cluster_count = 0;
|
||||
uint32_t cluster_idx;
|
||||
|
||||
desc_extent = (struct spdk_blob_md_descriptor_extent *)desc;
|
||||
|
||||
for (i = 0; i < desc_extent->length / sizeof(desc_extent->extents[0]); i++) {
|
||||
for (j = 0; j < desc_extent->extents[i].length; j++) {
|
||||
spdk_bit_array_set(bs->used_clusters, desc_extent->extents[i].cluster_idx + j);
|
||||
if (bs->num_free_clusters == 0) {
|
||||
return -1;
|
||||
cluster_idx = desc_extent->extents[i].cluster_idx;
|
||||
/*
|
||||
* cluster_idx = 0 means an unallocated cluster - don't mark that
|
||||
* in the used cluster map.
|
||||
*/
|
||||
if (cluster_idx != 0) {
|
||||
spdk_bit_array_set(bs->used_clusters, cluster_idx + j);
|
||||
if (bs->num_free_clusters == 0) {
|
||||
return -1;
|
||||
}
|
||||
bs->num_free_clusters--;
|
||||
}
|
||||
bs->num_free_clusters--;
|
||||
cluster_count++;
|
||||
}
|
||||
}
|
||||
|
@ -524,9 +524,10 @@ blob_thin_provision(void)
|
||||
spdk_blob_close(blob, blob_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
|
||||
spdk_bs_unload(g_bs, bs_op_complete, NULL);
|
||||
CU_ASSERT(g_bserrno == 0);
|
||||
g_bs = NULL;
|
||||
/* Do not shut down cleanly. This makes sure that when we load again
|
||||
* and try to recover a valid used_cluster map, that blobstore will
|
||||
* ignore clusters with index 0 since these are unallocated clusters.
|
||||
*/
|
||||
|
||||
/* Load an existing blob store and check if invalid_flags is set */
|
||||
dev = init_dev();
|
||||
|
Loading…
Reference in New Issue
Block a user