IO 上下文 io_context

来源:互联网 发布:如何用qq注册淘宝账号 编辑:程序博客网 时间:2024/06/14 08:31
此结构用于跟踪进程的IO处理,此结构可在多个进程之间共享。
/* * I/O subsystem state of the associated processes.  It is refcounted * and kmalloc'ed. These could be shared between processes. */struct io_context {atomic_long_t refcount;atomic_t active_ref;atomic_t nr_tasks;/* all the fields below are protected by this lock */spinlock_t lock;unsigned short ioprio;/* * For request batching */int nr_batch_requests;     /* Number of requests left in the batch */unsigned long last_waited; /* Time last woken after wait for request */struct radix_tree_rooticq_tree;struct io_cq __rcu*icq_hint;struct hlist_headicq_list;struct work_struct release_work;};
函数create_task_io_context()用于创建io_context
int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node){struct io_context *ioc;int ret;ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags |
 __GFP_ZERO,node);if (unlikely(!ioc))return -ENOMEM;/* initialize */atomic_long_set(&ioc->refcount, 1);atomic_set(&ioc->nr_tasks, 1);atomic_set(&ioc->active_ref, 1);spin_lock_init(&ioc->lock);INIT_RADIX_TREE(&ioc->icq_tree, GFP_ATOMIC | __GFP_HIGH);INIT_HLIST_HEAD(&ioc->icq_list);INIT_WORK(&ioc->release_work, ioc_release_fn);/* * Try to install.  ioc shouldn't be installed if someone else * already did or @task, which isn't %current, is exiting.  Note * that we need to allow ioc creation on exiting %current as exit * path may issue IOs from e.g. exit_files().  The exit path is * responsible for not issuing IO after exit_io_context(). */task_lock(task);if (!task->io_context && (task == current || !(task->flags & PF_EXITING)))task->io_context = ioc;elsekmem_cache_free(iocontext_cachep, ioc);ret = task->io_context ? 0 : -EBUSY;task_unlock(task);return ret;}
static struct kmem_cache *iocontext_cachep;
create_task_io_context()
void ioc_release_fn(struct work_struct *work)
int __init blk_ioc_init(void){iocontext_cachep = kmem_cache_create("blkdev_ioc",sizeof(struct io_context), 0, SLAB_PANIC, NULL);return 0;}subsys_initcall(blk_ioc_init);
get_task_io_context
create_task_io_context
set_task_ioprio:ioprio_set, ext4_fill_super, ext4_remount
copy_io:fork
                                             
0 0
原创粉丝点击