From: Jie Wang <wangjie2011cs@163.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
wangjie2011cs@163.com
Subject: [PATCH] block: check disk flag before setting scan bit
Date: Tue, 17 Jan 2023 15:53:29 +0800 [thread overview]
Message-ID: <20230117075329.14968-1-wangjie2011cs@163.com> (raw)
No need to scan partitions for disk who has set flag GENHD_FL_NO_PART in
driver code. In disk_scan_partitions function, the same checking is
existing, so we believe this change is reasonable.
In our case, some virtual block devices are not managed by GPT, then scan
partition operation is not a must. So we set GENHD_FL_NO_PART flag in
driver intended to avoid partitions being dropped/added.
But GD_NEED_PART_SCAN bit was still set by bdev_check_media_change, which
causing problems here.
Signed-off-by: Jie Wang <wangjie2011cs@163.com>
---
block/disk-events.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/disk-events.c b/block/disk-events.c
index aee25a7e1ab7..68d911135bc7 100644
--- a/block/disk-events.c
+++ b/block/disk-events.c
@@ -284,7 +284,8 @@ bool bdev_check_media_change(struct block_device *bdev)
if (__invalidate_device(bdev, true))
pr_warn("VFS: busy inodes on changed media %s\n",
bdev->bd_disk->disk_name);
- set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
+ if (!(bdev->bd_disk->flags & GENHD_FL_NO_PART))
+ set_bit(GD_NEED_PART_SCAN, &bdev->bd_disk->state);
return true;
}
EXPORT_SYMBOL(bdev_check_media_change);
@@ -310,7 +311,8 @@ bool disk_force_media_change(struct gendisk *disk, unsigned int events)
if (__invalidate_device(disk->part0, true))
pr_warn("VFS: busy inodes on changed media %s\n",
disk->disk_name);
- set_bit(GD_NEED_PART_SCAN, &disk->state);
+ if (!(bdev->bd_disk->flags & GENHD_FL_NO_PART))
+ set_bit(GD_NEED_PART_SCAN, &disk->state);
return true;
}
EXPORT_SYMBOL_GPL(disk_force_media_change);
--
2.17.1
next reply other threads:[~2023-01-17 8:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-17 7:53 Jie Wang [this message]
2023-01-17 8:14 ` [PATCH] block: check disk flag before setting scan bit Christoph Hellwig
[not found] ` <1a61ffce.191e.185bef2aea0.Coremail.wangjie2011cs@163.com>
2023-01-17 8:58 ` Christoph Hellwig
[not found] <20230116083832.27305-1-wangjie22@lixiang.com>
2023-01-16 16:14 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230117075329.14968-1-wangjie2011cs@163.com \
--to=wangjie2011cs@163.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox