diff mbox

[v2,1/3] tcm_vhost: Introduce iov_num_pages

Message ID 1358824827-16169-2-git-send-email-asias@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Asias He Jan. 22, 2013, 3:20 a.m. UTC
Add a helper to calculate the number of pages needed for a iov entry.

Signed-off-by: Asias He <asias@redhat.com>
---
 drivers/vhost/tcm_vhost.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Nicholas A. Bellinger Jan. 29, 2013, 6:51 p.m. UTC | #1
Hi Asias,

On Tue, 2013-01-22 at 11:20 +0800, Asias He wrote:
> Add a helper to calculate the number of pages needed for a iov entry.
> 
> Signed-off-by: Asias He <asias@redhat.com>
> ---

Apologies for the long delay.  Applied to target-pending/for-next with a
minor nit below.

Thank you,

--nab

>  drivers/vhost/tcm_vhost.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
> index 3720604..ca35c16 100644
> --- a/drivers/vhost/tcm_vhost.c
> +++ b/drivers/vhost/tcm_vhost.c
> @@ -77,6 +77,12 @@ static struct workqueue_struct *tcm_vhost_workqueue;
>  static DEFINE_MUTEX(tcm_vhost_mutex);
>  static LIST_HEAD(tcm_vhost_list);
>  
> +static inline int iov_num_pages(struct iovec *iov)

Dropping the unnecessary inline here.

> +{
> +	return (PAGE_ALIGN((unsigned long)iov->iov_base + iov->iov_len) -
> +	       ((unsigned long)iov->iov_base & PAGE_MASK)) >> PAGE_SHIFT;
> +}
> +
>  static int tcm_vhost_check_true(struct se_portal_group *se_tpg)
>  {
>  	return 1;


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/vhost/tcm_vhost.c b/drivers/vhost/tcm_vhost.c
index 3720604..ca35c16 100644
--- a/drivers/vhost/tcm_vhost.c
+++ b/drivers/vhost/tcm_vhost.c
@@ -77,6 +77,12 @@  static struct workqueue_struct *tcm_vhost_workqueue;
 static DEFINE_MUTEX(tcm_vhost_mutex);
 static LIST_HEAD(tcm_vhost_list);
 
+static inline int iov_num_pages(struct iovec *iov)
+{
+	return (PAGE_ALIGN((unsigned long)iov->iov_base + iov->iov_len) -
+	       ((unsigned long)iov->iov_base & PAGE_MASK)) >> PAGE_SHIFT;
+}
+
 static int tcm_vhost_check_true(struct se_portal_group *se_tpg)
 {
 	return 1;