Merge pull request #216 from robertbaldyga/io-and-req-in-single-allocation
Allocate io and req in single allocation
This commit is contained in:
@@ -128,14 +128,23 @@ int ocf_core_get(ocf_cache_t cache, ocf_core_id_t id, ocf_core_t *core);
|
||||
* @brief Allocate new ocf_io
|
||||
*
|
||||
* @param[in] core Core object
|
||||
* @param[in] queue IO queue handle
|
||||
* @param[in] addr OCF IO destination address
|
||||
* @param[in] bytes OCF IO size in bytes
|
||||
* @param[in] dir OCF IO direction
|
||||
* @param[in] io_class OCF IO destination class
|
||||
* @param[in] flags OCF IO flags
|
||||
*
|
||||
* @retval ocf_io object
|
||||
*/
|
||||
static inline struct ocf_io *ocf_core_new_io(ocf_core_t core)
|
||||
static inline struct ocf_io *ocf_core_new_io(ocf_core_t core, ocf_queue_t queue,
|
||||
uint64_t addr, uint32_t bytes, uint32_t dir,
|
||||
uint32_t io_class, uint64_t flags)
|
||||
{
|
||||
ocf_volume_t volume = ocf_core_get_front_volume(core);
|
||||
|
||||
return ocf_volume_new_io(volume);
|
||||
return ocf_volume_new_io(volume, queue, addr, bytes, dir,
|
||||
io_class, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
59
inc/ocf_io.h
59
inc/ocf_io.h
@@ -48,16 +48,6 @@ typedef void (*ocf_end_io_t)(struct ocf_io *io, int error);
|
||||
* @brief OCF IO main structure
|
||||
*/
|
||||
struct ocf_io {
|
||||
/**
|
||||
* @brief OCF IO destination volume
|
||||
*/
|
||||
ocf_volume_t volume;
|
||||
|
||||
/**
|
||||
* @brief Operations set for this OCF IO
|
||||
*/
|
||||
const struct ocf_io_ops *ops;
|
||||
|
||||
/**
|
||||
* @brief OCF IO destination address
|
||||
*/
|
||||
@@ -150,26 +140,6 @@ struct ocf_io_ops {
|
||||
*/
|
||||
void *ocf_io_get_priv(struct ocf_io *io);
|
||||
|
||||
/**
|
||||
* @brief Configure OCF IO
|
||||
*
|
||||
* @param[in] io OCF IO
|
||||
* @param[in] addr OCF IO destination address
|
||||
* @param[in] bytes OCF IO size in bytes
|
||||
* @param[in] dir OCF IO direction
|
||||
* @param[in] io_class OCF IO destination class
|
||||
* @param[in] flags OCF IO flags
|
||||
*/
|
||||
static inline void ocf_io_configure(struct ocf_io *io, uint64_t addr,
|
||||
uint32_t bytes, uint32_t dir, uint32_t io_class, uint64_t flags)
|
||||
{
|
||||
io->addr = addr;
|
||||
io->bytes = bytes;
|
||||
io->io_class = io_class;
|
||||
io->flags = flags;
|
||||
io->dir = dir;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Increase reference counter in OCF IO
|
||||
*
|
||||
@@ -237,11 +207,7 @@ static inline void ocf_io_set_handle(struct ocf_io *io, ocf_handle_io_t fn)
|
||||
* @retval 0 Data set up successfully
|
||||
* @retval Non-zero Data set up failure
|
||||
*/
|
||||
static inline int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data,
|
||||
uint32_t offset)
|
||||
{
|
||||
return io->ops->set_data(io, data, offset);
|
||||
}
|
||||
int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data, uint32_t offset);
|
||||
|
||||
/**
|
||||
* @brief Get data vector from OCF IO
|
||||
@@ -252,21 +218,7 @@ static inline int ocf_io_set_data(struct ocf_io *io, ctx_data_t *data,
|
||||
*
|
||||
* @return Data vector from IO
|
||||
*/
|
||||
static inline ctx_data_t *ocf_io_get_data(struct ocf_io *io)
|
||||
{
|
||||
return io->ops->get_data(io);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set queue to which IO should be submitted
|
||||
*
|
||||
* @param[in] io OCF IO to set up
|
||||
* @param[in] queue IO queue handle
|
||||
*/
|
||||
static inline void ocf_io_set_queue(struct ocf_io *io, ocf_queue_t queue)
|
||||
{
|
||||
io->io_queue = queue;
|
||||
}
|
||||
ctx_data_t *ocf_io_get_data(struct ocf_io *io);
|
||||
|
||||
/**
|
||||
* @brief Handle IO in cache engine
|
||||
@@ -276,4 +228,11 @@ static inline void ocf_io_set_queue(struct ocf_io *io, ocf_queue_t queue)
|
||||
*/
|
||||
void ocf_io_handle(struct ocf_io *io, void *opaque);
|
||||
|
||||
/**
|
||||
* @brief Get volume associated with io
|
||||
*
|
||||
* @param[in] io OCF IO to be handled
|
||||
*/
|
||||
ocf_volume_t ocf_io_get_volume(struct ocf_io *io);
|
||||
|
||||
#endif /* __OCF_IO_H__ */
|
||||
|
||||
@@ -65,7 +65,7 @@ struct ocf_volume_type;
|
||||
/**
|
||||
* @brief handle to volume type
|
||||
*/
|
||||
typedef const struct ocf_volume_type *ocf_volume_type_t;
|
||||
typedef struct ocf_volume_type *ocf_volume_type_t;
|
||||
|
||||
/**
|
||||
* @brief handle to volume uuid
|
||||
|
||||
@@ -256,10 +256,19 @@ int ocf_volume_is_atomic(ocf_volume_t volume);
|
||||
* @brief Allocate new io
|
||||
*
|
||||
* @param[in] volume Volume
|
||||
* @param[in] queue IO queue handle
|
||||
* @param[in] addr OCF IO destination address
|
||||
* @param[in] bytes OCF IO size in bytes
|
||||
* @param[in] dir OCF IO direction
|
||||
* @param[in] io_class OCF IO destination class
|
||||
* @param[in] flags OCF IO flags
|
||||
*
|
||||
* @return ocf_io on success atomic, otherwise NULL
|
||||
*/
|
||||
struct ocf_io *ocf_volume_new_io(ocf_volume_t volume);
|
||||
struct ocf_io *ocf_volume_new_io(ocf_volume_t volume, ocf_queue_t queue,
|
||||
uint64_t addr, uint32_t bytes, uint32_t dir,
|
||||
uint32_t io_class, uint64_t flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Submit io to volume
|
||||
|
||||
Reference in New Issue
Block a user