Lines Matching refs:rbd
2 * rbd engine
8 #include <rbd/librbd.h>
63 .lname = "rbd engine rbdname",
65 .help = "RBD name for RBD engine",
72 .lname = "rbd engine pool",
74 .help = "Name of the pool hosting the RBD for the RBD engine",
81 .lname = "rbd engine clientname",
83 .help = "Name of the ceph client to access the RBD for the RBD engine",
106 struct rbd_data *rbd;
111 rbd = calloc(1, sizeof(struct rbd_data));
112 if (!rbd)
115 rbd->connected = false;
118 rbd->fd = -1;
120 rbd->aio_events = calloc(td->o.iodepth, sizeof(struct io_u *));
121 if (!rbd->aio_events)
124 rbd->sort_events = calloc(td->o.iodepth, sizeof(struct io_u *));
125 if (!rbd->sort_events)
128 *rbd_data_ptr = rbd;
132 if (rbd) {
133 if (rbd->aio_events)
134 free(rbd->aio_events);
135 if (rbd->sort_events)
136 free(rbd->sort_events);
137 free(rbd);
144 static bool _fio_rbd_setup_poll(struct rbd_data *rbd)
148 /* add for rbd poll */
149 rbd->fd = eventfd(0, EFD_NONBLOCK);
150 if (rbd->fd < 0) {
155 r = rbd_set_image_notification(rbd->image, rbd->fd, EVENT_TYPE_EVENTFD);
158 close(rbd->fd);
159 rbd->fd = -1;
166 static bool _fio_rbd_setup_poll(struct rbd_data *rbd)
174 struct rbd_data *rbd = td->io_ops_data;
197 r = rados_create2(&rbd->cluster, o->cluster_name,
203 r = rados_create(&rbd->cluster, o->client_name);
210 r = rados_conf_read_file(rbd->cluster, NULL);
216 r = rados_connect(rbd->cluster);
222 r = rados_ioctx_create(rbd->cluster, o->pool_name, &rbd->io_ctx);
228 r = rbd_open(rbd->io_ctx, o->rbd_name, &rbd->image, NULL /*snap */ );
234 if (!_fio_rbd_setup_poll(rbd))
240 rbd_close(rbd->image);
241 rbd->image = NULL;
243 rados_ioctx_destroy(rbd->io_ctx);
244 rbd->io_ctx = NULL;
246 rados_shutdown(rbd->cluster);
247 rbd->cluster = NULL;
252 static void _fio_rbd_disconnect(struct rbd_data *rbd)
254 if (!rbd)
258 if (rbd->fd != -1) {
259 close(rbd->fd);
260 rbd->fd = -1;
264 if (rbd->image) {
265 rbd_close(rbd->image);
266 rbd->image = NULL;
269 if (rbd->io_ctx) {
270 rados_ioctx_destroy(rbd->io_ctx);
271 rbd->io_ctx = NULL;
274 if (rbd->cluster) {
275 rados_shutdown(rbd->cluster);
276 rbd->cluster = NULL;
303 struct rbd_data *rbd = td->io_ops_data;
305 return rbd->aio_events[event];
308 static inline int fri_check_complete(struct rbd_data *rbd, struct io_u *io_u,
315 rbd->aio_events[*events] = io_u;
359 struct rbd_data *rbd = td->io_ops_data;
371 pfd.fd = rbd->fd;
380 event_num = rbd_poll_io_events(rbd->image, comps, min_evts);
393 if (fri_check_complete(rbd, io_u, events))
396 rbd->sort_events[sidx++] = io_u;
408 qsort(rbd->sort_events, sidx, sizeof(struct io_u *), rbd_io_u_cmp);
411 io_u = rbd->sort_events[i];
413 if (fri_check_complete(rbd, io_u, events)) {
427 if (fri_check_complete(rbd, io_u, events))
460 struct rbd_data *rbd = td->io_ops_data;
479 r = rbd_aio_write_traced(rbd->image, io_u->offset, io_u->xfer_buflen,
482 r = rbd_aio_write(rbd->image, io_u->offset, io_u->xfer_buflen,
493 r = rbd_aio_read_traced(rbd->image, io_u->offset, io_u->xfer_buflen,
496 r = rbd_aio_read(rbd->image, io_u->offset, io_u->xfer_buflen,
505 r = rbd_aio_discard(rbd->image, io_u->offset,
512 r = rbd_aio_flush(rbd->image, fri->completion);
535 struct rbd_data *rbd = td->io_ops_data;
537 if (rbd->connected)
554 struct rbd_data *rbd = td->io_ops_data;
556 if (rbd) {
557 _fio_rbd_disconnect(rbd);
558 free(rbd->aio_events);
559 free(rbd->sort_events);
560 free(rbd);
568 struct rbd_data *rbd = NULL;
572 r = _fio_setup_rbd_data(td, &rbd);
577 td->io_ops_data = rbd;
594 rbd->connected = true;
597 r = rbd_stat(rbd->image, &info, sizeof(info));
607 dprint(FD_IO, "rbd-engine: image size: %lu\n", info.size);
611 * The size of the RBD is set instead of a artificial file.
614 add_file(td, td->o.filename ? : "rbd", 0, 0);
636 struct rbd_data *rbd = td->io_ops_data;
638 return rbd_invalidate_cache(rbd->image);
665 .name = "rbd",