]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.34/scsi-core-replace-gfp_atomic-with-gfp_kernel-in-scsi.patch
Linux 4.19.34
[thirdparty/kernel/stable-queue.git] / releases / 4.19.34 / scsi-core-replace-gfp_atomic-with-gfp_kernel-in-scsi.patch
CommitLineData
ba172962
SL
1From b82e5b9ad86533fd2b65a3966a0133d4b2d1e1da Mon Sep 17 00:00:00 2001
2From: Benjamin Block <bblock@linux.ibm.com>
3Date: Thu, 21 Feb 2019 10:18:00 +0100
4Subject: scsi: core: replace GFP_ATOMIC with GFP_KERNEL in scsi_scan.c
5
6[ Upstream commit 1749ef00f7312679f76d5e9104c5d1e22a829038 ]
7
8We had a test-report where, under memory pressure, adding LUNs to the
9systems would fail (the tests add LUNs strictly in sequence):
10
11[ 5525.853432] scsi 0:0:1:1088045124: Direct-Access IBM 2107900 .148 PQ: 0 ANSI: 5
12[ 5525.853826] scsi 0:0:1:1088045124: alua: supports implicit TPGS
13[ 5525.853830] scsi 0:0:1:1088045124: alua: device naa.6005076303ffd32700000000000044da port group 0 rel port 43
14[ 5525.853931] sd 0:0:1:1088045124: Attached scsi generic sg10 type 0
15[ 5525.854075] sd 0:0:1:1088045124: [sdk] Disabling DIF Type 1 protection
16[ 5525.855495] sd 0:0:1:1088045124: [sdk] 2097152 512-byte logical blocks: (1.07 GB/1.00 GiB)
17[ 5525.855606] sd 0:0:1:1088045124: [sdk] Write Protect is off
18[ 5525.855609] sd 0:0:1:1088045124: [sdk] Mode Sense: ed 00 00 08
19[ 5525.855795] sd 0:0:1:1088045124: [sdk] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
20[ 5525.857838] sdk: sdk1
21[ 5525.859468] sd 0:0:1:1088045124: [sdk] Attached SCSI disk
22[ 5525.865073] sd 0:0:1:1088045124: alua: transition timeout set to 60 seconds
23[ 5525.865078] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA
24[ 5526.015070] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA
25[ 5526.015213] sd 0:0:1:1088045124: alua: port group 00 state A preferred supports tolusnA
26[ 5526.587439] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured
27[ 5526.588562] scsi_alloc_sdev: Allocation failure during SCSI scanning, some SCSI devices might not be configured
28
29Looking at the code of scsi_alloc_sdev(), and all the calling contexts,
30there seems to be no reason to use GFP_ATMOIC here. All the different
31call-contexts use a mutex at some point, and nothing in between that
32requires no sleeping, as far as I could see. Additionally, the code that
33later allocates the block queue for the device (scsi_mq_alloc_queue())
34already uses GFP_KERNEL.
35
36There are similar allocations in two other functions:
37scsi_probe_and_add_lun(), and scsi_add_lun(),; that can also be done with
38GFP_KERNEL.
39
40Here is the contexts for the three functions so far:
41
42 scsi_alloc_sdev()
43 scsi_probe_and_add_lun()
44 scsi_sequential_lun_scan()
45 __scsi_scan_target()
46 scsi_scan_target()
47 mutex_lock()
48 scsi_scan_channel()
49 scsi_scan_host_selected()
50 mutex_lock()
51 scsi_report_lun_scan()
52 __scsi_scan_target()
53 ...
54 __scsi_add_device()
55 mutex_lock()
56 __scsi_scan_target()
57 ...
58 scsi_report_lun_scan()
59 ...
60 scsi_get_host_dev()
61 mutex_lock()
62
63 scsi_probe_and_add_lun()
64 ...
65
66 scsi_add_lun()
67 scsi_probe_and_add_lun()
68 ...
69
70So replace all these, and give them a bit of a better chance to succeed,
71with more chances of reclaim.
72
73Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
74Reviewed-by: Bart Van Assche <bvanassche@acm.org>
75Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
76Signed-off-by: Sasha Levin <sashal@kernel.org>
77---
78 drivers/scsi/scsi_scan.c | 6 +++---
79 1 file changed, 3 insertions(+), 3 deletions(-)
80
81diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
82index 78ca63dfba4a..9a7e3a3bd5ce 100644
83--- a/drivers/scsi/scsi_scan.c
84+++ b/drivers/scsi/scsi_scan.c
85@@ -220,7 +220,7 @@ static struct scsi_device *scsi_alloc_sdev(struct scsi_target *starget,
86 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent);
87
88 sdev = kzalloc(sizeof(*sdev) + shost->transportt->device_size,
89- GFP_ATOMIC);
90+ GFP_KERNEL);
91 if (!sdev)
92 goto out;
93
94@@ -796,7 +796,7 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
95 */
96 sdev->inquiry = kmemdup(inq_result,
97 max_t(size_t, sdev->inquiry_len, 36),
98- GFP_ATOMIC);
99+ GFP_KERNEL);
100 if (sdev->inquiry == NULL)
101 return SCSI_SCAN_NO_RESPONSE;
102
103@@ -1087,7 +1087,7 @@ static int scsi_probe_and_add_lun(struct scsi_target *starget,
104 if (!sdev)
105 goto out;
106
107- result = kmalloc(result_len, GFP_ATOMIC |
108+ result = kmalloc(result_len, GFP_KERNEL |
109 ((shost->unchecked_isa_dma) ? __GFP_DMA : 0));
110 if (!result)
111 goto out_free_sdev;
112--
1132.19.1
114