blob: add forced recovery
Add the ability to open a blobstore in such a way that recovery happens even if the superblock says it is clean. Signed-off-by: Mike Gerdts <mgerdts@nvidia.com> Change-Id: I475e51beff24428d387446f7785e025294d2f014 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/11253 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
893ad78814
commit
a6c5feb0a2
@ -3,6 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) Intel Corporation.
|
* Copyright (c) Intel Corporation.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -233,6 +234,9 @@ struct spdk_bs_opts {
|
|||||||
* After that, new added fields should be put in the end of the struct.
|
* After that, new added fields should be put in the end of the struct.
|
||||||
*/
|
*/
|
||||||
size_t opts_size;
|
size_t opts_size;
|
||||||
|
|
||||||
|
/** Force recovery during import. This is a uint64_t for padding reasons, treated as a bool. */
|
||||||
|
uint64_t force_recover;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3260,6 +3260,7 @@ spdk_bs_opts_init(struct spdk_bs_opts *opts, size_t opts_size)
|
|||||||
|
|
||||||
SET_FIELD(iter_cb_fn, NULL);
|
SET_FIELD(iter_cb_fn, NULL);
|
||||||
SET_FIELD(iter_cb_arg, NULL);
|
SET_FIELD(iter_cb_arg, NULL);
|
||||||
|
SET_FIELD(force_recover, false);
|
||||||
|
|
||||||
#undef FIELD_OK
|
#undef FIELD_OK
|
||||||
#undef SET_FIELD
|
#undef SET_FIELD
|
||||||
@ -3302,6 +3303,8 @@ struct spdk_bs_load_ctx {
|
|||||||
struct spdk_blob *blob;
|
struct spdk_blob *blob;
|
||||||
spdk_blob_id blobid;
|
spdk_blob_id blobid;
|
||||||
|
|
||||||
|
bool force_recover;
|
||||||
|
|
||||||
/* These fields are used in the spdk_bs_dump path. */
|
/* These fields are used in the spdk_bs_dump path. */
|
||||||
bool dumping;
|
bool dumping;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -3345,6 +3348,7 @@ bs_alloc(struct spdk_bs_dev *dev, struct spdk_bs_opts *opts, struct spdk_blob_st
|
|||||||
ctx->bs = bs;
|
ctx->bs = bs;
|
||||||
ctx->iter_cb_fn = opts->iter_cb_fn;
|
ctx->iter_cb_fn = opts->iter_cb_fn;
|
||||||
ctx->iter_cb_arg = opts->iter_cb_arg;
|
ctx->iter_cb_arg = opts->iter_cb_arg;
|
||||||
|
ctx->force_recover = opts->force_recover;
|
||||||
|
|
||||||
ctx->super = spdk_zmalloc(sizeof(*ctx->super), 0x1000, NULL,
|
ctx->super = spdk_zmalloc(sizeof(*ctx->super), 0x1000, NULL,
|
||||||
SPDK_ENV_SOCKET_ID_ANY, SPDK_MALLOC_DMA);
|
SPDK_ENV_SOCKET_ID_ANY, SPDK_MALLOC_DMA);
|
||||||
@ -4414,7 +4418,7 @@ bs_load_super_cpl(spdk_bs_sequence_t *seq, void *cb_arg, int bserrno)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->super->used_blobid_mask_len == 0 || ctx->super->clean == 0) {
|
if (ctx->super->used_blobid_mask_len == 0 || ctx->super->clean == 0 || ctx->force_recover) {
|
||||||
bs_recover(ctx);
|
bs_recover(ctx);
|
||||||
} else {
|
} else {
|
||||||
bs_load_read_used_pages(ctx);
|
bs_load_read_used_pages(ctx);
|
||||||
@ -4449,12 +4453,13 @@ bs_opts_copy(struct spdk_bs_opts *src, struct spdk_bs_opts *dst)
|
|||||||
}
|
}
|
||||||
SET_FIELD(iter_cb_fn);
|
SET_FIELD(iter_cb_fn);
|
||||||
SET_FIELD(iter_cb_arg);
|
SET_FIELD(iter_cb_arg);
|
||||||
|
SET_FIELD(force_recover);
|
||||||
|
|
||||||
dst->opts_size = src->opts_size;
|
dst->opts_size = src->opts_size;
|
||||||
|
|
||||||
/* You should not remove this statement, but need to update the assert statement
|
/* You should not remove this statement, but need to update the assert statement
|
||||||
* if you add a new field, and also add a corresponding SET_FIELD statement */
|
* if you add a new field, and also add a corresponding SET_FIELD statement */
|
||||||
SPDK_STATIC_ASSERT(sizeof(struct spdk_bs_opts) == 64, "Incorrect size");
|
SPDK_STATIC_ASSERT(sizeof(struct spdk_bs_opts) == 72, "Incorrect size");
|
||||||
|
|
||||||
#undef FIELD_OK
|
#undef FIELD_OK
|
||||||
#undef SET_FIELD
|
#undef SET_FIELD
|
||||||
|
Loading…
Reference in New Issue
Block a user