From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA888C2BB1D for ; Tue, 17 Mar 2020 12:42:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8D92120767 for ; Tue, 17 Mar 2020 12:42:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbgCQMmt (ORCPT ); Tue, 17 Mar 2020 08:42:49 -0400 Received: from verein.lst.de ([213.95.11.211]:59628 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726596AbgCQMmt (ORCPT ); Tue, 17 Mar 2020 08:42:49 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id BBA8C68CEC; Tue, 17 Mar 2020 13:42:44 +0100 (CET) Date: Tue, 17 Mar 2020 13:42:44 +0100 From: Christoph Hellwig To: He Zhe Cc: Christoph Hellwig , jack@suse.cz, Jens Axboe , viro@zeniv.linux.org.uk, bvanassche@acm.org, keith.busch@intel.com, tglx@linutronix.de, mwilck@suse.com, yuyufen@huawei.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: disk revalidation updates and OOM Message-ID: <20200317124244.GA12316@lst.de> References: <93b395e6-5c3f-0157-9572-af0f9094dbd7@windriver.com> <20200310074018.GB26381@lst.de> <75865e17-48f8-a63a-3a29-f995115ffcfc@windriver.com> <20200310162647.GA6361@lst.de> <20200311155458.GA24376@lst.de> <18bbb6cd-578e-5ead-f2cd-a8a01db17e29@windriver.com> <20200316113746.GA15930@lst.de> <4215351e-89ac-4969-1d52-e2ff5c064d7d@windriver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4215351e-89ac-4969-1d52-e2ff5c064d7d@windriver.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 17, 2020 at 04:50:11PM +0800, He Zhe wrote: > >> With my build fix applied, the issue is triggered since 142fe8f. > >> And I can see the endless loop of invalidate and revalidate... > > Thanks. Can you test the patch below that restores the previous > > rather odd behavior of not clearing the capacity to 0 if partition > > scanning is not enabled? > > This fixes the issue. I also validated it on v5.6-rc6. Can you check this slight variant that only skips the capacity change for removable devices given that IIRC you reported the problem with a legacy ide-cd device? diff --git a/fs/block_dev.c b/fs/block_dev.c index 69bf2fb6f7cd..3212ac85d493 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1520,10 +1520,14 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate) if (ret) return ret; - if (invalidate) - set_capacity(disk, 0); - else if (disk->fops->revalidate_disk) - disk->fops->revalidate_disk(disk); + if (invalidate) { + if (!(disk->flags & GENHD_FL_REMOVABLE) || + disk_part_scan_enabled(disk)) + set_capacity(disk, 0); + } else { + if (disk->fops->revalidate_disk) + disk->fops->revalidate_disk(disk); + } check_disk_size_change(disk, bdev, !invalidate);