Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp228670ybi; Fri, 24 May 2019 02:57:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqy4Ptq2uOTpz6VRiPcT96V6thb6EP4XeoTWO7sjuE1VuMY1tJC3JnxWGymcmhWQLdmrOrir X-Received: by 2002:a65:62c6:: with SMTP id m6mr9705167pgv.306.1558691859922; Fri, 24 May 2019 02:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558691859; cv=none; d=google.com; s=arc-20160816; b=Tzi4pgp4QBQklLaMvaayCxOjRF57e0y2UmFKbrgGrcA/BmDLLPtQEvOLsM926S0Zvx tV+NJu9k6e6u/V5+IxeW59xoavcW9bmOLHxLe40B7pu8FWGLQS3s/SAOJikpipAQxulh athGQMQbejY/WCtm6UMGB34QUuGzjoky3Uwh6ZQyrnKmQdHCxXZTr+tQdIdVQYwu9pzH az9MzXGnU8Ox1jzr1hhJR7m/nRQBKB9ECokK8VJ3n/vfbJDKXW1Nq0z+PHJeHUPNI5HV Lq1twHBizETCjpYE/qsB5bmFUzsMcsr6r1utbniAUjGQuQI8NsOQibhj+TNHc9O+wNld /z5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=mRvO8FpNWfMsL6Q1Xcoi0KOPVkham9SKHD4jjiUwMww=; b=f0R7wqcd/odTJQxcHYKfU6QW54JyscteWI26uXBwywzru6TczO/XWg+sR+U3J/mNWN WfmBj3ZFpgGvfLCOuXDOnqcGFXWeqYsZpArevSBVkenMKYThdcDK7cixEpMPLOUjKyct aHur6MZmysWGL+nWPTwCgc50Qmnz3k6zYJKyMyksJXKKXLml4KFn7gUQ0MY2BW3w4GmB yx4KfDx/vBmxRLr2os4Pmr2EoLMyUjWEnnUOWzqCeKA2qLTHBZp4rudHykqtYFbuXQjl 5lo4S8e3Y8f9DYaWiidwMo6gLECNHNcN4B2une5j+nBk+yQXrQGuyY3lcspahaKd+AKG 6EWg== 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 h191si3406053pge.15.2019.05.24.02.57.22; Fri, 24 May 2019 02:57:39 -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 S2390262AbfEXJzo (ORCPT + 99 others); Fri, 24 May 2019 05:55:44 -0400 Received: from m9784.mail.qiye.163.com ([220.181.97.84]:30680 "EHLO m9784.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390046AbfEXJzo (ORCPT ); Fri, 24 May 2019 05:55:44 -0400 Received: from kernel_test2.localdomain (unknown [120.132.1.243]) by m9784.mail.qiye.163.com (Hmail) with ESMTPA id D2F2B41C01; Fri, 24 May 2019 17:48:47 +0800 (CST) From: Yao Liu To: Josef Bacik , Jens Axboe Cc: linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] nbd: notify userland even if nbd has already disconnected Date: Fri, 24 May 2019 17:43:55 +0800 Message-Id: <1558691036-16281-2-git-send-email-yotta.liu@ucloud.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1558691036-16281-1-git-send-email-yotta.liu@ucloud.cn> References: <1558691036-16281-1-git-send-email-yotta.liu@ucloud.cn> X-HM-Spam-Status: e1kIGBQJHllBWVZKVUJNSktLS0lLT0tDTUhZV1koWUFJQjdXWS1ZQUlXWQ kOFx4IWUFZNTQpNjo3JCkuNz5ZBg++ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6Ngg6EAw6Qjg6NiwQMTdODzw* VgwwCg5VSlVKTk5DTUJKSElDSkhDVTMWGhIXVQIUDw8aVRcSDjsOGBcUDh9VGBVFWVdZEgtZQVlK SUtVSkhJVUpVSU9IWVdZCAFZQUlKS0I3Bg++ X-HM-Tid: 0a6ae93e302f2086kuqyd2f2b41c01 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/block/nbd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index ca69d6e..22e86f4 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -246,7 +246,7 @@ static int nbd_disconnected(struct nbd_config *config) static void nbd_mark_nsock_dead(struct nbd_device *nbd, struct nbd_sock *nsock, int notify) { - if (!nsock->dead && notify && !nbd_disconnected(nbd->config)) { + if (!nsock->dead && notify) { struct link_dead_args *args; args = kmalloc(sizeof(struct link_dead_args), GFP_NOIO); if (args) { @@ -1891,7 +1891,6 @@ static void nbd_disconnect_and_put(struct nbd_device *nbd) { mutex_lock(&nbd->config_lock); nbd_disconnect(nbd); - nbd_clear_sock(nbd); mutex_unlock(&nbd->config_lock); if (test_and_clear_bit(NBD_HAS_CONFIG_REF, &nbd->config->runtime_flags)) -- 1.8.3.1