scsi: target: tcmu: Use GFP_NOIO while handling cmds or holding cmdr_lock
authorBodo Stroesser <bostroesser@gmail.com>
Fri, 5 Mar 2021 19:00:09 +0000 (20:00 +0100)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 10 Mar 2021 04:47:17 +0000 (23:47 -0500)
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.

Link: https://lore.kernel.org/r/20210305190009.32242-1-bostroesser@gmail.com
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bodo Stroesser <bostroesser@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_user.c

index ada3ef9..9e1b115 100644 (file)
@@ -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;