Commit 6888da81 authored by Mike Christie's avatar Mike Christie Committed by Martin K. Petersen

scsi: target: tcmu: Add backend plug/unplug callouts

This patch adds plug/unplug callouts for tcmu, so we can avoid the number
of times we switch to userspace. Using this driver with tcm_loop is a
common config, and dependng on the nr_hw_queues (nr_hw_queues=1 performs
much better) and fio jobs (lower num jobs around 4) this patch can increase
IOPS by only around 5-10% because we hit other issues like the big per tcmu
device mutex.

Link: https://lore.kernel.org/r/20210227170006.5077-24-michael.christie@oracle.comReviewed-by: default avatarBodo Stroesser <bostroesser@gmail.com>
Signed-off-by: default avatarMike Christie <michael.christie@oracle.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 415ccd98
...@@ -111,6 +111,7 @@ struct tcmu_dev { ...@@ -111,6 +111,7 @@ struct tcmu_dev {
struct kref kref; struct kref kref;
struct se_device se_dev; struct se_device se_dev;
struct se_dev_plug se_plug;
char *name; char *name;
struct se_hba *hba; struct se_hba *hba;
...@@ -119,6 +120,7 @@ struct tcmu_dev { ...@@ -119,6 +120,7 @@ struct tcmu_dev {
#define TCMU_DEV_BIT_BROKEN 1 #define TCMU_DEV_BIT_BROKEN 1
#define TCMU_DEV_BIT_BLOCKED 2 #define TCMU_DEV_BIT_BLOCKED 2
#define TCMU_DEV_BIT_TMR_NOTIFY 3 #define TCMU_DEV_BIT_TMR_NOTIFY 3
#define TCM_DEV_BIT_PLUGGED 4
unsigned long flags; unsigned long flags;
struct uio_info uio_info; struct uio_info uio_info;
...@@ -959,6 +961,25 @@ static uint32_t ring_insert_padding(struct tcmu_dev *udev, size_t cmd_size) ...@@ -959,6 +961,25 @@ static uint32_t ring_insert_padding(struct tcmu_dev *udev, size_t cmd_size)
return cmd_head; return cmd_head;
} }
static void tcmu_unplug_device(struct se_dev_plug *se_plug)
{
struct se_device *se_dev = se_plug->se_dev;
struct tcmu_dev *udev = TCMU_DEV(se_dev);
clear_bit(TCM_DEV_BIT_PLUGGED, &udev->flags);
uio_event_notify(&udev->uio_info);
}
static struct se_dev_plug *tcmu_plug_device(struct se_device *se_dev)
{
struct tcmu_dev *udev = TCMU_DEV(se_dev);
if (!test_and_set_bit(TCM_DEV_BIT_PLUGGED, &udev->flags))
return &udev->se_plug;
return NULL;
}
/** /**
* queue_cmd_ring - queue cmd to ring or internally * queue_cmd_ring - queue cmd to ring or internally
* @tcmu_cmd: cmd to queue * @tcmu_cmd: cmd to queue
...@@ -1086,7 +1107,7 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err) ...@@ -1086,7 +1107,7 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
list_add_tail(&tcmu_cmd->queue_entry, &udev->inflight_queue); list_add_tail(&tcmu_cmd->queue_entry, &udev->inflight_queue);
/* TODO: only if FLUSH and FUA? */ if (!test_bit(TCM_DEV_BIT_PLUGGED, &udev->flags))
uio_event_notify(&udev->uio_info); uio_event_notify(&udev->uio_info);
return 0; return 0;
...@@ -2863,6 +2884,8 @@ static struct target_backend_ops tcmu_ops = { ...@@ -2863,6 +2884,8 @@ static struct target_backend_ops tcmu_ops = {
.configure_device = tcmu_configure_device, .configure_device = tcmu_configure_device,
.destroy_device = tcmu_destroy_device, .destroy_device = tcmu_destroy_device,
.free_device = tcmu_free_device, .free_device = tcmu_free_device,
.unplug_device = tcmu_unplug_device,
.plug_device = tcmu_plug_device,
.parse_cdb = tcmu_parse_cdb, .parse_cdb = tcmu_parse_cdb,
.tmr_notify = tcmu_tmr_notify, .tmr_notify = tcmu_tmr_notify,
.set_configfs_dev_params = tcmu_set_configfs_dev_params, .set_configfs_dev_params = tcmu_set_configfs_dev_params,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment