tcm_vhost: Introduce iov_num_pages
authorAsias He <asias@redhat.com>
Tue, 22 Jan 2013 03:20:25 +0000 (11:20 +0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 13 Feb 2013 19:27:40 +0000 (11:27 -0800)
Add a helper to calculate the number of pages needed for a iov entry.

(nab: Drop unnecessary inline)

Signed-off-by: Asias He <asias@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/vhost/tcm_vhost.c

index 77d760bb2e44b4fb7626ab460e00b0f95bd10f1b..defc28595656897165ee97fa84b2cf96fa6b64cb 100644 (file)
@@ -77,6 +77,12 @@ static struct workqueue_struct *tcm_vhost_workqueue;
 static DEFINE_MUTEX(tcm_vhost_mutex);
 static LIST_HEAD(tcm_vhost_list);
 
+static 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;