All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock
@ 2021-03-05 19:00 Bodo Stroesser
  2021-03-06 22:23 ` michael.christie
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Bodo Stroesser @ 2021-03-05 19:00 UTC (permalink / raw)
  To: linux-scsi, target-devel, Martin K. Petersen, Mike Christie
  Cc: Bodo Stroesser

Especially when using tcmu with tcm_loop, memory allocations with
GFP_KERNEL for a LUN can cause write back to the same LUN.

So we have to use GFP_NOIO when allocation is done while handling
commands or while holding cmdr_lock.

Signed-off-by: Bodo Stroesser <bostroesser@gmail.com>
---

This patch is based on Martin's for-next branch plus my short
series "scsi: target: tcmu: Replace IDR and radix_tree with XArray"
See:
 https://lore.kernel.org/linux-scsi/20210224185335.13844-1-bostroesser@gmail.com/

 drivers/target/target_core_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index ada3ef982969..9e1b115cb032 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -518,7 +518,7 @@ static inline int tcmu_get_empty_block(struct tcmu_dev *udev,
 		if (!page)
 			goto err_alloc;
 
-		if (xa_store(&udev->data_blocks, dbi, page, GFP_KERNEL))
+		if (xa_store(&udev->data_blocks, dbi, page, GFP_NOIO))
 			goto err_insert;
 	}
 
@@ -1272,7 +1272,7 @@ tcmu_tmr_notify(struct se_device *se_dev, enum tcm_tmreq_table tmf,
 	pr_debug("TMR event %d on dev %s, aborted cmds %d, afflicted cmd_ids %d\n",
 		 tcmu_tmr_type(tmf), udev->name, i, cmd_cnt);
 
-	tmr = kmalloc(sizeof(*tmr) + cmd_cnt * sizeof(*cmd_ids), GFP_KERNEL);
+	tmr = kmalloc(sizeof(*tmr) + cmd_cnt * sizeof(*cmd_ids), GFP_NOIO);
 	if (!tmr)
 		goto unlock;
 
-- 
2.12.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock
  2021-03-05 19:00 [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock Bodo Stroesser
@ 2021-03-06 22:23 ` michael.christie
  2021-03-10  2:36 ` Martin K. Petersen
  2021-03-16  3:14 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: michael.christie @ 2021-03-06 22:23 UTC (permalink / raw)
  To: Bodo Stroesser, linux-scsi, target-devel, Martin K. Petersen

On 3/5/21 1:00 PM, Bodo Stroesser wrote:
> Especially when using tcmu with tcm_loop, memory allocations with
> GFP_KERNEL for a LUN can cause write back to the same LUN.
> 
> So we have to use GFP_NOIO when allocation is done while handling
> commands or while holding cmdr_lock.
> 
> Signed-off-by: Bodo Stroesser <bostroesser@gmail.com>

Reviewed-by: Mike Christie <michael.christie@oracle.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock
  2021-03-05 19:00 [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock Bodo Stroesser
  2021-03-06 22:23 ` michael.christie
@ 2021-03-10  2:36 ` Martin K. Petersen
  2021-03-16  3:14 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-03-10  2:36 UTC (permalink / raw)
  To: Bodo Stroesser
  Cc: linux-scsi, target-devel, Martin K. Petersen, Mike Christie


Bodo,

> Especially when using tcmu with tcm_loop, memory allocations with
> GFP_KERNEL for a LUN can cause write back to the same LUN.

Applied to 5.13/scsi-staging, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock
  2021-03-05 19:00 [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock Bodo Stroesser
  2021-03-06 22:23 ` michael.christie
  2021-03-10  2:36 ` Martin K. Petersen
@ 2021-03-16  3:14 ` Martin K. Petersen
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2021-03-16  3:14 UTC (permalink / raw)
  To: linux-scsi, target-devel, Bodo Stroesser, Mike Christie
  Cc: Martin K . Petersen

On Fri, 5 Mar 2021 20:00:09 +0100, Bodo Stroesser wrote:

> Especially when using tcmu with tcm_loop, memory allocations with
> GFP_KERNEL for a LUN can cause write back to the same LUN.
> 
> So we have to use GFP_NOIO when allocation is done while handling
> commands or while holding cmdr_lock.

Applied to 5.13/scsi-queue, thanks!

[1/1] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock
      https://git.kernel.org/mkp/scsi/c/1080782f13e3

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-16  3:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 19:00 [PATCH] scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock Bodo Stroesser
2021-03-06 22:23 ` michael.christie
2021-03-10  2:36 ` Martin K. Petersen
2021-03-16  3:14 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.