Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3735178ybh; Tue, 17 Mar 2020 05:44:10 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtvJvv3IkbLbShK/6PRq/Px71Xjq96C9NfYT4qiLQ2mViBlMOtsQRdO3d3eY6Ho8N5Hbc3l X-Received: by 2002:a9d:4d02:: with SMTP id n2mr3284759otf.107.1584449050039; Tue, 17 Mar 2020 05:44:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584449050; cv=none; d=google.com; s=arc-20160816; b=oKTFaiQbVSsMd7wkHuSZJK5lC8sLlUTXCqwlimpTxr1OQdhktvBzGTN+P2XWy4NDSX u/Fk20JfRsmi8Ly+zHgf0awUGLZtJT18A3H9v8Yx/lPeRKFqdjI2Qy6jotGLciIcGOWL veBzLJv7fnU0Bz6Cah10x/KBWd1+RIRo2Mve7S7PvySJMBGrRJPY0x4mpUR1YzWnxYWw Kh6sxg3Go533gDATlSXO0zt1xZ+CiECLOIR30ftIRy0PQE8UdBY3XiR0RphkwjU06q0K PVLcUwzJ7cDV3tC6vW+DX/5T0cD1UxYLpQFNg2v1RJF3Mx4t63ZlWoPLmxSpLhfX7bsu 4uIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=A6vNZzIJcWrmuDHM8sDz+H4YA5ab9+ih61bqD4kfcj8=; b=ms8PaZPgJLsQhZKoKAJ87MsufR5xBYBk289YnlwKWfeXYYd9hFBxjRqpXpx1sF6u/p NpdH+q5hI72V96hjbXrAQU9J9yeDwEdMvCM/fBISUQsUuCVFj1iwO/MBc42f4g1brkjI UGeh8VsXgEDs8ZoIJJuc+KfwgRf/IZW3QCrFNgDOsbjhZDQRvRVdpKgPxT5TagxzrmMF AhwsHBOikqQSbuu9mayZ6GM87lHTrEWrQXtzW1RgRsB/WRvlqtLeW0n08ilvOTnqBwVr 5pyfNmTkjleTyyE78LsuuJTLcPDfRhqSyDsCYE2xz6G2ecxwHzlDPHlrcIKDrAFfILyO YT+A== 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 c19si2091524ots.118.2020.03.17.05.43.56; Tue, 17 Mar 2020 05:44:10 -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 S1726667AbgCQMmt (ORCPT + 99 others); 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);