From: Maxim Patlasov <mpatlasov@parallels.com>
To: miklos@szeredi.hu
Cc: fuse-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org,
devel@openvz.org
Subject: [PATCH 03/12] fuse: rework fuse_retrieve()
Date: Fri, 26 Oct 2012 19:48:42 +0400 [thread overview]
Message-ID: <20121026154835.18931.12676.stgit@maximpc.sw.ru> (raw)
In-Reply-To: <20121026152957.18931.46330.stgit@maximpc.sw.ru>
The patch reworks fuse_retrieve() to allocate only so many page pointers
as needed. The core part of the patch is the following calculation:
num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
(thanks Miklos for formula). All other changes are mostly shuffling lines.
Signed-off-by: Maxim Patlasov <mpatlasov@parallels.com>
---
fs/fuse/dev.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index a5d4440..1266a5c 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -1563,13 +1563,24 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
unsigned int num;
unsigned int offset;
size_t total_len = 0;
+ int num_pages;
- req = fuse_get_req(fc, FUSE_MAX_PAGES_PER_REQ);
+ offset = outarg->offset & ~PAGE_CACHE_MASK;
+ file_size = i_size_read(inode);
+
+ num = outarg->size;
+ if (outarg->offset > file_size)
+ num = 0;
+ else if (outarg->offset + num > file_size)
+ num = file_size - outarg->offset;
+
+ num_pages = (num + offset + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ num_pages = min(num_pages, FUSE_MAX_PAGES_PER_REQ);
+
+ req = fuse_get_req(fc, num_pages);
if (IS_ERR(req))
return PTR_ERR(req);
- offset = outarg->offset & ~PAGE_CACHE_MASK;
-
req->in.h.opcode = FUSE_NOTIFY_REPLY;
req->in.h.nodeid = outarg->nodeid;
req->in.numargs = 2;
@@ -1578,14 +1589,8 @@ static int fuse_retrieve(struct fuse_conn *fc, struct inode *inode,
req->end = fuse_retrieve_end;
index = outarg->offset >> PAGE_CACHE_SHIFT;
- file_size = i_size_read(inode);
- num = outarg->size;
- if (outarg->offset > file_size)
- num = 0;
- else if (outarg->offset + num > file_size)
- num = file_size - outarg->offset;
- while (num && req->num_pages < FUSE_MAX_PAGES_PER_REQ) {
+ while (num && req->num_pages < num_pages) {
struct page *page;
unsigned int this_num;
next prev parent reply other threads:[~2012-10-26 15:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-26 15:47 [PATCH v3 00/12] fuse: optimize scatter-gather direct IO Maxim Patlasov
2012-10-26 15:48 ` [PATCH 01/12] fuse: general infrastructure for pages[] of variable size Maxim Patlasov
2012-10-26 15:48 ` [PATCH 02/12] fuse: categorize fuse_get_req() Maxim Patlasov
2012-10-26 15:48 ` Maxim Patlasov [this message]
2012-10-26 15:48 ` [PATCH 04/12] fuse: rework fuse_readpages() Maxim Patlasov
2012-10-26 15:49 ` [PATCH 05/12] fuse: rework fuse_perform_write() Maxim Patlasov
2012-10-26 15:49 ` [PATCH 06/12] fuse: rework fuse_do_ioctl() Maxim Patlasov
2012-10-26 15:49 ` [PATCH 07/12] fuse: add per-page descriptor <offset, length> to fuse_req Maxim Patlasov
2012-10-26 15:49 ` [PATCH 08/12] fuse: use req->page_descs[] for argpages cases Maxim Patlasov
2012-10-26 15:50 ` [PATCH 09/12] mm: minor cleanup of iov_iter_single_seg_count() Maxim Patlasov
2012-10-26 15:50 ` [PATCH 10/12] fuse: pass iov[] to fuse_get_user_pages() Maxim Patlasov
2012-10-26 15:50 ` [PATCH 11/12] fuse: optimize fuse_get_user_pages() Maxim Patlasov
2012-10-26 15:50 ` [PATCH 12/12] fuse: optimize __fuse_direct_io() Maxim Patlasov
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=20121026154835.18931.12676.stgit@maximpc.sw.ru \
--to=mpatlasov@parallels.com \
--cc=devel@openvz.org \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
/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
Powered by JetHome