From patchwork Mon Feb 7 07:21:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 537261 X-Patchwork-Delegate: ericvh@gmail.com Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p176irnq027269 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 7 Feb 2011 06:46:18 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1PmKpw-0000pr-PW; Mon, 07 Feb 2011 06:44:36 +0000 Received: from sog-mx-4.v43.ch3.sourceforge.com ([172.29.43.194] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.74) (envelope-from ) id 1PmKpv-0000pf-Tq for v9fs-developer@lists.sourceforge.net; Mon, 07 Feb 2011 06:44:35 +0000 X-ACL-Warn: Received: from e4.ny.us.ibm.com ([32.97.182.144]) by sog-mx-4.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.74) id 1PmKpv-0000uh-31 for v9fs-developer@lists.sourceforge.net; Mon, 07 Feb 2011 06:44:35 +0000 Received: from d01dlp01.pok.ibm.com (d01dlp01.pok.ibm.com [9.56.224.56]) by e4.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p176Pr3B001115 for ; Mon, 7 Feb 2011 01:25:59 -0500 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id 463DE728059 for ; Mon, 7 Feb 2011 01:44:24 -0500 (EST) Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p176iNsW178478 for ; Mon, 7 Feb 2011 01:44:23 -0500 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p176iNVc018086 for ; Sun, 6 Feb 2011 23:44:23 -0700 Received: from localhost.localdomain (elm3c187.beaverton.ibm.com [9.47.69.187]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p176iMMA018004; Sun, 6 Feb 2011 23:44:23 -0700 From: "Venkateswararao Jujjuri (JV)" To: v9fs-developer@lists.sourceforge.net Date: Sun, 6 Feb 2011 23:21:18 -0800 Message-Id: <1297063283-2180-3-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1297063283-2180-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1297063283-2180-1-git-send-email-jvrao@linux.vnet.ibm.com> X-Content-Scanned: Fidelis XPS MAILER X-Spam-Score: -0.0 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1PmKpv-0000uh-31 Cc: linux-fsdevel@vger.kernel.org Subject: [V9fs-developer] [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate zero copy. X-BeenThere: v9fs-developer@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: v9fs-developer-bounces@lists.sourceforge.net X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Mon, 07 Feb 2011 06:46:18 +0000 (UTC) diff --git a/net/9p/Makefile b/net/9p/Makefile index 198a640..a0874cc 100644 --- a/net/9p/Makefile +++ b/net/9p/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_NET_9P_RDMA) += 9pnet_rdma.o util.o \ protocol.o \ trans_fd.o \ + trans_common.o \ 9pnet_virtio-objs := \ trans_virtio.o \ diff --git a/net/9p/trans_common.c b/net/9p/trans_common.c new file mode 100644 index 0000000..dad57d2 --- /dev/null +++ b/net/9p/trans_common.c @@ -0,0 +1,88 @@ +/* + * Copyright IBM Corporation, 2010 + * Author Venkateswararao Jujjuri + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include +#include +#include +#include +#include "trans_common.h" + +/** + * p9_release_req_pages - Release pages after the transaction. + * @*private: PDU's private page of type virtio_rpage_info_t + */ +void +p9_release_req_pages(void *private) +{ + virtio_rpage_info_t *vpinfo = private; + int i = 0; + + while (vpinfo->vp_data[i] && vpinfo->vp_nr_pages--) { + put_page(vpinfo->vp_data[i]); + i++; + } +} + +/** + * payload_gup - Calculates number of pages that needs to be pinned and + * pins them ehter for read/write through get_user_pages_fast(). + */ +int +payload_gup(struct p9_req_t *req, size_t *pdata_off, int *pdata_len, u8 rw) +{ + int nr_pages; + uint32_t first_page_bytes = 0; + uint32_t pdata_mapped_pages; + virtio_rpage_info_t *rpinfo; + + nr_pages = req->tc->pbuf_size >> PAGE_SHIFT; + *pdata_off = (size_t)req->tc->pbuf & (PAGE_SIZE-1); + + if (*pdata_off) + first_page_bytes = min((PAGE_SIZE - *pdata_off), + req->tc->pbuf_size); + + if (req->tc->pbuf_size - (first_page_bytes + (nr_pages << PAGE_SHIFT))){ + /* trailing partial page */ + nr_pages++; + } + if (first_page_bytes) { + /* leading partial page */ + nr_pages++; + } + /* TODO: Use buffer on PDU instead of allocating */ + rpinfo = kmalloc(sizeof(virtio_rpage_info_t) + + sizeof(struct page *) * nr_pages, GFP_KERNEL); + req->tc->private = (void *)rpinfo; + pdata_mapped_pages = get_user_pages_fast((unsigned long)req->tc->pbuf, + nr_pages, rw, &rpinfo->vp_data[0]); + + if (pdata_mapped_pages < 0) { + printk("get_user_pages_fast failed:%d udata:%p" "nr_pages:%d\n", + pdata_mapped_pages, req->tc->pbuf, nr_pages); + pdata_mapped_pages = 0; + kfree(rpinfo); + return -EIO; + } + rpinfo->vp_nr_pages = pdata_mapped_pages; + if (*pdata_off) { + *pdata_len = first_page_bytes; + *pdata_len += min((req->tc->pbuf_size - *pdata_len), + ((size_t)pdata_mapped_pages - 1) << PAGE_SHIFT); + } else { + *pdata_len = min (req->tc->pbuf_size, + (size_t)pdata_mapped_pages << PAGE_SHIFT); + } + return 0; +} diff --git a/net/9p/trans_common.h b/net/9p/trans_common.h new file mode 100644 index 0000000..8c85392 --- /dev/null +++ b/net/9p/trans_common.h @@ -0,0 +1,26 @@ +/* + * Copyright IBM Corporation, 2010 + * Author Venkateswararao Jujjuri + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2.1 of the GNU Lesser General Public License + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it would be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +/** + * struct virtio_rpage_info - To store mapped page information in PDU. + * @vp_nr_pages: Number of mapped pages + * @vp_data: Array of page pointers + */ +typedef struct virtio_rpage_info { + int vp_nr_pages; + struct page *vp_data[0]; +} virtio_rpage_info_t; + +void p9_release_req_pages(void *); +int payload_gup(struct p9_req_t *, size_t *, int *, u8);