linux/include/linux/iocontext.h
<<
>>
Prefs
   1#ifndef IOCONTEXT_H
   2#define IOCONTEXT_H
   3
   4#include <linux/radix-tree.h>
   5#include <linux/rcupdate.h>
   6
   7struct cfq_queue;
   8struct cfq_io_context {
   9        void *key;
  10        unsigned long dead_key;
  11
  12        struct cfq_queue *cfqq[2];
  13
  14        struct io_context *ioc;
  15
  16        unsigned long last_end_request;
  17
  18        unsigned long ttime_total;
  19        unsigned long ttime_samples;
  20        unsigned long ttime_mean;
  21
  22        struct list_head queue_list;
  23        struct hlist_node cic_list;
  24
  25        void (*dtor)(struct io_context *); /* destructor */
  26        void (*exit)(struct io_context *); /* called on task exit */
  27
  28        struct rcu_head rcu_head;
  29};
  30
  31/*
  32 * I/O subsystem state of the associated processes.  It is refcounted
  33 * and kmalloc'ed. These could be shared between processes.
  34 */
  35struct io_context {
  36        atomic_long_t refcount;
  37        atomic_t nr_tasks;
  38
  39        /* all the fields below are protected by this lock */
  40        spinlock_t lock;
  41
  42        unsigned short ioprio;
  43        unsigned short ioprio_changed;
  44
  45#ifdef CONFIG_BLK_CGROUP
  46        unsigned short cgroup_changed;
  47#endif
  48
  49        /*
  50         * For request batching
  51         */
  52        unsigned long last_waited; /* Time last woken after wait for request */
  53        int nr_batch_requests;     /* Number of requests left in the batch */
  54
  55        struct radix_tree_root radix_root;
  56        struct hlist_head cic_list;
  57        void *ioc_data;
  58};
  59
  60static inline struct io_context *ioc_task_link(struct io_context *ioc)
  61{
  62        /*
  63         * if ref count is zero, don't allow sharing (ioc is going away, it's
  64         * a race).
  65         */
  66        if (ioc && atomic_long_inc_not_zero(&ioc->refcount)) {
  67                atomic_inc(&ioc->nr_tasks);
  68                return ioc;
  69        }
  70
  71        return NULL;
  72}
  73
  74struct task_struct;
  75#ifdef CONFIG_BLOCK
  76int put_io_context(struct io_context *ioc);
  77void exit_io_context(struct task_struct *task);
  78struct io_context *get_io_context(gfp_t gfp_flags, int node);
  79struct io_context *alloc_io_context(gfp_t gfp_flags, int node);
  80void copy_io_context(struct io_context **pdst, struct io_context **psrc);
  81#else
  82static inline void exit_io_context(struct task_struct *task)
  83{
  84}
  85
  86struct io_context;
  87static inline int put_io_context(struct io_context *ioc)
  88{
  89        return 1;
  90}
  91#endif
  92
  93#endif
  94
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.