From nobody Tue Feb 10 23:01:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C201C6FD1D for ; Fri, 17 Mar 2023 20:29:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230176AbjCQU26 (ORCPT ); Fri, 17 Mar 2023 16:28:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjCQU2v (ORCPT ); Fri, 17 Mar 2023 16:28:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4AC5AA54C2 for ; Fri, 17 Mar 2023 13:28:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679084879; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0R5I27ov4lNPeGd1XvXpj2Wrky39OKo2yJm6P6Bnges=; b=Is6slL3g5jbnz5o4rzY+2frP2C9vk2ckKcsekFz2QBWdVLGXU5rI3CrLLWCwQeQEFoSySb 3e0nhsHhSCsBf8qw02tLHjQQig/HxHVhTVcaIAMj7syQaJ6piUdRZnZJ4FuHdePn/nbjl5 Gnkrd01KEwsj7HuVTWxBh+ZuGHhZCIE= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-zpc23gJ5NoWr0lHdeCqhig-1; Fri, 17 Mar 2023 16:27:55 -0400 X-MC-Unique: zpc23gJ5NoWr0lHdeCqhig-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1865C3C025C0; Fri, 17 Mar 2023 20:27:55 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 218CD492B00; Fri, 17 Mar 2023 20:27:54 +0000 (UTC) From: Eric Blake 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, Ming Lei Subject: [PATCH v2 1/5] uapi nbd: improve doc links to userspace spec Date: Fri, 17 Mar 2023 15:27:45 -0500 Message-Id: <20230317202749.419094-2-eblake@redhat.com> In-Reply-To: <20230317202749.419094-1-eblake@redhat.com> References: <20230317202749.419094-1-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The uapi header intentionally documents only the NBD server features that the kernel module will utilize as a client. But while it already had one mention of skipped bits due to userspace extensions, it did not actually direct the reader to the canonical source to learn about those extensions. While touching comments, fix an outdated reference that listed only READ and WRITE as commands. Signed-off-by: Eric Blake Reviewed-by: Ming Lei Reviewed-by: Josef Bacik --- v2: Split change to sourceforge link to separate patch --- include/uapi/linux/nbd.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h index 20d6cc91435d..8797387caaf7 100644 --- a/include/uapi/linux/nbd.h +++ b/include/uapi/linux/nbd.h @@ -11,6 +11,8 @@ * Cleanup PARANOIA usage & code. * 2004/02/19 Paul Clements * Removed PARANOIA, plus various cleanup and comments + * 2023 Copyright Red Hat + * Link to userspace extensions. */ #ifndef _UAPILINUX_NBD_H @@ -30,12 +32,18 @@ #define NBD_SET_TIMEOUT _IO( 0xab, 9 ) #define NBD_SET_FLAGS _IO( 0xab, 10) +/* + * See also https://github.com/NetworkBlockDevice/nbd/blob/master/doc/prot= o.md + * for additional userspace extensions not yet utilized in the kernel modu= le. + */ + enum { NBD_CMD_READ =3D 0, NBD_CMD_WRITE =3D 1, NBD_CMD_DISC =3D 2, NBD_CMD_FLUSH =3D 3, NBD_CMD_TRIM =3D 4 + /* userspace defines additional extension commands */ }; /* values for flags field, these are server interaction specific. */ @@ -64,14 +72,15 @@ enum { #define NBD_REQUEST_MAGIC 0x25609513 #define NBD_REPLY_MAGIC 0x67446698 /* Do *not* use magics: 0x12560953 0x96744668. */ +/* magic 0x668e33ef for structured reply not supported by kernel yet */ /* * This is the packet used for communication between client and * server. All data are in network byte order. */ struct nbd_request { - __be32 magic; - __be32 type; /* =3D=3D READ || =3D=3D WRITE */ + __be32 magic; /* NBD_REQUEST_MAGIC */ + __be32 type; /* See NBD_CMD_* */ char handle[8]; __be64 from; __be32 len; @@ -82,7 +91,7 @@ struct nbd_request { * it has completed an I/O request (or an error occurs). */ struct nbd_reply { - __be32 magic; + __be32 magic; /* NBD_REPLY_MAGIC */ __be32 error; /* 0 =3D ok, else error */ char handle[8]; /* handle you got from request */ }; --=20 2.39.2 From nobody Tue Feb 10 23:01:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 860C0C7618B for ; Fri, 17 Mar 2023 20:28:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230107AbjCQU2y (ORCPT ); Fri, 17 Mar 2023 16:28:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229997AbjCQU2u (ORCPT ); Fri, 17 Mar 2023 16:28:50 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E88F53B878 for ; Fri, 17 Mar 2023 13:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679084880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SwZBg+6O/Oe6TP7FO/stIooN++Hb7G11H2vCfhbvtbY=; b=AzbKMxuDmvfzBsdtIK8H5k2DWW5JoJOlTEQ6bXOs3XAzSR/u9z4Qxz54aTT3GF7gLgVK7K 3AgIoTEsbiKmeY98mJsmvj1RtlaMxRh1BTHFRm4gPt+nkeRcV1RMIepugB0zCzGSbB7oto WM5Pu0wblDmr++1LnRtewRCJcUpqs3w= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-Noqphx4HOairI2HF7qQiGg-1; Fri, 17 Mar 2023 16:27:56 -0400 X-MC-Unique: Noqphx4HOairI2HF7qQiGg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E901F85A5A3; Fri, 17 Mar 2023 20:27:55 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 371E3492B00; Fri, 17 Mar 2023 20:27:55 +0000 (UTC) From: Eric Blake 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 2/5] block nbd: send handle in network order Date: Fri, 17 Mar 2023 15:27:46 -0500 Message-Id: <20230317202749.419094-3-eblake@redhat.com> In-Reply-To: <20230317202749.419094-1-eblake@redhat.com> References: <20230317202749.419094-1-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The NBD spec says the client handle (or cookie) is opaque on the server, and therefore it really doesn't matter what endianness we use; to date, the use of memcpy() between u64 and a char[8] has exposed native endianness when treating the handle as a 64-bit number. However, since NBD protocol documents that everything else is in network order, and tools like Wireshark will dump even the contents of the handle as seen over the network, it's worth using a consistent ordering regardless of the native endianness. Plus, using a consistent endianness now allows an upcoming patch to simplify this to directly use integer assignment instead of memcpy(). Signed-off-by: Eric Blake Reviewed-by: Josef Bacik --- v2: new patch --- drivers/block/nbd.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 592cfa8b765a..8a9487e79f1c 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -560,6 +560,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct = nbd_cmd *cmd, int index) unsigned long size =3D blk_rq_bytes(req); struct bio *bio; u64 handle; + __be64 tmp; u32 type; u32 nbd_cmd_flags =3D 0; int sent =3D nsock->sent, skip =3D 0; @@ -606,7 +607,8 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct = nbd_cmd *cmd, int index) request.len =3D htonl(size); } handle =3D nbd_cmd_handle(cmd); - memcpy(request.handle, &handle, sizeof(handle)); + tmp =3D cpu_to_be64(handle); + memcpy(request.handle, &tmp, sizeof(tmp)); trace_nbd_send_request(&request, nbd->index, blk_mq_rq_from_pdu(cmd)); @@ -618,7 +620,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct = nbd_cmd *cmd, int index) trace_nbd_header_sent(req, handle); if (result < 0) { if (was_interrupted(result)) { - /* If we havne't sent anything we can just return BUSY, + /* If we haven't sent anything we can just return BUSY, * however if we have sent something we need to make * sure we only allow this req to be sent until we are * completely done. @@ -727,12 +729,14 @@ static struct nbd_cmd *nbd_handle_reply(struct nbd_de= vice *nbd, int index, int result; struct nbd_cmd *cmd; struct request *req =3D NULL; + __be64 tmp; u64 handle; u16 hwq; u32 tag; int ret =3D 0; - memcpy(&handle, reply->handle, sizeof(handle)); + memcpy(&tmp, reply->handle, sizeof(tmp)); + handle =3D be64_to_cpu(tmp); tag =3D nbd_handle_to_tag(handle); hwq =3D blk_mq_unique_tag_to_hwq(tag); if (hwq < nbd->tag_set.nr_hw_queues) --=20 2.39.2 From nobody Tue Feb 10 23:01:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9499FC74A5B for ; Fri, 17 Mar 2023 20:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229839AbjCQU2u (ORCPT ); Fri, 17 Mar 2023 16:28:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229473AbjCQU2o (ORCPT ); Fri, 17 Mar 2023 16:28:44 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89902A616B for ; Fri, 17 Mar 2023 13:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679084880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GsYNbSh5zaQpqPToVrw2INmBUKfltsbn27ZhrwN66l0=; b=bGWVKGWvrcbadStpkpb1OHnBuEuhkUn7jUc5A2jt1i1eZ+GyQD6sAdI3VMsXBkwR9J9Sna 9+pXYE3sIg/mZvE/cpPboLnj6Qo0ZowN9SoEjk8yTwpbFN3eu/K/BCoGrjv8DAOG29wlmc 9mPR3ondoqqSXoW2atT7HuwAx9A04Wo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-508-BMu_1d4VN-CdyMOrQPqmSw-1; Fri, 17 Mar 2023 16:27:57 -0400 X-MC-Unique: BMu_1d4VN-CdyMOrQPqmSw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C41153806737; Fri, 17 Mar 2023 20:27:56 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id 12E05492B00; Fri, 17 Mar 2023 20:27:56 +0000 (UTC) From: Eric Blake 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 3/5] uapi nbd: add cookie alias to handle Date: Fri, 17 Mar 2023 15:27:47 -0500 Message-Id: <20230317202749.419094-4-eblake@redhat.com> In-Reply-To: <20230317202749.419094-1-eblake@redhat.com> References: <20230317202749.419094-1-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The uapi header declares a 'char handle[8]' per request; which is overloaded in English (are you referring to "handle" the verb, such as handling a signal or writing a callback handler, or "handle" the noun, the value used in a lookup table to correlate a response back to the request). Many client-side NBD implementations (both servers and clients) have instead used 'uint64_t cookie' or similar, as it is easier to directly assign an integer than to futz around with memcpy. In fact, upstream documentation is now encouraging this shift in terminology: https://lists.debian.org/nbd/2023/03/msg00031.html Accomplish this by use of an anonymous union to provide the alias for anyone getting the definition from the uapi; this does not break existing clients, while exposing the nicer name for those who prefer it. Note that block/nbd.c still uses the term handle (in fact, it actually combines a 32-bit cookie and a 32-bit tag into the 64-bit handle), but that internal usage is not changed the public uapi, since no compliant NBD server has any reason to inspect or alter the 64 bits sent over the socket. Signed-off-by: Eric Blake Reviewed-by: Josef Bacik --- v2: swap order of anonymous union and add comments to list favored name --- include/uapi/linux/nbd.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/nbd.h b/include/uapi/linux/nbd.h index 8797387caaf7..80ce0ef43afd 100644 --- a/include/uapi/linux/nbd.h +++ b/include/uapi/linux/nbd.h @@ -12,7 +12,7 @@ * 2004/02/19 Paul Clements * Removed PARANOIA, plus various cleanup and comments * 2023 Copyright Red Hat - * Link to userspace extensions. + * Link to userspace extensions, favor cookie over handle. */ #ifndef _UAPILINUX_NBD_H @@ -81,7 +81,10 @@ enum { struct nbd_request { __be32 magic; /* NBD_REQUEST_MAGIC */ __be32 type; /* See NBD_CMD_* */ - char handle[8]; + union { + __be64 cookie; /* Opaque identifier for request */ + char handle[8]; /* older spelling of cookie */ + }; __be64 from; __be32 len; } __attribute__((packed)); @@ -93,6 +96,9 @@ struct nbd_request { struct nbd_reply { __be32 magic; /* NBD_REPLY_MAGIC */ __be32 error; /* 0 =3D ok, else error */ - char handle[8]; /* handle you got from request */ + union { + __be64 cookie; /* Opaque identifier from request */ + char handle[8]; /* older spelling of cookie */ + }; }; #endif /* _UAPILINUX_NBD_H */ --=20 2.39.2 From nobody Tue Feb 10 23:01:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42B6DC74A5B for ; Fri, 17 Mar 2023 20:29:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbjCQU3O (ORCPT ); Fri, 17 Mar 2023 16:29:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230028AbjCQU3E (ORCPT ); Fri, 17 Mar 2023 16:29:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90DF6C8319 for ; Fri, 17 Mar 2023 13:28:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679084883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LMNmNTOdx390ioTe9XNiCAi1NYjBrn3x8X89rBxIitg=; b=WazmDTzj2Z3HfpEHD5v0sK5b0QPNEDvzdtjXO2bGsUwSgKcYRdUKjMtylzQfhMI1o79ZyC gNcCFKCjHHb8m044X1OeecEAet79kS9WE+qX65bTk7eNFuDAyqlDxpsPs3SG2WS8GDqHj8 b5DxF0nqugOCzssnvdpQoKtKb/bnkjg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-294-Mxwocp_hMcOEN5qt7QZfpw-1; Fri, 17 Mar 2023 16:27:58 -0400 X-MC-Unique: Mxwocp_hMcOEN5qt7QZfpw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D7602999B21; Fri, 17 Mar 2023 20:27:57 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id E243B492B00; Fri, 17 Mar 2023 20:27:56 +0000 (UTC) From: Eric Blake 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 Message-Id: <20230317202749.419094-5-eblake@redhat.com> In-Reply-To: <20230317202749.419094-1-eblake@redhat.com> References: <20230317202749.419094-1-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Josef Bacik --- 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 =3D blk_rq_bytes(req); struct bio *bio; u64 handle; - __be64 tmp; u32 type; u32 nbd_cmd_flags =3D 0; int sent =3D nsock->sent, skip =3D 0; @@ -607,8 +606,7 @@ static int nbd_send_cmd(struct nbd_device *nbd, struct = nbd_cmd *cmd, int index) request.len =3D htonl(size); } handle =3D nbd_cmd_handle(cmd); - tmp =3D cpu_to_be64(handle); - memcpy(request.handle, &tmp, sizeof(tmp)); + request.cookie =3D 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_de= vice *nbd, int index, int result; struct nbd_cmd *cmd; struct request *req =3D NULL; - __be64 tmp; u64 handle; u16 hwq; u32 tag; int ret =3D 0; - memcpy(&tmp, reply->handle, sizeof(tmp)); - handle =3D be64_to_cpu(tmp); + handle =3D be64_to_cpu(reply->cookie); tag =3D nbd_handle_to_tag(handle); hwq =3D blk_mq_unique_tag_to_hwq(tag); if (hwq < nbd->tag_set.nr_hw_queues) --=20 2.39.2 From nobody Tue Feb 10 23:01:52 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0842C74A5B for ; Fri, 17 Mar 2023 20:29:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230133AbjCQU3S (ORCPT ); Fri, 17 Mar 2023 16:29:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229913AbjCQU3H (ORCPT ); Fri, 17 Mar 2023 16:29:07 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 079DCA8E99 for ; Fri, 17 Mar 2023 13:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679084883; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zrOb7zhbNBSA2vEfdnizburgLjEAzsaXpryIF7Glvbk=; b=Go3de1f8e9k1pGBJ5nh27kKzsiswOVo1k7PSkqDhEenEPawiY6Krc/BFNWkxG+tXN7mJTe fuDNHXOrSpP+Zq36MbVvDqP3xGwy06i4fO8kJVNnJm7FC1XmbpgR2tTpMCL0AyhEFP7Hw6 UKiYt4FpX1yO3vZSwIDg/ge6tqLOny4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-386-oN7h2_Q0PUqxhq_LDwb8xg-1; Fri, 17 Mar 2023 16:27:59 -0400 X-MC-Unique: oN7h2_Q0PUqxhq_LDwb8xg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 762FB1011573; Fri, 17 Mar 2023 20:27:58 +0000 (UTC) Received: from green.redhat.com (unknown [10.2.16.99]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB66D492B00; Fri, 17 Mar 2023 20:27:57 +0000 (UTC) From: Eric Blake 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 5/5] docs nbd: userspace NBD now favors github over sourceforge Date: Fri, 17 Mar 2023 15:27:49 -0500 Message-Id: <20230317202749.419094-6-eblake@redhat.com> In-Reply-To: <20230317202749.419094-1-eblake@redhat.com> References: <20230317202749.419094-1-eblake@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" While the sourceforge site for userspace NBD still exists, the code repository moved to github several years ago. Then with a recent patch[1], the github landing page contains just as much information as the sourceforge page, so we might as well point to a single location that also provides the code. [1] https://lists.debian.org/nbd/2023/03/msg00051.html Signed-off-by: Eric Blake Reviewed-by: Josef Bacik --- v2: split into its own patch --- Documentation/admin-guide/blockdev/nbd.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/admin-guide/blockdev/nbd.rst b/Documentation/adm= in-guide/blockdev/nbd.rst index d78dfe559dcf..faf2ac4b1509 100644 --- a/Documentation/admin-guide/blockdev/nbd.rst +++ b/Documentation/admin-guide/blockdev/nbd.rst @@ -14,7 +14,7 @@ to borrow disk space from another computer. Unlike NFS, it is possible to put any filesystem on it, etc. For more information, or to download the nbd-client and nbd-server -tools, go to http://nbd.sf.net/. +tools, go to https://github.com/NetworkBlockDevice/nbd. The nbd kernel module need only be installed on the client system, as the nbd-server is completely in userspace. In fact, --=20 2.39.2