Skip to contentSkip to conversation

nbd: Zero from and len fields in NBD_CMD_DISCONNECT.

PATCH Superseded Hani Benhabiles 2 participants 5 messages May 16, 2014 – May 25, 2014 1 message not in the archive

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nbd: Zero from and len fields in NBD_CMD_DISCONNECT.

Len field is already set to zero, but not the from field which is sent as 0xfffffffffffffe00. This makes no sense, and may cause confuse server implementations doing sanity checks (qemu-nbd is an example.)

---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a70ea2..657bdac 100644
@@ -246,7 +246,7 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
 	request.magic = htonl(NBD_REQUEST_MAGIC);
 	request.type = htonl(nbd_cmd(req));
 
-	if (nbd_cmd(req) == NBD_CMD_FLUSH) {
+	if (nbd_cmd(req) == NBD_CMD_FLUSH || nbd_cmd(req) == NBD_CMD_DISC) {
 		/* Other values are reserved for FLUSH requests.  */
 		request.from = 0;
 		request.len = 0;
Signature · 1 line
1.8.3.2

A message that is not in the archive (sent off-list or not yet received): CAECXXi4_RJ-yk8Ct=sPPe-pq=shdU-4cKvRTT3yNvsoY42-8_Q@mail.gmail.com

#2 lore raw
Quoted 3 lines · Paul Clements

Agreed. But better yet, the request structure should just be zeroed when it's allocated.

It is already initialized in __nbd_ioctl() with the blk_rq_init() call which sets the __sector value to -1 (which is 0xfffffffffffffe00 after the left shifts.)

This is the only (non-ugly / non-intrusive) way to do it afaict.

Quoted 34 lines

--
Paul

Quoted 28 lines · Hani Benhabiles

Len field is already set to zero, but not the from field which is sent as 0xfffffffffffffe00. This makes no sense, and may cause confuse server implementations doing sanity checks (qemu-nbd is an example.)

---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a70ea2..657bdac 100644
@@ -246,7 +246,7 @@ static int nbd_send_req(struct nbd_device *nbd, struct
 request *req)
        request.magic = htonl(NBD_REQUEST_MAGIC);
        request.type = htonl(nbd_cmd(req));
 
-       if (nbd_cmd(req) == NBD_CMD_FLUSH) {
+       if (nbd_cmd(req) == NBD_CMD_FLUSH || nbd_cmd(req) == NBD_CMD_DISC)
 {
                /* Other values are reserved for FLUSH requests.  */
                request.from = 0;
                request.len = 0;

--
1.8.3.2

#3 lore raw
Quoted 10 lines · Hani Benhabiles
Quoted 3 lines · Paul Clements

Agreed. But better yet, the request structure should just be zeroed when it's allocated.

It is already initialized in __nbd_ioctl() with the blk_rq_init() call which sets the __sector value to -1 (which is 0xfffffffffffffe00 after the left shifts.)

This is the only (non-ugly / non-intrusive) way to do it afaict.

Ping!

Anything blocking this patch ?

Thanks.

Quoted 34 lines
Quoted 34 lines

--
Paul

Quoted 28 lines · Hani Benhabiles

Len field is already set to zero, but not the from field which is sent as 0xfffffffffffffe00. This makes no sense, and may cause confuse server implementations doing sanity checks (qemu-nbd is an example.)

---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a70ea2..657bdac 100644
@@ -246,7 +246,7 @@ static int nbd_send_req(struct nbd_device *nbd, struct
 request *req)
        request.magic = htonl(NBD_REQUEST_MAGIC);
        request.type = htonl(nbd_cmd(req));
 
-       if (nbd_cmd(req) == NBD_CMD_FLUSH) {
+       if (nbd_cmd(req) == NBD_CMD_FLUSH || nbd_cmd(req) == NBD_CMD_DISC)
 {
                /* Other values are reserved for FLUSH requests.  */
                request.from = 0;
                request.len = 0;

--
1.8.3.2

#4 lore raw
Quoted 9 lines · Hani Benhabiles
Quoted 8 lines · Hani Benhabiles
Quoted 3 lines · Paul Clements

Agreed. But better yet, the request structure should just be zeroed when it's allocated.

It is already initialized in __nbd_ioctl() with the blk_rq_init() call which sets the __sector value to -1 (which is 0xfffffffffffffe00 after the left shifts.)

Quoted 6 lines
Quoted 2 lines

This is the only (non-ugly / non-intrusive) way to do it afaict.

Ping!

Anything blocking this patch ?

It's cleaner to just zero the struct and get rid of the conditional zeroing of specific fields. I'll prepare a patch in the next few days.

Thanks,
Paul

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines · Hani Benhabiles
Quoted 29 lines

Len field is already set to zero, but not the from field which is sent as 0xfffffffffffffe00. This makes no sense, and may cause confuse server implementations doing sanity checks (qemu-nbd is an example.)

---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a70ea2..657bdac 100644
@@ -246,7 +246,7 @@ static int nbd_send_req(struct nbd_device *nbd, struct
 request *req)
        request.magic = htonl(NBD_REQUEST_MAGIC);
        request.type = htonl(nbd_cmd(req));
 
-       if (nbd_cmd(req) == NBD_CMD_FLUSH) {
+       if (nbd_cmd(req) == NBD_CMD_FLUSH || nbd_cmd(req) == NBD_CMD_DISC)
 {
                /* Other values are reserved for FLUSH requests.  */
                request.from = 0;
                request.len = 0;

--
1.8.3.2

#5 lore raw
Quoted 13 lines · Paul Clements
Quoted 12 lines · Hani Benhabiles
Quoted 10 lines · Hani Benhabiles
Quoted 3 lines · Paul Clements

Agreed. But better yet, the request structure should just be zeroed when it's allocated.

It is already initialized in __nbd_ioctl() with the blk_rq_init() call which sets the __sector value to -1 (which is 0xfffffffffffffe00 after the left shifts.)

This is the only (non-ugly / non-intrusive) way to do it afaict.

Quoted 7 lines
Quoted 3 lines

Ping!

Anything blocking this patch ?

It's cleaner to just zero the struct and get rid of the conditional zeroing of specific fields. I'll prepare a patch in the next few days.

Sorry, I misunderstood which struct you were talking about!

Will send a v2 shortly.

Quoted 33 lines

Thanks,
Paul

Quoted 30 lines
Quoted 30 lines
Quoted 30 lines · Hani Benhabiles
Quoted 29 lines

Len field is already set to zero, but not the from field which is sent as 0xfffffffffffffe00. This makes no sense, and may cause confuse server implementations doing sanity checks (qemu-nbd is an example.)

---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/nbd.c +1 -1
index 3a70ea2..657bdac 100644
@@ -246,7 +246,7 @@ static int nbd_send_req(struct nbd_device *nbd, struct
 request *req)
        request.magic = htonl(NBD_REQUEST_MAGIC);
        request.type = htonl(nbd_cmd(req));
 
-       if (nbd_cmd(req) == NBD_CMD_FLUSH) {
+       if (nbd_cmd(req) == NBD_CMD_FLUSH || nbd_cmd(req) == NBD_CMD_DISC)
 {
                /* Other values are reserved for FLUSH requests.  */
                request.from = 0;
                request.len = 0;

--
1.8.3.2