Commit e8ddb060 authored by Jim Harris's avatar Jim Harris Committed by Daniel Verkamp
Browse files

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: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: If0dd42416f5de8d9972073bf6ed44eb8bc655415
Reviewed-on: https://review.gerrithub.io/410065


Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
parent 22898a91
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -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);
					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--;
					}
					cluster_count++;
				}
			}
+4 −3
Original line number Diff line number Diff line
@@ -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();