Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751523AbdCVVoC (ORCPT ); Wed, 22 Mar 2017 17:44:02 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:57462 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750812AbdCVVnx (ORCPT ); Wed, 22 Mar 2017 17:43:53 -0400 From: Josef Bacik To: Ming Lin CC: "nbd-general@lists.sourceforge.net" , Ratna Manoj Bolla , lkml , "linux-block@vger.kernel.org" , "jianshu.ljs@alibaba-inc.com" , "LIU, Fei" , Markus Pargmann , "xiongwei.jiang@alibaba-inc.com" Subject: Re: [Nbd] [RFC PATCH 1/1] nbd: replace kill_bdev() with __invalidate_device() Thread-Topic: [Nbd] [RFC PATCH 1/1] nbd: replace kill_bdev() with __invalidate_device() Thread-Index: AQHSoc2iwwkgiSl6f0ykX/La6AAfJKGhV5eA///McAA= Date: Wed, 22 Mar 2017 21:43:27 +0000 Message-ID: References: <1490050729-3578-1-git-send-email-mlin@kernel.org> <1490050729-3578-2-git-send-email-mlin@kernel.org> In-Reply-To: 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: [107.15.72.49] x-ms-office365-filtering-correlation-id: 1e608e30-2842-4dc7-2f03-08d4716c79c8 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075);SRVR:DM5PR15MB1914; x-microsoft-exchange-diagnostics: 1;DM5PR15MB1914;7:4YEzPKsgBfIqGLfpViY4RCdQRHxReDNcg+m966GWEq3F3yAjLk6z5xfRO0y7QezwetbFTzbm4Dj9ANDMalg/l0BaKs8yNaGlXjJ5rtISfrNE2z6ZLlLXamEW0i+j6ZE0OA4O+rKGuHsK00UjZqw+2nq1JJM+ggGnjDAHVwUIO9B3tSCaD5K320gUMW53Cp3lMDn1jad11//1J4wQgfIhi72Qt7YIfvJ8ga7jJZf+QiuWjmaYqXDA3w5khDOkAENHmCQLvDUk6vv7BjcijFR3Zyy4UZ/0OwqzjFOrkzcVgCEUrN7Y2M43//v8n5bVRzdiBqfqDtyhzaFAwb12ZUnoLQ==;20:QrK9Bjh9GDtsAxl00TaJMTi45BX3arWhQTbkbCkoaVfyx5Cryt7K0YmDJXKzRNHGbc+qKbySvOBEErTWZBrkPdGBJV5UPtaprXPbIpT34GdfAjuBSNz2xTjTR42Jy1TYwaSzm5Xi7S+gRXGJL3N4hG+5ZpeHhKRoDESONDak/I8= 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)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123560025)(20161123564025)(20161123555025)(20161123558025)(20161123562025)(6072148);SRVR:DM5PR15MB1914;BCL:0;PCL:0;RULEID:;SRVR:DM5PR15MB1914; x-forefront-prvs: 02543CD7CD x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39450400003)(39830400002)(39410400002)(377454003)(24454002)(8676002)(50986999)(53936002)(122556002)(6246003)(99286003)(3280700002)(86362001)(4326008)(305945005)(54356999)(39060400002)(77096006)(229853002)(38730400002)(5660300001)(2950100002)(110136004)(6436002)(6486002)(6916009)(54906002)(82746002)(6512007)(6506006)(81166006)(83716003)(2900100001)(33656002)(3846002)(3660700001)(7736002)(8936002)(36756003)(6116002)(2906002)(189998001)(25786009)(53546009)(66066001)(102836003)(76176999)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR15MB1914;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: <7462A7A5A1E70D4D9F3D6FBE7FC44749@namprd15.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Mar 2017 21:43:27.7159 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1914 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-22_17:,, 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 v2MLi4OM015665 Content-Length: 2245 Lines: 72 Hey sorry I just got back from LSF, I’ll look at this in the morning. Thanks, Josef On 3/22/17, 4:48 PM, "Ming Lin" wrote: On Mon, Mar 20, 2017 at 3: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 --- > drivers/block/nbd.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index cb4ccfc..a6a3643 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -125,7 +125,8 @@ static const char *nbdcmd_to_ascii(int cmd) > > static int nbd_size_clear(struct nbd_device *nbd, struct block_device *bdev) > { > - bd_set_size(bdev, 0); > + if (bdev->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 Hi Josef, Any comments? Thanks, Ming