From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4B92C433F5 for ; Wed, 22 Sep 2021 16:19:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 973D761168 for ; Wed, 22 Sep 2021 16:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236642AbhIVQVI (ORCPT ); Wed, 22 Sep 2021 12:21:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236634AbhIVQVG (ORCPT ); Wed, 22 Sep 2021 12:21:06 -0400 X-Greylist: delayed 1361 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 22 Sep 2021 09:19:36 PDT Received: from lounge.grep.be (lounge.grep.be [IPv6:2a01:4f8:200:91e8::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C173C061574 for ; Wed, 22 Sep 2021 09:19:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=uter.be; s=2021.lounge; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vX6Qu+emXOBeX55x21xlP5yK5xuZNhWOHbJG5PTxsow=; b=dXaiMB7WWoz7Zu09KijKcG32EI lhOXgJPMh3ProOjEwiW4/7buxU03QPvqXH40kT5kMxKFBQDHotzs10cUIJaE8AUBDiGff3jw17bkA uQRRJcUNymBuDycw8begbgGE3pYl9x0P6sfUBufEbuyKuRITWt1bng+7y0y4SmFY9jXdPnvwUCZbs a0J9KO1HWoqJhZOB6WQXmtZo/zE280weWx7kNi/36CP5QAPdonVU6IJ0gOTp1o2ZWL9j7sYZUeUAU W8ZSa4AhBEu5VQkPY8mgxuFcgB4r4Cjn3hXgrYJrpIChOhu+sB64WrzRyDtI2mylC5WotcPzIhYcN 358GTTTQ==; Received: from 197-101-72-171.ip.broadband.is ([197.101.72.171] helo=pc181009) by lounge.grep.be with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mT4bu-00Cfvr-R2; Wed, 22 Sep 2021 17:56:38 +0200 Received: from wouter by pc181009 with local (Exim 4.95-RC2) (envelope-from ) id 1mT4bg-0003l5-0I; Wed, 22 Sep 2021 17:56:24 +0200 Date: Wed, 22 Sep 2021 17:56:23 +0200 From: Wouter Verhelst To: Ming Lei Cc: "yukuai (C)" , josef@toxicpanda.com, axboe@kernel.dk, hch@infradead.org, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com Subject: Re: [patch v8 3/7] nbd: check sock index in nbd_read_stat() Message-ID: References: <20210916093350.1410403-1-yukuai3@huawei.com> <20210916093350.1410403-4-yukuai3@huawei.com> <7e2913ca-1089-9ab7-cfdb-5e8837d36034@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Speed: Gates' Law: Every 18 months, the speed of software halves. Organization: none Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 22, 2021 at 05:22:07PM +0800, Ming Lei wrote: > On Sun, Sep 19, 2021 at 06:34:28PM +0800, yukuai (C) wrote: > > On 2021/09/16 17:33, Yu Kuai wrote: > > > The sock that clent send request in nbd_send_cmd() and receive reply > > > in nbd_read_stat() should be the same. > > > > > > Signed-off-by: Yu Kuai > > > --- > > > drivers/block/nbd.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > > > index 614c6ab2b8fe..c724a5bd7fa4 100644 > > > --- a/drivers/block/nbd.c > > > +++ b/drivers/block/nbd.c > > > @@ -746,6 +746,10 @@ static struct nbd_cmd *nbd_read_stat(struct nbd_device *nbd, int index) > > > ret = -ENOENT; > > > goto out; > > > } > > > + if (cmd->index != index) { > > > + dev_err(disk_to_dev(nbd->disk), "Unexpected reply %d from different sock %d (expected %d)", > > > + tag, index, cmd->index); > > > + } > > > if (cmd->cmd_cookie != nbd_handle_to_cookie(handle)) { > > > dev_err(disk_to_dev(nbd->disk), "Double reply on req %p, cmd_cookie %u, handle cookie %u\n", > > > req, cmd->cmd_cookie, nbd_handle_to_cookie(handle)); > > > > > > > Hi, Ming > > > > Any suggestions about this patch? > > I think this one relies on nbd protocol between server and client, and > does the protocol require both request and reply xmitted via same > socket? As Eric already answered: yes, the request and reply are specified such that they must be transmitted over the same socket. For more details, you can find the protocol specification at https://github.com/NetworkBlockDevice/nbd/blob/master/doc/proto.md Please note that the protocol defined there has some options that are not currently supported by the Linux nbd implementation -- specifically the "structured reply" message format (and all that requires it) is not implemented (yet?). -- w@uter.{be,co.za} wouter@{grep.be,fosdem.org,debian.org}