linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Venkateswararao Jujjuri (JV)" <jvrao@linux.vnet.ibm.com>
To: Latchesar Ionkov <lucho@ionkov.net>
Cc: linux-fsdevel@vger.kernel.org, v9fs-developer@lists.sourceforge.net
Subject: Re: [V9fs-developer] [RFC] [PATCH 2/7] [net/9p] Adds supporting functions for zero copy.
Date: Tue, 08 Feb 2011 09:21:47 -0800	[thread overview]
Message-ID: <4D517BAB.8010501@linux.vnet.ibm.com> (raw)
In-Reply-To: <AANLkTikUsZomO6ESEWi-xnLJaHt81f1u8h3SXX+Tz2Tr@mail.gmail.com>

On 2/8/2011 7:20 AM, Latchesar Ionkov wrote:
> Can you please rename the common structures so they don't have virtio
> related names?
> 

Sure.

- JV

> Thanks,
>     Lucho
> 
> On Sun, Feb 6, 2011 at 11:56 PM, Venkateswararao Jujjuri (JV)
> <jvrao@linux.vnet.ibm.com> wrote:
>> On 2/6/2011 11:21 PM, Venkateswararao Jujjuri (JV) wrote:
>>> Signed-off-by: Venkateswararao Jujjuri <jvrao@linux.vnet.ibm.com>
>>> ---
>>>  net/9p/Makefile       |    1 +
>>>  net/9p/trans_common.c |   88 +++++++++++++++++++++++++++++++++++++++++++++++++
>>>  net/9p/trans_common.h |   26 ++++++++++++++
>>>  3 files changed, 115 insertions(+), 0 deletions(-)
>>>  create mode 100644 net/9p/trans_common.c
>>>  create mode 100644 net/9p/trans_common.h
>>>
>>> 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 <jvrao@linux.vnet.ibm.com>
>>> + *
>>> + * 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 <linux/slab.h>
>>> +#include <net/9p/9p.h>
>>> +#include <net/9p/client.h>
>>> +#include <linux/scatterlist.h>
>>> +#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 <jvrao@linux.vnet.ibm.com>
>>> + *
>>> + * 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);
>>
>>
>>
>> ------------------------------------------------------------------------------
>> The modern datacenter depends on network connectivity to access resources
>> and provide services. The best practices for maximizing a physical server's
>> connectivity to a physical network are well understood - see how these
>> rules translate into the virtual world?
>> http://p.sf.net/sfu/oracle-sfdevnlfb
>> _______________________________________________
>> V9fs-developer mailing list
>> V9fs-developer@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/v9fs-developer
>>



  reply	other threads:[~2011-02-08 17:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-07  7:21 [RFC-V2] [PATCH 0/7] Zero Copy Venkateswararao Jujjuri (JV)
2011-02-07  6:55 ` Venkateswararao Jujjuri (JV)
2011-02-07  7:21 ` [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate zero copy Venkateswararao Jujjuri (JV)
2011-02-07  7:21 ` Venkateswararao Jujjuri (JV)
2011-02-07  6:56   ` [RFC] [PATCH 2/7] [net/9p] Adds supporting functions for " Venkateswararao Jujjuri (JV)
2011-02-08 15:20     ` [V9fs-developer] " Latchesar Ionkov
2011-02-08 17:21       ` Venkateswararao Jujjuri (JV) [this message]
2011-02-07  7:21 ` [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate " Venkateswararao Jujjuri (JV)
2011-02-07  6:56   ` [RFC] [PATCH 3/7] [net/9p] Assign type of transaction to tc->pdu->id which is otherwise unsed Venkateswararao Jujjuri (JV)
2011-02-07  7:21 ` [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate zero copy Venkateswararao Jujjuri (JV)
2011-02-07  6:56   ` [RFC] [PATCH 4/7] [net/9p] Add gup/zero_copy support to VirtIO transport layer Venkateswararao Jujjuri (JV)
2011-02-07  7:21 ` [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate zero copy Venkateswararao Jujjuri (JV)
2011-02-07  6:57   ` [RFC] [PATCH 5/7] [net/9p] Add preferences to transport layer Venkateswararao Jujjuri (JV)
2011-02-07  7:21 ` [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate zero copy Venkateswararao Jujjuri (JV)
2011-02-07  6:57   ` :[RFC] [PATCH 6/7] [net/9p] Read and Write side zerocopy changes for 9P2000.L protocol Venkateswararao Jujjuri (JV)
2011-02-08 21:09     ` [V9fs-developer] " Eric Van Hensbergen
2011-02-08 21:16       ` Eric Van Hensbergen
2011-02-09 21:09         ` Venkateswararao Jujjuri (JV)
2011-02-09 21:12           ` Venkateswararao Jujjuri (JV)
2011-02-09 21:18           ` Eric Van Hensbergen
2011-02-09 21:39             ` Venkateswararao Jujjuri (JV)
2011-02-08 23:50       ` Venkateswararao Jujjuri (JV)
2011-02-09  1:59         ` Venkateswararao Jujjuri (JV)
2011-02-09 14:28           ` Eric Van Hensbergen
2011-02-07  7:21 ` [RFC] [PATCH 1/7] [net/9p] Additional elements to p9_fcall to accomodate zero copy Venkateswararao Jujjuri (JV)
2011-02-07  6:58   ` [PATCH 7/7] [net/9p] Handle TREAD/RERROR case in !dotl case Venkateswararao Jujjuri (JV)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D517BAB.8010501@linux.vnet.ibm.com \
    --to=jvrao@linux.vnet.ibm.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=v9fs-developer@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).