Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Make wait_for_device_probe() also do scsi_complete_async_scans()

Commit a7a20d103994 ("sd: limit the scope of the async probe domain")
make the SCSI device probing run device discovery in it's own async
domain.

However, as a result, the partition detection was no longer synchronized
by async_synchronize_full() (which, despite the name, only synchronizes
the global async space, not all of them). Which in turn meant that
"wait_for_device_probe()" would not wait for the SCSI partitions to be
parsed.

And "wait_for_device_probe()" was what the boot time init code relied on
for mounting the root filesystem.

Now, most people never noticed this, because not only is it
timing-dependent, but modern distributions all use initrd. So the root
filesystem isn't actually on a disk at all. And then before they
actually mount the final disk filesystem, they will have loaded the
scsi-wait-scan module, which not only does the expected
wait_for_device_probe(), but also does scsi_complete_async_scans().

[ Side note: scsi_complete_async_scans() had also been partially broken,
but that was fixed in commit 43a8d39d0137 ("fix async probe
regression"), so that same commit a7a20d103994 had actually broken
setups even if you used scsi-wait-scan explicitly ]

Solve this problem by just moving the scsi_complete_async_scans() call
into wait_for_device_probe(). Everybody who wants to wait for device
probing to finish really wants the SCSI probing to complete, so there's
no reason not to do this.

So now "wait_for_device_probe()" really does what the name implies, and
properly waits for device probing to finish. This also removes the now
unnecessary extra calls to scsi_complete_async_scans().

Reported-and-tested-by: Artem S. Tashkinov <t.artem@mailcity.com>
Cc: Dan Williams <dan.j.williams@gmail.com>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: James Bottomley <jbottomley@parallels.com>
Cc: Borislav Petkov <bp@amd64.org>
Cc: linux-scsi <linux-scsi@vger.kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+2 -17
+2
drivers/base/dd.c
··· 24 24 #include <linux/wait.h> 25 25 #include <linux/async.h> 26 26 #include <linux/pm_runtime.h> 27 + #include <scsi/scsi_scan.h> 27 28 28 29 #include "base.h" 29 30 #include "power/power.h" ··· 333 332 /* wait for the known devices to complete their probing */ 334 333 wait_event(probe_waitqueue, atomic_read(&probe_count) == 0); 335 334 async_synchronize_full(); 335 + scsi_complete_async_scans(); 336 336 } 337 337 EXPORT_SYMBOL_GPL(wait_for_device_probe); 338 338
-5
drivers/scsi/scsi_wait_scan.c
··· 22 22 * and might not yet have reached the scsi async scanning 23 23 */ 24 24 wait_for_device_probe(); 25 - /* 26 - * and then we wait for the actual asynchronous scsi scan 27 - * to finish. 28 - */ 29 - scsi_complete_async_scans(); 30 25 return 0; 31 26 } 32 27
-2
include/linux/device.h
··· 865 865 extern struct device *get_device(struct device *dev); 866 866 extern void put_device(struct device *dev); 867 867 868 - extern void wait_for_device_probe(void); 869 - 870 868 #ifdef CONFIG_DEVTMPFS 871 869 extern int devtmpfs_create_node(struct device *dev); 872 870 extern int devtmpfs_delete_node(struct device *dev);
-8
kernel/power/hibernate.c
··· 27 27 #include <linux/syscore_ops.h> 28 28 #include <linux/ctype.h> 29 29 #include <linux/genhd.h> 30 - #include <scsi/scsi_scan.h> 31 30 32 31 #include "power.h" 33 32 ··· 746 747 msleep(10); 747 748 async_synchronize_full(); 748 749 } 749 - 750 - /* 751 - * We can't depend on SCSI devices being available after loading 752 - * one of their modules until scsi_complete_async_scans() is 753 - * called and the resume device usually is a SCSI one. 754 - */ 755 - scsi_complete_async_scans(); 756 750 757 751 swsusp_resume_device = name_to_dev_t(resume_file); 758 752 if (!swsusp_resume_device) {
-2
kernel/power/user.c
··· 24 24 #include <linux/console.h> 25 25 #include <linux/cpu.h> 26 26 #include <linux/freezer.h> 27 - #include <scsi/scsi_scan.h> 28 27 29 28 #include <asm/uaccess.h> 30 29 ··· 83 84 * appear. 84 85 */ 85 86 wait_for_device_probe(); 86 - scsi_complete_async_scans(); 87 87 88 88 data->swap = -1; 89 89 data->mode = O_WRONLY;