diff options
author | Jeff Dike <jdike@addtoit.com> | 2006-04-11 01:54:52 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-04-11 09:18:48 -0400 |
commit | 385a17bfc3cb035333c8a91eddc78a6e04c4625e (patch) | |
tree | 7a9fde77c95f0e4cc86f31e8b1f5d23b6d815634 /fs/fuse/dev.c | |
parent | 7025d9ad10a38dadef8b286e0092731c2d3cdc53 (diff) |
[PATCH] fuse: add O_ASYNC support to FUSE device
This adds asynchronous notification to FUSE - a FUSE server can request
O_ASYNC on a /dev/fuse file descriptor and receive SIGIO when there is input
available.
One subtlety - fuse_dev_fasync, which is called when O_ASYNC is requested,
does no locking, unlink the other methods. I think it's unnecessary, as the
fuse_conn.fasync list is manipulated only by fasync_helper and kill_fasync,
which provide their own locking. It would also be wrong to use the fuse_lock,
as it's a spin lock and fasync_helper can sleep. My one concern with this is
the fuse_conn going away underneath fuse_dev_fasync - sys_fcntl takes a
reference on the file struct, so this seems not to be a problem.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/fuse/dev.c')
-rw-r--r-- | fs/fuse/dev.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index b2e8613a26d8..438770f8867f 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
@@ -317,6 +317,7 @@ static void queue_request(struct fuse_conn *fc, struct fuse_req *req) | |||
317 | list_add_tail(&req->list, &fc->pending); | 317 | list_add_tail(&req->list, &fc->pending); |
318 | req->state = FUSE_REQ_PENDING; | 318 | req->state = FUSE_REQ_PENDING; |
319 | wake_up(&fc->waitq); | 319 | wake_up(&fc->waitq); |
320 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | ||
320 | } | 321 | } |
321 | 322 | ||
322 | /* | 323 | /* |
@@ -901,6 +902,7 @@ void fuse_abort_conn(struct fuse_conn *fc) | |||
901 | end_requests(fc, &fc->pending); | 902 | end_requests(fc, &fc->pending); |
902 | end_requests(fc, &fc->processing); | 903 | end_requests(fc, &fc->processing); |
903 | wake_up_all(&fc->waitq); | 904 | wake_up_all(&fc->waitq); |
905 | kill_fasync(&fc->fasync, SIGIO, POLL_IN); | ||
904 | } | 906 | } |
905 | spin_unlock(&fuse_lock); | 907 | spin_unlock(&fuse_lock); |
906 | } | 908 | } |
@@ -917,12 +919,24 @@ static int fuse_dev_release(struct inode *inode, struct file *file) | |||
917 | end_requests(fc, &fc->processing); | 919 | end_requests(fc, &fc->processing); |
918 | } | 920 | } |
919 | spin_unlock(&fuse_lock); | 921 | spin_unlock(&fuse_lock); |
920 | if (fc) | 922 | if (fc) { |
923 | fasync_helper(-1, file, 0, &fc->fasync); | ||
921 | kobject_put(&fc->kobj); | 924 | kobject_put(&fc->kobj); |
925 | } | ||
922 | 926 | ||
923 | return 0; | 927 | return 0; |
924 | } | 928 | } |
925 | 929 | ||
930 | static int fuse_dev_fasync(int fd, struct file *file, int on) | ||
931 | { | ||
932 | struct fuse_conn *fc = fuse_get_conn(file); | ||
933 | if (!fc) | ||
934 | return -ENODEV; | ||
935 | |||
936 | /* No locking - fasync_helper does its own locking */ | ||
937 | return fasync_helper(fd, file, on, &fc->fasync); | ||
938 | } | ||
939 | |||
926 | const struct file_operations fuse_dev_operations = { | 940 | const struct file_operations fuse_dev_operations = { |
927 | .owner = THIS_MODULE, | 941 | .owner = THIS_MODULE, |
928 | .llseek = no_llseek, | 942 | .llseek = no_llseek, |
@@ -932,6 +946,7 @@ const struct file_operations fuse_dev_operations = { | |||
932 | .writev = fuse_dev_writev, | 946 | .writev = fuse_dev_writev, |
933 | .poll = fuse_dev_poll, | 947 | .poll = fuse_dev_poll, |
934 | .release = fuse_dev_release, | 948 | .release = fuse_dev_release, |
949 | .fasync = fuse_dev_fasync, | ||
935 | }; | 950 | }; |
936 | 951 | ||
937 | static struct miscdevice fuse_miscdevice = { | 952 | static struct miscdevice fuse_miscdevice = { |