aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2008-11-26 06:03:55 -0500
committerMiklos Szeredi <miklos@szeredi.hu>2008-11-26 06:03:55 -0500
commit8599396b5062bf6bd2a0b433503849e2322df1c2 (patch)
tree8ce5f253eaf5fe28324c497db780d824ea60bb5c /fs
parentacf99433d98c2570a619d8fb8b51abce4e532059 (diff)
fuse: implement unsolicited notification
Clients always used to write only in response to read requests. To implement poll efficiently, clients should be able to issue unsolicited notifications. This patch implements basic notification support. Zero fuse_out_header.unique is now accepted and considered unsolicited notification and the error field contains notification code. This patch doesn't implement any actual notification. Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r--fs/fuse/dev.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 225388f54ae7..ffd670bb8c8c 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -816,6 +816,15 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
816 return err; 816 return err;
817} 817}
818 818
819static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
820 unsigned int size, struct fuse_copy_state *cs)
821{
822 switch (code) {
823 default:
824 return -EINVAL;
825 }
826}
827
819/* Look up request on processing list by unique ID */ 828/* Look up request on processing list by unique ID */
820static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique) 829static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique)
821{ 830{
@@ -879,9 +888,23 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
879 err = fuse_copy_one(&cs, &oh, sizeof(oh)); 888 err = fuse_copy_one(&cs, &oh, sizeof(oh));
880 if (err) 889 if (err)
881 goto err_finish; 890 goto err_finish;
891
892 err = -EINVAL;
893 if (oh.len != nbytes)
894 goto err_finish;
895
896 /*
897 * Zero oh.unique indicates unsolicited notification message
898 * and error contains notification code.
899 */
900 if (!oh.unique) {
901 err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), &cs);
902 fuse_copy_finish(&cs);
903 return err ? err : nbytes;
904 }
905
882 err = -EINVAL; 906 err = -EINVAL;
883 if (!oh.unique || oh.error <= -1000 || oh.error > 0 || 907 if (oh.error <= -1000 || oh.error > 0)
884 oh.len != nbytes)
885 goto err_finish; 908 goto err_finish;
886 909
887 spin_lock(&fc->lock); 910 spin_lock(&fc->lock);