vserver 1.9.3
[linux-2.6.git] / include / linux / aio.h
index 93fe788..a4d5af9 100644 (file)
@@ -23,8 +23,6 @@ struct kioctx;
 
 #define KIOCB_SYNC_KEY         (~0U)
 
-#define KIOCB_PRIVATE_SIZE     (24 * sizeof(long))
-
 /* ki_flags bits */
 #define KIF_LOCKED             0
 #define KIF_KICKED             1
@@ -54,7 +52,8 @@ struct kiocb {
        struct file             *ki_filp;
        struct kioctx           *ki_ctx;        /* may be NULL for sync ops */
        int                     (*ki_cancel)(struct kiocb *, struct io_event *);
-       long                    (*ki_retry)(struct kiocb *);
+       ssize_t                 (*ki_retry)(struct kiocb *);
+       void                    (*ki_dtor)(struct kiocb *);
 
        struct list_head        ki_list;        /* the aio core uses this
                                                 * for cancellation */
@@ -65,8 +64,17 @@ struct kiocb {
        } ki_obj;
        __u64                   ki_user_data;   /* user's data for completion */
        loff_t                  ki_pos;
-
-       char                    private[KIOCB_PRIVATE_SIZE];
+       /* State that we remember to be able to restart/retry  */
+       unsigned short          ki_opcode;
+       size_t                  ki_nbytes;      /* copy of iocb->aio_nbytes */
+       char                    __user *ki_buf; /* remaining iocb->aio_buf */
+       size_t                  ki_left;        /* remaining bytes */
+       wait_queue_t            ki_wait;
+       long                    ki_retried;     /* just for testing */
+       long                    ki_kicked;      /* just for testing */
+       long                    ki_queued;      /* just for testing */
+
+       void                    *private;
 };
 
 #define is_sync_kiocb(iocb)    ((iocb)->ki_key == KIOCB_SYNC_KEY)
@@ -79,7 +87,10 @@ struct kiocb {
                (x)->ki_filp = (filp);                  \
                (x)->ki_ctx = &tsk->active_mm->default_kioctx;  \
                (x)->ki_cancel = NULL;                  \
+               (x)->ki_dtor = NULL;                    \
                (x)->ki_obj.tsk = tsk;                  \
+               (x)->ki_user_data = 0;                  \
+               init_wait((&(x)->ki_wait));             \
        } while (0)
 
 #define AIO_RING_MAGIC                 0xa10a10a1
@@ -162,6 +173,20 @@ int FASTCALL(io_submit_one(struct kioctx *ctx, struct iocb __user *user_iocb,
 #define get_ioctx(kioctx)      do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0)
 #define put_ioctx(kioctx)      do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0)
 
+#define in_aio() !is_sync_wait(current->io_wait)
+/* may be used for debugging */
+#define warn_if_async()                                                        \
+do {                                                                   \
+       if (in_aio()) {                                                 \
+               printk(KERN_ERR "%s(%s:%d) called in async context!\n", \
+                       __FUNCTION__, __FILE__, __LINE__);              \
+               dump_stack();                                           \
+       }                                                               \
+} while (0)
+
+#define io_wait_to_kiocb(wait) container_of(wait, struct kiocb, ki_wait)
+#define is_retried_kiocb(iocb) ((iocb)->ki_retried > 1)
+
 #include <linux/aio_abi.h>
 
 static inline struct kiocb *list_kiocb(struct list_head *h)