From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Christoph Hellwig <hch@lst.de>,
Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 6.9 24/25] block: add a disk_has_partscan helper
Date: Thu, 23 May 2024 15:13:09 +0200 [thread overview]
Message-ID: <20240523130331.292645865@linuxfoundation.org> (raw)
In-Reply-To: <20240523130330.386580714@linuxfoundation.org>
6.9-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christoph Hellwig <hch@lst.de>
commit 140ce28dd3bee8e53acc27f123ae474d69ef66f0 upstream.
Add a helper to check if partition scanning is enabled instead of
open coding the check in a few places. This now always checks for
the hidden flag even if all but one of the callers are never reachable
for hidden gendisks.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20240502130033.1958492-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
block/genhd.c | 7 ++-----
block/partitions/core.c | 5 +----
include/linux/blkdev.h | 13 +++++++++++++
3 files changed, 16 insertions(+), 9 deletions(-)
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -345,9 +345,7 @@ int disk_scan_partitions(struct gendisk
struct file *file;
int ret = 0;
- if (disk->flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN))
- return -EINVAL;
- if (test_bit(GD_SUPPRESS_PART_SCAN, &disk->state))
+ if (!disk_has_partscan(disk))
return -EINVAL;
if (disk->open_partitions)
return -EBUSY;
@@ -503,8 +501,7 @@ int __must_check device_add_disk(struct
goto out_unregister_bdi;
/* Make sure the first partition scan will be proceed */
- if (get_capacity(disk) && !(disk->flags & GENHD_FL_NO_PART) &&
- !test_bit(GD_SUPPRESS_PART_SCAN, &disk->state))
+ if (get_capacity(disk) && disk_has_partscan(disk))
set_bit(GD_NEED_PART_SCAN, &disk->state);
bdev_add(disk->part0, ddev->devt);
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -573,10 +573,7 @@ static int blk_add_partitions(struct gen
struct parsed_partitions *state;
int ret = -EAGAIN, p;
- if (disk->flags & GENHD_FL_NO_PART)
- return 0;
-
- if (test_bit(GD_SUPPRESS_PART_SCAN, &disk->state))
+ if (!disk_has_partscan(disk))
return 0;
state = check_partition(disk);
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -233,6 +233,19 @@ static inline unsigned int disk_openers(
return atomic_read(&disk->part0->bd_openers);
}
+/**
+ * disk_has_partscan - return %true if partition scanning is enabled on a disk
+ * @disk: disk to check
+ *
+ * Returns %true if partitions scanning is enabled for @disk, or %false if
+ * partition scanning is disabled either permanently or temporarily.
+ */
+static inline bool disk_has_partscan(struct gendisk *disk)
+{
+ return !(disk->flags & (GENHD_FL_NO_PART | GENHD_FL_HIDDEN)) &&
+ !test_bit(GD_SUPPRESS_PART_SCAN, &disk->state);
+}
+
/*
* The gendisk is refcounted by the part0 block_device, and the bd_device
* therein is also used for device model presentation in sysfs.
next prev parent reply other threads:[~2024-05-23 13:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-23 13:12 [PATCH 6.9 00/25] 6.9.2-rc1 review Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 01/25] Bluetooth: btusb: Fix the patch for MT7920 the affected to MT7921 Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 02/25] wifi: iwlwifi: Use request_module_nowait Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 03/25] cpufreq: amd-pstate: fix the highest frequency issue which limits performance Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 04/25] drm/amd/display: Fix division by zero in setup_dsc_config Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 05/25] net: ks8851: Fix another TX stall caused by wrong ISR flag handling Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 06/25] x86/percpu: Use __force to cast from __percpu address space Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 07/25] Bluetooth: L2CAP: Fix div-by-zero in l2cap_le_flowctl_init() Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 08/25] KEYS: trusted: Fix memory leak in tpm2_key_encode() Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 09/25] ASoC: Intel: sof_sdw: use generic rtd_init function for Realtek SDW DMICs Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 10/25] binder: fix max_thread type inconsistency Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 11/25] usb: dwc3: Wait unconditionally after issuing EndXfer command Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 12/25] net: usb: ax88179_178a: fix link status when link is set to down/up Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 13/25] usb: typec: ucsi: displayport: Fix potential deadlock Greg Kroah-Hartman
2024-05-23 13:12 ` [PATCH 6.9 14/25] usb: typec: tipd: fix event checking for tps25750 Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 15/25] usb: typec: tipd: fix event checking for tps6598x Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 16/25] serial: kgdboc: Fix NMI-safety problems from keyboard reset code Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 17/25] remoteproc: mediatek: Make sure IPI buffer fits in L2TCM Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 18/25] Revert "media: v4l2-ctrls: show all owned controls in log_status" Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 19/25] KEYS: trusted: Do not use WARN when encode fails Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 20/25] admin-guide/hw-vuln/core-scheduling: fix return type of PR_SCHED_CORE_GET Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 21/25] docs: kernel_include.py: Cope with docutils 0.21 Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 22/25] Docs/admin-guide/mm/damon/usage: fix wrong example of DAMOS filter matching sysfs file Greg Kroah-Hartman
2024-05-23 13:13 ` [PATCH 6.9 23/25] Docs/admin-guide/mm/damon/usage: fix wrong schemes effective quota update command Greg Kroah-Hartman
2024-05-23 13:13 ` Greg Kroah-Hartman [this message]
2024-05-23 13:13 ` [PATCH 6.9 25/25] block: add a partscan sysfs attribute for disks Greg Kroah-Hartman
2024-05-23 16:22 ` [PATCH 6.9 00/25] 6.9.2-rc1 review Mark Brown
2024-05-23 17:05 ` SeongJae Park
2024-05-23 21:06 ` Florian Fainelli
2024-05-23 21:18 ` Florian Fainelli
2024-05-24 4:47 ` Bagas Sanjaya
2024-05-24 8:52 ` Ron Economos
2024-05-24 9:32 ` Anders Roxell
2024-05-24 14:34 ` Shuah Khan
2024-05-24 15:20 ` Jon Hunter
2024-05-24 18:47 ` Pavel Machek
2024-05-25 9:35 ` Pascal Ernster
2024-05-25 9:35 ` Pascal Ernster
2024-05-25 9:37 ` Pascal Ernster
2024-05-25 16:26 ` Allen
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=20240523130331.292645865@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=patches@lists.linux.dev \
--cc=stable@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).