From patchwork Mon Jan 21 08:05:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 2009541 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 951353FD1A for ; Mon, 21 Jan 2013 08:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752132Ab3AUIDu (ORCPT ); Mon, 21 Jan 2013 03:03:50 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39467 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752001Ab3AUIDu (ORCPT ); Mon, 21 Jan 2013 03:03:50 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r0L83lF8005737 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 21 Jan 2013 03:03:47 -0500 Received: from hj.localdomain.com ([10.66.6.0]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r0L83ZcM012334; Mon, 21 Jan 2013 03:03:42 -0500 From: Asias He To: Nicholas Bellinger Cc: "Michael S. Tsirkin" , Rusty Russell , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, target-devel@vger.kernel.org Subject: [PATCH 1/3] tcm_vhost: Introduce iov_num_pages Date: Mon, 21 Jan 2013 16:05:26 +0800 Message-Id: <1358755528-31421-2-git-send-email-asias@redhat.com> In-Reply-To: <1358755528-31421-1-git-send-email-asias@redhat.com> References: <1358755528-31421-1-git-send-email-asias@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Add a helper to calculate the number of pages needed for a iov entry. Signed-off-by: Asias He --- 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) +{ + 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;