Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6001021ybi; Wed, 31 Jul 2019 06:47:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqyscaqe/EOJs1x8/erIALkBsmNTu1UsYhpJyL0SqrxT9XVA2IPm55pUln1Nh5XIl0MC72qI X-Received: by 2002:a17:90a:d593:: with SMTP id v19mr3092272pju.1.1564580873004; Wed, 31 Jul 2019 06:47:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564580872; cv=none; d=google.com; s=arc-20160816; b=jSKqZczlbUkaAMSVPnYYkueMRo5PyW9I0H1+XCJLEeCzCwqsxrrYK+la75Wxufp+La 0UPFN+cCPFhpZqtyUa5ti6DcQSv+WvnBAg2i6KmqdU6+TO2G70jc8dDi2Piw4GUExBbz r2vu4J7YepUP1gwFWzBn0dv8oXzqKIh/Jng0JOleH6bSBoj35NOPVqf5ZORaSaaGMUO3 Zp7feFlBg8MmYyteStmfbfRKAHUBsWlplSh73k0IttMOQv3Adtoi1FKQkYkBavYuTiyI nMRbrIK8PsWc+j46jw0enO87F43+2waKAqfWjNNJ/Rysv+DcRyDS5K9J1SpZ6Srrxn5s ezAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:to :from; bh=s0YZaoCshgcwz0NEtJJ+X/b0gfbtfid3EqPzAgDO6lc=; b=w3sBxM75+B/TloTZ38A+oFajs643NB8mwIMI4JHvnovDTGCEXrCvWC3y6e1BUCZpnq Ld5ldB8XcrAHkmvxxSRvNKtjRlTd9rS+zkVMKCWwRl7QwG09/GV31av7Ob8KRK1+p66U F64nDMd7SZyhtO4rpVvJC/se9yQZqUJ8ueXFMkaDT6I+pb5ZvN23uvTouj3D9LNIHsel /l0OaRUhoXC6YvO0SpN7hbzWH3B/+LwgHlaW2QPiWXZ4yim4uO6pi1zd2zBhPKn8tdvu 8dEtDR6ffSGyoMufXIPzT+MZbrDtfYYXIer0Kp/rlaUE4RjEzkNGjTJjL471Ad8v4JEF /f+w== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n5si10861060pgq.154.2019.07.31.06.47.36; Wed, 31 Jul 2019 06:47:52 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728988AbfGaMHq (ORCPT + 99 others); Wed, 31 Jul 2019 08:07:46 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:3670 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726185AbfGaMHq (ORCPT ); Wed, 31 Jul 2019 08:07:46 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 26166B29F60F478F0E4D; Wed, 31 Jul 2019 20:07:27 +0800 (CST) Received: from RH5885H-V3.huawei.com (10.90.53.225) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Wed, 31 Jul 2019 20:07:18 +0800 From: SunKe To: , , , , , , , , , Subject: [PATCH v2] nbd: replace kill_bdev() with __invalidate_device() again Date: Wed, 31 Jul 2019 20:13:10 +0800 Message-ID: <1564575190-132357-1-git-send-email-sunke32@huawei.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Munehisa Kamata Commit abbbdf12497d ("replace kill_bdev() with __invalidate_device()") once did this, but 29eaadc03649 ("nbd: stop using the bdev everywhere") resurrected kill_bdev() and it has been there since then. So buffer_head mappings still get killed on a server disconnection, and we can still hit the BUG_ON on a filesystem on the top of the nbd device. EXT4-fs (nbd0): mounted filesystem with ordered data mode. Opts: (null) block nbd0: Receive control failed (result -32) block nbd0: shutting down sockets print_req_error: I/O error, dev nbd0, sector 66264 flags 3000 EXT4-fs warning (device nbd0): htree_dirblock_to_tree:979: inode #2: lblock 0: comm ls: error -5 reading directory block print_req_error: I/O error, dev nbd0, sector 2264 flags 3000 EXT4-fs error (device nbd0): __ext4_get_inode_loc:4690: inode #2: block 283: comm ls: unable to read itable block EXT4-fs error (device nbd0) in ext4_reserve_inode_write:5894: IO failure ------------[ cut here ]------------ kernel BUG at fs/buffer.c:3057! invalid opcode: 0000 [#1] SMP PTI CPU: 7 PID: 40045 Comm: jbd2/nbd0-8 Not tainted 5.1.0-rc3+ #4 Hardware name: Amazon EC2 m5.12xlarge/, BIOS 1.0 10/16/2017 RIP: 0010:submit_bh_wbc+0x18b/0x190 ... Call Trace: jbd2_write_superblock+0xf1/0x230 [jbd2] ? account_entity_enqueue+0xc5/0xf0 jbd2_journal_update_sb_log_tail+0x94/0xe0 [jbd2] jbd2_journal_commit_transaction+0x12f/0x1d20 [jbd2] ? __switch_to_asm+0x40/0x70 ... ? lock_timer_base+0x67/0x80 kjournald2+0x121/0x360 [jbd2] ? remove_wait_queue+0x60/0x60 kthread+0xf8/0x130 ? commit_timeout+0x10/0x10 [jbd2] ? kthread_bind+0x10/0x10 ret_from_fork+0x35/0x40 With __invalidate_device(), I no longer hit the BUG_ON with sync or unmount on the disconnected device. Fixes: 29eaadc03649 ("nbd: stop using the bdev everywhere") Cc: linux-block@vger.kernel.org Cc: Ratna Manoj Bolla Cc: nbd@other.debian.org Cc: stable@vger.kernel.org Cc: David Woodhouse Signed-off-by: Munehisa Kamata --- I reproduced this phenomenon on the fat file system. reproduce steps : 1.Establish a nbd connection. 2.Run two threads:one do mount and umount,anther one do clear_sock ioctl 3.Then hit the BUG_ON. v2: Delete a link. Signed-off-by: SunKe drivers/block/nbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 9bcde23..e21d2de 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -1231,7 +1231,7 @@ static void nbd_clear_sock_ioctl(struct nbd_device *nbd, struct block_device *bdev) { sock_shutdown(nbd); - kill_bdev(bdev); + __invalidate_device(bdev, true); nbd_bdev_reset(bdev); if (test_and_clear_bit(NBD_HAS_CONFIG_REF, &nbd->config->runtime_flags)) -- 2.7.4