orangefs: delay freeing slot until cancel completes
[deliverable/linux.git] / fs / orangefs / orangefs-kernel.h
index 2b72806d0f68fc26beb1be8683ab744776dad0df..3ceeeaed414327e64c0a1d6f2744639c46aeba80 100644 (file)
@@ -128,7 +128,6 @@ struct client_debug_mask {
 #define ORANGEFS_CACHE_CREATE_FLAGS 0
 #endif /* ((defined ORANGEFS_KERNEL_DEBUG) && (defined CONFIG_DEBUG_SLAB)) */
 
-#define ORANGEFS_CACHE_ALLOC_FLAGS (GFP_KERNEL)
 #define ORANGEFS_GFP_FLAGS (GFP_KERNEL)
 #define ORANGEFS_BUFMAP_GFP_FLAGS (GFP_KERNEL)
 
@@ -191,9 +190,14 @@ struct orangefs_kernel_op_s {
        /*
         * Set uses_shared_memory to 1 if this operation uses shared memory.
         * If true, then a retry on the op must also get a new shared memory
-        * buffer and re-populate it.
+        * buffer and re-populate it.  Cancels don't care - it only matters
+        * for service_operation() retry logics and cancels don't go through
+        * it anymore.
         */
-       int uses_shared_memory;
+       union {
+               int uses_shared_memory;
+               int slot_to_free;
+       };
 
        struct orangefs_upcall_s upcall;
        struct orangefs_downcall_s downcall;
@@ -201,16 +205,12 @@ struct orangefs_kernel_op_s {
        wait_queue_head_t waitq;
        spinlock_t lock;
 
-       int io_completed;
-       wait_queue_head_t io_completion_waitq;
+       struct completion done;
 
        atomic_t ref_count;
 
        /* VFS aio fields */
 
-       /* used by the async I/O code to stash the orangefs_kiocb_s structure */
-       void *priv;
-
        int attempts;
 
        struct list_head list;
@@ -218,22 +218,19 @@ struct orangefs_kernel_op_s {
 
 #define set_op_state_waiting(op)     ((op)->op_state = OP_VFS_STATE_WAITING)
 #define set_op_state_inprogress(op)  ((op)->op_state = OP_VFS_STATE_INPROGR)
+#define set_op_state_given_up(op)  ((op)->op_state = OP_VFS_STATE_GIVEN_UP)
 static inline void set_op_state_serviced(struct orangefs_kernel_op_s *op)
 {
        op->op_state = OP_VFS_STATE_SERVICED;
        wake_up_interruptible(&op->waitq);
 }
-static inline void set_op_state_purged(struct orangefs_kernel_op_s *op)
-{
-       op->op_state |= OP_VFS_STATE_PURGED;
-       wake_up_interruptible(&op->waitq);
-}
 
 #define op_state_waiting(op)     ((op)->op_state & OP_VFS_STATE_WAITING)
 #define op_state_in_progress(op) ((op)->op_state & OP_VFS_STATE_INPROGR)
 #define op_state_serviced(op)    ((op)->op_state & OP_VFS_STATE_SERVICED)
 #define op_state_purged(op)      ((op)->op_state & OP_VFS_STATE_PURGED)
 #define op_state_given_up(op)    ((op)->op_state & OP_VFS_STATE_GIVEN_UP)
+#define op_is_cancel(op)         ((op)->upcall.type == ORANGEFS_VFS_OP_CANCEL)
 
 static inline void get_op(struct orangefs_kernel_op_s *op)
 {
@@ -253,6 +250,27 @@ static inline void op_release(struct orangefs_kernel_op_s *op)
        }
 }
 
+extern void orangefs_bufmap_put(int);
+static inline void put_cancel(struct orangefs_kernel_op_s *op)
+{
+       orangefs_bufmap_put(op->slot_to_free);
+       op_release(op);
+}
+
+static inline void set_op_state_purged(struct orangefs_kernel_op_s *op)
+{
+       spin_lock(&op->lock);
+       if (unlikely(op_is_cancel(op))) {
+               list_del(&op->list);
+               spin_unlock(&op->lock);
+               put_cancel(op);
+       } else {
+               op->op_state |= OP_VFS_STATE_PURGED;
+               wake_up_interruptible(&op->waitq);
+               spin_unlock(&op->lock);
+       }
+}
+
 /* per inode private orangefs info */
 struct orangefs_inode_s {
        struct orangefs_object_kref refn;
@@ -452,21 +470,12 @@ static inline int match_handle(struct orangefs_khandle resp_handle,
 int op_cache_initialize(void);
 int op_cache_finalize(void);
 struct orangefs_kernel_op_s *op_alloc(__s32 type);
+void orangefs_new_tag(struct orangefs_kernel_op_s *op);
 char *get_opname_string(struct orangefs_kernel_op_s *new_op);
 
-int dev_req_cache_initialize(void);
-int dev_req_cache_finalize(void);
-void *dev_req_alloc(void);
-void dev_req_release(void *);
-
 int orangefs_inode_cache_initialize(void);
 int orangefs_inode_cache_finalize(void);
 
-int kiocb_cache_initialize(void);
-int kiocb_cache_finalize(void);
-struct orangefs_kiocb_s *kiocb_alloc(void);
-void kiocb_release(struct orangefs_kiocb_s *ptr);
-
 /*
  * defined in orangefs-mod.c
  */
@@ -507,6 +516,8 @@ int orangefs_getattr(struct vfsmount *mnt,
                  struct dentry *dentry,
                  struct kstat *kstat);
 
+int orangefs_permission(struct inode *inode, int mask);
+
 /*
  * defined in xattr.c
  */
@@ -540,6 +551,7 @@ ssize_t orangefs_inode_read(struct inode *inode,
 int orangefs_dev_init(void);
 void orangefs_dev_cleanup(void);
 int is_daemon_in_service(void);
+bool __is_daemon_in_service(void);
 int fs_mount_pending(__s32 fsid);
 
 /*
@@ -562,12 +574,10 @@ int orangefs_inode_setxattr(struct inode *inode,
                         size_t size,
                         int flags);
 
-int orangefs_inode_getattr(struct inode *inode, __u32 mask);
+int orangefs_inode_getattr(struct inode *inode, __u32 mask, int check);
 
 int orangefs_inode_setattr(struct inode *inode, struct iattr *iattr);
 
-void orangefs_op_initialize(struct orangefs_kernel_op_s *op);
-
 void orangefs_make_bad_inode(struct inode *inode);
 
 void orangefs_block_signals(sigset_t *);
@@ -576,7 +586,7 @@ void orangefs_set_signals(sigset_t *);
 
 int orangefs_unmount_sb(struct super_block *sb);
 
-int orangefs_cancel_op_in_progress(__u64 tag);
+bool orangefs_cancel_op_in_progress(struct orangefs_kernel_op_s *op);
 
 static inline __u64 orangefs_convert_time_field(const struct timespec *ts)
 {
@@ -625,46 +635,6 @@ int service_operation(struct orangefs_kernel_op_s *op,
                      const char *op_name,
                      int flags);
 
-/*
- * handles two possible error cases, depending on context.
- *
- * by design, our vfs i/o errors need to be handled in one of two ways,
- * depending on where the error occured.
- *
- * if the error happens in the waitqueue code because we either timed
- * out or a signal was raised while waiting, we need to cancel the
- * userspace i/o operation and free the op manually.  this is done to
- * avoid having the device start writing application data to our shared
- * bufmap pages without us expecting it.
- *
- * FIXME: POSSIBLE OPTIMIZATION:
- * However, if we timed out or if we got a signal AND our upcall was never
- * picked off the queue (i.e. we were in OP_VFS_STATE_WAITING), then we don't
- * need to send a cancellation upcall. The way we can handle this is
- * set error_exit to 2 in such cases and 1 whenever cancellation has to be
- * sent and have handle_error
- * take care of this situation as well..
- *
- * if a orangefs sysint level error occured and i/o has been completed,
- * there is no need to cancel the operation, as the user has finished
- * using the bufmap page and so there is no danger in this case.  in
- * this case, we wake up the device normally so that it may free the
- * op, as normal.
- *
- * note the only reason this is a macro is because both read and write
- * cases need the exact same handling code.
- */
-#define handle_io_error()                                      \
-do {                                                           \
-       if (!op_state_serviced(new_op)) {                       \
-               orangefs_cancel_op_in_progress(new_op->tag);    \
-       } else {                                                \
-               wake_up_daemon_for_return(new_op);              \
-       }                                                       \
-       orangefs_bufmap_put(bufmap, buffer_index);                              \
-       buffer_index = -1;                                      \
-} while (0)
-
 #define get_interruptible_flag(inode) \
        ((ORANGEFS_SB(inode->i_sb)->flags & ORANGEFS_OPT_INTR) ? \
                ORANGEFS_OP_INTERRUPTIBLE : 0)
This page took 0.025649 seconds and 5 git commands to generate.