linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: yehuda <yehuda@hq.newdream.net>
To: Andi Kleen <andi@firstfloor.org>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	sage@newdream.net, axboe@kernel.dk
Subject: Re: [PATCH 5/6] ceph: refactor mount related functions, add helpers
Date: Wed, 14 Apr 2010 10:39:23 -0700	[thread overview]
Message-ID: <1271266763.7701.20.camel@yehudasa-desktop> (raw)
In-Reply-To: <87bpdm9x0e.fsf@basil.nowhere.org>

On Wed, 2010-04-14 at 11:57 +0200, Andi Kleen wrote:
> Yehuda Sadeh <yehuda@hq.newdream.net> writes:
> >  
> > +int ceph_copy_to_page_vector(struct page **pages,
> > +				    const char *data,
> > +				    loff_t off, size_t len)
> > +{
> > +	int i = 0;
> > +	int po = off & ~PAGE_CACHE_MASK;
> > +	int left = len;
> > +	int l;
> > +
> > +	while (left > 0) {
> > +		l = min_t(int, PAGE_CACHE_SIZE-po, left);
> 
> int seems like exactly the wrong type here.

Ah yes.. there are other places around there that need fixing too.
Changing to size_t:

@@ -362,6 +362,52 @@ static int copy_user_to_page_vector(struct page
**pages,
 	return len;
 }
 
+int ceph_copy_to_page_vector(struct page **pages,
+				    const char *data,
+				    loff_t off, size_t len)
+{
+	int i = 0;
+	size_t po = off & ~PAGE_CACHE_MASK;
+	size_t left = len;
+	size_t l;
+
+	while (left > 0) {
+		l = min_t(size_t, PAGE_CACHE_SIZE-po, left);
+		memcpy(page_address(pages[i]) + po, data, l);
+		data += l;
+		left -= l;
+		po += l;
+		if (po == PAGE_CACHE_SIZE) {
+			po = 0;
+			i++;
+		}
+	}
+	return len;
+}
+
+int ceph_copy_from_page_vector(struct page **pages,
+				    char *data,
+				    loff_t off, size_t len)
+{
+	int i = 0;
+	size_t po = off & ~PAGE_CACHE_MASK;
+	size_t left = len;
+	size_t l;
+
+	while (left > 0) {
+		l = min_t(size_t, PAGE_CACHE_SIZE-po, left);
+		memcpy(data, page_address(pages[i]) + po, l);
+		data += l;
+		left -= l;
+		po += l;
+		if (po == PAGE_CACHE_SIZE) {
+			po = 0;
+			i++;
+		}
+	}
+	return len;
+}
+
 /*
  * copy user data from a page vector into a user pointer
  */

Thanks,
Yehuda

  reply	other threads:[~2010-04-14 17:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-13 23:29 [PATCH 0/6] Ceph RADOS block device Yehuda Sadeh
2010-04-13 23:29 ` [PATCH 1/6] ceph: all allocation functions should get gfp_mask Yehuda Sadeh
2010-04-13 23:29   ` [PATCH 2/6] ceph: refactor osdc requests creation functions Yehuda Sadeh
2010-04-13 23:29   ` [PATCH 3/6] ceph: message layer can send/receive data in bio Yehuda Sadeh
2010-04-13 23:29   ` [PATCH 4/6] ceph: enable creation of clients that don't need mds Yehuda Sadeh
2010-04-13 23:29   ` [PATCH 5/6] ceph: refactor mount related functions, add helpers Yehuda Sadeh
2010-04-14  9:57     ` Andi Kleen
2010-04-14 17:39       ` yehuda [this message]
2010-04-13 23:29   ` [PATCH 6/6] ceph: rados block device Yehuda Sadeh

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=1271266763.7701.20.camel@yehudasa-desktop \
    --to=yehuda@hq.newdream.net \
    --cc=andi@firstfloor.org \
    --cc=axboe@kernel.dk \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sage@newdream.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).