Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp625426pxb; Wed, 22 Sep 2021 09:22:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxnIZrcA+AQ0Ju8MNEBVKlb7Nz4cdyBt4U6CBiT+yU48+RHyH0XdddBVLqcb+pgfJ9Zgxm3 X-Received: by 2002:a17:906:dc0d:: with SMTP id yy13mr20050ejb.88.1632327759714; Wed, 22 Sep 2021 09:22:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632327759; cv=none; d=google.com; s=arc-20160816; b=XS4MxjRVA62ie3LqT/VLPMoJ0Un1imTyAMFiiAQjjlFKjATe1r/+AIHwhtrviD/Fpq 1tmWazriMqlyBXsfBLNlh+t3bhRtH/yyPr/oskNeMKQI8MkZfP5nz8dD1LmThyZ05WP0 EoD5TFDODiRj+lJ944nb1DYEXt6p8RVLLzhq3n5VvyW3mZ79n7VO6ty6xFhH2Z3l+xNn 7f+jcBLzECL/qLFYgi+BetfhaGB+58TefXHwExfTVExUy0sa1urtg2Gxuedv4MFnLxyV rWEL4+fLImUORgHyxtiLHTjvHSedfJF+zUmhCKgFX4EGaKfaR5c3sWnelgeEvv7lcguh 59Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=vX6Qu+emXOBeX55x21xlP5yK5xuZNhWOHbJG5PTxsow=; b=clC10vamAezTErvgzb+xbX2TBDksAngbrdD/wktbj3M4Zvq6J7oX57kLmPBJLxSkmG gpSrPPk4we8Uwc92XXZAcdYtBUJgVI7S/rzUCTRT9IDNzzMSYfMfl5JUmW1UEdlJcYNx GoJg0vOwpvbzSvRwBW5aqGwG5XI57dhe1On6vupa2pRGHAULGWaJSl2DHv9tMK7DnPEw 1kdlQ68itlo4eCeCk9AbaAz5GCIpxuErlgppR7y68BLb+6rF2P7TUUrI4fIvzwftuxD3 ynVcasOJj6libA+AFAQzLomHyYIfRtHN95UipK+/dyyAgtX6zuwWtPYNfV4k9XUGFM2S XLiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@uter.be header.s=2021.lounge header.b=dXaiMB7W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uter.be Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y21si3184732edl.278.2021.09.22.09.22.10; Wed, 22 Sep 2021 09:22:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@uter.be header.s=2021.lounge header.b=dXaiMB7W; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=uter.be Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236558AbhIVQVH (ORCPT + 99 others); Wed, 22 Sep 2021 12:21:07 -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}