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

[PATCH] proto: add xNBD command NBD_CMD_CACHE to the spec



Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---

Hi all.

The actual usage case, as already described in mailing list:

some kind of VM restore from backup:

    +---------- VM --------------+
    |                            |
    | guest                      |
    |  |                         |
    | local disk -- (NBD server)<----CACHE-------+(third party NBD client)
    |  |                         |
    | (NBD client*)<----------------(data)-------+(NBD server) -- [VM backup]
    |                            |
    +----------------------------+

    - copy-on-read is set up between "local disk" and "NBD client*"
    - when guest read block and there is no corresponding block in the local
      disk it is read from the NBD client*, and saved in the local disk
    - when guest writes something, it is written into the local disk
    - on CMD_CACHE, if there is no corresponding block in local disk, it is
      read from NBD client and saved in the local disk
    - on CMD_CACHE, if there is corresponding block in local disk - do nothing 


 doc/proto.md | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/doc/proto.md b/doc/proto.md
index c7803e0..73ce5de 100644
--- a/doc/proto.md
+++ b/doc/proto.md
@@ -897,6 +897,7 @@ The field has the following format:
   the export.
 - bit 9, `NBD_FLAG_SEND_RESIZE`: defined by the experimental `RESIZE`
   [extension](https://github.com/NetworkBlockDevice/nbd/blob/extension-resize/doc/proto.md).
+- bit 10, `NBD_FLAG_SEND_CACHE`: exposes support for `NBD_CMD_CACHE`.
 
 Clients SHOULD ignore unknown flags.
 
@@ -1632,6 +1633,20 @@ The following request types exist:
     A client MUST NOT send a trim request unless `NBD_FLAG_SEND_TRIM`
     was set in the transmission flags field.
 
+* `NBD_CMD_CACHE` (5)
+
+    Cache request. Implies server to perform some action to speed-up
+    further read requests to the area specified by *offset* and
+    *length*. However, performance gain is not guaranteed and depends on
+    server implementation.
+
+    If an error occurs, the server MUST set the appropriate error code
+    in the error field. However failure on this operation doesn't mean
+    that further read requests on this area will fail.
+
+    A client MUST NOT send a cache request unless `NBD_FLAG_SEND_CACHE`
+    was set in the transmission flags field.
+
 * `NBD_CMD_WRITE_ZEROES` (6)
 
     A write request with no payload. *Offset* and *length* define the
@@ -1679,9 +1694,6 @@ The following request types exist:
     maintainer of this document, so that these messages can be listed here
     to avoid conflicting implementations.
 
-    Currently one such message is known: `NBD_CMD_CACHE`, with type set to
-    5, implemented by xnbd.
-
 #### Error values
 
 The error values are used for the error field in the reply message.
-- 
2.11.1


Reply to: