fuse: implement poll support
Implement poll support. Polled files are indexed using kh in a RB tree rooted at fuse_conn->polled_files. Client should send FUSE_NOTIFY_POLL notification once after processing FUSE_POLL which has FUSE_POLL_SCHEDULE_NOTIFY set. Sending notification unconditionally after the latest poll or everytime file content might have changed is inefficient but won't cause malfunction. fuse_file_poll() can sleep and requires patches from the following thread which allows f_op->poll() to sleep. http://thread.gmane.org/gmane.linux.kernel/726176 Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
This commit is contained in:

committed by
Miklos Szeredi

parent
8599396b50
commit
95668a69a4
@@ -19,6 +19,8 @@
|
||||
#include <linux/backing-dev.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/rwsem.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/poll.h>
|
||||
|
||||
/** Max number of pages that can be used in a single read request */
|
||||
#define FUSE_MAX_PAGES_PER_REQ 32
|
||||
@@ -111,6 +113,12 @@ struct fuse_file {
|
||||
|
||||
/** Entry on inode's write_files list */
|
||||
struct list_head write_entry;
|
||||
|
||||
/** RB node to be linked on fuse_conn->polled_files */
|
||||
struct rb_node polled_node;
|
||||
|
||||
/** Wait queue head for poll */
|
||||
wait_queue_head_t poll_wait;
|
||||
};
|
||||
|
||||
/** One input argument of a request */
|
||||
@@ -328,6 +336,9 @@ struct fuse_conn {
|
||||
/** The next unique kernel file handle */
|
||||
u64 khctr;
|
||||
|
||||
/** rbtree of fuse_files waiting for poll events indexed by ph */
|
||||
struct rb_root polled_files;
|
||||
|
||||
/** Number of requests currently in the background */
|
||||
unsigned num_background;
|
||||
|
||||
@@ -416,6 +427,9 @@ struct fuse_conn {
|
||||
/** Is bmap not implemented by fs? */
|
||||
unsigned no_bmap:1;
|
||||
|
||||
/** Is poll not implemented by fs? */
|
||||
unsigned no_poll:1;
|
||||
|
||||
/** Do multi-page cached writes */
|
||||
unsigned big_writes:1;
|
||||
|
||||
@@ -524,6 +538,12 @@ int fuse_release_common(struct inode *inode, struct file *file, int isdir);
|
||||
int fuse_fsync_common(struct file *file, struct dentry *de, int datasync,
|
||||
int isdir);
|
||||
|
||||
/**
|
||||
* Notify poll wakeup
|
||||
*/
|
||||
int fuse_notify_poll_wakeup(struct fuse_conn *fc,
|
||||
struct fuse_notify_poll_wakeup_out *outarg);
|
||||
|
||||
/**
|
||||
* Initialize file operations on a regular file
|
||||
*/
|
||||
|
Reference in New Issue
Block a user