kernel/kernel-rt/centos/patches/0015-Revert-scsi-sd-Inline-sd_probe_part2.patch
Jiping Ma bb6ec6697a scsi: Make the disk detection order more consistent
Starting with the v5.x kernels asynchronous device scanning is enabled
by default to speed up the boot process. This results in device
detection order and thus naming potentially changing from one boot to
the next, affecting disk and USB storage device names.

We revert two related patches, returning the kernel device naming
convention of pre-v5.x kernels. Since we are slotting a 5.10 kernel into
a fairly old userspace, this is preferred approach versus adapting the
userspace to this new kernel behavior, at least at this time.

NOTE: BIOS and other factors outside the kernel's control may still
result in different device naming, users should be aware of this if
performing firmware updates. In the long term different approaches will
be required to determine which devices to use that don't rely on device
names, allowing the original 5.10 kernel behavior to work as designed.

Verification:
Ran test 120 times with an unpatched 5.10.74 kernel, 120 times with an
unpatched 5.10.74 kernel with "scsi_mod.scan=sync" and 220 times with a
patched 5.10.74 kernel with the two commits reverted. Here are the
results:

1. 5.10.74 unpatched without scsi_mod.scan=sync
   --14/120 instances of unexpected disk order.
2. 5.10.74 unpatched with scsi_mod.scan=sync
   --12/120 instances of unexpected disk order.
3. 5.10.74 patched without scsi_mod.scan=sync
   --220 instances of the same disk order.

Closes-bug: #1953433
Closes-Bug: #1950163

[Submitted on behalf of Vefa Bicakci.]
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
Change-Id: I4f508fce99a30deb4ab6688682a1057205013679
2021-12-09 01:50:17 -05:00

168 lines
4.8 KiB
Diff

From 42f1ccc21f873a27c125a4e1aa3cb70a2336aa14 Mon Sep 17 00:00:00 2001
From: Jiping Ma <jiping.ma2@windriver.com>
Date: Wed, 8 Dec 2021 17:49:56 -0800
Subject: [PATCH] Revert "scsi: sd: Inline sd_probe_part2()"
This reverts commit 82a54da641f3cacfa31db36fc58a5e903f804c22.
Merge conflicts were encountered when reverting this commit, which
inlines sd_probe_part2() into sd_probe(). However, the inlined parts
of sd_probe_part2() have since been modified. To avoid a difference
in behaviour, the updated code was relocated to sd_probe_part2().
The inlined code has been modified as follows since the inlining
happened:
The following code was added
if (sdp->rpm_autosuspend) {
pm_runtime_set_autosuspend_delay(dev,
sdp->host->hostt->rpm_autosuspend_delay);
}
between the following line
blk_pm_runtime_init(sdp->request_queue, dev);
and the following line
device_add_disk(dev, gd, NULL);
In addition, init_opal_dev() is now passed the pointer "sdkp"
instead of "sdp" as the first argument. This commit ensures that
these two changes were accounted for when reverting the inlining
of sd_probe_part2().
Signed-off-by: M. Vefa Bicakci <vefa.bicakci@windriver.com>
Signed-off-by: Jiping Ma <jiping.ma2@windriver.com>
---
drivers/scsi/sd.c | 111 ++++++++++++++++++++++++++--------------------
1 file changed, 63 insertions(+), 48 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 56e291708587..d1d27516fc6a 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3364,6 +3364,68 @@ static int sd_format_disk_name(char *prefix, int index, char *buf, int buflen)
return 0;
}
+static void sd_probe_part2(struct scsi_disk *sdkp)
+{
+ struct scsi_device *sdp;
+ struct gendisk *gd;
+ u32 index;
+ struct device *dev;
+
+ sdp = sdkp->device;
+ gd = sdkp->disk;
+ index = sdkp->index;
+ dev = &sdp->sdev_gendev;
+
+ gd->major = sd_major((index & 0xf0) >> 4);
+ gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
+
+ gd->fops = &sd_fops;
+ gd->private_data = &sdkp->driver;
+ gd->queue = sdkp->device->request_queue;
+
+ /* defaults, until the device tells us otherwise */
+ sdp->sector_size = 512;
+ sdkp->capacity = 0;
+ sdkp->media_present = 1;
+ sdkp->write_prot = 0;
+ sdkp->cache_override = 0;
+ sdkp->WCE = 0;
+ sdkp->RCD = 0;
+ sdkp->ATO = 0;
+ sdkp->first_scan = 1;
+ sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
+
+ sd_revalidate_disk(gd);
+
+ gd->flags = GENHD_FL_EXT_DEVT;
+ if (sdp->removable) {
+ gd->flags |= GENHD_FL_REMOVABLE;
+ gd->events |= DISK_EVENT_MEDIA_CHANGE;
+ gd->event_flags = DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
+ }
+
+ blk_pm_runtime_init(sdp->request_queue, dev);
+ if (sdp->rpm_autosuspend) {
+ pm_runtime_set_autosuspend_delay(dev,
+ sdp->host->hostt->rpm_autosuspend_delay);
+ }
+ device_add_disk(dev, gd, NULL);
+ if (sdkp->capacity)
+ sd_dif_config_host(sdkp);
+
+ sd_revalidate_disk(gd);
+
+ if (sdkp->security) {
+ sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
+ if (sdkp->opal_dev)
+ sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
+ }
+
+ sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
+ sdp->removable ? "removable " : "");
+ scsi_autopm_put_device(sdp);
+}
+
/**
* sd_probe - called during driver initialization and whenever a
* new scsi device is attached to the system. It is called once
@@ -3455,54 +3517,7 @@ static int sd_probe(struct device *dev)
dev_set_drvdata(dev, sdkp);
- gd->major = sd_major((index & 0xf0) >> 4);
- gd->first_minor = ((index & 0xf) << 4) | (index & 0xfff00);
-
- gd->fops = &sd_fops;
- gd->private_data = &sdkp->driver;
- gd->queue = sdkp->device->request_queue;
-
- /* defaults, until the device tells us otherwise */
- sdp->sector_size = 512;
- sdkp->capacity = 0;
- sdkp->media_present = 1;
- sdkp->write_prot = 0;
- sdkp->cache_override = 0;
- sdkp->WCE = 0;
- sdkp->RCD = 0;
- sdkp->ATO = 0;
- sdkp->first_scan = 1;
- sdkp->max_medium_access_timeouts = SD_MAX_MEDIUM_TIMEOUTS;
-
- sd_revalidate_disk(gd);
-
- gd->flags = GENHD_FL_EXT_DEVT;
- if (sdp->removable) {
- gd->flags |= GENHD_FL_REMOVABLE;
- gd->events |= DISK_EVENT_MEDIA_CHANGE;
- gd->event_flags = DISK_EVENT_FLAG_POLL | DISK_EVENT_FLAG_UEVENT;
- }
-
- blk_pm_runtime_init(sdp->request_queue, dev);
- if (sdp->rpm_autosuspend) {
- pm_runtime_set_autosuspend_delay(dev,
- sdp->host->hostt->rpm_autosuspend_delay);
- }
- device_add_disk(dev, gd, NULL);
- if (sdkp->capacity)
- sd_dif_config_host(sdkp);
-
- sd_revalidate_disk(gd);
-
- if (sdkp->security) {
- sdkp->opal_dev = init_opal_dev(sdkp, &sd_sec_submit);
- if (sdkp->opal_dev)
- sd_printk(KERN_NOTICE, sdkp, "supports TCG Opal\n");
- }
-
- sd_printk(KERN_NOTICE, sdkp, "Attached SCSI %sdisk\n",
- sdp->removable ? "removable " : "");
- scsi_autopm_put_device(sdp);
+ sd_probe_part2(sdkp);
return 0;
--
2.31.1