From patchwork Tue Aug 17 17:27:25 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: jvrao X-Patchwork-Id: 119982 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o7HHJssD010435 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 17 Aug 2010 17:20:30 GMT Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OlPpG-0007DR-0p; Tue, 17 Aug 2010 17:19:50 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.69) (envelope-from ) id 1OlPpE-0007DD-Pb for v9fs-developer@lists.sourceforge.net; Tue, 17 Aug 2010 17:19:48 +0000 X-ACL-Warn: Received: from e39.co.us.ibm.com ([32.97.110.160]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) id 1OlPpB-00069C-Rw for v9fs-developer@lists.sourceforge.net; Tue, 17 Aug 2010 17:19:46 +0000 Received: from d03relay05.boulder.ibm.com (d03relay05.boulder.ibm.com [9.17.195.107]) by e39.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id o7HH9d7R008101 for ; Tue, 17 Aug 2010 11:09:39 -0600 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d03relay05.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o7HHJchl097726 for ; Tue, 17 Aug 2010 11:19:39 -0600 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 o7HHJb8O002511 for ; Tue, 17 Aug 2010 11:19:38 -0600 Received: from localhost.localdomain (elm9m80.beaverton.ibm.com [9.47.81.80]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o7HHJWS0001997; Tue, 17 Aug 2010 11:19:37 -0600 From: "Venkateswararao Jujjuri (JV)" To: v9fs-developer@lists.sourceforge.net Date: Tue, 17 Aug 2010 10:27:25 -0700 Message-Id: <1282066045-3945-6-git-send-email-jvrao@linux.vnet.ibm.com> X-Mailer: git-send-email 1.6.0.6 In-Reply-To: <1282066045-3945-1-git-send-email-jvrao@linux.vnet.ibm.com> References: <1282066045-3945-1-git-send-email-jvrao@linux.vnet.ibm.com> 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: 1OlPpB-00069C-Rw Cc: linux-fsdevel@vger.kernel.org, Badari Pulavarty Subject: [V9fs-developer] [PATCH 5/5] [net/9p] Achieve zero copy on read path. 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.3 (demeter.kernel.org [140.211.167.41]); Tue, 17 Aug 2010 17:20:30 +0000 (UTC) diff --git a/net/9p/client.c b/net/9p/client.c index 7ce58fb..d11c7dd 100644 --- a/net/9p/client.c +++ b/net/9p/client.c @@ -1282,6 +1282,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, struct p9_client *clnt; struct p9_req_t *req; char *dataptr; + int page_direct = 0; P9_DPRINTK(P9_DEBUG_9P, ">>> TREAD fid %d offset %llu %d\n", fid->fid, (long long unsigned) offset, count); @@ -1296,7 +1297,20 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, if (count < rsize) rsize = count; - req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset, rsize); + if (clnt->trans_mod->capability && + clnt->trans_mod->capability(P9_CAP_GET_MAX_SG_PAGES) && + (udata && !segment_eq(get_fs(), KERNEL_DS))) + page_direct = 1; + + if (page_direct) { + rsize = count; + req = p9_client_rpc(clnt, P9_TREAD, "dqE", fid->fid, offset, + rsize, udata); + } else { + req = p9_client_rpc(clnt, P9_TREAD, "dqd", fid->fid, offset, + rsize); + } + if (IS_ERR(req)) { err = PTR_ERR(req); goto error; @@ -1314,7 +1328,7 @@ p9_client_read(struct p9_fid *fid, char *data, char __user *udata, u64 offset, memmove(data, dataptr, count); } - if (udata) { + if (udata && !page_direct) { err = copy_to_user(udata, dataptr, count); if (err) { err = -EFAULT; diff --git a/net/9p/protocol.c b/net/9p/protocol.c index 97f313d..b82d117 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c @@ -194,6 +194,25 @@ pdu_write_u(struct p9_fcall *pdu, struct p9_client *c, const char __user *udata, return len; } + static size_t +pdu_write_ur(struct p9_fcall *pdu, struct p9_client *c, + const char __user *udata, size_t size) +{ + size_t len = size; + int max_req_sg_pages = 0; + + if (c->trans_mod->capability) + max_req_sg_pages = + c->trans_mod->capability(P9_CAP_GET_MAX_SG_PAGES); + if (max_req_sg_pages) { + len = pdu_fill_pages(pdu, udata, size, 1, max_req_sg_pages); + if (len < 0) + return len; + pdu->pdata_read_len = len; + } + return len; +} + /* b - int8_t w - int16_t @@ -534,8 +553,18 @@ p9pdu_vwritef(struct p9_fcall *pdu, struct p9_client *c, const char *fmt, if (!errcode && pdu_write_u(pdu, c, udata, count) < 0) errcode = -EFAULT; - } - break; + } + break; + case 'E':{ + int32_t count = va_arg(ap, int32_t); + const char __user *udata = + va_arg(ap, const void __user *); + errcode = p9pdu_writef(pdu, c, "d", count); + if (!errcode && + pdu_write_ur(pdu, c, udata, count) < 0) + errcode = -EFAULT; + } + break; case 'T':{ int16_t nwname = va_arg(ap, int); const char **wnames = va_arg(ap, const char **);