* [PATCHv2] nbd: Zero from and len fields in NBD_CMD_DISCONNECT.
@ 2014-05-25 22:22 Hani Benhabiles
2014-05-26 12:57 ` Paul Clements
0 siblings, 1 reply; 2+ messages in thread
From: Hani Benhabiles @ 2014-05-25 22:22 UTC (permalink / raw)
To: Paul.Clements; +Cc: nbd-general, linux-kernel
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.)
Signed-off-by: Hani Benhabiles <hani@linux.com>
---
Compared to v1:
* Zero the request structure instead of conditionally zeroing specific fields.
drivers/block/nbd.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 3a70ea2..8e1df52 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -243,14 +243,11 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
struct nbd_request request;
unsigned long size = blk_rq_bytes(req);
+ memset(&request, 0, sizeof(request));
request.magic = htonl(NBD_REQUEST_MAGIC);
request.type = htonl(nbd_cmd(req));
- if (nbd_cmd(req) == NBD_CMD_FLUSH) {
- /* Other values are reserved for FLUSH requests. */
- request.from = 0;
- request.len = 0;
- } else {
+ if (nbd_cmd(req) != NBD_CMD_FLUSH && nbd_cmd(req) != NBD_CMD_DISC) {
request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
request.len = htonl(size);
}
--
1.8.3.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCHv2] nbd: Zero from and len fields in NBD_CMD_DISCONNECT.
2014-05-25 22:22 [PATCHv2] nbd: Zero from and len fields in NBD_CMD_DISCONNECT Hani Benhabiles
@ 2014-05-26 12:57 ` Paul Clements
0 siblings, 0 replies; 2+ messages in thread
From: Paul Clements @ 2014-05-26 12:57 UTC (permalink / raw)
To: Hani Benhabiles; +Cc: nbd-general, kernel list
On Sun, May 25, 2014 at 6:22 PM, Hani Benhabiles <kroosec@gmail.com> wrote:
> 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.)
>
> Signed-off-by: Hani Benhabiles <hani@linux.com>
> ---
>
> Compared to v1:
> * Zero the request structure instead of conditionally zeroing specific fields.
Yeah, this one looks good. Sorry for the confusion on the structs...
> drivers/block/nbd.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 3a70ea2..8e1df52 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -243,14 +243,11 @@ static int nbd_send_req(struct nbd_device *nbd, struct request *req)
> struct nbd_request request;
> unsigned long size = blk_rq_bytes(req);
>
> + memset(&request, 0, sizeof(request));
> request.magic = htonl(NBD_REQUEST_MAGIC);
> request.type = htonl(nbd_cmd(req));
>
> - if (nbd_cmd(req) == NBD_CMD_FLUSH) {
> - /* Other values are reserved for FLUSH requests. */
> - request.from = 0;
> - request.len = 0;
> - } else {
> + if (nbd_cmd(req) != NBD_CMD_FLUSH && nbd_cmd(req) != NBD_CMD_DISC) {
> request.from = cpu_to_be64((u64)blk_rq_pos(req) << 9);
> request.len = htonl(size);
> }
> --
> 1.8.3.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-26 12:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-25 22:22 [PATCHv2] nbd: Zero from and len fields in NBD_CMD_DISCONNECT Hani Benhabiles
2014-05-26 12:57 ` Paul Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®