blob: add _spdk_blob_request_submit_op_impl()

This breaks out the logic for building a batch for
non-iov operations to a separate function.  Future
patches will do further modifications on this
new function - separating it out into two separate
functions, one for operations that span a cluster boundary
and one for those that do not.

No functional change here - this is just moving code
around to reduce size of upcoming patches.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
Change-Id: Id1e67e6305d7ba2317700e1477e12c749ebf664c

Reviewed-on: https://review.gerrithub.io/395026
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Maciej Szwed <maciej.szwed@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
Jim Harris 2018-01-16 22:02:41 -07:00
parent a5ecbadb2c
commit 96d11441be

View File

@ -1194,13 +1194,10 @@ _spdk_blob_persist(spdk_bs_sequence_t *seq, struct spdk_blob_data *blob,
}
static void
_spdk_blob_request_submit_op(struct spdk_blob *_blob, struct spdk_io_channel *_channel,
_spdk_blob_request_submit_op_impl(spdk_bs_batch_t *batch, struct spdk_blob_data *blob,
void *payload, uint64_t offset, uint64_t length,
spdk_blob_op_complete cb_fn, void *cb_arg, enum spdk_blob_op_type op_type)
{
struct spdk_blob_data *blob = __blob_to_data(_blob);
spdk_bs_batch_t *batch;
struct spdk_bs_cpl cpl;
uint64_t lba;
uint32_t lba_count;
uint8_t *buf;
@ -1208,26 +1205,6 @@ _spdk_blob_request_submit_op(struct spdk_blob *_blob, struct spdk_io_channel *_c
assert(blob != NULL);
if (blob->data_ro && op_type != SPDK_BLOB_READ) {
cb_fn(cb_arg, -EPERM);
return;
}
if (offset + length > blob->active.num_clusters * blob->bs->pages_per_cluster) {
cb_fn(cb_arg, -EINVAL);
return;
}
cpl.type = SPDK_BS_CPL_TYPE_BLOB_BASIC;
cpl.u.blob_basic.cb_fn = cb_fn;
cpl.u.blob_basic.cb_arg = cb_arg;
batch = spdk_bs_batch_open(_channel, &cpl);
if (!batch) {
cb_fn(cb_arg, -ENOMEM);
return;
}
length = _spdk_bs_page_to_lba(blob->bs, length);
page = offset;
buf = payload;
@ -1258,6 +1235,41 @@ _spdk_blob_request_submit_op(struct spdk_blob *_blob, struct spdk_io_channel *_c
buf += _spdk_bs_lba_to_byte(blob->bs, lba_count);
}
}
}
static void
_spdk_blob_request_submit_op(struct spdk_blob *_blob, struct spdk_io_channel *_channel,
void *payload, uint64_t offset, uint64_t length,
spdk_blob_op_complete cb_fn, void *cb_arg, enum spdk_blob_op_type op_type)
{
struct spdk_blob_data *blob = __blob_to_data(_blob);
spdk_bs_batch_t *batch;
struct spdk_bs_cpl cpl;
assert(blob != NULL);
if (blob->data_ro && op_type != SPDK_BLOB_READ) {
cb_fn(cb_arg, -EPERM);
return;
}
if (offset + length > blob->active.num_clusters * blob->bs->pages_per_cluster) {
cb_fn(cb_arg, -EINVAL);
return;
}
cpl.type = SPDK_BS_CPL_TYPE_BLOB_BASIC;
cpl.u.blob_basic.cb_fn = cb_fn;
cpl.u.blob_basic.cb_arg = cb_arg;
batch = spdk_bs_batch_open(_channel, &cpl);
if (!batch) {
cb_fn(cb_arg, -ENOMEM);
return;
}
_spdk_blob_request_submit_op_impl(batch, blob, payload, offset, length,
cb_fn, cb_arg, op_type);
spdk_bs_batch_close(batch);
}