From: Alex Elder <elder@inktank.com>
To: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: [PATCH 7/9] ceph: kill ceph alloc_page_vec()
Date: Thu, 04 Apr 2013 11:19:52 -0500 [thread overview]
Message-ID: <515DA828.7070206@inktank.com> (raw)
In-Reply-To: <515DA755.2090504@inktank.com>
There is a helper function alloc_page_vec() that, despite its
generic sounding name depends heavily on an osd request structure
being populated with certain information.
There is only one place this function is used, and it ends up
being a bit simpler to just open code what it does, so get
rid of the helper.
The real motivation for this is deferring building the of the osd
request message, and this is a step in that direction.
Signed-off-by: Alex Elder <elder@inktank.com>
---
fs/ceph/addr.c | 45 ++++++++++++++++++---------------------------
1 file changed, 18 insertions(+), 27 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5b4ac17..e976c6d 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -631,29 +631,6 @@ static void writepages_finish(struct
ceph_osd_request *req,
ceph_osdc_put_request(req);
}
-/*
- * allocate a page vec, either directly, or if necessary, via a the
- * mempool. we avoid the mempool if we can because req->r_data_out.length
- * may be less than the maximum write size.
- */
-static void alloc_page_vec(struct ceph_fs_client *fsc,
- struct ceph_osd_request *req)
-{
- size_t size;
- int num_pages;
-
- num_pages = calc_pages_for((u64)req->r_data_out.alignment,
- (u64)req->r_data_out.length);
- size = sizeof (struct page *) * num_pages;
- req->r_data_out.pages = kmalloc(size, GFP_NOFS);
- if (!req->r_data_out.pages) {
- req->r_data_out.pages = mempool_alloc(fsc->wb_pagevec_pool,
- GFP_NOFS);
- req->r_data_out.pages_from_pool = 1;
- WARN_ON(!req->r_data_out.pages);
- }
-}
-
static struct ceph_osd_request *
ceph_writepages_osd_request(struct inode *inode, u64 offset, u64 *len,
struct ceph_snap_context *snapc,
@@ -851,6 +828,9 @@ get_more_pages:
if (locked_pages == 0) {
struct ceph_vino vino;
int num_ops = do_sync ? 2 : 1;
+ size_t size;
+ struct page **pages;
+ mempool_t *pool = NULL;
/* prepare async write request */
offset = (u64) page_offset(page);
@@ -870,13 +850,24 @@ get_more_pages:
num_ops, ops, snapc, vino.snap,
&inode->i_mtime);
+ req->r_callback = writepages_finish;
+ req->r_inode = inode;
+
+ max_pages = calc_pages_for(0, (u64)len);
+ size = max_pages * sizeof (*pages);
+ pages = kmalloc(size, GFP_NOFS);
+ if (!pages) {
+ pool = fsc->wb_pagevec_pool;
+
+ pages = mempool_alloc(pool, GFP_NOFS);
+ WARN_ON(!pages);
+ }
+
+ req->r_data_out.pages = pages;
+ req->r_data_out.pages_from_pool = !!pool;
req->r_data_out.type = CEPH_OSD_DATA_TYPE_PAGES;
req->r_data_out.length = len;
req->r_data_out.alignment = 0;
- max_pages = calc_pages_for(0, (u64)len);
- alloc_page_vec(fsc, req);
- req->r_callback = writepages_finish;
- req->r_inode = inode;
}
/* note position of first page in pvec */
--
1.7.9.5
next prev parent reply other threads:[~2013-04-04 16:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-04 16:16 [PATCH 0/9] Alex Elder
2013-04-04 16:18 ` [PATCH 1/9] ceph: use page_offset() in ceph_writepages_start() Alex Elder
2013-04-04 16:18 ` [PATCH 2/9] libceph: drop ceph_osd_request->r_con_filling_msg Alex Elder
2013-04-04 16:18 ` [PATCH 3/9] libceph: record length of bio list with bio Alex Elder
2013-04-04 16:19 ` [PATCH 4/9] libceph: record message data length Alex Elder
2013-04-04 18:34 ` [PATCH 4/9, v2] " Alex Elder
2013-04-04 16:19 ` [PATCH 5/9] libceph: don't build request in ceph_osdc_new_request() Alex Elder
2013-04-04 16:19 ` [PATCH 6/9] ceph: define ceph_writepages_osd_request() Alex Elder
2013-04-04 16:19 ` Alex Elder [this message]
2013-04-04 16:20 ` [PATCH 8/9] libceph: hold off building osd request Alex Elder
2013-04-04 16:20 ` [PATCH 9/9] ceph: build osd request message later for writepages Alex Elder
2013-04-05 3:03 ` [PATCH 0/9] Josh Durgin
2013-04-05 12:09 ` Alex Elder
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=515DA828.7070206@inktank.com \
--to=elder@inktank.com \
--cc=ceph-devel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.