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

[Nbd] [PATCH 2/2] NBD: Use zeros for req.from and req.len in NBD_CMD_FLUSH



---
 nbd.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/nbd.c b/nbd.c
index 274e2f7..37949be 100644
--- 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",
-- 
1.7.4.1




Reply to: