[Patch] cleanup: GFP_ATOMIC to GFP_KERNEL in scsi_scan.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It seems to be safe to replace all 4 occurrences of GFP_ATOMIC in
scsi_scan.c by GFP_KERNEL. I found that calling code always held a mutex
(indicating process context) while not acquiring a spin_lock or such
inside the mutex sections and when using GFP_ATOMIC (see details below).

http://marc.theaimsgroup.com/?l=linux-scsi&m=115522223917634&w=2
indicates that these occurrences of GFP_ATOMIC are just there for
historical reasons.

Patch ist against 2.6.18-rc4-mm2. Please consider applying this cleanup.
It didn't break my test machine with 3 SCSI disks attached.

kzalloc(..., GFP_ATOMIC) in scsi_alloc_sdev()
        scsi_get_host_dev()
                => holds mutex
        scsi_report_lun_scan()
                __scsi_scan_target()
                        scsi_scan_target()
                                => holds mutex
                        scsi_scan_channel()
                                scsi_scan_host_selected()
                                        => holds mutex
        scsi_probe_and_add_lun()
                scsi_sequential_lun_scan()
                        __scsi_scan_target()
                                ... => holds mutex (see above)
                scsi_report_lun_scan()
                        ... => holds mutex (see above)
                __scsi_add_device()
                        => holds mutex
                __scsi_scan_target()
                        ... => holds mutex (see above)

kmalloc(..., GFP_ATOMIC) in scsi_add_lun()
        scsi_probe_and_add_lun()
                ... => holds mutex (see above)

kmalloc(..., GFP_ATOMIC) in scsi_probe_and_add_lun()
        ... => holds mutex (see above)

kmalloc(..., GFP_ATOMIC) in scsi_report_lun_scan()
        ... => holds mutex (see above)

Signed-off-by: Martin Peschke <mp3@xxxxxxxxxx>
---

 scsi_scan.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff -ur a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
--- a/drivers/scsi/scsi_scan.c	2006-08-21 20:10:26.000000000 +0200
+++ b/drivers/scsi/scsi_scan.c	2006-08-21 20:07:57.000000000 +0200
@@ -205,7 +205,7 @@
 	struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
 
 	sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
-		       GFP_ATOMIC);
+		       GFP_KERNEL);
 	if (!sdev)
 		goto out;
 
@@ -640,7 +640,7 @@
 	 * scanning run at their own risk, or supply a user level program
 	 * that can correctly scan.
 	 */
-	sdev->inquiry = kmalloc(sdev->inquiry_len, GFP_ATOMIC);
+	sdev->inquiry = kmalloc(sdev->inquiry_len, GFP_KERNEL);
 	if (sdev->inquiry == NULL) {
 		return SCSI_SCAN_NO_RESPONSE;
 	}
@@ -898,7 +898,7 @@
 	if (!sdev)
 		goto out;
 
-	result = kmalloc(result_len, GFP_ATOMIC |
+	result = kmalloc(result_len, GFP_KERNEL |
 			((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
 	if (!result)
 		goto out_free_sdev;
@@ -1194,7 +1194,7 @@
 	 * prevent us from finding any LUNs on this target.
 	 */
 	length = (max_scsi_report_luns + 1) * sizeof(struct scsi_lun);
-	lun_data = kmalloc(length, GFP_ATOMIC |
+	lun_data = kmalloc(length, GFP_KERNEL |
 			   (sdev->host->unchecked_isa_dma ? __GFP_DMA : 0));
 	if (!lun_data) {
 		printk(ALLOC_FAILURE_MSG, __FUNCTION__);


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux