Skip to content

Commit 6888da8

Browse files
mikechristiemartinkpetersen
authored andcommitted
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/[email protected] Reviewed-by: Bodo Stroesser <[email protected]> Signed-off-by: Mike Christie <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 415ccd9 commit 6888da8

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

drivers/target/target_core_user.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct tcmu_dev {
111111
struct kref kref;
112112

113113
struct se_device se_dev;
114+
struct se_dev_plug se_plug;
114115

115116
char *name;
116117
struct se_hba *hba;
@@ -119,6 +120,7 @@ struct tcmu_dev {
119120
#define TCMU_DEV_BIT_BROKEN 1
120121
#define TCMU_DEV_BIT_BLOCKED 2
121122
#define TCMU_DEV_BIT_TMR_NOTIFY 3
123+
#define TCM_DEV_BIT_PLUGGED 4
122124
unsigned long flags;
123125

124126
struct uio_info uio_info;
@@ -959,6 +961,25 @@ static uint32_t ring_insert_padding(struct tcmu_dev *udev, size_t cmd_size)
959961
return cmd_head;
960962
}
961963

964+
static void tcmu_unplug_device(struct se_dev_plug *se_plug)
965+
{
966+
struct se_device *se_dev = se_plug->se_dev;
967+
struct tcmu_dev *udev = TCMU_DEV(se_dev);
968+
969+
clear_bit(TCM_DEV_BIT_PLUGGED, &udev->flags);
970+
uio_event_notify(&udev->uio_info);
971+
}
972+
973+
static struct se_dev_plug *tcmu_plug_device(struct se_device *se_dev)
974+
{
975+
struct tcmu_dev *udev = TCMU_DEV(se_dev);
976+
977+
if (!test_and_set_bit(TCM_DEV_BIT_PLUGGED, &udev->flags))
978+
return &udev->se_plug;
979+
980+
return NULL;
981+
}
982+
962983
/**
963984
* queue_cmd_ring - queue cmd to ring or internally
964985
* @tcmu_cmd: cmd to queue
@@ -1086,8 +1107,8 @@ static int queue_cmd_ring(struct tcmu_cmd *tcmu_cmd, sense_reason_t *scsi_err)
10861107

10871108
list_add_tail(&tcmu_cmd->queue_entry, &udev->inflight_queue);
10881109

1089-
/* TODO: only if FLUSH and FUA? */
1090-
uio_event_notify(&udev->uio_info);
1110+
if (!test_bit(TCM_DEV_BIT_PLUGGED, &udev->flags))
1111+
uio_event_notify(&udev->uio_info);
10911112

10921113
return 0;
10931114

@@ -2863,6 +2884,8 @@ static struct target_backend_ops tcmu_ops = {
28632884
.configure_device = tcmu_configure_device,
28642885
.destroy_device = tcmu_destroy_device,
28652886
.free_device = tcmu_free_device,
2887+
.unplug_device = tcmu_unplug_device,
2888+
.plug_device = tcmu_plug_device,
28662889
.parse_cdb = tcmu_parse_cdb,
28672890
.tmr_notify = tcmu_tmr_notify,
28682891
.set_configfs_dev_params = tcmu_set_configfs_dev_params,

0 commit comments

Comments
 (0)