From patchwork Thu Mar 23 17:51:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9641741 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BA16A60327 for ; Thu, 23 Mar 2017 17:51:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ACAFD27C14 for ; Thu, 23 Mar 2017 17:51:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E03D28433; Thu, 23 Mar 2017 17:51:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 199A127C14 for ; Thu, 23 Mar 2017 17:51:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754985AbdCWRvd (ORCPT ); Thu, 23 Mar 2017 13:51:33 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:51302 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754890AbdCWRvc (ORCPT ); Thu, 23 Mar 2017 13:51:32 -0400 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2NHmkfa011954; Thu, 23 Mar 2017 10:51:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=6KgOc+IaRylFkovDQ26bKUAlBZznn/9qmuAtxYLDLYs=; b=StAbYqyZyixbxjTxT4RP6kqqxedkPhVarRWqnKdfzffiIEKonLX4mbOtfn6Z7uGawTIG A6egxrcfO0KQPV36iU91wCLA15EXIJy0UYS3hcYRFdKCjm1dTWlNox0Whui/fDmPhJf4 1kC0lbi3onZmbCY3/wzgeff8c/mzuvUH+w8= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 29ca0tjk1b-2 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 23 Mar 2017 10:51:13 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.17) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 23 Mar 2017 10:51:08 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=6KgOc+IaRylFkovDQ26bKUAlBZznn/9qmuAtxYLDLYs=; b=he4a6eHxByw8dE6/7Z7+ar4XkeZX7dlvZzJKRVzCJh0G2avLi/UoA5DVoCjgcKRRFvu9WQiNH7PC7OfSMpwZyl3b7QACvtETMIMnvET8IcG5ZI880k8oeM68Zyc73HL7snrE/Idr0EpK4EbehLN46PizDxuIhQQXJCXvBpauD3U= Received: from DM5PR15MB1914.namprd15.prod.outlook.com (10.174.247.142) by DM5PR15MB1913.namprd15.prod.outlook.com (10.174.247.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.977.11; Thu, 23 Mar 2017 17:51:07 +0000 Received: from DM5PR15MB1914.namprd15.prod.outlook.com ([10.174.247.142]) by DM5PR15MB1914.namprd15.prod.outlook.com ([10.174.247.142]) with mapi id 15.01.0947.020; Thu, 23 Mar 2017 17:51:07 +0000 From: Josef Bacik To: Ming Lin , "nbd-general@lists.sourceforge.net" , Ratna Manoj Bolla CC: "linux-block@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "jianshu.ljs@alibaba-inc.com" , "xiongwei.jiang@alibaba-inc.com" , "james.liu@alibaba-inc.com" Subject: Re: [RFC PATCH 1/1] nbd: replace kill_bdev() with __invalidate_device() Thread-Topic: [RFC PATCH 1/1] nbd: replace kill_bdev() with __invalidate_device() Thread-Index: AQHSoc2iwwkgiSl6f0ykX/La6AAfJKGidW0A Date: Thu, 23 Mar 2017 17:51:07 +0000 Message-ID: <8AA3DAC1-5E9C-438E-904B-D4C708A4F624@fb.com> References: <1490050729-3578-1-git-send-email-mlin@kernel.org> <1490050729-3578-2-git-send-email-mlin@kernel.org> In-Reply-To: <1490050729-3578-2-git-send-email-mlin@kernel.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=fb.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2606:a000:4381:1201:796a:c35e:3365:2de2] x-ms-office365-filtering-correlation-id: 3fbf8bb0-d781-4395-b282-08d472152f0e x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254075); SRVR:DM5PR15MB1913; x-microsoft-exchange-diagnostics: 1; DM5PR15MB1913; 7:EDvM/M9D5dNGyXt0nOn29/HRHeH3P0YMi/fyHmiJufIlqMWl22HEIcmR22aL6j61fNTMD/9qW2dXoxmvE959hMusTxe3Bylvhr78UmZAWDWhWRONswx82SdD1KXe1TuYJnQw2AFyf9aC9DIyHqmGDA96GdniuaP8L/amNox5wHs1Zjl2FSwg2+uXhHdyXTGPMeziUB2gGVZMXvkb4lmtezdX6jdPOKfhaxePGp0lDsiQ/DyOx0VOL704br0wDRqTA756du3uwRNQhgW9WO1fZxHXjK9HT1p3lnbT9c0rmdtYU2GZnRsncTyu8dKjlfC3f28l3a6fcqPhx3NfAXUSyg==; 20:V4LS/kGZYGph/udchUMuqQ0DG00riSekGwCrX7Ow2t+UgV6UAnKeDV/KwWXH9haX+ef+EnoH81TdAM7mNBpQLvptZvj+n9KhYwFZAWHh8iXGANnzzrvrYkRejzI+zt2bq91T74qPv9+7Uk9nv2k4AYqLzHu8hHgK7/ByeB+KVLQ= x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(788757137089); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6041248)(20161123560025)(20161123558025)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:DM5PR15MB1913; BCL:0; PCL:0; RULEID:; SRVR:DM5PR15MB1913; x-forefront-prvs: 0255DF69B9 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6009001)(39450400003)(39830400002)(39410400002)(377454003)(24454002)(6512007)(102836003)(5660300001)(2501003)(83716003)(6486002)(6506006)(3280700002)(81166006)(50986999)(76176999)(8676002)(54356999)(7736002)(3660700001)(25786009)(99286003)(54906002)(6116002)(6436002)(2950100002)(189998001)(229853002)(38730400002)(39060400002)(82746002)(6246003)(2906002)(122556002)(33656002)(36756003)(2900100001)(4326008)(305945005)(8936002)(86362001)(53546009)(77096006)(53936002)(217873001); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR15MB1913; H:DM5PR15MB1914.namprd15.prod.outlook.com; FPR:; SPF:None; MLV:ovrnspm; PTR:InfoNoRecords; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-ID: MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2017 17:51:07.3342 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1913 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-23_16:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Yeah I think this is ok, I’ll throw it on my queue for fixes for this cycle. Thanks, Josef On 3/20/17, 6:58 PM, "Ming Lin" wrote: From: Ratna Manoj Bolla When a filesystem is mounted on a nbd device and on a disconnect, because of kill_bdev(), and resetting bdev size to zero, buffer_head mappings are getting destroyed under mounted filesystem. After a bdev size reset(i.e bdev->bd_inode->i_size = 0) on a disconnect, followed by a sys_umount(), generic_shutdown_super()->... ->__sync_blockdev()->... -blkdev_writepages()->... ->do_invalidatepage()->... -discard_buffer() is discarding superblock buffer_head assumed to be in mapped state by ext4_commit_super(). [mlin: ported to 4.11-rc2] Signed-off-by: Ratna Manoj Bolla bd_openers <= 1) + bd_set_size(bdev, 0); set_capacity(nbd->disk, 0); kobject_uevent(&nbd_to_dev(nbd)->kobj, KOBJ_CHANGE); @@ -603,6 +604,8 @@ static void nbd_reset(struct nbd_device *nbd) static void nbd_bdev_reset(struct block_device *bdev) { + if (bdev->bd_openers > 1) + return; set_device_ro(bdev, false); bdev->bd_inode->i_size = 0; if (max_part > 0) { @@ -666,7 +669,8 @@ static int nbd_clear_sock(struct nbd_device *nbd, struct block_device *bdev) { sock_shutdown(nbd); nbd_clear_que(nbd); - kill_bdev(bdev); + + __invalidate_device(bdev, true); nbd_bdev_reset(bdev); /* * We want to give the run thread a chance to wait for everybody