volume: Introduce general IO forward mechanism
Allow the core volume IOs to be forwarded directly to backend volumes to avoid unnecessary allocations. Signed-off-by: Robert Baldyga <robert.baldyga@huawei.com> Signed-off-by: Michal Mielewczyk <michal.mielewczyk@huawei.com>
This commit is contained in:
committed by
Michal Mielewczyk
parent
edce2c26a5
commit
7e73de0d51
65
inc/ocf_io.h
65
inc/ocf_io.h
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@@ -235,4 +236,68 @@ void ocf_io_handle(struct ocf_io *io, void *opaque);
|
||||
*/
|
||||
ocf_volume_t ocf_io_get_volume(struct ocf_io *io);
|
||||
|
||||
/**
|
||||
* @brief Get the original OCF IO associated with forward token
|
||||
*
|
||||
* @param[in] token Forward token
|
||||
*/
|
||||
struct ocf_io *ocf_forward_get_io(ocf_forward_token_t token);
|
||||
|
||||
/**
|
||||
* @brief Forward io 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] token Forward token
|
||||
* @param[in] volume Volume to which IO is being submitted
|
||||
* @param[in] token Token representing IO to be forwarded
|
||||
* @param[in] dir Direction OCF_READ/OCF_WRITE
|
||||
* @param[in] addr Address to which IO is being submitted
|
||||
* @param[in] bytes Length of the IO
|
||||
* @param[in] offset Offset within the IO data
|
||||
*/
|
||||
void ocf_forward_io(ocf_volume_t volume, ocf_forward_token_t token,
|
||||
int dir, uint64_t addr, uint64_t bytes, uint64_t offset);
|
||||
|
||||
/**
|
||||
* @brief Forward flush 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
|
||||
*/
|
||||
void ocf_forward_flush(ocf_volume_t volume, ocf_forward_token_t token);
|
||||
|
||||
/**
|
||||
* @brief Forward discard 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_discard(ocf_volume_t volume, ocf_forward_token_t token,
|
||||
uint64_t addr, uint64_t bytes);
|
||||
|
||||
/**
|
||||
* @brief Increment forwarded io refcount
|
||||
*
|
||||
* @param[in] token Forward token
|
||||
*/
|
||||
void ocf_forward_get(ocf_forward_token_t token);
|
||||
|
||||
/**
|
||||
* @brief Complete the forwarded io
|
||||
*
|
||||
* @param[in] token Forward token to be completed
|
||||
* @param[in] error Completion status code
|
||||
*/
|
||||
void ocf_forward_end(ocf_forward_token_t token, int error);
|
||||
|
||||
#endif /* __OCF_IO_H__ */
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2021 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@@ -72,6 +73,17 @@ typedef struct ocf_volume_uuid *ocf_uuid_t;
|
||||
*/
|
||||
typedef void ctx_data_t;
|
||||
|
||||
/**
|
||||
* @brief IO forward token
|
||||
*
|
||||
* The token is associated with IO that is being forwarded. It allows
|
||||
* OCF to keep track of which IO has been forwarded where. It also has
|
||||
* refcount which can be increased/decreased on each forward level, so
|
||||
* that there is no need to introduce additional counters if at some
|
||||
* level the forward needs to be splitted into several sub-forwards.
|
||||
*/
|
||||
typedef uint64_t ocf_forward_token_t;
|
||||
|
||||
/**
|
||||
* @brief handle to I/O queue
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright(c) 2012-2022 Intel Corporation
|
||||
* Copyright(c) 2024 Huawei Technologies
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
@@ -82,6 +83,39 @@ struct ocf_volume_ops {
|
||||
*/
|
||||
void (*submit_write_zeroes)(struct ocf_io *io);
|
||||
|
||||
/**
|
||||
* @brief Forward the original io directly to the volume
|
||||
*
|
||||
* @param[in] volume Volume to which IO is being submitted
|
||||
* @param[in] token Token representing IO to be forwarded
|
||||
* @param[in] dir Direction OCF_READ/OCF_WRITE
|
||||
* @param[in] addr Address to which IO is being submitted
|
||||
* @param[in] bytes Length of the IO
|
||||
* @param[in] offset Offset within the IO data
|
||||
*/
|
||||
void (*forward_io)(ocf_volume_t volume, ocf_forward_token_t token,
|
||||
int dir, uint64_t addr, uint64_t bytes,
|
||||
uint64_t offset);
|
||||
|
||||
/**
|
||||
* @brief Forward the original flush io directly to the volume
|
||||
*
|
||||
* @param[in] volume Volume to which IO is being submitted
|
||||
* @param[in] token Token representing IO to be forwarded
|
||||
*/
|
||||
void (*forward_flush)(ocf_volume_t volume, ocf_forward_token_t token);
|
||||
|
||||
/**
|
||||
* @brief Forward the original discard io directly to the volume
|
||||
*
|
||||
* @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_discard)(ocf_volume_t volume, ocf_forward_token_t token,
|
||||
uint64_t addr, uint64_t bytes);
|
||||
|
||||
/**
|
||||
* @brief Volume initialization callback, called when volume object
|
||||
* is being initialized
|
||||
|
||||
Reference in New Issue
Block a user