Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5239194ybi; Tue, 28 May 2019 09:39:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUsUnRFs+BiUe3Yb4d79NvXIC8kqtVh/3gS6rzzmhGyUGu5XIvYpssl7JOJKcNa+TPEZ3N X-Received: by 2002:a63:c046:: with SMTP id z6mr132111751pgi.387.1559061542788; Tue, 28 May 2019 09:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559061542; cv=none; d=google.com; s=arc-20160816; b=Dlnzc5yvNmvzsUr9+3NVJwMAanEbsN0oO/b9dzBW+H9KT0vvZo+OMmxASB7gC3bI3M Fpwtt/rp/XPUlFpX7w/rEskwtjo9Et5TszRWT92Un4YtbErKSB61apfjzurQdK/ZKwVZ VduHNkVwjT7PFc3kKGaCkBtDjrYmNgZoczt4biHomuochTmLRii45UMPKBrxLETGzp3k Q/PyRVkDd+rwOvRlq1UcrFCv5koUtUoW77S0kqsscDdEfOtRPt4YHcFnllNAv3aM6BhK wgW+Gq+D8wEuABX0R4TwuSmvBSbK1SgQW4MhNpRI+exRdcYEB7XK042RIK/rthllThXX abog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=R1/0un/jONQ7TFTHuGKq1KGba17YAxDnFmfTcpJFJWk=; b=AVrvo/zKnz5epy8RI1FoChnb5W1zZjfYoTh8nkbgyYMoP8Or7k+lG2uMgtX22VoiRW OVGYnFJkXfXVYZ8m2DPzt3f6bicHPY5TLYa+V7MSq1nv10fuMJ8it1PchIENXmYTtQyS y47tYBfQkQ+RY3QMKBWXGKujxoITPQvQs5epNsbdro+w8lQddnrbmRDlvWNGo0nZW5hn 0ablTR8A5nm1s28WNUSJU/wCxn/f591L8rSlTQ3W9M0dFJqAkIASk35/ZAXEQwrhhfAj db4NlroLDiB4Xn+2ro0mCs2QKH7Xxe6B7ikLnhzWdXYJg0uXpaM6WyIwtBMNWWQ4d2gd EvBg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k69si4012207pje.13.2019.05.28.09.38.47; Tue, 28 May 2019 09:39:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbfE1Qga (ORCPT + 99 others); Tue, 28 May 2019 12:36:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56190 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbfE1Qg3 (ORCPT ); Tue, 28 May 2019 12:36:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D27630C1328; Tue, 28 May 2019 16:36:24 +0000 (UTC) Received: from [10.10.126.56] (ovpn-126-56.rdu2.redhat.com [10.10.126.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 549375D6A9; Tue, 28 May 2019 16:36:22 +0000 (UTC) Subject: Re: [PATCH 2/3] nbd: notify userland even if nbd has already disconnected To: Yao Liu , Josef Bacik References: <1558691036-16281-1-git-send-email-yotta.liu@ucloud.cn> <1558691036-16281-2-git-send-email-yotta.liu@ucloud.cn> <20190524130856.zod5agp7hk74pcnr@MacBook-Pro-91.local.dhcp.thefacebook.com> <20190527182323.GB20702@192-168-150-246.7~> Cc: Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org From: Mike Christie Message-ID: <5CED6385.3000802@redhat.com> Date: Tue, 28 May 2019 11:36:21 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20190527182323.GB20702@192-168-150-246.7~> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Tue, 28 May 2019 16:36:29 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/27/2019 01:23 PM, Yao Liu wrote: > On Fri, May 24, 2019 at 09:08:58AM -0400, Josef Bacik wrote: >> On Fri, May 24, 2019 at 05:43:55PM +0800, Yao Liu wrote: >>> Some nbd client implementations have a userland's daemon, so we should >>> inform client daemon to clean up and exit. >>> >>> Signed-off-by: Yao Liu >> >> Except the nbd_disconnected() check is for the case that the client told us >> specifically to disconnect, so we don't want to send the notification to >> re-connect because we've already been told we want to tear everything down. >> Nack to this as well. Thanks, >> >> Josef >> > > But in userland, client daemon process and process which send disconnect > command are not same process, so they are not clear to each other, so > client daemon expect driver inform it to exit. > In addition, client daemon will get nbd status with nbd_genl_status interface > after it get notified and it should not re-connect if status connected == 0 > When using the netlink interface you get the NBD_CMD_LINK_DEAD first then the configs_refs goes to zero right? nbd_disconnect_and_put -> sock_shutdown -> nbd_mark_nsock_dead then later we do the final nbd_config_put? Maybe it would be best to add a new netlink event to signal what has happened, because the above nl and stat algorithm seems like a pain. The NBD_CMD_LINK_DEAD will be sent, then userspace has to possibly poll the status to check if this was caused due to nbd_genl_disconnect instead of a downed link due to something like a command timeout, because the refcount may not be down when userspace gets the NL event. Or, I guess the admin/tool process could just send a msg to the daemon process to tell it to do the netlink disconnect request.