Introduce ocf_forward_write_zeros()
This is meant to be used in atomic mode to avoid allocating huge buffers for zeroing data on drive. Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
parent
c7580a75d7
commit
cd544e8ee5
14
inc/ocf_io.h
14
inc/ocf_io.h
@ -285,6 +285,20 @@ void ocf_forward_flush(ocf_volume_t volume, ocf_forward_token_t token);
|
|||||||
void ocf_forward_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
void ocf_forward_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
||||||
uint64_t addr, uint64_t bytes);
|
uint64_t addr, uint64_t bytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Forward write_zeros to another subvolume
|
||||||
|
*
|
||||||
|
* Forwarding automatically increases forwarded io refcount, so at some
|
||||||
|
* point additional ocf_forward_end() needs to be called to balance it.
|
||||||
|
*
|
||||||
|
* @param[in] volume Volume to which IO is being submitted
|
||||||
|
* @param[in] token Token representing IO to be forwarded
|
||||||
|
* @param[in] addr Address to which IO is being submitted
|
||||||
|
* @param[in] bytes Length of the IO
|
||||||
|
*/
|
||||||
|
void ocf_forward_write_zeros(ocf_volume_t volume, ocf_forward_token_t token,
|
||||||
|
uint64_t addr, uint64_t bytes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Increment forwarded io refcount
|
* @brief Increment forwarded io refcount
|
||||||
*
|
*
|
||||||
|
@ -116,6 +116,19 @@ struct ocf_volume_ops {
|
|||||||
void (*forward_discard)(ocf_volume_t volume, ocf_forward_token_t token,
|
void (*forward_discard)(ocf_volume_t volume, ocf_forward_token_t token,
|
||||||
uint64_t addr, uint64_t bytes);
|
uint64_t addr, uint64_t bytes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Froward operation to write zeros to target address (including
|
||||||
|
* metadata extended LBAs in atomic mode)
|
||||||
|
*
|
||||||
|
* @param[in] volume Volume to which IO is being submitted
|
||||||
|
* @param[in] token Token representing IO to be forwarded
|
||||||
|
* @param[in] addr Address to which IO is being submitted
|
||||||
|
* @param[in] bytes Length of the IO
|
||||||
|
*/
|
||||||
|
void (*forward_write_zeros)(ocf_volume_t volume,
|
||||||
|
ocf_forward_token_t token, uint64_t addr,
|
||||||
|
uint64_t bytes);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Volume initialization callback, called when volume object
|
* @brief Volume initialization callback, called when volume object
|
||||||
* is being initialized
|
* is being initialized
|
||||||
|
@ -467,6 +467,18 @@ void ocf_req_forward_cache_discard(struct ocf_request *req, uint64_t addr,
|
|||||||
ocf_volume_forward_discard(volume, token, addr, bytes);
|
ocf_volume_forward_discard(volume, token, addr, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ocf_req_forward_cache_write_zeros(struct ocf_request *req, uint64_t addr,
|
||||||
|
uint64_t bytes)
|
||||||
|
{
|
||||||
|
ocf_volume_t volume = ocf_cache_get_volume(req->cache);
|
||||||
|
ocf_forward_token_t token = ocf_req_to_cache_forward_token(req);
|
||||||
|
|
||||||
|
req->cache_error = 0;
|
||||||
|
|
||||||
|
ocf_req_forward_cache_get(req);
|
||||||
|
ocf_volume_forward_write_zeros(volume, token, addr, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
void ocf_req_forward_core_io(struct ocf_request *req, int dir, uint64_t addr,
|
void ocf_req_forward_core_io(struct ocf_request *req, int dir, uint64_t addr,
|
||||||
uint64_t bytes, uint64_t offset)
|
uint64_t bytes, uint64_t offset)
|
||||||
{
|
{
|
||||||
@ -544,6 +556,13 @@ void ocf_forward_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
|||||||
ocf_volume_forward_discard(volume, token, addr, bytes);
|
ocf_volume_forward_discard(volume, token, addr, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ocf_forward_write_zeros(ocf_volume_t volume, ocf_forward_token_t token,
|
||||||
|
uint64_t addr, uint64_t bytes)
|
||||||
|
{
|
||||||
|
_ocf_forward_get(token);
|
||||||
|
ocf_volume_forward_write_zeros(volume, token, addr, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
void ocf_forward_end(ocf_forward_token_t token, int error)
|
void ocf_forward_end(ocf_forward_token_t token, int error)
|
||||||
{
|
{
|
||||||
struct ocf_request *req = ocf_req_forward_token_to_req(token);
|
struct ocf_request *req = ocf_req_forward_token_to_req(token);
|
||||||
|
@ -561,6 +561,9 @@ void ocf_req_forward_cache_flush(struct ocf_request *req);
|
|||||||
void ocf_req_forward_cache_discard(struct ocf_request *req, uint64_t addr,
|
void ocf_req_forward_cache_discard(struct ocf_request *req, uint64_t addr,
|
||||||
uint64_t bytes);
|
uint64_t bytes);
|
||||||
|
|
||||||
|
void ocf_req_forward_cache_write_zeros(struct ocf_request *req, uint64_t addr,
|
||||||
|
uint64_t bytes);
|
||||||
|
|
||||||
void ocf_req_forward_core_io(struct ocf_request *req, int dir, uint64_t addr,
|
void ocf_req_forward_core_io(struct ocf_request *req, int dir, uint64_t addr,
|
||||||
uint64_t bytes, uint64_t offset);
|
uint64_t bytes, uint64_t offset);
|
||||||
|
|
||||||
|
@ -370,6 +370,20 @@ void ocf_volume_forward_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
|||||||
addr, bytes);
|
addr, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ocf_volume_forward_write_zeros(ocf_volume_t volume,
|
||||||
|
ocf_forward_token_t token, uint64_t addr, uint64_t bytes)
|
||||||
|
{
|
||||||
|
ENV_BUG_ON(!volume->type->properties->ops.forward_write_zeros);
|
||||||
|
|
||||||
|
if (!volume->opened) {
|
||||||
|
ocf_forward_end(token, -OCF_ERR_IO);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
volume->type->properties->ops.forward_write_zeros(volume, token,
|
||||||
|
addr, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
int ocf_volume_open(ocf_volume_t volume, void *volume_params)
|
int ocf_volume_open(ocf_volume_t volume, void *volume_params)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -55,6 +55,9 @@ void ocf_volume_forward_flush(ocf_volume_t volume, ocf_forward_token_t token);
|
|||||||
void ocf_volume_forward_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
void ocf_volume_forward_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
||||||
uint64_t addr, uint64_t bytes);
|
uint64_t addr, uint64_t bytes);
|
||||||
|
|
||||||
|
void ocf_volume_forward_write_zeros(ocf_volume_t volume,
|
||||||
|
ocf_forward_token_t token, uint64_t addr, uint64_t bytes);
|
||||||
|
|
||||||
static inline void ocf_volume_submit_metadata(struct ocf_io *io)
|
static inline void ocf_volume_submit_metadata(struct ocf_io *io)
|
||||||
{
|
{
|
||||||
ocf_volume_t volume = ocf_io_get_volume(io);
|
ocf_volume_t volume = ocf_io_get_volume(io);
|
||||||
|
@ -54,6 +54,7 @@ class VolumeOps(Structure):
|
|||||||
FORWARD_IO = CFUNCTYPE(None, c_void_p, c_uint64, c_int, c_uint64, c_uint64, c_uint64)
|
FORWARD_IO = CFUNCTYPE(None, c_void_p, c_uint64, c_int, c_uint64, c_uint64, c_uint64)
|
||||||
FORWARD_FLUSH = CFUNCTYPE(None, c_void_p, c_uint64)
|
FORWARD_FLUSH = CFUNCTYPE(None, c_void_p, c_uint64)
|
||||||
FORWARD_DISCARD = CFUNCTYPE(None, c_void_p, c_uint64, c_uint64, c_uint64)
|
FORWARD_DISCARD = CFUNCTYPE(None, c_void_p, c_uint64, c_uint64, c_uint64)
|
||||||
|
FORWARD_WRITE_ZEROS = CFUNCTYPE(None, c_void_p, c_uint64, c_uint64, c_uint64)
|
||||||
ON_INIT = CFUNCTYPE(c_int, c_void_p)
|
ON_INIT = CFUNCTYPE(c_int, c_void_p)
|
||||||
ON_DEINIT = CFUNCTYPE(None, c_void_p)
|
ON_DEINIT = CFUNCTYPE(None, c_void_p)
|
||||||
OPEN = CFUNCTYPE(c_int, c_void_p, c_void_p)
|
OPEN = CFUNCTYPE(c_int, c_void_p, c_void_p)
|
||||||
@ -70,6 +71,7 @@ class VolumeOps(Structure):
|
|||||||
("_forward_io", FORWARD_IO),
|
("_forward_io", FORWARD_IO),
|
||||||
("_forward_flush", FORWARD_FLUSH),
|
("_forward_flush", FORWARD_FLUSH),
|
||||||
("_forward_discard", FORWARD_DISCARD),
|
("_forward_discard", FORWARD_DISCARD),
|
||||||
|
("_forward_write_zeros", FORWARD_WRITE_ZEROS),
|
||||||
("_on_init", ON_INIT),
|
("_on_init", ON_INIT),
|
||||||
("_on_deinit", ON_DEINIT),
|
("_on_deinit", ON_DEINIT),
|
||||||
("_open", OPEN),
|
("_open", OPEN),
|
||||||
|
Loading…
Reference in New Issue
Block a user