diff options
| author | Jens Axboe <jens.axboe@oracle.com> | 2008-01-24 02:53:35 -0500 |
|---|---|---|
| committer | Jens Axboe <jens.axboe@oracle.com> | 2008-01-28 04:50:31 -0500 |
| commit | d38ecf935fcb10264a6bc190855d9595165e6eeb (patch) | |
| tree | 64e3146ef76678ad3ae8f75c32df9f25ea470953 /include/linux | |
| parent | fd0928df98b9578be8a786ac0cb78a47a5e17a20 (diff) | |
io context sharing: preliminary support
Detach task state from ioc, instead keep track of how many processes
are accessing the ioc.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/blkdev.h | 2 | ||||
| -rw-r--r-- | include/linux/iocontext.h | 22 |
2 files changed, 19 insertions, 5 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 510a18ba1ec..2483a05231c 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
| @@ -34,7 +34,7 @@ struct sg_io_hdr; | |||
| 34 | #define BLKDEV_MIN_RQ 4 | 34 | #define BLKDEV_MIN_RQ 4 |
| 35 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ | 35 | #define BLKDEV_MAX_RQ 128 /* Default maximum */ |
| 36 | 36 | ||
| 37 | void put_io_context(struct io_context *ioc); | 37 | int put_io_context(struct io_context *ioc); |
| 38 | void exit_io_context(void); | 38 | void exit_io_context(void); |
| 39 | struct io_context *get_io_context(gfp_t gfp_flags, int node); | 39 | struct io_context *get_io_context(gfp_t gfp_flags, int node); |
| 40 | struct io_context *alloc_io_context(gfp_t gfp_flags, int node); | 40 | struct io_context *alloc_io_context(gfp_t gfp_flags, int node); |
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h index 186807ea62e..cd44d458124 100644 --- a/include/linux/iocontext.h +++ b/include/linux/iocontext.h | |||
| @@ -54,13 +54,15 @@ struct cfq_io_context { | |||
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | /* | 56 | /* |
| 57 | * This is the per-process I/O subsystem state. It is refcounted and | 57 | * I/O subsystem state of the associated processes. It is refcounted |
| 58 | * kmalloc'ed. Currently all fields are modified in process io context | 58 | * and kmalloc'ed. These could be shared between processes. |
| 59 | * (apart from the atomic refcount), so require no locking. | ||
| 60 | */ | 59 | */ |
| 61 | struct io_context { | 60 | struct io_context { |
| 62 | atomic_t refcount; | 61 | atomic_t refcount; |
| 63 | struct task_struct *task; | 62 | atomic_t nr_tasks; |
| 63 | |||
| 64 | /* all the fields below are protected by this lock */ | ||
| 65 | spinlock_t lock; | ||
| 64 | 66 | ||
| 65 | unsigned short ioprio; | 67 | unsigned short ioprio; |
| 66 | unsigned short ioprio_changed; | 68 | unsigned short ioprio_changed; |
| @@ -76,4 +78,16 @@ struct io_context { | |||
| 76 | void *ioc_data; | 78 | void *ioc_data; |
| 77 | }; | 79 | }; |
| 78 | 80 | ||
| 81 | static inline struct io_context *ioc_task_link(struct io_context *ioc) | ||
| 82 | { | ||
| 83 | /* | ||
| 84 | * if ref count is zero, don't allow sharing (ioc is going away, it's | ||
| 85 | * a race). | ||
| 86 | */ | ||
| 87 | if (ioc && atomic_inc_not_zero(&ioc->refcount)) | ||
| 88 | return ioc; | ||
| 89 | |||
| 90 | return NULL; | ||
| 91 | } | ||
| 92 | |||
| 79 | #endif | 93 | #endif |
