Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / fs / fuse / fuse_i.h
index 69c7750..0474202 100644 (file)
@@ -8,13 +8,12 @@
 
 #include <linux/fuse.h>
 #include <linux/fs.h>
-#include <linux/mount.h>
 #include <linux/wait.h>
 #include <linux/list.h>
 #include <linux/spinlock.h>
 #include <linux/mm.h>
 #include <linux/backing-dev.h>
-#include <linux/mutex.h>
+#include <asm/semaphore.h>
 
 /** Max number of pages that can be used in a single read request */
 #define FUSE_MAX_PAGES_PER_REQ 32
@@ -25,9 +24,6 @@
 /** It could be as large as PATH_MAX, but would that have any uses? */
 #define FUSE_NAME_MAX 1024
 
-/** Number of dentries for each connection in the control filesystem */
-#define FUSE_CTL_NUM_DENTRIES 3
-
 /** If the FUSE_DEFAULT_PERMISSIONS flag is given, the filesystem
     module will check permissions based on the file mode.  Otherwise no
     permission checking is done in the kernel */
     doing the mount will be allowed to access the filesystem */
 #define FUSE_ALLOW_OTHER         (1 << 1)
 
-/** List of active connections */
-extern struct list_head fuse_conn_list;
-
-/** Global mutex protecting fuse_conn_list and the control filesystem */
-extern struct mutex fuse_mutex;
 
 /** FUSE inode */
 struct fuse_inode {
@@ -59,13 +50,13 @@ struct fuse_inode {
        struct fuse_req *forget_req;
 
        /** Time in jiffies until the file attributes are valid */
-       u64 i_time;
+       unsigned long i_time;
 };
 
 /** FUSE specific file data */
 struct fuse_file {
        /** Request reserved for flush and release */
-       struct fuse_req *reserved_req;
+       struct fuse_req *release_req;
 
        /** File handle used by userspace */
        u64 fh;
@@ -131,7 +122,6 @@ enum fuse_req_state {
        FUSE_REQ_PENDING,
        FUSE_REQ_READING,
        FUSE_REQ_SENT,
-       FUSE_REQ_WRITING,
        FUSE_REQ_FINISHED
 };
 
@@ -145,15 +135,12 @@ struct fuse_req {
            fuse_conn */
        struct list_head list;
 
-       /** Entry on the interrupts list  */
-       struct list_head intr_entry;
+       /** Entry on the background list */
+       struct list_head bg_entry;
 
        /** refcount */
        atomic_t count;
 
-       /** Unique ID for the interrupt request */
-       u64 intr_unique;
-
        /*
         * The following bitfields are either set once before the
         * request is queued or setting/clearing them is protected by
@@ -163,18 +150,12 @@ struct fuse_req {
        /** True if the request has reply */
        unsigned isreply:1;
 
-       /** Force sending of the request even if interrupted */
-       unsigned force:1;
-
-       /** The request was aborted */
-       unsigned aborted:1;
+       /** The request was interrupted */
+       unsigned interrupted:1;
 
        /** Request is sent in the background */
        unsigned background:1;
 
-       /** The request has been interrupted */
-       unsigned interrupted:1;
-
        /** Data is being copied to/from the request */
        unsigned locked:1;
 
@@ -200,7 +181,6 @@ struct fuse_req {
                struct fuse_init_in init_in;
                struct fuse_init_out init_out;
                struct fuse_read_in read_in;
-               struct fuse_lk_in lk_in;
        } misc;
 
        /** page vector */
@@ -212,20 +192,17 @@ struct fuse_req {
        /** offset of data on first page */
        unsigned page_offset;
 
-       /** File used in the request (or NULL) */
-       struct file *file;
+       /** Inode used in the request */
+       struct inode *inode;
 
-       /** vfsmount used in release */
-       struct vfsmount *vfsmount;
+       /** Second inode used in the request (or NULL) */
+       struct inode *inode2;
 
-       /** dentry used in release */
-       struct dentry *dentry;
+       /** File used in the request (or NULL) */
+       struct file *file;
 
        /** Request completion callback */
        void (*end)(struct fuse_conn *, struct fuse_req *);
-
-       /** Request is stolen from fuse_file->reserved_req */
-       struct file *stolen_file;
 };
 
 /**
@@ -239,9 +216,6 @@ struct fuse_conn {
        /** Lock protecting accessess to  members of this structure */
        spinlock_t lock;
 
-       /** Refcount */
-       atomic_t count;
-
        /** The user id for this mount */
        uid_t user_id;
 
@@ -269,12 +243,13 @@ struct fuse_conn {
        /** The list of requests under I/O */
        struct list_head io;
 
+       /** Requests put in the background (RELEASE or any other
+           interrupted request) */
+       struct list_head background;
+
        /** Number of requests currently in the background */
        unsigned num_background;
 
-       /** Pending interrupts */
-       struct list_head interrupts;
-
        /** Flag indicating if connection is blocked.  This will be
            the case before the INIT reply is received, and if there
            are too many outstading backgrounds requests */
@@ -283,9 +258,15 @@ struct fuse_conn {
        /** waitq for blocked connection */
        wait_queue_head_t blocked_waitq;
 
+       /** RW semaphore for exclusion with fuse_put_super() */
+       struct rw_semaphore sbput_sem;
+
        /** The next unique request id */
        u64 reqctr;
 
+       /** Mount is active */
+       unsigned mounted;
+
        /** Connection established, cleared on umount, connection
            abort and device release */
        unsigned connected;
@@ -324,18 +305,12 @@ struct fuse_conn {
        /** Is removexattr not implemented by fs? */
        unsigned no_removexattr : 1;
 
-       /** Are file locking primitives not implemented by fs? */
-       unsigned no_lock : 1;
-
        /** Is access not implemented by fs? */
        unsigned no_access : 1;
 
        /** Is create not implemented by fs? */
        unsigned no_create : 1;
 
-       /** Is interrupt not implemented by fs? */
-       unsigned no_interrupt : 1;
-
        /** The number of requests waiting for completion */
        atomic_t num_waiting;
 
@@ -345,23 +320,11 @@ struct fuse_conn {
        /** Backing dev info */
        struct backing_dev_info bdi;
 
-       /** Entry on the fuse_conn_list */
-       struct list_head entry;
-
-       /** Unique ID */
-       u64 id;
-
-       /** Dentries in the control filesystem */
-       struct dentry *ctl_dentry[FUSE_CTL_NUM_DENTRIES];
-
-       /** number of dentries used in the above array */
-       int ctl_ndents;
+       /** kobject */
+       struct kobject kobj;
 
        /** O_ASYNC requests */
        struct fasync_struct *fasync;
-
-       /** Key for lock owner ID scrambling */
-       u32 scramble_key[4];
 };
 
 static inline struct fuse_conn *get_fuse_conn_super(struct super_block *sb)
@@ -374,6 +337,11 @@ static inline struct fuse_conn *get_fuse_conn(struct inode *inode)
        return get_fuse_conn_super(inode->i_sb);
 }
 
+static inline struct fuse_conn *get_fuse_conn_kobj(struct kobject *obj)
+{
+       return container_of(obj, struct fuse_conn, kobj);
+}
+
 static inline struct fuse_inode *get_fuse_inode(struct inode *inode)
 {
        return container_of(inode, struct fuse_inode, inode);
@@ -415,9 +383,12 @@ void fuse_file_free(struct fuse_file *ff);
 void fuse_finish_open(struct inode *inode, struct file *file,
                      struct fuse_file *ff, struct fuse_open_out *outarg);
 
-/** */
-struct fuse_req *fuse_release_fill(struct fuse_file *ff, u64 nodeid, int flags,
-                                  int opcode);
+/**
+ * Send a RELEASE request
+ */
+void fuse_send_release(struct fuse_conn *fc, struct fuse_file *ff,
+                      u64 nodeid, struct inode *inode, int flags, int isdir);
+
 /**
  * Send RELEASE or RELEASEDIR request
  */
@@ -464,9 +435,6 @@ int fuse_dev_init(void);
  */
 void fuse_dev_cleanup(void);
 
-int fuse_ctl_init(void);
-void fuse_ctl_cleanup(void);
-
 /**
  * Allocate a request
  */
@@ -478,14 +446,14 @@ struct fuse_req *fuse_request_alloc(void);
 void fuse_request_free(struct fuse_req *req);
 
 /**
- * Get a request, may fail with -ENOMEM
+ * Reinitialize a request, the preallocated flag is left unmodified
  */
-struct fuse_req *fuse_get_req(struct fuse_conn *fc);
+void fuse_reset_request(struct fuse_req *req);
 
 /**
- * Gets a requests for a file operation, always succeeds
+ * Reserve a preallocated request
  */
-struct fuse_req *fuse_get_req_nofail(struct fuse_conn *fc, struct file *file);
+struct fuse_req *fuse_get_req(struct fuse_conn *fc);
 
 /**
  * Decrement reference count of a request.  If count goes to zero free
@@ -508,6 +476,11 @@ void request_send_noreply(struct fuse_conn *fc, struct fuse_req *req);
  */
 void request_send_background(struct fuse_conn *fc, struct fuse_req *req);
 
+/**
+ * Release inodes and file associated with background request
+ */
+void fuse_release_background(struct fuse_conn *fc, struct fuse_req *req);
+
 /* Abort all requests */
 void fuse_abort_conn(struct fuse_conn *fc);
 
@@ -520,23 +493,3 @@ int fuse_do_getattr(struct inode *inode);
  * Invalidate inode attributes
  */
 void fuse_invalidate_attr(struct inode *inode);
-
-/**
- * Acquire reference to fuse_conn
- */
-struct fuse_conn *fuse_conn_get(struct fuse_conn *fc);
-
-/**
- * Release reference to fuse_conn
- */
-void fuse_conn_put(struct fuse_conn *fc);
-
-/**
- * Add connection to control filesystem
- */
-int fuse_ctl_add_conn(struct fuse_conn *fc);
-
-/**
- * Remove connection from control filesystem
- */
-void fuse_ctl_remove_conn(struct fuse_conn *fc);