From: Miklos Szeredi <miklos@szeredi.hu>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 16/17] fuse: use asynchronous READ requests for readpages
Date: Sat, 14 Jan 2006 01:40:04 +0100 [thread overview]
Message-ID: <20060114004143.743157000@dorka.pomaz.szeredi.hu> (raw)
In-Reply-To: 20060114003948.793910000@dorka.pomaz.szeredi.hu
[-- Attachment #1: fuse_async_read.patch --]
[-- Type: text/plain, Size: 3019 bytes --]
This patch changes fuse_readpages() to send READ requests
asynchronously. This makes it possible for userspace filesystems to
utilize the kernel readahead logic instead of having to implement
their own (resulting in double caching).
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Index: linux/fs/fuse/file.c
===================================================================
--- linux.orig/fs/fuse/file.c 2006-01-14 00:48:17.000000000 +0100
+++ linux/fs/fuse/file.c 2006-01-14 00:53:07.000000000 +0100
@@ -265,7 +265,7 @@ void fuse_read_fill(struct fuse_req *req
req->file = file;
req->in.numargs = 1;
req->in.args[0].size = sizeof(struct fuse_read_in);
- req->in.args[0].value = &inarg;
+ req->in.args[0].value = inarg;
req->out.argpages = 1;
req->out.argvar = 1;
req->out.numargs = 1;
@@ -311,21 +311,33 @@ static int fuse_readpage(struct file *fi
return err;
}
-static int fuse_send_readpages(struct fuse_req *req, struct file *file,
- struct inode *inode)
+static void fuse_readpages_end(struct fuse_conn *fc, struct fuse_req *req)
{
- loff_t pos = page_offset(req->pages[0]);
- size_t count = req->num_pages << PAGE_CACHE_SHIFT;
- unsigned i;
- req->out.page_zeroing = 1;
- fuse_send_read(req, file, inode, pos, count);
+ int i;
+
+ fuse_invalidate_attr(req->pages[0]->mapping->host); /* atime changed */
+
for (i = 0; i < req->num_pages; i++) {
struct page *page = req->pages[i];
if (!req->out.h.error)
SetPageUptodate(page);
+ else
+ SetPageError(page);
unlock_page(page);
}
- return req->out.h.error;
+ fuse_put_request(fc, req);
+}
+
+static void fuse_send_readpages(struct fuse_req *req, struct file *file,
+ struct inode *inode)
+{
+ struct fuse_conn *fc = get_fuse_conn(inode);
+ loff_t pos = page_offset(req->pages[0]);
+ size_t count = req->num_pages << PAGE_CACHE_SHIFT;
+ req->out.page_zeroing = 1;
+ req->end = fuse_readpages_end;
+ fuse_read_fill(req, file, inode, pos, count, FUSE_READ);
+ request_send_background(fc, req);
}
struct fuse_readpages_data {
@@ -345,12 +357,12 @@ static int fuse_readpages_fill(void *_da
(req->num_pages == FUSE_MAX_PAGES_PER_REQ ||
(req->num_pages + 1) * PAGE_CACHE_SIZE > fc->max_read ||
req->pages[req->num_pages - 1]->index + 1 != page->index)) {
- int err = fuse_send_readpages(req, data->file, inode);
- if (err) {
+ fuse_send_readpages(req, data->file, inode);
+ data->req = req = fuse_get_request(fc);
+ if (!req) {
unlock_page(page);
- return err;
+ return -EINTR;
}
- fuse_reset_request(req);
}
req->pages[req->num_pages] = page;
req->num_pages ++;
@@ -375,10 +387,8 @@ static int fuse_readpages(struct file *f
return -EINTR;
err = read_cache_pages(mapping, pages, fuse_readpages_fill, &data);
- if (!err && data.req->num_pages)
- err = fuse_send_readpages(data.req, file, inode);
- fuse_put_request(fc, data.req);
- fuse_invalidate_attr(inode); /* atime changed */
+ if (!err)
+ fuse_send_readpages(data.req, file, inode);
return err;
}
--
next prev parent reply other threads:[~2006-01-14 0:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-14 0:39 [PATCH 00/17] fuse: fixes, cleanups and asynchronous read requests Miklos Szeredi
2006-01-14 0:39 ` [PATCH 01/17] add /sys/fs Miklos Szeredi
2006-01-17 12:47 ` Christoph Hellwig
2006-01-17 12:52 ` Miklos Szeredi
2006-01-14 0:39 ` [PATCH 02/17] fuse: fuse_copy_finish() order fix Miklos Szeredi
2006-01-14 0:39 ` [PATCH 03/17] fuse: fix request_end() Miklos Szeredi
2006-01-14 0:39 ` [PATCH 04/17] fuse: handle error INIT reply Miklos Szeredi
2006-01-14 0:39 ` [PATCH 05/17] fuse: uninline some functions Miklos Szeredi
2006-01-14 0:39 ` [PATCH 06/17] fuse: miscellaneous cleanup Miklos Szeredi
2006-01-14 0:39 ` [PATCH 07/17] fuse: introduce unified request state Miklos Szeredi
2006-01-14 0:39 ` [PATCH 08/17] fuse: introduce list for requests under I/O Miklos Szeredi
2006-01-14 0:39 ` [PATCH 09/17] fuse: extend semantics of connected flag Miklos Szeredi
2006-01-14 0:39 ` [PATCH 10/17] fuse: make fuse connection a kobject Miklos Szeredi
2006-01-14 0:39 ` [PATCH 11/17] fuse: add number of waiting requests attribute Miklos Szeredi
2006-01-14 1:28 ` Andrew Morton
2006-01-14 9:44 ` Miklos Szeredi
2006-01-14 9:53 ` Andrew Morton
2006-01-18 5:56 ` Eric Dumazet
2006-01-14 0:40 ` [PATCH 12/17] fuse: add connection aborting Miklos Szeredi
2006-01-14 1:31 ` Andrew Morton
2006-01-14 9:50 ` Miklos Szeredi
2006-01-14 0:40 ` [PATCH 13/17] fuse: add asynchronous request support Miklos Szeredi
2006-01-14 0:40 ` [PATCH 14/17] fuse: move INIT handling to inode.c Miklos Szeredi
2006-01-14 0:40 ` [PATCH 15/17] fuse: READ request initialization Miklos Szeredi
2006-01-14 0:40 ` Miklos Szeredi [this message]
2006-01-14 0:40 ` [PATCH 17/17] fuse: update documentation for sysfs Miklos Szeredi
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=20060114004143.743157000@dorka.pomaz.szeredi.hu \
--to=miklos@szeredi.hu \
--cc=akpm@osdl.org \
--cc=linux-kernel@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 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).