Skip to contentSkip to conversation

scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock

PATCH Applied Bodo Stroesser 3 participants 4 messages Mar 5, 2021 – Mar 16, 2021

Subsystems (3)
lore
Share & tools
lore

Bodo Stroesser

author maintainer
#0 lore raw

PATCH 1/1 scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock

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.

---

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/[email protected]/

 drivers/target/target_core_user.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/target/target_core_user.c +2 -2
index ada3ef982969..9e1b115cb032 100644
@@ -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;
 
Signature · 1 line
2.12.3
#2 lore raw
In reply to Bodo Stroesser

Bodo,

Quoted 2 lines

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!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#3 lore raw
In reply to Bodo Stroesser
Quoted 5 lines · 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.

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
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering