summaryrefslogtreecommitdiff
path: root/drivers/target
diff options
context:
space:
mode:
authorSheng Yang <sheng@yasker.org>2016-02-26 14:59:56 -0800
committerNicholas Bellinger <nab@linux-iscsi.org>2016-03-10 21:49:00 -0800
commit0c28481ffb4683ef21c6664d15dbd5ae5a6cd027 (patch)
tree7ba549758d90b0bd2f1f4574263fe4c45acf9d3e /drivers/target
parentf1dbd087cc7a28c6c174cb28cf98c19f4efb1fba (diff)
target/user: Free data ring in unified function
Prepare for data_bitmap in the next patch. Reviewed-by: Andy Grover <agrover@redhat.com> Signed-off-by: Sheng Yang <sheng@yasker.org> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/target_core_user.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index 93de51fbe392..baa8720ab24f 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -303,6 +303,11 @@ static void alloc_and_scatter_data_area(struct tcmu_dev *udev,
}
}
+static void free_data_area(struct tcmu_dev *udev, size_t length)
+{
+ UPDATE_HEAD(udev->data_tail, length, udev->data_size);
+}
+
static void gather_and_free_data_area(struct tcmu_dev *udev,
struct scatterlist *data_sg, unsigned int data_nents)
{
@@ -323,7 +328,7 @@ static void gather_and_free_data_area(struct tcmu_dev *udev,
tcmu_flush_dcache_range(from, copy_bytes);
memcpy(to, from, copy_bytes);
- UPDATE_HEAD(udev->data_tail, copy_bytes, udev->data_size);
+ free_data_area(udev, copy_bytes);
/* Uh oh, wrapped the data buffer for this sg's data */
if (sg->length != copy_bytes) {
@@ -336,8 +341,7 @@ static void gather_and_free_data_area(struct tcmu_dev *udev,
tcmu_flush_dcache_range(from, copy_bytes);
memcpy(to_skip, from, copy_bytes);
- UPDATE_HEAD(udev->data_tail,
- copy_bytes, udev->data_size);
+ free_data_area(udev, copy_bytes);
}
kunmap_atomic(to - sg->offset);
}
@@ -543,24 +547,22 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
if (test_bit(TCMU_CMD_BIT_EXPIRED, &cmd->flags)) {
/* cmd has been completed already from timeout, just reclaim data
ring space */
- UPDATE_HEAD(udev->data_tail, cmd->data_length, udev->data_size);
+ free_data_area(udev, cmd->data_length);
return;
}
if (entry->hdr.uflags & TCMU_UFLAG_UNKNOWN_OP) {
- UPDATE_HEAD(udev->data_tail, cmd->data_length, udev->data_size);
+ free_data_area(udev, cmd->data_length);
pr_warn("TCMU: Userspace set UNKNOWN_OP flag on se_cmd %p\n",
cmd->se_cmd);
entry->rsp.scsi_status = SAM_STAT_CHECK_CONDITION;
} else if (entry->rsp.scsi_status == SAM_STAT_CHECK_CONDITION) {
memcpy(se_cmd->sense_buffer, entry->rsp.sense_buffer,
se_cmd->scsi_sense_length);
-
- UPDATE_HEAD(udev->data_tail, cmd->data_length, udev->data_size);
+ free_data_area(udev, cmd->data_length);
} else if (se_cmd->se_cmd_flags & SCF_BIDI) {
/* Discard data_out buffer */
- UPDATE_HEAD(udev->data_tail,
- (size_t)se_cmd->t_data_sg->length, udev->data_size);
+ free_data_area(udev, (size_t)se_cmd->t_data_sg->length);
/* Get Data-In buffer */
gather_and_free_data_area(udev,
@@ -569,7 +571,7 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
gather_and_free_data_area(udev,
se_cmd->t_data_sg, se_cmd->t_data_nents);
} else if (se_cmd->data_direction == DMA_TO_DEVICE) {
- UPDATE_HEAD(udev->data_tail, cmd->data_length, udev->data_size);
+ free_data_area(udev, cmd->data_length);
} else if (se_cmd->data_direction != DMA_NONE) {
pr_warn("TCMU: data direction was %d!\n",
se_cmd->data_direction);