Open CAS Framework
Open source framework of Cache Acceleration Software
ocf_volume.h
Go to the documentation of this file.
1 /*
2  * Copyright(c) 2012-2020 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause-Clear
4  */
5 
6 #ifndef __OCF_VOLUME_H__
7 #define __OCF_VOLUME_H__
8 
14 #include "ocf_types.h"
15 #include "ocf_env_headers.h"
16 #include "ocf/ocf_err.h"
17 
18 struct ocf_io;
19 
23 #define OCF_VOLUME_UUID_MAX_SIZE (4096UL - sizeof(uint32_t))
24 
29  size_t size;
32  void *data;
34 };
35 
40  uint32_t atomic_writes : 1;
42 };
43 
53  void (*submit_io)(struct ocf_io *io);
54 
60  void (*submit_flush)(struct ocf_io *io);
61 
67  void (*submit_metadata)(struct ocf_io *io);
68 
74  void (*submit_discard)(struct ocf_io *io);
75 
82  void (*submit_write_zeroes)(struct ocf_io *io);
83 
95  int (*open)(ocf_volume_t volume, void *volume_params);
96 
102  void (*close)(ocf_volume_t volume);
103 
111  unsigned int (*get_max_io_size)(ocf_volume_t volume);
112 
120  uint64_t (*get_length)(ocf_volume_t volume);
121 };
122 
127  const char *name;
130  uint32_t io_priv_size;
136  struct ocf_volume_caps caps;
139  struct ocf_volume_ops ops;
142  struct ocf_io_ops io_ops;
145  void (*deinit)(void);
147 };
148 
157 int ocf_uuid_set_str(ocf_uuid_t uuid, char *str);
158 
164 static inline const char *ocf_uuid_to_str(const struct ocf_volume_uuid *uuid)
165 {
166  return (const char *)uuid->data;
167 }
168 
180  struct ocf_volume_uuid *uuid, bool uuid_copy);
181 
187 void ocf_volume_deinit(ocf_volume_t volume);
188 
199  struct ocf_volume_uuid *uuid);
200 
206 void ocf_volume_destroy(ocf_volume_t volume);
207 
216 
224 const struct ocf_volume_uuid *ocf_volume_get_uuid(ocf_volume_t volume);
225 
233 void *ocf_volume_get_priv(ocf_volume_t volume);
234 
243 
252 
266 struct ocf_io *ocf_volume_new_io(ocf_volume_t volume, ocf_queue_t queue,
267  uint64_t addr, uint32_t bytes, uint32_t dir,
268  uint32_t io_class, uint64_t flags);
269 
270 
276 void ocf_volume_submit_io(struct ocf_io *io);
277 
283 void ocf_volume_submit_flush(struct ocf_io *io);
284 
290 void ocf_volume_submit_discard(struct ocf_io *io);
291 
300 int ocf_volume_open(ocf_volume_t volume, void *volume_params);
301 
307 void ocf_volume_close(ocf_volume_t volume);
308 
316 unsigned int ocf_volume_get_max_io_size(ocf_volume_t volume);
317 
325 uint64_t ocf_volume_get_length(ocf_volume_t volume);
326 
327 #endif /* __OCF_VOLUME_H__ */
struct ocf_cache * ocf_cache_t
handle to object designating ocf cache device
Definition: ocf_types.h:44
int ocf_uuid_set_str(ocf_uuid_t uuid, char *str)
Initialize UUID from string.
ocf_cache_t ocf_volume_get_cache(ocf_volume_t volume)
Get cache handle for given volume.
const char * name
Definition: ocf_volume.h:127
unsigned int ocf_volume_get_max_io_size(ocf_volume_t volume)
Get volume max io size.
uint32_t io_priv_size
Definition: ocf_volume.h:130
OCF IO main structure.
Definition: ocf_io.h:50
struct ocf_volume_type * ocf_volume_type_t
handle to volume type
Definition: ocf_types.h:63
const struct ocf_volume_uuid * ocf_volume_get_uuid(ocf_volume_t volume)
Get volume UUID.
void ocf_volume_destroy(ocf_volume_t volume)
Deinitialize and free volume.
size_t size
Definition: ocf_volume.h:29
uint64_t flags
OCF IO flags.
Definition: ocf_io.h:59
void ocf_volume_submit_io(struct ocf_io *io)
Submit io to volume.
This structure describes volume capabilities.
Definition: ocf_volume.h:39
int ocf_volume_is_atomic(ocf_volume_t volume)
Check if volume supports atomic mode.
OCF volume interface declaration.
Definition: ocf_volume.h:47
int ocf_volume_create(ocf_volume_t *volume, ocf_volume_type_t type, struct ocf_volume_uuid *uuid)
Allocate and initialize volume.
OCF volume UUID.
Definition: ocf_volume.h:28
uint32_t atomic_writes
Definition: ocf_volume.h:40
OCF IO operations set structure.
Definition: ocf_io.h:110
OCF types.
void ocf_volume_close(ocf_volume_t volume)
Get volume max io size.
uint32_t dir
OCF IO direction.
Definition: ocf_io.h:74
ocf_volume_type_t ocf_volume_get_type(ocf_volume_t volume)
Get volume type.
uint32_t io_class
OCF IO destination class.
Definition: ocf_io.h:69
void * data
Definition: ocf_volume.h:32
struct ocf_volume * ocf_volume_t
handle to object designating ocf volume
Definition: ocf_types.h:56
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)
Allocate new io.
struct ocf_queue * ocf_queue_t
handle to I/O queue
Definition: ocf_types.h:78
int ocf_volume_init(ocf_volume_t volume, ocf_volume_type_t type, struct ocf_volume_uuid *uuid, bool uuid_copy)
Initialize volume.
uint64_t ocf_volume_get_length(ocf_volume_t volume)
Get volume length.
uint64_t addr
OCF IO destination address.
Definition: ocf_io.h:54
uint32_t volume_priv_size
Definition: ocf_volume.h:133
uint32_t bytes
OCF IO size in bytes.
Definition: ocf_io.h:64
void ocf_volume_submit_flush(struct ocf_io *io)
Submit flush to volume.
void ocf_volume_submit_discard(struct ocf_io *io)
Submit discard to volume.
void ocf_volume_deinit(ocf_volume_t volume)
Deinitialize volume.
int ocf_volume_open(ocf_volume_t volume, void *volume_params)
Open volume.
void * ocf_volume_get_priv(ocf_volume_t volume)
Get private context of volume.
This structure describes volume properties.
Definition: ocf_volume.h:126