From: Tejun Heo <tj@kernel.org>
To: linux-kernel@vger.kernel.org, fuse-devel@lists.sourceforge.net,
miklos@szeredi.hu, akpm@linux-foundation.org, npiggin@suse.de
Cc: Tejun Heo <tj@kernel.org>
Subject: [PATCH 3/4] FUSE: implement fuse_req->prep()
Date: Thu, 18 Jun 2009 18:24:32 +0900 [thread overview]
Message-ID: <1245317073-24000-4-git-send-email-tj@kernel.org> (raw)
In-Reply-To: <1245317073-24000-1-git-send-email-tj@kernel.org>
Implement ->prep() which is the opposite equivalent of ->end(). It's
called right before the request is passed to userland server in the
kernel context of the server. ->prep() can fail the request without
disrupting the whole channel.
This will be used by direct mmap implementation.
Signed-off-by: Tejun Heo <tj@kernel.org>
---
fs/fuse/dev.c | 29 ++++++++++++++++++++++++++---
fs/fuse/fuse_i.h | 6 ++++++
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 0745728..1c56c6e 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -758,6 +758,7 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
unsigned long nr_segs, loff_t pos)
{
int err;
+ bool restart;
struct fuse_req *req;
struct fuse_in *in;
struct fuse_copy_state cs;
@@ -804,12 +805,32 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
goto restart;
}
spin_unlock(&fc->lock);
+
+ restart = false;
fuse_copy_init(&cs, fc, 1, req, iov, nr_segs);
+
+ /*
+ * Execute prep if available. Failure from prep doesn't
+ * indicate faulty channel. On failure, fail the current
+ * request and proceed to the next one.
+ */
+ if (req->prep) {
+ err = req->prep(fc, req);
+ if (err) {
+ restart = true;
+ goto finish;
+ }
+ }
+
err = fuse_copy_one(&cs, &in->h, sizeof(in->h));
- if (!err)
- err = fuse_copy_args(&cs, in->numargs, in->argpages,
- (struct fuse_arg *) in->args, 0);
+ if (err)
+ goto finish;
+
+ err = fuse_copy_args(&cs, in->numargs, in->argpages,
+ (struct fuse_arg *) in->args, 0);
+ finish:
fuse_copy_finish(&cs);
+
spin_lock(&fc->lock);
req->locked = 0;
if (req->aborted) {
@@ -819,6 +840,8 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
if (err) {
req->out.h.error = -EIO;
request_end(fc, req);
+ if (restart)
+ goto restart;
return err;
}
if (!req->isreply)
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 7b930b6..aa112e2 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -292,6 +292,12 @@ struct fuse_req {
/** Link on fi->writepages */
struct list_head writepages_entry;
+ /** Request preparation callback. Called from the kernel
+ context of the FUSE server before passing the request to
+ the FUSE server. Non-zero return from this function will
+ fail the request. */
+ int (*prep)(struct fuse_conn *, struct fuse_req *);
+
/** Request completion callback. This function is called from
the kernel context of the FUSE server if the request isn't
being aborted. If the request is being aborted, it's
--
1.6.0.2
next prev parent reply other threads:[~2009-06-18 9:26 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-18 9:24 [PATCHSET] FUSE/CUSE: implement direct mmap, take#3 Tejun Heo
2009-06-18 9:24 ` [PATCH 1/4] fdtable: export alloc_fd() Tejun Heo
2009-06-24 4:39 ` Al Viro
2009-06-30 3:05 ` Tejun Heo
2009-06-18 9:24 ` [PATCH 2/4] FUSE: make request_wait_answer() wait for ->end() completion Tejun Heo
[not found] ` <20090623165354.073a61fe.akpm@linux-foundation.org>
2009-06-24 0:04 ` Tejun Heo
2009-06-24 10:02 ` Miklos Szeredi
2009-06-29 16:20 ` Tejun Heo
2009-06-18 9:24 ` Tejun Heo [this message]
2009-06-23 23:56 ` [PATCH 3/4] FUSE: implement fuse_req->prep() Andrew Morton
2009-06-24 0:07 ` Tejun Heo
2009-06-18 9:24 ` [PATCH 4/4] FUSE: implement direct mmap Tejun Heo
2009-06-24 0:14 ` Andrew Morton
2009-06-29 16:59 ` Tejun Heo
2009-06-24 10:33 ` Miklos Szeredi
2009-06-29 16:42 ` Tejun Heo
2009-07-02 13:51 ` Miklos Szeredi
2009-07-04 11:14 ` Tejun Heo
2009-07-06 11:41 ` Miklos Szeredi
2009-07-08 23:14 ` Tejun Heo
2009-07-09 10:35 ` Miklos Szeredi
2009-06-18 9:27 ` [PATCH libfuse] implement direct mmap support Tejun Heo
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=1245317073-24000-4-git-send-email-tj@kernel.org \
--to=tj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=fuse-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=npiggin@suse.de \
/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