From patchwork Sat May 26 10:27:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10428927 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 780176038C for ; Sat, 26 May 2018 10:28:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 67D41297F8 for ; Sat, 26 May 2018 10:28:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C72029817; Sat, 26 May 2018 10:28:00 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 E90B3297F8 for ; Sat, 26 May 2018 10:27:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031677AbeEZK17 (ORCPT ); Sat, 26 May 2018 06:27:59 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:45042 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031615AbeEZK16 (ORCPT ); Sat, 26 May 2018 06:27:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KrbDbI/RHsHLj953YBldyua5W28RuSoyDDrXa8AhDP8=; b=DcfuMenUyaLiAOMmN/3QgICbL QCKIE+8/5ZT7WNtd6m56+FzzupPjw/a+6akMmzUuo46sUjUGNgjItxfvYRXEbBcnqTAIBZQfSuY3j w2Rh+npqehi0dUgjvsdg1HfgCk53AvyioDJ5nxopchQ/feT6zQueV9L7PY3UVoH3fitlNguo58/vB 3qxvgkXEM63cxUS3aLhbAtKaPiMRGKZB+dnyyu7Ykw8Q5vckQM0nvJtuQVuOSd3hx4RzszaEjoUSL dVFGI6mcsCwXuezqc9j95PvkcfpqSMUk8nLJ2g2erEgHy7uhIohoujftIscW8Ii+mGFdAvpYoYmI6 3Si77MmYw==; Received: from 089144199016.atnat0008.highway.a1.net ([89.144.199.16] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fMWQN-0001J9-56; Sat, 26 May 2018 10:27:47 +0000 From: Christoph Hellwig To: linux-nvme@lists.infradead.org Cc: Jens Axboe , Keith Busch , Sagi Grimberg , Hannes Reinecke , linux-block@vger.kernel.org Subject: [PATCH 02/14] block: don't print a message when the device went away Date: Sat, 26 May 2018 12:27:23 +0200 Message-Id: <20180526102735.31404-3-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180526102735.31404-1-hch@lst.de> References: <20180526102735.31404-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 The information about a size change in this case just creates confusion. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- block/partition-generic.c | 4 ++-- fs/block_dev.c | 14 +++++++++----- include/linux/fs.h | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index db57cced9b98..9fe4816a1289 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -518,7 +518,7 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) if (disk->fops->revalidate_disk) disk->fops->revalidate_disk(disk); - check_disk_size_change(disk, bdev); + check_disk_size_change(disk, bdev, true); bdev->bd_invalidated = 0; if (!get_capacity(disk) || !(state = check_partition(disk, bdev))) return 0; @@ -643,7 +643,7 @@ int invalidate_partitions(struct gendisk *disk, struct block_device *bdev) return res; set_capacity(disk, 0); - check_disk_size_change(disk, bdev); + check_disk_size_change(disk, bdev, false); bdev->bd_invalidated = 0; /* tell userspace that the media / partition table may have changed */ kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE); diff --git a/fs/block_dev.c b/fs/block_dev.c index 771ddfa29dc9..81c57c14fae8 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1322,21 +1322,25 @@ static void flush_disk(struct block_device *bdev, bool kill_dirty) * check_disk_size_change - checks for disk size change and adjusts bdev size. * @disk: struct gendisk to check * @bdev: struct bdev to adjust. + * @verbose: if %true log a message about a size change if there is any * * This routine checks to see if the bdev size does not match the disk size * and adjusts it if it differs. When shrinking the bdev size, its all caches * are freed. */ -void check_disk_size_change(struct gendisk *disk, struct block_device *bdev) +void check_disk_size_change(struct gendisk *disk, struct block_device *bdev, + bool verbose) { loff_t disk_size, bdev_size; disk_size = (loff_t)get_capacity(disk) << 9; bdev_size = i_size_read(bdev->bd_inode); if (disk_size != bdev_size) { - printk(KERN_INFO - "%s: detected capacity change from %lld to %lld\n", - disk->disk_name, bdev_size, disk_size); + if (verbose) { + printk(KERN_INFO + "%s: detected capacity change from %lld to %lld\n", + disk->disk_name, bdev_size, disk_size); + } i_size_write(bdev->bd_inode, disk_size); if (bdev_size > disk_size) flush_disk(bdev, false); @@ -1363,7 +1367,7 @@ int revalidate_disk(struct gendisk *disk) return ret; mutex_lock(&bdev->bd_mutex); - check_disk_size_change(disk, bdev); + check_disk_size_change(disk, bdev, ret == 0); bdev->bd_invalidated = 0; mutex_unlock(&bdev->bd_mutex); bdput(bdev); diff --git a/include/linux/fs.h b/include/linux/fs.h index 760d8da1b6c7..d8d4831af9ff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2570,7 +2570,7 @@ extern bool is_bad_inode(struct inode *); #ifdef CONFIG_BLOCK extern void check_disk_size_change(struct gendisk *disk, - struct block_device *bdev); + struct block_device *bdev, bool verbose); extern int revalidate_disk(struct gendisk *); extern int check_disk_change(struct block_device *); extern int __invalidate_device(struct block_device *, bool);