qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v5 1/9] nbd: Create struct for tracking export i


From: Vladimir Sementsov-Ogievskiy
Subject: Re: [Qemu-block] [PATCH v5 1/9] nbd: Create struct for tracking export info
Date: Thu, 13 Jul 2017 15:31:24 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

13.07.2017 15:09, Vladimir Sementsov-Ogievskiy wrote:
07.07.2017 23:30, Eric Blake wrote:
The NBD Protocol is introducing some additional information
about exports, such as minimum request size and alignment, as
well as an advertised maximum request size.  It will be easier
to feed this information back to the block layer if we gather
all the information into a struct, rather than adding yet more
pointer parameters during negotiation.

// it was me who do so)


Signed-off-by: Eric Blake <address@hidden>

---
v5: rebase to master, enough differences to drop R-b
v4: rebase to master
v3: new patch
---
  block/nbd-client.h  |  3 +--
  include/block/nbd.h | 15 +++++++++++----
  block/nbd-client.c  | 18 ++++++++----------
  block/nbd.c         |  2 +-
  nbd/client.c        | 44 ++++++++++++++++++++++----------------------
  qemu-nbd.c          | 10 ++++------
  6 files changed, 47 insertions(+), 45 deletions(-)

diff --git a/block/nbd-client.h b/block/nbd-client.h
index 49636bc..df80771 100644
--- a/block/nbd-client.h
+++ b/block/nbd-client.h
@@ -20,8 +20,7 @@
  typedef struct NBDClientSession {
      QIOChannelSocket *sioc; /* The master data channel */
QIOChannel *ioc; /* The current I/O channel which may differ (eg TLS) */
-    uint16_t nbdflags;
-    off_t size;

was signed

+    NBDExportInfo info;

      CoMutex send_mutex;
      CoQueue free_sema;
diff --git a/include/block/nbd.h b/include/block/nbd.h
index 6d75d5a..9092374 100644
--- a/include/block/nbd.h
+++ b/include/block/nbd.h
@@ -123,13 +123,20 @@ enum {
   * aren't overflowing some other buffer. */
  #define NBD_MAX_NAME_SIZE 256

+/* Details collected by NBD_OPT_EXPORT_NAME and NBD_OPT_GO */
+struct NBDExportInfo {
+    uint64_t size;

becomes unsigned

+    uint16_t flags;
+};
+typedef struct NBDExportInfo NBDExportInfo;
+
ssize_t nbd_rwv(QIOChannel *ioc, struct iovec *iov, size_t niov, size_t length,
                  bool do_read, Error **errp);

[...]

--- a/nbd/client.c
+++ b/nbd/client.c


[...]

@@ -570,13 +570,13 @@ int nbd_receive_negotiate(QIOChannel *ioc, const char *name, uint16_t *flags, error_setg(errp, "Unexpected export flags %0x" PRIx32, oldflags);
              goto fail;
          }
-        *flags = oldflags;
+        info->flags = oldflags;
      } else {
          error_setg(errp, "Bad magic received");
          goto fail;
      }

-    trace_nbd_receive_negotiate_size_flags(*size, *flags);
+    trace_nbd_receive_negotiate_size_flags(info->size, info->flags);

trace function declared with uint64_t so this was not very good and becomes ok with this patch.

      if (zeroes && nbd_drop(ioc, 124, errp) < 0) {
          error_prepend(errp, "Failed to read reserved block");
          goto fail;
@@ -588,13 +588,13 @@ fail:
  }

  #ifdef __linux__
-int nbd_init(int fd, QIOChannelSocket *sioc, uint16_t flags, off_t size,
+int nbd_init(int fd, QIOChannelSocket *sioc, NBDExportInfo *info,
               Error **errp)
  {
-    unsigned long sectors = size / BDRV_SECTOR_SIZE;
-    if (size / BDRV_SECTOR_SIZE != sectors) {
- error_setg(errp, "Export size %lld too large for 32-bit kernel",
-                   (long long) size);
+    unsigned long sectors = info->size / BDRV_SECTOR_SIZE;
+    if (info->size / BDRV_SECTOR_SIZE != sectors) {
+ error_setg(errp, "Export size %" PRId64 " too large for 32-bit kernel",

should be PRIu64

+                   info->size);
          return -E2BIG;
      }

[...]


with fixed:

Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>

(if it is not too late ;)


--
Best regards,
Vladimir




reply via email to

[Prev in Thread] Current Thread [Next in Thread]