summaryrefslogtreecommitdiff
path: root/nbd/nbd-internal.h
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2017-06-02 18:01:39 +0300
committerPaolo Bonzini <pbonzini@redhat.com>2017-06-15 11:04:06 +0200
commitd1fdf257d52822695f5ace6c586e059aa17d4b79 (patch)
treed5fb4687e70f916512592a286f6d1ebb64e10c1d /nbd/nbd-internal.h
parent92229a57bba10d5bbf469221c32a18d4bed642f4 (diff)
downloadqemu-d1fdf257d52822695f5ace6c586e059aa17d4b79.tar.gz
nbd: rename read_sync and friends
Rename nbd_wr_syncv -> nbd_rwv read_sync -> nbd_read read_sync_eof -> nbd_read_eof write_sync -> nbd_write drop_sync -> nbd_drop 1. nbd_ prefix read_sync and write_sync are already shared, so it is good to have a namespace prefix. drop_sync will be shared, and read_sync_eof is related to read_sync, so let's rename them all. 2. _sync suffix _sync is related to the fact that nbd_wr_syncv doesn't return if a write to socket returns EAGAIN. The first implementation of nbd_wr_syncv (was wr_sync in 7a5ca8648b) just loops while getting EAGAIN, the current implementation yields in this case. Why we want to get rid of it: - it is normal for r/w functions to be synchronous, so having an additional suffix for it looks redundant (contrariwise, we have _aio suffix for async functions) - _sync suffix in block layer is used when function does flush (so using it for other thing is confusing a bit) - keep function names short after adding nbd_ prefix 3. for nbd_wr_syncv let's use more common notation 'rw' Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20170602150150.258222-2-vsementsov@virtuozzo.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'nbd/nbd-internal.h')
-rw-r--r--nbd/nbd-internal.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/nbd/nbd-internal.h b/nbd/nbd-internal.h
index d6071640a0..753cb9d9c5 100644
--- a/nbd/nbd-internal.h
+++ b/nbd/nbd-internal.h
@@ -94,14 +94,14 @@
#define NBD_ENOSPC 28
#define NBD_ESHUTDOWN 108
-/* read_sync_eof
+/* nbd_read_eof
* Tries to read @size bytes from @ioc. Returns number of bytes actually read.
* May return a value >= 0 and < size only on EOF, i.e. when iteratively called
- * qio_channel_readv() returns 0. So, there are no needs to call read_sync_eof
+ * qio_channel_readv() returns 0. So, there is no need to call nbd_read_eof
* iteratively.
*/
-static inline ssize_t read_sync_eof(QIOChannel *ioc, void *buffer, size_t size,
- Error **errp)
+static inline ssize_t nbd_read_eof(QIOChannel *ioc, void *buffer, size_t size,
+ Error **errp)
{
struct iovec iov = { .iov_base = buffer, .iov_len = size };
/* Sockets are kept in blocking mode in the negotiation phase. After
@@ -109,16 +109,16 @@ static inline ssize_t read_sync_eof(QIOChannel *ioc, void *buffer, size_t size,
* our request/reply. Synchronization is done with recv_coroutine, so
* that this is coroutine-safe.
*/
- return nbd_wr_syncv(ioc, &iov, 1, size, true, errp);
+ return nbd_rwv(ioc, &iov, 1, size, true, errp);
}
-/* read_sync
+/* nbd_read
* Reads @size bytes from @ioc. Returns 0 on success.
*/
-static inline int read_sync(QIOChannel *ioc, void *buffer, size_t size,
- Error **errp)
+static inline int nbd_read(QIOChannel *ioc, void *buffer, size_t size,
+ Error **errp)
{
- ssize_t ret = read_sync_eof(ioc, buffer, size, errp);
+ ssize_t ret = nbd_read_eof(ioc, buffer, size, errp);
if (ret >= 0 && ret != size) {
ret = -EINVAL;
@@ -128,15 +128,15 @@ static inline int read_sync(QIOChannel *ioc, void *buffer, size_t size,
return ret < 0 ? ret : 0;
}
-/* write_sync
+/* nbd_write
* Writes @size bytes to @ioc. Returns 0 on success.
*/
-static inline int write_sync(QIOChannel *ioc, const void *buffer, size_t size,
- Error **errp)
+static inline int nbd_write(QIOChannel *ioc, const void *buffer, size_t size,
+ Error **errp)
{
struct iovec iov = { .iov_base = (void *) buffer, .iov_len = size };
- ssize_t ret = nbd_wr_syncv(ioc, &iov, 1, size, false, errp);
+ ssize_t ret = nbd_rwv(ioc, &iov, 1, size, false, errp);
assert(ret < 0 || ret == size);