Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp115465pxb; Wed, 22 Sep 2021 17:33:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMfgBv/tWNuS2D8nIfgbdLCiD+nzgEdHxlfjIHSb3cB9sMmS1eKFWlDFJOfPBGC5vcVzu2 X-Received: by 2002:a5d:9581:: with SMTP id a1mr1582666ioo.24.1632357198937; Wed, 22 Sep 2021 17:33:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632357198; cv=none; d=google.com; s=arc-20160816; b=ywos8IbW3qjGdY7slkb/jg4y5DIKahcNGJ9xX4xlUhloqDriJI9/Il9VByskVBHxUm xYnVFoFCPB+IjpJHje5cx5UhrqXdAkdJ5izbwx0MNsBMQZ8USCq/tPmRDgxjJLD3Wg83 YEiSBa3c7C1tKq+PvvFJCK8YDfU4IJfjStlM8xKAI7yyy57nTA98r6A8xNMyqjJChNn/ AcgExYszaATzclyBwY5T1ICDoMTiPOKjdx8ZQkWJH4Bb8cXg7OGIUzeAkNqPnaH4ig4W mGbnmRalpxOU4nguY0bUOZu/Iq7BfKdDx9V6UhtsEvUBp+3AI0CKXHtDZguDKnwUqpr3 4E2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GQ4nKO9QLZyOaq5KobOVDwUgQKCMwd+DmtbeAAuRsqo=; b=LPncr8qfvPhYlcEiGzr9h0udOO/kpkYeHMPLvDsoLSu76/vN7+zAyvr+qDEEajx2fM R8OMs8jkROt4Id6vHg/eJok0IPkzuwfMWNUscAawZsUr4ie6YJ62UH4oh3EzF7soXFP0 BZtPPqfaLPNTJfLLS860mwliOHp0d0rZr7H33XT8OFwtoYKQ1Co8z1Jy2OdUm7mI2raL wp0x03gb4c3D/52AFvXqRgPHlPm644FOkSlozU0RPYuSKTJmEOH43VRmEtHS6OTP3BlT y6fWRvrX+8f9UFn89KQf5R4Bu1r13VTAqRSIgZ8Ad6b3l2cT7PcteMEs0JYzCi5rrRnw 0tIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="cu+x/Gxf"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v18si4197940ilc.7.2021.09.22.17.32.38; Wed, 22 Sep 2021 17:33:18 -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=pass header.i=@redhat.com header.s=mimecast20190719 header.b="cu+x/Gxf"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238613AbhIWAbb (ORCPT + 99 others); Wed, 22 Sep 2021 20:31:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22028 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbhIWAbb (ORCPT ); Wed, 22 Sep 2021 20:31:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632357000; 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: in-reply-to:in-reply-to:references:references; bh=GQ4nKO9QLZyOaq5KobOVDwUgQKCMwd+DmtbeAAuRsqo=; b=cu+x/Gxf69z7M6TjT5mLsLhxWLKkqNFWEwSBoaKnBV0xqBIAeI25l8yzxI6dD9mni1bLc5 1k51rdAQ5QEJRs8rdOEQ7+07ijNBbTIQvMbYlv4aUVb7QYgFkooJmw0cqbSsswFTfrSe6e D/oQZUR5qr1NDGiejDEDN0fmUkCrc7w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-483-51W_odj_PrevgNel2Mccng-1; Wed, 22 Sep 2021 20:29:58 -0400 X-MC-Unique: 51W_odj_PrevgNel2Mccng-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13C77180830E; Thu, 23 Sep 2021 00:29:57 +0000 (UTC) Received: from T590 (ovpn-8-17.pek2.redhat.com [10.72.8.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9644B60BF1; Thu, 23 Sep 2021 00:29:48 +0000 (UTC) Date: Thu, 23 Sep 2021 08:29:57 +0800 From: Ming Lei To: Yu Kuai Cc: 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210916093350.1410403-4-yukuai3@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 16, 2021 at 05:33:46PM +0800, 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)); > -- > 2.31.1 > Reviewed-by: Ming Lei -- Ming