Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6144642ybi; Wed, 29 May 2019 03:35:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqxgRK8kmcJdE5i8bMtY84DlrNNkAntJ7+l+DpyQV0aPjqeAiraWtBPdgFNn1uegf8KHbqZ5 X-Received: by 2002:a63:f44f:: with SMTP id p15mr137220755pgk.65.1559126104282; Wed, 29 May 2019 03:35:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559126104; cv=none; d=google.com; s=arc-20160816; b=r0jWgu6TfNI3e/h7O7wzfa7ZAXY36bKw1NP8ODOXevGQga7gPFGdvVSfs1aWIZcv9z VR1miHXkd6Qe389n/zvkbo+jIyC4hqBaLbiFTUTneZbH4xYo1/2EeyTKKgsl3YpI/+Ne I1jc2TE9ZfydiXr1Tmonz+cDGeqF1C/jokILN3BGVfANqOo7sdi5U/Z4OUCncoZM4Rt1 PIC5gSddafspIbNKLZ+0wny67s1gjCxa546tBPOLEKNev/i94FhTVe4naVIU1fy8/aoe aVK594ud6S9J7NQ7p3fW1E0xajEPxbeIpqlcbEJy2BPOWWBStOIwK5v4eYirUXXRGnXz pZ/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rwsCq1rSW/BkZhvY3etb0AEJJO+bFw9FFFMahLhRciQ=; b=M2Nx6Bzr5biHPMdBXZ9YhR4QKdN8j9Pqz2rlXRONR9irwvHvFMn/kPAS+sIgKBNP5v hPhtECirs/GhHAC/mgSIZ65n3Af4hY81Zl3hZplHN7tkkbpEJHyzu8ADYmxfppfdczyC L3wlAwsk0Kg3y7gOjDq3Nt6tTtHQ2ckWRWF2UerO5A6S110Yo0ZxIS77fNwE1GMCgXke bFsJTtOqSbr/Xtt6pgiO4enhYrg1AWns8EhLMN4ENxWHo2Kl7t/xGZ4Se+rwTxliherM Yzo77ORcIlBSEGOlX6NYYhr8+rPpobPZh8+drXSwYOzRWGmjvpWHe6C3KWZglW/bQjwC /n9w== 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=ucloud.cn Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y4si16976631pfq.10.2019.05.29.03.34.47; Wed, 29 May 2019 03:35:04 -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=ucloud.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726557AbfE2Kcl (ORCPT + 99 others); Wed, 29 May 2019 06:32:41 -0400 Received: from m97179.mail.qiye.163.com ([220.181.97.179]:6940 "EHLO m97179.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbfE2Kcl (ORCPT ); Wed, 29 May 2019 06:32:41 -0400 Received: from localhost (unknown [120.132.1.243]) by m97179.mail.qiye.163.com (Hmail) with ESMTPA id 1966BE01AC1; Wed, 29 May 2019 18:32:33 +0800 (CST) Date: Wed, 29 May 2019 04:05:54 +0800 From: Yao Liu To: Mike Christie Cc: Josef Bacik , Jens Axboe , linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] nbd: notify userland even if nbd has already disconnected Message-ID: <20190528200554.GA21633@192-168-150-246.7~> 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~> <5CED6385.3000802@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5CED6385.3000802@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-HM-Spam-Status: e1kIGBQJHllBWUtVQ01JQkJCQ05NT0xJS0pOWVdZKFlBSUI3V1ktWUFJV1 kJDhceCFlBWTU0KTY6NyQpLjc#WQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Nxw6USo*Vjg0OiI9KgoSPyhD OBNPCzhVSlVKTk5CSklOQk5ISUtIVTMWGhIXVQIUDw8aVRcSDjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSU9IWVdZCAFZQUhOTk83Bg++ X-HM-Tid: 0a6b03260a5320bdkuqy1966be01ac1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 28, 2019 at 11:36:21AM -0500, Mike Christie wrote: > 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. > Adding a new netlink event sames good.