[PATCH 5/6] ceph: refactor mount related functions, add helpers

Previous thread: [PATCH 4/6] ceph: enable creation of clients that don't need mds by Yehuda Sadeh on Tuesday, April 13, 2010 - 4:29 pm. (1 message)

Next thread: [PATCH 2/6] ceph: refactor osdc requests creation functions by Yehuda Sadeh on Tuesday, April 13, 2010 - 4:29 pm. (1 message)
From: Yehuda Sadeh
Date: Tuesday, April 13, 2010 - 4:29 pm

Removed some functions' static declarations, separated mount
operation to __open_session and open_root_dentry for clients
that don't need the latter (rbd). Added other helper functions
that will be used later in the rbd.

Signed-off-by: Yehuda Sadeh <yehuda@hq.newdream.net>
---
 fs/ceph/file.c       |   46 ++++++++++++++++
 fs/ceph/osd_client.h |    1 +
 fs/ceph/super.c      |  142 ++++++++++++++++++++++++++++++++++++++-----------
 fs/ceph/super.h      |   29 +++++++++--
 4 files changed, 182 insertions(+), 36 deletions(-)

diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index ef8f9e9..bf7d002 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -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;
+	int po = off & ~PAGE_CACHE_MASK;
+	int left = len;
+	int l;
+
+	while (left > 0) {
+		l = min_t(int, 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;
+	int po = off & ~PAGE_CACHE_MASK;
+	int left = len;
+	int l;
+
+	while (left > 0) {
+		l = min_t(int, 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
  */
diff --git a/fs/ceph/osd_client.h b/fs/ceph/osd_client.h
index 76aa63e..870b323 100644
--- a/fs/ceph/osd_client.h
+++ b/fs/ceph/osd_client.h
@@ -67,6 +67,7 @@ struct ceph_osd_request {
 
 	struct inode *r_inode;         	      /* for use by callbacks */
 	struct writeback_control *r_wbc;      /* ditto ...
From: Andi Kleen
Date: Wednesday, April 14, 2010 - 2:57 am

int seems like exactly the wrong type here.

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.
--

From: yehuda
Date: Wednesday, April 14, 2010 - 10:39 am

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

--

Previous thread: [PATCH 4/6] ceph: enable creation of clients that don't need mds by Yehuda Sadeh on Tuesday, April 13, 2010 - 4:29 pm. (1 message)

Next thread: [PATCH 2/6] ceph: refactor osdc requests creation functions by Yehuda Sadeh on Tuesday, April 13, 2010 - 4:29 pm. (1 message)