From: Eric Blake <eblake@redhat.com>
To: josef@toxicpanda.com, linux-block@vger.kernel.org, nbd@other.debian.org
Cc: philipp.reisner@linbit.com, lars.ellenberg@linbit.com,
christoph.boehmwalder@linbit.com, corbet@lwn.net,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/5] block nbd: use req.cookie instead of req.handle
Date: Fri, 17 Mar 2023 15:27:48 -0500 [thread overview]
Message-ID: <20230317202749.419094-5-eblake@redhat.com> (raw)
In-Reply-To: <20230317202749.419094-1-eblake@redhat.com>
A good optimizing compiler should not compile this any differently,
but it is nicer to work directly with integers instead of memcpy().
Signed-off-by: Eric Blake <eblake@redhat.com>
---
v2: Fix kernel test robot complaint about wrong endianness on loongarch:
https://lore.kernel.org/oe-kbuild-all/202303121323.Jd35Q1Au-lkp@intel.com/
---
drivers/block/nbd.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 8a9487e79f1c..94ae85400b46 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -560,7 +560,6 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
unsigned long size = blk_rq_bytes(req);
struct bio *bio;
u64 handle;
- __be64 tmp;
u32 type;
u32 nbd_cmd_flags = 0;
int sent = nsock->sent, skip = 0;
@@ -607,8 +606,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct nbd_cmd *cmd, int index)
request.len = htonl(size);
}
handle = nbd_cmd_handle(cmd);
- tmp = cpu_to_be64(handle);
- memcpy(request.handle, &tmp, sizeof(tmp));
+ request.cookie = cpu_to_be64(handle);
trace_nbd_send_request(&request, nbd->index, blk_mq_rq_from_pdu(cmd));
@@ -729,14 +727,12 @@ static struct nbd_cmd *nbd_handle_reply(struct nbd_device *nbd, int index,
int result;
struct nbd_cmd *cmd;
struct request *req = NULL;
- __be64 tmp;
u64 handle;
u16 hwq;
u32 tag;
int ret = 0;
- memcpy(&tmp, reply->handle, sizeof(tmp));
- handle = be64_to_cpu(tmp);
+ handle = be64_to_cpu(reply->cookie);
tag = nbd_handle_to_tag(handle);
hwq = blk_mq_unique_tag_to_hwq(tag);
if (hwq < nbd->tag_set.nr_hw_queues)
--
2.39.2
next prev parent reply other threads:[~2023-03-17 20:29 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 20:27 [PATCH v2 0/5] nbd: s/handle/cookie/ Eric Blake
2023-03-17 20:27 ` [PATCH v2 1/5] uapi nbd: improve doc links to userspace spec Eric Blake
2023-03-17 20:27 ` [PATCH v2 2/5] block nbd: send handle in network order Eric Blake
2023-03-20 23:20 ` Ming Lei
2023-03-21 13:59 ` Eric Blake
2023-03-22 0:47 ` Ming Lei
2023-03-22 12:29 ` Eric Blake
2023-03-22 13:23 ` Ming Lei
2023-03-17 20:27 ` [PATCH v2 3/5] uapi nbd: add cookie alias to handle Eric Blake
2023-03-17 20:27 ` Eric Blake [this message]
2023-03-17 20:27 ` [PATCH v2 5/5] docs nbd: userspace NBD now favors github over sourceforge Eric Blake
2023-03-22 14:15 ` [PATCH v2 0/5] nbd: s/handle/cookie/ Josef Bacik
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230317202749.419094-5-eblake@redhat.com \
--to=eblake@redhat.com \
--cc=christoph.boehmwalder@linbit.com \
--cc=corbet@lwn.net \
--cc=josef@toxicpanda.com \
--cc=lars.ellenberg@linbit.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nbd@other.debian.org \
--cc=philipp.reisner@linbit.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox