Use zeros for req.from and req.len in NBD_CMD_FLUSH
authorAlex Bligh <alex@alex.org.uk>
Sun, 22 May 2011 10:08:35 +0000 (11:08 +0100)
committerAlex Bligh <alex@alex.org.uk>
Sun, 22 May 2011 10:08:35 +0000 (11:08 +0100)
nbd.c

diff --git a/nbd.c b/nbd.c
index 274e2f7..37949be 100644 (file)
--- a/nbd.c
+++ b/nbd.c
@@ -247,8 +247,14 @@ static int nbd_send_req(struct nbd_device *lo, struct request *req)
        request.type = htonl(nbd_cmd(req) |
                             (( (req->cmd_flags & REQ_FUA) && (lo->flags & NBD_FLAG_SEND_FUA)) ?
                              NBD_CMD_FLAG_FUA : 0));
-       request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
-       request.len = htonl(size);
+       /* Send from & len as zero on FLUSH - other values reserved per protocol */
+       if (request.type == NBD_CMD_FLUSH) {
+               request.from = 0;
+               request.len = 0;
+       } else {
+               request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
+               request.len = htonl(size);
+       }
        memcpy(request.handle, &req, sizeof(req));
 
        dprintk(DBG_TX, "%s: request %p: sending control (%s@%llu,%uB)\n",