From 2948183f2b9cf0d51ef85c32456444c76b6d7788 Mon Sep 17 00:00:00 2001 From: Mike Gerdts Date: Mon, 13 Mar 2023 23:24:41 -0500 Subject: [PATCH] blob: prepare sequences for esnap channels When a sequence is used to perform IO on an esnap clone, differenent channels will be needed for the blobstore device and the esnap device. No special esnap handling is required when a sequence is used to perform IO directly on the blobstore device. This commit splits bs_sequence_start() into bs_sequence_start_bs() and bs_sequence_start_blob() to handle these two scenarios. A later commit introduces special handling of ensap clone blobs. Signed-off-by: Mike Gerdts Change-Id: I3a6f46640cdb7fdc380bf557736638f1b39f05e3 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/17172 Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Community-CI: Mellanox Build Bot --- lib/blob/blobstore.c | 34 +++++++++++++++++----------------- lib/blob/request.c | 17 ++++++++++++++++- lib/blob/request.h | 7 +++++-- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/lib/blob/blobstore.c b/lib/blob/blobstore.c index dba7e37cb..30f6d6942 100644 --- a/lib/blob/blobstore.c +++ b/lib/blob/blobstore.c @@ -2619,7 +2619,7 @@ bs_allocate_and_copy_cluster(struct spdk_blob *blob, cpl.u.blob_basic.cb_fn = blob_allocate_and_copy_cluster_cpl; cpl.u.blob_basic.cb_arg = ctx; - ctx->seq = bs_sequence_start(_ch, &cpl); + ctx->seq = bs_sequence_start_blob(_ch, &cpl, blob); if (!ctx->seq) { spdk_spin_lock(&blob->bs->used_lock); bs_release_cluster(blob->bs, ctx->new_cluster); @@ -2806,7 +2806,7 @@ blob_request_submit_op_split(struct spdk_io_channel *ch, struct spdk_blob *blob, cpl.u.blob_basic.cb_fn = cb_fn; cpl.u.blob_basic.cb_arg = cb_arg; - seq = bs_sequence_start(ch, &cpl); + seq = bs_sequence_start_blob(ch, &cpl, blob); if (!seq) { free(ctx); cb_fn(cb_arg, -ENOMEM); @@ -3134,7 +3134,7 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan if (read) { spdk_bs_sequence_t *seq; - seq = bs_sequence_start(_channel, &cpl); + seq = bs_sequence_start_blob(_channel, &cpl, blob); if (!seq) { cb_fn(cb_arg, -ENOMEM); return; @@ -3152,7 +3152,7 @@ blob_request_submit_rw_iov(struct spdk_blob *blob, struct spdk_io_channel *_chan if (is_allocated) { spdk_bs_sequence_t *seq; - seq = bs_sequence_start(_channel, &cpl); + seq = bs_sequence_start_blob(_channel, &cpl, blob); if (!seq) { cb_fn(cb_arg, -ENOMEM); return; @@ -4743,7 +4743,7 @@ spdk_bs_load(struct spdk_bs_dev *dev, struct spdk_bs_opts *o, cpl.u.bs_handle.cb_arg = cb_arg; cpl.u.bs_handle.bs = bs; - ctx->seq = bs_sequence_start(bs->md_channel, &cpl); + ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!ctx->seq) { spdk_free(ctx->super); free(ctx); @@ -5123,7 +5123,7 @@ spdk_bs_dump(struct spdk_bs_dev *dev, FILE *fp, spdk_bs_dump_print_xattr print_x cpl.u.bs_basic.cb_fn = cb_fn; cpl.u.bs_basic.cb_arg = cb_arg; - ctx->seq = bs_sequence_start(bs->md_channel, &cpl); + ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!ctx->seq) { spdk_free(ctx->super); free(ctx); @@ -5340,7 +5340,7 @@ spdk_bs_init(struct spdk_bs_dev *dev, struct spdk_bs_opts *o, cpl.u.bs_handle.cb_arg = cb_arg; cpl.u.bs_handle.bs = bs; - seq = bs_sequence_start(bs->md_channel, &cpl); + seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!seq) { spdk_free(ctx->super); free(ctx); @@ -5425,7 +5425,7 @@ spdk_bs_destroy(struct spdk_blob_store *bs, spdk_bs_op_complete cb_fn, ctx->bs = bs; - seq = bs_sequence_start(bs->md_channel, &cpl); + seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!seq) { free(ctx); cb_fn(cb_arg, -ENOMEM); @@ -5568,7 +5568,7 @@ spdk_bs_unload(struct spdk_blob_store *bs, spdk_bs_op_complete cb_fn, void *cb_a cpl.u.bs_basic.cb_fn = cb_fn; cpl.u.bs_basic.cb_arg = cb_arg; - ctx->seq = bs_sequence_start(bs->md_channel, &cpl); + ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!ctx->seq) { spdk_free(ctx->super); free(ctx); @@ -5653,7 +5653,7 @@ spdk_bs_set_super(struct spdk_blob_store *bs, spdk_blob_id blobid, cpl.u.bs_basic.cb_fn = cb_fn; cpl.u.bs_basic.cb_arg = cb_arg; - seq = bs_sequence_start(bs->md_channel, &cpl); + seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!seq) { spdk_free(ctx->super); free(ctx); @@ -5963,7 +5963,7 @@ bs_create_blob(struct spdk_blob_store *bs, cpl.u.blobid.cb_arg = cb_arg; cpl.u.blobid.blobid = blob->id; - seq = bs_sequence_start(bs->md_channel, &cpl); + seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!seq) { rc = -ENOMEM; goto error; @@ -7370,7 +7370,7 @@ spdk_bs_delete_blob(struct spdk_blob_store *bs, spdk_blob_id blobid, cpl.u.blob_basic.cb_fn = cb_fn; cpl.u.blob_basic.cb_arg = cb_arg; - seq = bs_sequence_start(bs->md_channel, &cpl); + seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!seq) { cb_fn(cb_arg, -ENOMEM); return; @@ -7486,7 +7486,7 @@ bs_open_blob(struct spdk_blob_store *bs, cpl.u.blob_handle.blob = blob; cpl.u.blob_handle.esnap_ctx = opts_local.esnap_ctx; - seq = bs_sequence_start(bs->md_channel, &cpl); + seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!seq) { blob_free(blob); cb_fn(cb_arg, NULL, -ENOMEM); @@ -7550,7 +7550,7 @@ blob_sync_md(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_arg) cpl.u.blob_basic.cb_fn = cb_fn; cpl.u.blob_basic.cb_arg = cb_arg; - seq = bs_sequence_start(blob->bs->md_channel, &cpl); + seq = bs_sequence_start_bs(blob->bs->md_channel, &cpl); if (!seq) { cb_fn(cb_arg, -ENOMEM); return; @@ -7670,7 +7670,7 @@ blob_write_extent_page(struct spdk_blob *blob, uint32_t extent, uint64_t cluster cpl.u.blob_basic.cb_fn = cb_fn; cpl.u.blob_basic.cb_arg = cb_arg; - seq = bs_sequence_start(blob->bs->md_channel, &cpl); + seq = bs_sequence_start_bs(blob->bs->md_channel, &cpl); if (!seq) { free(ctx); cb_fn(cb_arg, -ENOMEM); @@ -7807,7 +7807,7 @@ spdk_blob_close(struct spdk_blob *blob, spdk_blob_op_complete cb_fn, void *cb_ar cpl.u.blob_basic.cb_fn = cb_fn; cpl.u.blob_basic.cb_arg = cb_arg; - seq = bs_sequence_start(blob->bs->md_channel, &cpl); + seq = bs_sequence_start_bs(blob->bs->md_channel, &cpl); if (!seq) { cb_fn(cb_arg, -ENOMEM); return; @@ -8543,7 +8543,7 @@ spdk_bs_grow(struct spdk_bs_dev *dev, struct spdk_bs_opts *o, cpl.u.bs_handle.cb_arg = cb_arg; cpl.u.bs_handle.bs = bs; - ctx->seq = bs_sequence_start(bs->md_channel, &cpl); + ctx->seq = bs_sequence_start_bs(bs->md_channel, &cpl); if (!ctx->seq) { spdk_free(ctx->super); free(ctx); diff --git a/lib/blob/request.c b/lib/blob/request.c index 18ee1f957..d4e1730aa 100644 --- a/lib/blob/request.c +++ b/lib/blob/request.c @@ -72,7 +72,7 @@ bs_sequence_completion(struct spdk_io_channel *channel, void *cb_arg, int bserrn set->u.sequence.cb_fn((spdk_bs_sequence_t *)set, set->u.sequence.cb_arg, bserrno); } -spdk_bs_sequence_t * +static spdk_bs_sequence_t * bs_sequence_start(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl) { @@ -100,6 +100,21 @@ bs_sequence_start(struct spdk_io_channel *_channel, return (spdk_bs_sequence_t *)set; } +/* Use when performing IO directly on the blobstore (e.g. metadata - not a blob). */ +spdk_bs_sequence_t * +bs_sequence_start_bs(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl) +{ + return bs_sequence_start(_channel, cpl); +} + +/* Use when performing IO on a blob. */ +spdk_bs_sequence_t * +bs_sequence_start_blob(struct spdk_io_channel *_channel, struct spdk_bs_cpl *cpl, + struct spdk_blob *blob) +{ + return bs_sequence_start(_channel, cpl); +} + void bs_sequence_read_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev, void *payload, uint64_t lba, uint32_t lba_count, diff --git a/lib/blob/request.h b/lib/blob/request.h index 5fcf2fd36..bc2764ed0 100644 --- a/lib/blob/request.h +++ b/lib/blob/request.h @@ -129,8 +129,11 @@ struct spdk_bs_request_set { void bs_call_cpl(struct spdk_bs_cpl *cpl, int bserrno); -spdk_bs_sequence_t *bs_sequence_start(struct spdk_io_channel *channel, - struct spdk_bs_cpl *cpl); +spdk_bs_sequence_t *bs_sequence_start_bs(struct spdk_io_channel *channel, + struct spdk_bs_cpl *cpl); + +spdk_bs_sequence_t *bs_sequence_start_blob(struct spdk_io_channel *channel, + struct spdk_bs_cpl *cpl, struct spdk_blob *blob); void bs_sequence_read_bs_dev(spdk_bs_sequence_t *seq, struct spdk_bs_dev *bs_dev, void *payload, uint64_t lba, uint32_t lba_count,