Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755772AbdCWRve (ORCPT ); Thu, 23 Mar 2017 13:51:34 -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 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-Type: text/plain; charset="utf-8" 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v2NHpbOs006102 Content-Length: 1929 Lines: 65 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 -- 1.8.3.1