Changeset View
Standalone View
usr.sbin/bhyve/block_if.h
- This file was copied to usr.sbin/bhyve/block_backends.h.
Show All 32 Lines | |||||
* are thread safe, with no assumptions about the context of the completion | * are thread safe, with no assumptions about the context of the completion | ||||
* callback - it may occur in the caller's context, or asynchronously in | * callback - it may occur in the caller's context, or asynchronously in | ||||
* another thread. | * another thread. | ||||
*/ | */ | ||||
#ifndef _BLOCK_IF_H_ | #ifndef _BLOCK_IF_H_ | ||||
#define _BLOCK_IF_H_ | #define _BLOCK_IF_H_ | ||||
#include <sys/queue.h> | |||||
#include <sys/uio.h> | #include <sys/uio.h> | ||||
#include <sys/unistd.h> | #include <sys/unistd.h> | ||||
/* | #include "block_backends.h" | ||||
* BLOCKIF_IOV_MAX is the maximum number of scatter/gather entries in | |||||
* a single request. BLOCKIF_RING_MAX is the maxmimum number of | |||||
* pending requests that can be queued. | |||||
*/ | |||||
#define BLOCKIF_IOV_MAX 128 /* not practical to be IOV_MAX */ | |||||
#define BLOCKIF_RING_MAX 128 | |||||
struct blockif_req { | struct locblk_elem { | ||||
int br_iovcnt; | TAILQ_ENTRY(locblk_elem) be_link; | ||||
off_t br_offset; | struct blockif_req *be_req; | ||||
ssize_t br_resid; | enum blockop be_op; | ||||
void (*br_callback)(struct blockif_req *req, int err); | enum blockstat be_status; | ||||
void *br_param; | pthread_t be_tid; | ||||
struct iovec br_iov[BLOCKIF_IOV_MAX]; | off_t be_block; | ||||
}; | }; | ||||
typedef struct locblk_elem locblk_elem_t; | |||||
struct blockif_ctxt; | struct locblk_ctxt { | ||||
struct blockif_ctxt *blockif_open(const char *optstr, const char *ident); | int bc_magic; | ||||
off_t blockif_size(struct blockif_ctxt *bc); | int bc_fd; | ||||
void blockif_chs(struct blockif_ctxt *bc, uint16_t *c, uint8_t *h, | int bc_ischr; | ||||
uint8_t *s); | int bc_isgeom; | ||||
int blockif_sectsz(struct blockif_ctxt *bc); | int bc_candelete; | ||||
void blockif_psectsz(struct blockif_ctxt *bc, int *size, int *off); | int bc_rdonly; | ||||
int blockif_queuesz(struct blockif_ctxt *bc); | off_t bc_size; | ||||
freqlabs: Please prefix the struct members with `bb_`. | |||||
int blockif_is_ro(struct blockif_ctxt *bc); | int bc_sectsz; | ||||
int blockif_candelete(struct blockif_ctxt *bc); | int bc_psectsz; | ||||
Done Inline Actionsnit: I would call it bb_name and store the backend name without ending ':' ("file", "rbd"). trociny: nit: I would call it `bb_name` and store the backend name without ending ':' ("file", "rbd"). | |||||
Done Inline Actions
what if optstr contains /file/, so it will require checking if strstr returns start of optstr AND that bb_name != "" wjw_digiware.nl: 1) Sure, can do
2) that makes the code only more convoluted.
what if `optstr` contains… | |||||
Done Inline ActionsI am not quite sure I follow. I suggest not to store ':' in the backend name, but sure the ':' should be present in optstr to separate scheme (backend) name from the rests of params. When parsing optstr for the backend name you should look for the first occurrence of ':' character and use the part of the string before ':' as a backend name if all characters there are alphanumeric. And the part of the string after ':' is passed to the backend open function (if you found the backend with such a name). trociny: I am not quite sure I follow. I suggest not to store ':' in the backend name, but sure the ':'… | |||||
int blockif_read(struct blockif_ctxt *bc, struct blockif_req *breq); | int bc_psectoff; | ||||
int blockif_write(struct blockif_ctxt *bc, struct blockif_req *breq); | int bc_closing; | ||||
int blockif_flush(struct blockif_ctxt *bc, struct blockif_req *breq); | pthread_t bc_btid[BLOCKIF_NUMTHR]; | ||||
int blockif_delete(struct blockif_ctxt *bc, struct blockif_req *breq); | pthread_mutex_t bc_mtx; | ||||
int blockif_cancel(struct blockif_ctxt *bc, struct blockif_req *breq); | pthread_cond_t bc_cond; | ||||
int blockif_close(struct blockif_ctxt *bc); | |||||
/* Request elements and free/pending/busy queues */ | |||||
TAILQ_HEAD(, locblk_elem) bc_freeq; | |||||
TAILQ_HEAD(, locblk_elem) bc_pendq; | |||||
TAILQ_HEAD(, locblk_elem) bc_busyq; | |||||
/* */ | |||||
struct locblk_elem bc_reqs[BLOCKIF_MAXREQ]; | |||||
}; | |||||
typedef struct locblk_ctxt locblk_ctxt_t; | |||||
#endif /* _BLOCK_IF_H_ */ | #endif /* _BLOCK_IF_H_ */ | ||||
Done Inline ActionsI think it would be a bit simpler to use an opaque pointer for private data. freqlabs: I think it would be a bit simpler to use an opaque //pointer// for private data. | |||||
Done Inline Actionsvoid * is more appropriate for private data. freqlabs: `void *` is more appropriate for private data. |
Please prefix the struct members with bb_.