]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
fuse: implement unsolicited notification
authorTejun Heo <tj@kernel.org>
Wed, 26 Nov 2008 11:03:55 +0000 (12:03 +0100)
committerMiklos Szeredi <miklos@szeredi.hu>
Wed, 26 Nov 2008 11:03:55 +0000 (12:03 +0100)
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>
fs/fuse/dev.c
include/linux/fuse.h

index 225388f54ae72c92c3b6af528210c7103414a63e..ffd670bb8c8c540b735a4353a8bb07453c797f1d 100644 (file)
@@ -816,6 +816,15 @@ static ssize_t fuse_dev_read(struct kiocb *iocb, const struct iovec *iov,
        return err;
 }
 
+static int fuse_notify(struct fuse_conn *fc, enum fuse_notify_code code,
+                      unsigned int size, struct fuse_copy_state *cs)
+{
+       switch (code) {
+       default:
+               return -EINVAL;
+       }
+}
+
 /* Look up request on processing list by unique ID */
 static struct fuse_req *request_find(struct fuse_conn *fc, u64 unique)
 {
@@ -879,9 +888,23 @@ static ssize_t fuse_dev_write(struct kiocb *iocb, const struct iovec *iov,
        err = fuse_copy_one(&cs, &oh, sizeof(oh));
        if (err)
                goto err_finish;
+
+       err = -EINVAL;
+       if (oh.len != nbytes)
+               goto err_finish;
+
+       /*
+        * Zero oh.unique indicates unsolicited notification message
+        * and error contains notification code.
+        */
+       if (!oh.unique) {
+               err = fuse_notify(fc, oh.error, nbytes - sizeof(oh), &cs);
+               fuse_copy_finish(&cs);
+               return err ? err : nbytes;
+       }
+
        err = -EINVAL;
-       if (!oh.unique || oh.error <= -1000 || oh.error > 0 ||
-           oh.len != nbytes)
+       if (oh.error <= -1000 || oh.error > 0)
                goto err_finish;
 
        spin_lock(&fc->lock);
index 608e300ae883d9289410f3cf8f431f6e2888e5d5..abde9949e2c08a066d6ce5f8fca407a1ec1f2ca2 100644 (file)
@@ -203,6 +203,10 @@ enum fuse_opcode {
        FUSE_IOCTL         = 39,
 };
 
+enum fuse_notify_code {
+       FUSE_NOTIFY_CODE_MAX,
+};
+
 /* The read buffer is required to be at least 8k, but may be much larger */
 #define FUSE_MIN_READ_BUFFER 8192