md: Fix check for overlapping devices.
[pandora-kernel.git] / include / linux / delayacct.h
index 11487b6..ab94bc0 100644 (file)
  * Used to set current->delays->flags
  */
 #define DELAYACCT_PF_SWAPIN    0x00000001      /* I am doing a swapin */
+#define DELAYACCT_PF_BLKIO     0x00000002      /* I am waiting on IO */
 
 #ifdef CONFIG_TASK_DELAY_ACCT
 
 extern int delayacct_on;       /* Delay accounting turned on/off */
-extern kmem_cache_t *delayacct_cache;
+extern struct kmem_cache *delayacct_cache;
 extern void delayacct_init(void);
 extern void __delayacct_tsk_init(struct task_struct *);
 extern void __delayacct_tsk_exit(struct task_struct *);
@@ -39,6 +40,14 @@ extern void __delayacct_blkio_end(void);
 extern int __delayacct_add_tsk(struct taskstats *, struct task_struct *);
 extern __u64 __delayacct_blkio_ticks(struct task_struct *);
 
+static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
+{
+       if (p->delays)
+               return (p->delays->flags & DELAYACCT_PF_BLKIO);
+       else
+               return 0;
+}
+
 static inline void delayacct_set_flag(int flag)
 {
        if (current->delays)
@@ -59,14 +68,19 @@ static inline void delayacct_tsk_init(struct task_struct *tsk)
                __delayacct_tsk_init(tsk);
 }
 
-static inline void delayacct_tsk_exit(struct task_struct *tsk)
+/* Free tsk->delays. Called from bad fork and __put_task_struct
+ * where there's no risk of tsk->delays being accessed elsewhere
+ */
+static inline void delayacct_tsk_free(struct task_struct *tsk)
 {
        if (tsk->delays)
-               __delayacct_tsk_exit(tsk);
+               kmem_cache_free(delayacct_cache, tsk->delays);
+       tsk->delays = NULL;
 }
 
 static inline void delayacct_blkio_start(void)
 {
+       delayacct_set_flag(DELAYACCT_PF_BLKIO);
        if (current->delays)
                __delayacct_blkio_start();
 }
@@ -75,6 +89,7 @@ static inline void delayacct_blkio_end(void)
 {
        if (current->delays)
                __delayacct_blkio_end();
+       delayacct_clear_flag(DELAYACCT_PF_BLKIO);
 }
 
 static inline int delayacct_add_tsk(struct taskstats *d,
@@ -101,7 +116,7 @@ static inline void delayacct_init(void)
 {}
 static inline void delayacct_tsk_init(struct task_struct *tsk)
 {}
-static inline void delayacct_tsk_exit(struct task_struct *tsk)
+static inline void delayacct_tsk_free(struct task_struct *tsk)
 {}
 static inline void delayacct_blkio_start(void)
 {}
@@ -112,6 +127,8 @@ static inline int delayacct_add_tsk(struct taskstats *d,
 { return 0; }
 static inline __u64 delayacct_blkio_ticks(struct task_struct *tsk)
 { return 0; }
+static inline int delayacct_is_task_waiting_on_io(struct task_struct *p)
+{ return 0; }
 #endif /* CONFIG_TASK_DELAY_ACCT */
 
 #endif