nbd: Rename struct nbd_request and nbd_reply
Our coding convention prefers CamelCase names, and we already have other existing structs with NBDFoo naming. Let's be consistent, before later patches add even more structs. Signed-off-by: Eric Blake <eblake@redhat.com> Message-Id: <1476469998-28592-6-git-send-email-eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
		
							parent
							
								
									10676b81a9
								
							
						
					
					
						commit
						ed2dd91267
					
				| 
						 | 
				
			
			@ -116,7 +116,7 @@ static void nbd_restart_write(void *opaque)
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static int nbd_co_send_request(BlockDriverState *bs,
 | 
			
		||||
                               struct nbd_request *request,
 | 
			
		||||
                               NBDRequest *request,
 | 
			
		||||
                               QEMUIOVector *qiov)
 | 
			
		||||
{
 | 
			
		||||
    NBDClientSession *s = nbd_get_client_session(bs);
 | 
			
		||||
| 
						 | 
				
			
			@ -168,8 +168,8 @@ static int nbd_co_send_request(BlockDriverState *bs,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void nbd_co_receive_reply(NBDClientSession *s,
 | 
			
		||||
                                 struct nbd_request *request,
 | 
			
		||||
                                 struct nbd_reply *reply,
 | 
			
		||||
                                 NBDRequest *request,
 | 
			
		||||
                                 NBDReply *reply,
 | 
			
		||||
                                 QEMUIOVector *qiov)
 | 
			
		||||
{
 | 
			
		||||
    int ret;
 | 
			
		||||
| 
						 | 
				
			
			@ -196,7 +196,7 @@ static void nbd_co_receive_reply(NBDClientSession *s,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void nbd_coroutine_start(NBDClientSession *s,
 | 
			
		||||
   struct nbd_request *request)
 | 
			
		||||
                                NBDRequest *request)
 | 
			
		||||
{
 | 
			
		||||
    /* Poor man semaphore.  The free_sema is locked when no other request
 | 
			
		||||
     * can be accepted, and unlocked after receiving one reply.  */
 | 
			
		||||
| 
						 | 
				
			
			@ -210,7 +210,7 @@ static void nbd_coroutine_start(NBDClientSession *s,
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
static void nbd_coroutine_end(NBDClientSession *s,
 | 
			
		||||
    struct nbd_request *request)
 | 
			
		||||
                              NBDRequest *request)
 | 
			
		||||
{
 | 
			
		||||
    int i = HANDLE_TO_INDEX(s, request->handle);
 | 
			
		||||
    s->recv_coroutine[i] = NULL;
 | 
			
		||||
| 
						 | 
				
			
			@ -223,12 +223,12 @@ int nbd_client_co_preadv(BlockDriverState *bs, uint64_t offset,
 | 
			
		|||
                         uint64_t bytes, QEMUIOVector *qiov, int flags)
 | 
			
		||||
{
 | 
			
		||||
    NBDClientSession *client = nbd_get_client_session(bs);
 | 
			
		||||
    struct nbd_request request = {
 | 
			
		||||
    NBDRequest request = {
 | 
			
		||||
        .type = NBD_CMD_READ,
 | 
			
		||||
        .from = offset,
 | 
			
		||||
        .len = bytes,
 | 
			
		||||
    };
 | 
			
		||||
    struct nbd_reply reply;
 | 
			
		||||
    NBDReply reply;
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
 | 
			
		||||
    assert(bytes <= NBD_MAX_BUFFER_SIZE);
 | 
			
		||||
| 
						 | 
				
			
			@ -249,12 +249,12 @@ int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
 | 
			
		|||
                          uint64_t bytes, QEMUIOVector *qiov, int flags)
 | 
			
		||||
{
 | 
			
		||||
    NBDClientSession *client = nbd_get_client_session(bs);
 | 
			
		||||
    struct nbd_request request = {
 | 
			
		||||
    NBDRequest request = {
 | 
			
		||||
        .type = NBD_CMD_WRITE,
 | 
			
		||||
        .from = offset,
 | 
			
		||||
        .len = bytes,
 | 
			
		||||
    };
 | 
			
		||||
    struct nbd_reply reply;
 | 
			
		||||
    NBDReply reply;
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
 | 
			
		||||
    if (flags & BDRV_REQ_FUA) {
 | 
			
		||||
| 
						 | 
				
			
			@ -278,8 +278,8 @@ int nbd_client_co_pwritev(BlockDriverState *bs, uint64_t offset,
 | 
			
		|||
int nbd_client_co_flush(BlockDriverState *bs)
 | 
			
		||||
{
 | 
			
		||||
    NBDClientSession *client = nbd_get_client_session(bs);
 | 
			
		||||
    struct nbd_request request = { .type = NBD_CMD_FLUSH };
 | 
			
		||||
    struct nbd_reply reply;
 | 
			
		||||
    NBDRequest request = { .type = NBD_CMD_FLUSH };
 | 
			
		||||
    NBDReply reply;
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
 | 
			
		||||
    if (!(client->nbdflags & NBD_FLAG_SEND_FLUSH)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -303,12 +303,12 @@ int nbd_client_co_flush(BlockDriverState *bs)
 | 
			
		|||
int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count)
 | 
			
		||||
{
 | 
			
		||||
    NBDClientSession *client = nbd_get_client_session(bs);
 | 
			
		||||
    struct nbd_request request = {
 | 
			
		||||
    NBDRequest request = {
 | 
			
		||||
        .type = NBD_CMD_TRIM,
 | 
			
		||||
        .from = offset,
 | 
			
		||||
        .len = count,
 | 
			
		||||
    };
 | 
			
		||||
    struct nbd_reply reply;
 | 
			
		||||
    NBDReply reply;
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
 | 
			
		||||
    if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) {
 | 
			
		||||
| 
						 | 
				
			
			@ -344,7 +344,7 @@ void nbd_client_attach_aio_context(BlockDriverState *bs,
 | 
			
		|||
void nbd_client_close(BlockDriverState *bs)
 | 
			
		||||
{
 | 
			
		||||
    NBDClientSession *client = nbd_get_client_session(bs);
 | 
			
		||||
    struct nbd_request request = { .type = NBD_CMD_DISC };
 | 
			
		||||
    NBDRequest request = { .type = NBD_CMD_DISC };
 | 
			
		||||
 | 
			
		||||
    if (client->ioc == NULL) {
 | 
			
		||||
        return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ typedef struct NBDClientSession {
 | 
			
		|||
    int in_flight;
 | 
			
		||||
 | 
			
		||||
    Coroutine *recv_coroutine[MAX_NBD_REQUESTS];
 | 
			
		||||
    struct nbd_reply reply;
 | 
			
		||||
    NBDReply reply;
 | 
			
		||||
 | 
			
		||||
    bool is_unix;
 | 
			
		||||
} NBDClientSession;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,18 +29,20 @@
 | 
			
		|||
/* Note: these are _NOT_ the same as the network representation of an NBD
 | 
			
		||||
 * request and reply!
 | 
			
		||||
 */
 | 
			
		||||
struct nbd_request {
 | 
			
		||||
struct NBDRequest {
 | 
			
		||||
    uint64_t handle;
 | 
			
		||||
    uint64_t from;
 | 
			
		||||
    uint32_t len;
 | 
			
		||||
    uint16_t flags;
 | 
			
		||||
    uint16_t type;
 | 
			
		||||
};
 | 
			
		||||
typedef struct NBDRequest NBDRequest;
 | 
			
		||||
 | 
			
		||||
struct nbd_reply {
 | 
			
		||||
struct NBDReply {
 | 
			
		||||
    uint64_t handle;
 | 
			
		||||
    uint32_t error;
 | 
			
		||||
};
 | 
			
		||||
typedef struct NBDReply NBDReply;
 | 
			
		||||
 | 
			
		||||
/* Transmission (export) flags: sent from server to client during handshake,
 | 
			
		||||
   but describe what will happen during transmission */
 | 
			
		||||
| 
						 | 
				
			
			@ -101,8 +103,8 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags,
 | 
			
		|||
                          QIOChannel **outioc,
 | 
			
		||||
                          off_t *size, Error **errp);
 | 
			
		||||
int nbd_init(int fd, QIOChannelSocket *sioc, uint16_t flags, off_t size);
 | 
			
		||||
ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request);
 | 
			
		||||
ssize_t nbd_receive_reply(QIOChannel *ioc, struct nbd_reply *reply);
 | 
			
		||||
ssize_t nbd_send_request(QIOChannel *ioc, NBDRequest *request);
 | 
			
		||||
ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply);
 | 
			
		||||
int nbd_client(int fd);
 | 
			
		||||
int nbd_disconnect(int fd);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -708,7 +708,7 @@ int nbd_disconnect(int fd)
 | 
			
		|||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request)
 | 
			
		||||
ssize_t nbd_send_request(QIOChannel *ioc, NBDRequest *request)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t buf[NBD_REQUEST_SIZE];
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
| 
						 | 
				
			
			@ -738,7 +738,7 @@ ssize_t nbd_send_request(QIOChannel *ioc, struct nbd_request *request)
 | 
			
		|||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
ssize_t nbd_receive_reply(QIOChannel *ioc, struct nbd_reply *reply)
 | 
			
		||||
ssize_t nbd_receive_reply(QIOChannel *ioc, NBDReply *reply)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t buf[NBD_REPLY_SIZE];
 | 
			
		||||
    uint32_t magic;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										12
									
								
								nbd/server.c
								
								
								
								
							
							
						
						
									
										12
									
								
								nbd/server.c
								
								
								
								
							| 
						 | 
				
			
			@ -635,7 +635,7 @@ fail:
 | 
			
		|||
    return rc;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ssize_t nbd_receive_request(QIOChannel *ioc, struct nbd_request *request)
 | 
			
		||||
static ssize_t nbd_receive_request(QIOChannel *ioc, NBDRequest *request)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t buf[NBD_REQUEST_SIZE];
 | 
			
		||||
    uint32_t magic;
 | 
			
		||||
| 
						 | 
				
			
			@ -678,7 +678,7 @@ static ssize_t nbd_receive_request(QIOChannel *ioc, struct nbd_request *request)
 | 
			
		|||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ssize_t nbd_send_reply(QIOChannel *ioc, struct nbd_reply *reply)
 | 
			
		||||
static ssize_t nbd_send_reply(QIOChannel *ioc, NBDReply *reply)
 | 
			
		||||
{
 | 
			
		||||
    uint8_t buf[NBD_REPLY_SIZE];
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
| 
						 | 
				
			
			@ -976,7 +976,7 @@ void nbd_export_close_all(void)
 | 
			
		|||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static ssize_t nbd_co_send_reply(NBDRequestData *req, struct nbd_reply *reply,
 | 
			
		||||
static ssize_t nbd_co_send_reply(NBDRequestData *req, NBDReply *reply,
 | 
			
		||||
                                 int len)
 | 
			
		||||
{
 | 
			
		||||
    NBDClient *client = req->client;
 | 
			
		||||
| 
						 | 
				
			
			@ -1013,7 +1013,7 @@ static ssize_t nbd_co_send_reply(NBDRequestData *req, struct nbd_reply *reply,
 | 
			
		|||
 * (although the caller may still need to disconnect after reporting
 | 
			
		||||
 * the error).  */
 | 
			
		||||
static ssize_t nbd_co_receive_request(NBDRequestData *req,
 | 
			
		||||
                                      struct nbd_request *request)
 | 
			
		||||
                                      NBDRequest *request)
 | 
			
		||||
{
 | 
			
		||||
    NBDClient *client = req->client;
 | 
			
		||||
    ssize_t rc;
 | 
			
		||||
| 
						 | 
				
			
			@ -1107,8 +1107,8 @@ static void nbd_trip(void *opaque)
 | 
			
		|||
    NBDClient *client = opaque;
 | 
			
		||||
    NBDExport *exp = client->exp;
 | 
			
		||||
    NBDRequestData *req;
 | 
			
		||||
    struct nbd_request request;
 | 
			
		||||
    struct nbd_reply reply;
 | 
			
		||||
    NBDRequest request;
 | 
			
		||||
    NBDReply reply;
 | 
			
		||||
    ssize_t ret;
 | 
			
		||||
    int flags;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue