Replace submit with forward in mngt
Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
1c2d5bbcf3
commit
834786866c
@ -506,8 +506,7 @@ static void ocf_metadata_flush_disk(ocf_pipeline_t pipeline,
|
|||||||
struct ocf_metadata_context *context = priv;
|
struct ocf_metadata_context *context = priv;
|
||||||
ocf_cache_t cache = context->cache;
|
ocf_cache_t cache = context->cache;
|
||||||
|
|
||||||
ocf_submit_volume_flush(ocf_cache_get_volume(cache),
|
ocf_submit_cache_flush(cache, ocf_metadata_flush_disk_end, context);
|
||||||
ocf_metadata_flush_disk_end, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ocf_pipeline_arg ocf_metadata_flush_sb_args[] = {
|
struct ocf_pipeline_arg ocf_metadata_flush_sb_args[] = {
|
||||||
|
@ -1057,9 +1057,9 @@ static void _ocf_mngt_test_volume_discard(
|
|||||||
* Submit discard request
|
* Submit discard request
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ocf_submit_volume_discard(&cache->device->volume,
|
ocf_submit_cache_discard(cache, context->test.reserved_lba_addr,
|
||||||
context->test.reserved_lba_addr, PAGE_SIZE,
|
PAGE_SIZE, _ocf_mngt_test_volume_discard_complete,
|
||||||
_ocf_mngt_test_volume_discard_complete, context);
|
context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _ocf_mngt_test_volume_second_read_complete(void *priv, int error)
|
static void _ocf_mngt_test_volume_second_read_complete(void *priv, int error)
|
||||||
@ -1819,11 +1819,11 @@ static void _ocf_mngt_attach_discard(ocf_pipeline_t pipeline,
|
|||||||
|
|
||||||
if (!discard && ocf_volume_is_atomic(&cache->device->volume)) {
|
if (!discard && ocf_volume_is_atomic(&cache->device->volume)) {
|
||||||
/* discard doesn't zero data - need to explicitly write zeros */
|
/* discard doesn't zero data - need to explicitly write zeros */
|
||||||
ocf_submit_write_zeros(&cache->device->volume, addr, length,
|
ocf_submit_cache_write_zeros(cache, addr, length,
|
||||||
_ocf_mngt_attach_discard_complete, context);
|
_ocf_mngt_attach_discard_complete, context);
|
||||||
} else {
|
} else {
|
||||||
/* Discard volume after metadata */
|
/* Discard volume after metadata */
|
||||||
ocf_submit_volume_discard(&cache->device->volume, addr, length,
|
ocf_submit_cache_discard(cache, addr, length,
|
||||||
_ocf_mngt_attach_discard_complete, context);
|
_ocf_mngt_attach_discard_complete, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1843,8 +1843,8 @@ static void _ocf_mngt_attach_flush(ocf_pipeline_t pipeline,
|
|||||||
bool discard = cache->device->volume.features.discard_zeroes;
|
bool discard = cache->device->volume.features.discard_zeroes;
|
||||||
|
|
||||||
if (!discard && ocf_volume_is_atomic(&cache->device->volume)) {
|
if (!discard && ocf_volume_is_atomic(&cache->device->volume)) {
|
||||||
ocf_submit_volume_flush(&cache->device->volume,
|
ocf_submit_cache_flush(cache, _ocf_mngt_attach_flush_complete,
|
||||||
_ocf_mngt_attach_flush_complete, context);
|
context);
|
||||||
} else {
|
} else {
|
||||||
ocf_pipeline_next(pipeline);
|
ocf_pipeline_next(pipeline);
|
||||||
}
|
}
|
||||||
|
@ -12,134 +12,116 @@
|
|||||||
#include "utils_io.h"
|
#include "utils_io.h"
|
||||||
#include "utils_cache_line.h"
|
#include "utils_cache_line.h"
|
||||||
|
|
||||||
struct ocf_submit_volume_context {
|
struct ocf_submit_cache_context {
|
||||||
env_atomic req_remaining;
|
|
||||||
int error;
|
|
||||||
ocf_submit_end_t cmpl;
|
ocf_submit_end_t cmpl;
|
||||||
void *priv;
|
void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void _ocf_volume_flush_end(struct ocf_io *io, int error)
|
static void ocf_submit_cache_end(struct ocf_request *req, int error)
|
||||||
{
|
{
|
||||||
ocf_submit_end_t cmpl = io->priv1;
|
struct ocf_submit_cache_context *context = req->priv;
|
||||||
|
|
||||||
cmpl(io->priv2, error);
|
context->cmpl(context->priv, error);
|
||||||
ocf_io_put(io);
|
env_vfree(context);
|
||||||
|
ocf_req_put(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_volume_flush(ocf_volume_t volume,
|
void ocf_submit_cache_flush(ocf_cache_t cache,
|
||||||
ocf_submit_end_t cmpl, void *priv)
|
ocf_submit_end_t cmpl, void *priv)
|
||||||
{
|
{
|
||||||
struct ocf_io *io;
|
struct ocf_submit_cache_context *context;
|
||||||
|
struct ocf_request *req;
|
||||||
|
|
||||||
io = ocf_volume_new_io(volume, NULL, 0, 0, OCF_WRITE, 0, 0);
|
context = env_vzalloc(sizeof(*context));
|
||||||
if (!io)
|
if (!context)
|
||||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||||
|
|
||||||
ocf_io_set_cmpl(io, cmpl, priv, _ocf_volume_flush_end);
|
context->cmpl = cmpl;
|
||||||
|
context->priv = priv;
|
||||||
|
|
||||||
ocf_volume_submit_flush(io);
|
req = ocf_req_new_mngt(cache, cache->mngt_queue);
|
||||||
}
|
if (!req) {
|
||||||
|
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||||
static void ocf_submit_volume_end(struct ocf_io *io, int error)
|
env_vfree(context);
|
||||||
{
|
|
||||||
struct ocf_submit_volume_context *context = io->priv1;
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
context->error = error;
|
|
||||||
|
|
||||||
ocf_io_put(io);
|
|
||||||
|
|
||||||
if (env_atomic_dec_return(&context->req_remaining))
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context->cmpl(context->priv, context->error);
|
req->cache_forward_end = ocf_submit_cache_end;
|
||||||
env_vfree(context);
|
req->priv = context;
|
||||||
|
|
||||||
|
ocf_req_forward_cache_flush(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_volume_discard(ocf_volume_t volume, uint64_t addr,
|
void ocf_submit_cache_discard(ocf_cache_t cache, uint64_t addr,
|
||||||
uint64_t length, ocf_submit_end_t cmpl, void *priv)
|
uint64_t length, ocf_submit_end_t cmpl, void *priv)
|
||||||
{
|
{
|
||||||
struct ocf_submit_volume_context *context;
|
struct ocf_submit_cache_context *context;
|
||||||
uint64_t bytes;
|
uint64_t bytes;
|
||||||
uint64_t sector_mask = (1 << ENV_SECTOR_SHIFT) - 1;
|
uint64_t sector_mask = (1 << ENV_SECTOR_SHIFT) - 1;
|
||||||
uint64_t max_length = (uint32_t)~0 & ~sector_mask;
|
uint64_t max_length = (uint32_t)~0 & ~sector_mask;
|
||||||
struct ocf_io *io;
|
struct ocf_request *req;
|
||||||
|
|
||||||
context = env_vzalloc(sizeof(*context));
|
context = env_vzalloc(sizeof(*context));
|
||||||
if (!context)
|
if (!context)
|
||||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||||
|
|
||||||
env_atomic_set(&context->req_remaining, 1);
|
|
||||||
context->cmpl = cmpl;
|
context->cmpl = cmpl;
|
||||||
context->priv = priv;
|
context->priv = priv;
|
||||||
|
|
||||||
|
req = ocf_req_new_mngt(cache, cache->mngt_queue);
|
||||||
|
if (!req) {
|
||||||
|
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||||
|
env_vfree(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
req->cache_forward_end = ocf_submit_cache_end;
|
||||||
|
req->priv = context;
|
||||||
|
|
||||||
|
ocf_req_forward_cache_get(req);
|
||||||
while (length) {
|
while (length) {
|
||||||
bytes = OCF_MIN(length, max_length);
|
bytes = OCF_MIN(length, max_length);
|
||||||
|
|
||||||
io = ocf_volume_new_io(volume, NULL, addr, bytes,
|
ocf_req_forward_cache_discard(req, addr, bytes);
|
||||||
OCF_WRITE, 0, 0);
|
|
||||||
if (!io) {
|
|
||||||
context->error = -OCF_ERR_NO_MEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
env_atomic_inc(&context->req_remaining);
|
|
||||||
|
|
||||||
ocf_io_set_cmpl(io, context, NULL, ocf_submit_volume_end);
|
|
||||||
ocf_volume_submit_discard(io);
|
|
||||||
|
|
||||||
addr += bytes;
|
addr += bytes;
|
||||||
length -= bytes;
|
length -= bytes;
|
||||||
}
|
}
|
||||||
|
ocf_req_forward_cache_put(req);
|
||||||
if (env_atomic_dec_return(&context->req_remaining))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cmpl(priv, context->error);
|
|
||||||
env_vfree(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_write_zeros(ocf_volume_t volume, uint64_t addr,
|
void ocf_submit_cache_write_zeros(ocf_cache_t cache, uint64_t addr,
|
||||||
uint64_t length, ocf_submit_end_t cmpl, void *priv)
|
uint64_t length, ocf_submit_end_t cmpl, void *priv)
|
||||||
{
|
{
|
||||||
struct ocf_submit_volume_context *context;
|
struct ocf_submit_cache_context *context;
|
||||||
uint32_t bytes;
|
uint32_t bytes;
|
||||||
uint32_t max_length = ~((uint32_t)PAGE_SIZE - 1);
|
uint32_t max_length = ~((uint32_t)PAGE_SIZE - 1);
|
||||||
struct ocf_io *io;
|
struct ocf_request *req;
|
||||||
|
|
||||||
context = env_vzalloc(sizeof(*context));
|
context = env_vzalloc(sizeof(*context));
|
||||||
if (!context)
|
if (!context)
|
||||||
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
OCF_CMPL_RET(priv, -OCF_ERR_NO_MEM);
|
||||||
|
|
||||||
env_atomic_set(&context->req_remaining, 1);
|
|
||||||
context->cmpl = cmpl;
|
context->cmpl = cmpl;
|
||||||
context->priv = priv;
|
context->priv = priv;
|
||||||
|
|
||||||
|
req = ocf_req_new_mngt(cache, cache->mngt_queue);
|
||||||
|
if (!req) {
|
||||||
|
cmpl(priv, -OCF_ERR_NO_MEM);
|
||||||
|
env_vfree(context);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ocf_req_forward_cache_get(req);
|
||||||
while (length) {
|
while (length) {
|
||||||
bytes = OCF_MIN(length, max_length);
|
bytes = OCF_MIN(length, max_length);
|
||||||
|
|
||||||
io = ocf_volume_new_io(volume, NULL, addr, bytes,
|
ocf_req_forward_cache_write_zeros(req, addr, bytes);
|
||||||
OCF_WRITE, 0, 0);
|
|
||||||
if (!io) {
|
|
||||||
context->error = -OCF_ERR_NO_MEM;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
env_atomic_inc(&context->req_remaining);
|
|
||||||
|
|
||||||
ocf_io_set_cmpl(io, context, NULL, ocf_submit_volume_end);
|
|
||||||
ocf_volume_submit_write_zeroes(io);
|
|
||||||
|
|
||||||
addr += bytes;
|
addr += bytes;
|
||||||
length -= bytes;
|
length -= bytes;
|
||||||
}
|
}
|
||||||
|
ocf_req_forward_cache_put(req);
|
||||||
if (env_atomic_dec_return(&context->req_remaining))
|
|
||||||
return;
|
|
||||||
|
|
||||||
cmpl(priv, context->error);
|
|
||||||
env_vfree(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ocf_submit_cache_page_context {
|
struct ocf_submit_cache_page_context {
|
||||||
@ -149,12 +131,12 @@ struct ocf_submit_cache_page_context {
|
|||||||
void *priv;
|
void *priv;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void ocf_submit_cache_page_end(struct ocf_io *io, int error)
|
static void ocf_submit_cache_page_end(struct ocf_request *req, int error)
|
||||||
{
|
{
|
||||||
struct ocf_submit_cache_page_context *context = io->priv1;
|
struct ocf_submit_cache_page_context *context = req->priv;
|
||||||
ctx_data_t *data = ocf_io_get_data(io);
|
ctx_data_t *data = req->data;
|
||||||
|
|
||||||
if (io->dir == OCF_READ) {
|
if (req->rw == OCF_READ) {
|
||||||
ctx_data_rd_check(context->cache->owner, context->buffer,
|
ctx_data_rd_check(context->cache->owner, context->buffer,
|
||||||
data, PAGE_SIZE);
|
data, PAGE_SIZE);
|
||||||
}
|
}
|
||||||
@ -162,7 +144,7 @@ static void ocf_submit_cache_page_end(struct ocf_io *io, int error)
|
|||||||
context->cmpl(context->priv, error);
|
context->cmpl(context->priv, error);
|
||||||
ctx_data_free(context->cache->owner, data);
|
ctx_data_free(context->cache->owner, data);
|
||||||
env_vfree(context);
|
env_vfree(context);
|
||||||
ocf_io_put(io);
|
ocf_req_put(req);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
||||||
@ -170,7 +152,7 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
|||||||
{
|
{
|
||||||
struct ocf_submit_cache_page_context *context;
|
struct ocf_submit_cache_page_context *context;
|
||||||
ctx_data_t *data;
|
ctx_data_t *data;
|
||||||
struct ocf_io *io;
|
struct ocf_request *req;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
context = env_vmalloc(sizeof(*context));
|
context = env_vmalloc(sizeof(*context));
|
||||||
@ -182,10 +164,10 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
|||||||
context->cmpl = cmpl;
|
context->cmpl = cmpl;
|
||||||
context->priv = priv;
|
context->priv = priv;
|
||||||
|
|
||||||
io = ocf_new_cache_io(cache, NULL, addr, PAGE_SIZE, dir, 0, 0);
|
req = ocf_req_new_mngt(cache, cache->mngt_queue);
|
||||||
if (!io) {
|
if (!req) {
|
||||||
result = -OCF_ERR_NO_MEM;
|
result = -OCF_ERR_NO_MEM;
|
||||||
goto err_io;
|
goto err_req;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = ctx_data_alloc(cache->owner, 1);
|
data = ctx_data_alloc(cache->owner, 1);
|
||||||
@ -197,20 +179,21 @@ void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
|||||||
if (dir == OCF_WRITE)
|
if (dir == OCF_WRITE)
|
||||||
ctx_data_wr_check(cache->owner, data, buffer, PAGE_SIZE);
|
ctx_data_wr_check(cache->owner, data, buffer, PAGE_SIZE);
|
||||||
|
|
||||||
result = ocf_io_set_data(io, data, 0);
|
req->data = data;
|
||||||
if (result)
|
|
||||||
goto err_set_data;
|
|
||||||
|
|
||||||
ocf_io_set_cmpl(io, context, NULL, ocf_submit_cache_page_end);
|
req->cache_forward_end = ocf_submit_cache_page_end;
|
||||||
|
req->priv = context;
|
||||||
|
req->rw = dir;
|
||||||
|
req->byte_position = addr;
|
||||||
|
req->byte_length = PAGE_SIZE;
|
||||||
|
|
||||||
|
ocf_req_forward_cache_io(req, dir, addr, PAGE_SIZE, 0);
|
||||||
|
|
||||||
ocf_volume_submit_io(io);
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
err_set_data:
|
|
||||||
ctx_data_free(cache->owner, data);
|
|
||||||
err_data:
|
err_data:
|
||||||
ocf_io_put(io);
|
ocf_req_put(req);
|
||||||
err_io:
|
err_req:
|
||||||
env_vfree(context);
|
env_vfree(context);
|
||||||
cmpl(priv, result);
|
cmpl(priv, result);
|
||||||
}
|
}
|
||||||
|
@ -11,13 +11,13 @@
|
|||||||
|
|
||||||
typedef void (*ocf_submit_end_t)(void *priv, int error);
|
typedef void (*ocf_submit_end_t)(void *priv, int error);
|
||||||
|
|
||||||
void ocf_submit_volume_flush(ocf_volume_t volume,
|
void ocf_submit_cache_flush(ocf_cache_t cache,
|
||||||
ocf_submit_end_t cmpl, void *priv);
|
ocf_submit_end_t cmpl, void *priv);
|
||||||
|
|
||||||
void ocf_submit_volume_discard(ocf_volume_t volume, uint64_t addr,
|
void ocf_submit_cache_discard(ocf_cache_t cache, uint64_t addr,
|
||||||
uint64_t length, ocf_submit_end_t cmpl, void *priv);
|
uint64_t length, ocf_submit_end_t cmpl, void *priv);
|
||||||
|
|
||||||
void ocf_submit_write_zeros(ocf_volume_t volume, uint64_t addr,
|
void ocf_submit_cache_write_zeros(ocf_cache_t cache, uint64_t addr,
|
||||||
uint64_t length, ocf_submit_end_t cmpl, void *priv);
|
uint64_t length, ocf_submit_end_t cmpl, void *priv);
|
||||||
|
|
||||||
void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
void ocf_submit_cache_page(ocf_cache_t cache, uint64_t addr, int dir,
|
||||||
|
Loading…
Reference in New Issue
Block a user