From: Mike Christie <mchristi@redhat.com>
To: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com,
linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
nab@linux-iscsi.org
Cc: Xiubo Li <lixiubo@cmss.chinamobile.com>,
Mike Christie <mchristi@redhat.com>
Subject: [PATCH 13/19] tcmu: clean up the scatter helper
Date: Sun, 29 Oct 2017 22:44:33 -0500 [thread overview]
Message-ID: <1509335079-5276-14-git-send-email-mchristi@redhat.com> (raw)
In-Reply-To: <1509335079-5276-1-git-send-email-mchristi@redhat.com>
From: Xiubo Li <lixiubo@cmss.chinamobile.com>
Add some comments to make the scatter code to be more readable,
and drop unused arg to new_iov.
Signed-off-by: Xiubo Li <lixiubo@cmss.chinamobile.com>
Reviewed-by: Mike Christie <mchristi@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Mike Christie <mchristi@redhat.com>
---
drivers/target/target_core_user.c | 30 +++++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c
index b7eeb25..91e0601 100644
--- a/drivers/target/target_core_user.c
+++ b/drivers/target/target_core_user.c
@@ -491,8 +491,7 @@ static inline size_t head_to_end(size_t head, size_t size)
return size - head;
}
-static inline void new_iov(struct iovec **iov, int *iov_cnt,
- struct tcmu_dev *udev)
+static inline void new_iov(struct iovec **iov, int *iov_cnt)
{
struct iovec *iovec;
@@ -545,19 +544,38 @@ static void scatter_data_area(struct tcmu_dev *udev,
to = kmap_atomic(page);
}
- copy_bytes = min_t(size_t, sg_remaining,
- block_remaining);
+ /*
+ * Covert to virtual offset of the ring data area.
+ */
to_offset = get_block_offset_user(udev, dbi,
block_remaining);
+ /*
+ * The following code will gather and map the blocks
+ * to the same iovec when the blocks are all next to
+ * each other.
+ */
+ copy_bytes = min_t(size_t, sg_remaining,
+ block_remaining);
if (*iov_cnt != 0 &&
to_offset == iov_tail(*iov)) {
+ /*
+ * Will append to the current iovec, because
+ * the current block page is next to the
+ * previous one.
+ */
(*iov)->iov_len += copy_bytes;
} else {
- new_iov(iov, iov_cnt, udev);
+ /*
+ * Will allocate a new iovec because we are
+ * first time here or the current block page
+ * is not next to the previous one.
+ */
+ new_iov(iov, iov_cnt);
(*iov)->iov_base = (void __user *)to_offset;
(*iov)->iov_len = copy_bytes;
}
+
if (copy_data) {
offset = DATA_BLOCK_SIZE - block_remaining;
memcpy(to + offset,
@@ -565,11 +583,13 @@ static void scatter_data_area(struct tcmu_dev *udev,
copy_bytes);
tcmu_flush_dcache_range(to, copy_bytes);
}
+
sg_remaining -= copy_bytes;
block_remaining -= copy_bytes;
}
kunmap_atomic(from - sg->offset);
}
+
if (to)
kunmap_atomic(to);
}
--
1.8.3.1
next prev parent reply other threads:[~2017-10-30 3:44 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-30 3:44 [PATCH 00/19] target/target_core_user: changes for 4.16 Mike Christie
2017-10-30 3:44 ` [PATCH 01/19] tcmu: fix crash when removing the tcmu device v4 Mike Christie
2017-10-30 3:44 ` [PATCH 02/19] tcmu: Add netlink command reply supported option for each device Mike Christie
2017-10-30 3:44 ` [PATCH 03/19] tcmu: Use macro to call container_of in tcmu_cmd_time_out_show Mike Christie
2017-10-30 3:44 ` [PATCH 04/19] tcmu: fix double se_cmd completion Mike Christie
2017-10-30 3:44 ` [PATCH 05/19] tcmu: merge common block release code Mike Christie
2017-10-30 3:44 ` [PATCH 06/19] tcmu: split unmap_thread_fn Mike Christie
2017-10-30 3:44 ` [PATCH 07/19] tcmu: fix unmap thread race Mike Christie
2017-10-30 3:44 ` [PATCH 08/19] tcmu: move expired command completion to unmap thread Mike Christie
2017-10-30 3:44 ` [PATCH 09/19] tcmu: remove commands_lock Mike Christie
2017-10-30 3:44 ` [PATCH 10/19] tcmu: release blocks for partially setup cmds Mike Christie
2017-10-30 3:44 ` [PATCH 11/19] tcmu: simplify scatter_data_area error handling Mike Christie
2017-10-30 3:44 ` [PATCH 12/19] tcmu: fix free block calculation Mike Christie
2017-10-30 3:44 ` Mike Christie [this message]
2017-10-30 3:44 ` [PATCH 14/19] tcmu: prep queue_cmd_ring to be used by unmap wq Mike Christie
2017-10-30 3:44 ` [PATCH 15/19] tcmu: simplify dbi thresh handling Mike Christie
2017-10-30 3:44 ` [PATCH 16/19] tcmu: don't block submitting context for block waits Mike Christie
2017-10-30 3:44 ` [PATCH 17/19] tcmu: make ring buffer timer configurable Mike Christie
2017-10-30 3:44 ` [PATCH 18/19] tcmu: allow max block and global max blocks to be settable Mike Christie
2017-10-30 3:44 ` [PATCH 19/19] target: return SAM_STAT_TASK_SET_FULL for TCM_OUT_OF_RESOURCES Mike Christie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1509335079-5276-14-git-send-email-mchristi@redhat.com \
--to=mchristi@redhat.com \
--cc=jejb@linux.vnet.ibm.com \
--cc=linux-scsi@vger.kernel.org \
--cc=lixiubo@cmss.chinamobile.com \
--cc=martin.petersen@oracle.com \
--cc=nab@linux-iscsi.org \
--cc=target-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).