diff options
author | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-11-13 21:34:55 -0500 |
---|---|---|
committer | Nicholas Bellinger <nab@linux-iscsi.org> | 2013-11-13 21:34:55 -0500 |
commit | ee480683d975973e3ff679850871e00e011c4a96 (patch) | |
tree | a7c5d09f34b8f606fb3f709eb15615513d5981db /drivers | |
parent | 29f4c090079f442ea2723d292e4e64f0b6ac1f27 (diff) |
target: Convert se_device statistics to atomic_long_t
This patch converts the handful of se_device statistics to type
atomic_long_t, instead of using se_device->stats_lock when
incrementing these values.
More importantly, go ahead and drop the spinlock usage within
transport_lookup_cmd_lun() fast-path code.
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/target/target_core_device.c | 10 | ||||
-rw-r--r-- | drivers/target/target_core_stat.c | 15 | ||||
-rw-r--r-- | drivers/target/target_core_tmr.c | 4 |
3 files changed, 13 insertions, 16 deletions
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index dbe40ef14776..986afd2ee3f6 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c | |||
@@ -130,15 +130,12 @@ transport_lookup_cmd_lun(struct se_cmd *se_cmd, u32 unpacked_lun) | |||
130 | /* Directly associate cmd with se_dev */ | 130 | /* Directly associate cmd with se_dev */ |
131 | se_cmd->se_dev = se_lun->lun_se_dev; | 131 | se_cmd->se_dev = se_lun->lun_se_dev; |
132 | 132 | ||
133 | /* TODO: get rid of this and use atomics for stats */ | ||
134 | dev = se_lun->lun_se_dev; | 133 | dev = se_lun->lun_se_dev; |
135 | spin_lock_irqsave(&dev->stats_lock, flags); | 134 | atomic_long_inc(&dev->num_cmds); |
136 | dev->num_cmds++; | ||
137 | if (se_cmd->data_direction == DMA_TO_DEVICE) | 135 | if (se_cmd->data_direction == DMA_TO_DEVICE) |
138 | dev->write_bytes += se_cmd->data_length; | 136 | atomic_long_add(se_cmd->data_length, &dev->write_bytes); |
139 | else if (se_cmd->data_direction == DMA_FROM_DEVICE) | 137 | else if (se_cmd->data_direction == DMA_FROM_DEVICE) |
140 | dev->read_bytes += se_cmd->data_length; | 138 | atomic_long_add(se_cmd->data_length, &dev->read_bytes); |
141 | spin_unlock_irqrestore(&dev->stats_lock, flags); | ||
142 | 139 | ||
143 | return 0; | 140 | return 0; |
144 | } | 141 | } |
@@ -1426,7 +1423,6 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name) | |||
1426 | INIT_LIST_HEAD(&dev->state_list); | 1423 | INIT_LIST_HEAD(&dev->state_list); |
1427 | INIT_LIST_HEAD(&dev->qf_cmd_list); | 1424 | INIT_LIST_HEAD(&dev->qf_cmd_list); |
1428 | INIT_LIST_HEAD(&dev->g_dev_node); | 1425 | INIT_LIST_HEAD(&dev->g_dev_node); |
1429 | spin_lock_init(&dev->stats_lock); | ||
1430 | spin_lock_init(&dev->execute_task_lock); | 1426 | spin_lock_init(&dev->execute_task_lock); |
1431 | spin_lock_init(&dev->delayed_cmd_lock); | 1427 | spin_lock_init(&dev->delayed_cmd_lock); |
1432 | spin_lock_init(&dev->dev_reservation_lock); | 1428 | spin_lock_init(&dev->dev_reservation_lock); |
diff --git a/drivers/target/target_core_stat.c b/drivers/target/target_core_stat.c index 632665c026a8..03538994d2f7 100644 --- a/drivers/target/target_core_stat.c +++ b/drivers/target/target_core_stat.c | |||
@@ -213,7 +213,8 @@ static ssize_t target_stat_scsi_tgt_dev_show_attr_resets( | |||
213 | struct se_device *dev = | 213 | struct se_device *dev = |
214 | container_of(sgrps, struct se_device, dev_stat_grps); | 214 | container_of(sgrps, struct se_device, dev_stat_grps); |
215 | 215 | ||
216 | return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); | 216 | return snprintf(page, PAGE_SIZE, "%lu\n", |
217 | atomic_long_read(&dev->num_resets)); | ||
217 | } | 218 | } |
218 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets); | 219 | DEV_STAT_SCSI_TGT_DEV_ATTR_RO(resets); |
219 | 220 | ||
@@ -396,8 +397,8 @@ static ssize_t target_stat_scsi_lu_show_attr_num_cmds( | |||
396 | container_of(sgrps, struct se_device, dev_stat_grps); | 397 | container_of(sgrps, struct se_device, dev_stat_grps); |
397 | 398 | ||
398 | /* scsiLuNumCommands */ | 399 | /* scsiLuNumCommands */ |
399 | return snprintf(page, PAGE_SIZE, "%llu\n", | 400 | return snprintf(page, PAGE_SIZE, "%lu\n", |
400 | (unsigned long long)dev->num_cmds); | 401 | atomic_long_read(&dev->num_cmds)); |
401 | } | 402 | } |
402 | DEV_STAT_SCSI_LU_ATTR_RO(num_cmds); | 403 | DEV_STAT_SCSI_LU_ATTR_RO(num_cmds); |
403 | 404 | ||
@@ -408,7 +409,8 @@ static ssize_t target_stat_scsi_lu_show_attr_read_mbytes( | |||
408 | container_of(sgrps, struct se_device, dev_stat_grps); | 409 | container_of(sgrps, struct se_device, dev_stat_grps); |
409 | 410 | ||
410 | /* scsiLuReadMegaBytes */ | 411 | /* scsiLuReadMegaBytes */ |
411 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->read_bytes >> 20)); | 412 | return snprintf(page, PAGE_SIZE, "%lu\n", |
413 | atomic_long_read(&dev->read_bytes) >> 20); | ||
412 | } | 414 | } |
413 | DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes); | 415 | DEV_STAT_SCSI_LU_ATTR_RO(read_mbytes); |
414 | 416 | ||
@@ -419,7 +421,8 @@ static ssize_t target_stat_scsi_lu_show_attr_write_mbytes( | |||
419 | container_of(sgrps, struct se_device, dev_stat_grps); | 421 | container_of(sgrps, struct se_device, dev_stat_grps); |
420 | 422 | ||
421 | /* scsiLuWrittenMegaBytes */ | 423 | /* scsiLuWrittenMegaBytes */ |
422 | return snprintf(page, PAGE_SIZE, "%u\n", (u32)(dev->write_bytes >> 20)); | 424 | return snprintf(page, PAGE_SIZE, "%lu\n", |
425 | atomic_long_read(&dev->write_bytes) >> 20); | ||
423 | } | 426 | } |
424 | DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes); | 427 | DEV_STAT_SCSI_LU_ATTR_RO(write_mbytes); |
425 | 428 | ||
@@ -430,7 +433,7 @@ static ssize_t target_stat_scsi_lu_show_attr_resets( | |||
430 | container_of(sgrps, struct se_device, dev_stat_grps); | 433 | container_of(sgrps, struct se_device, dev_stat_grps); |
431 | 434 | ||
432 | /* scsiLuInResets */ | 435 | /* scsiLuInResets */ |
433 | return snprintf(page, PAGE_SIZE, "%u\n", dev->num_resets); | 436 | return snprintf(page, PAGE_SIZE, "%lu\n", atomic_long_read(&dev->num_resets)); |
434 | } | 437 | } |
435 | DEV_STAT_SCSI_LU_ATTR_RO(resets); | 438 | DEV_STAT_SCSI_LU_ATTR_RO(resets); |
436 | 439 | ||
diff --git a/drivers/target/target_core_tmr.c b/drivers/target/target_core_tmr.c index 250009909d49..70c638f730af 100644 --- a/drivers/target/target_core_tmr.c +++ b/drivers/target/target_core_tmr.c | |||
@@ -386,9 +386,7 @@ int core_tmr_lun_reset( | |||
386 | pr_debug("LUN_RESET: SCSI-2 Released reservation\n"); | 386 | pr_debug("LUN_RESET: SCSI-2 Released reservation\n"); |
387 | } | 387 | } |
388 | 388 | ||
389 | spin_lock_irq(&dev->stats_lock); | 389 | atomic_long_inc(&dev->num_resets); |
390 | dev->num_resets++; | ||
391 | spin_unlock_irq(&dev->stats_lock); | ||
392 | 390 | ||
393 | pr_debug("LUN_RESET: %s for [%s] Complete\n", | 391 | pr_debug("LUN_RESET: %s for [%s] Complete\n", |
394 | (preempt_and_abort_list) ? "Preempt" : "TMR", | 392 | (preempt_and_abort_list) ? "Preempt" : "TMR", |