aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2012-02-15 03:45:49 -0500
committerJens Axboe <axboe@kernel.dk>2012-02-15 03:45:49 -0500
commitd705ae6b133f9f6a8beee617b1224b6a5c99c5da (patch)
treeb1a0b09ae01f8385e66c021c338106b88e8d23f8
parent7ada1dd62804ca9ce1cb8666c6e563cd92fa50c1 (diff)
block: replace icq->changed with icq->flags
icq->changed was used for ICQ_*_CHANGED bits. Rename it to flags and access it under ioc->lock instead of using atomic bitops. ioc_get_changed() is added so that the changed part can be fetched and cleared as before. icq->flags will be used to carry other flags. Signed-off-by: Tejun Heo <tj@kernel.org> Tested-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--block/blk-ioc.c30
-rw-r--r--block/cfq-iosched.c12
-rw-r--r--include/linux/iocontext.h9
3 files changed, 38 insertions, 13 deletions
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 8b782a63c297..811879c752e4 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -363,13 +363,13 @@ struct io_cq *ioc_create_icq(struct request_queue *q, gfp_t gfp_mask)
363 return icq; 363 return icq;
364} 364}
365 365
366void ioc_set_changed(struct io_context *ioc, int which) 366void ioc_set_icq_flags(struct io_context *ioc, unsigned int flags)
367{ 367{
368 struct io_cq *icq; 368 struct io_cq *icq;
369 struct hlist_node *n; 369 struct hlist_node *n;
370 370
371 hlist_for_each_entry(icq, n, &ioc->icq_list, ioc_node) 371 hlist_for_each_entry(icq, n, &ioc->icq_list, ioc_node)
372 set_bit(which, &icq->changed); 372 icq->flags |= flags;
373} 373}
374 374
375/** 375/**
@@ -387,7 +387,7 @@ void ioc_ioprio_changed(struct io_context *ioc, int ioprio)
387 387
388 spin_lock_irqsave(&ioc->lock, flags); 388 spin_lock_irqsave(&ioc->lock, flags);
389 ioc->ioprio = ioprio; 389 ioc->ioprio = ioprio;
390 ioc_set_changed(ioc, ICQ_IOPRIO_CHANGED); 390 ioc_set_icq_flags(ioc, ICQ_IOPRIO_CHANGED);
391 spin_unlock_irqrestore(&ioc->lock, flags); 391 spin_unlock_irqrestore(&ioc->lock, flags);
392} 392}
393 393
@@ -404,11 +404,33 @@ void ioc_cgroup_changed(struct io_context *ioc)
404 unsigned long flags; 404 unsigned long flags;
405 405
406 spin_lock_irqsave(&ioc->lock, flags); 406 spin_lock_irqsave(&ioc->lock, flags);
407 ioc_set_changed(ioc, ICQ_CGROUP_CHANGED); 407 ioc_set_icq_flags(ioc, ICQ_CGROUP_CHANGED);
408 spin_unlock_irqrestore(&ioc->lock, flags); 408 spin_unlock_irqrestore(&ioc->lock, flags);
409} 409}
410EXPORT_SYMBOL(ioc_cgroup_changed); 410EXPORT_SYMBOL(ioc_cgroup_changed);
411 411
412/**
413 * icq_get_changed - fetch and clear icq changed mask
414 * @icq: icq of interest
415 *
416 * Fetch and clear ICQ_*_CHANGED bits from @icq. Grabs and releases
417 * @icq->ioc->lock.
418 */
419unsigned icq_get_changed(struct io_cq *icq)
420{
421 unsigned int changed = 0;
422 unsigned long flags;
423
424 if (unlikely(icq->flags & ICQ_CHANGED_MASK)) {
425 spin_lock_irqsave(&icq->ioc->lock, flags);
426 changed = icq->flags & ICQ_CHANGED_MASK;
427 icq->flags &= ~ICQ_CHANGED_MASK;
428 spin_unlock_irqrestore(&icq->ioc->lock, flags);
429 }
430 return changed;
431}
432EXPORT_SYMBOL(icq_get_changed);
433
412static int __init blk_ioc_init(void) 434static int __init blk_ioc_init(void)
413{ 435{
414 iocontext_cachep = kmem_cache_create("blkdev_ioc", 436 iocontext_cachep = kmem_cache_create("blkdev_ioc",
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index d0ba50533668..457295253566 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -3470,20 +3470,20 @@ cfq_set_request(struct request_queue *q, struct request *rq, gfp_t gfp_mask)
3470 const int rw = rq_data_dir(rq); 3470 const int rw = rq_data_dir(rq);
3471 const bool is_sync = rq_is_sync(rq); 3471 const bool is_sync = rq_is_sync(rq);
3472 struct cfq_queue *cfqq; 3472 struct cfq_queue *cfqq;
3473 unsigned int changed;
3473 3474
3474 might_sleep_if(gfp_mask & __GFP_WAIT); 3475 might_sleep_if(gfp_mask & __GFP_WAIT);
3475 3476
3476 spin_lock_irq(q->queue_lock); 3477 spin_lock_irq(q->queue_lock);
3477 3478
3478 /* handle changed notifications */ 3479 /* handle changed notifications */
3479 if (unlikely(cic->icq.changed)) { 3480 changed = icq_get_changed(&cic->icq);
3480 if (test_and_clear_bit(ICQ_IOPRIO_CHANGED, &cic->icq.changed)) 3481 if (unlikely(changed & ICQ_IOPRIO_CHANGED))
3481 changed_ioprio(cic); 3482 changed_ioprio(cic);
3482#ifdef CONFIG_CFQ_GROUP_IOSCHED 3483#ifdef CONFIG_CFQ_GROUP_IOSCHED
3483 if (test_and_clear_bit(ICQ_CGROUP_CHANGED, &cic->icq.changed)) 3484 if (unlikely(changed & ICQ_CGROUP_CHANGED))
3484 changed_cgroup(cic); 3485 changed_cgroup(cic);
3485#endif 3486#endif
3486 }
3487 3487
3488new_queue: 3488new_queue:
3489 cfqq = cic_to_cfqq(cic, is_sync); 3489 cfqq = cic_to_cfqq(cic, is_sync);
diff --git a/include/linux/iocontext.h b/include/linux/iocontext.h
index 119773eebe31..17839c7b9614 100644
--- a/include/linux/iocontext.h
+++ b/include/linux/iocontext.h
@@ -6,8 +6,10 @@
6#include <linux/workqueue.h> 6#include <linux/workqueue.h>
7 7
8enum { 8enum {
9 ICQ_IOPRIO_CHANGED, 9 ICQ_IOPRIO_CHANGED = 1 << 0,
10 ICQ_CGROUP_CHANGED, 10 ICQ_CGROUP_CHANGED = 1 << 1,
11
12 ICQ_CHANGED_MASK = ICQ_IOPRIO_CHANGED | ICQ_CGROUP_CHANGED,
11}; 13};
12 14
13/* 15/*
@@ -88,7 +90,7 @@ struct io_cq {
88 struct rcu_head __rcu_head; 90 struct rcu_head __rcu_head;
89 }; 91 };
90 92
91 unsigned long changed; 93 unsigned int flags;
92}; 94};
93 95
94/* 96/*
@@ -139,6 +141,7 @@ struct io_context *get_task_io_context(struct task_struct *task,
139 gfp_t gfp_flags, int node); 141 gfp_t gfp_flags, int node);
140void ioc_ioprio_changed(struct io_context *ioc, int ioprio); 142void ioc_ioprio_changed(struct io_context *ioc, int ioprio);
141void ioc_cgroup_changed(struct io_context *ioc); 143void ioc_cgroup_changed(struct io_context *ioc);
144unsigned int icq_get_changed(struct io_cq *icq);
142#else 145#else
143struct io_context; 146struct io_context;
144static inline void put_io_context(struct io_context *ioc) { } 147static inline void put_io_context(struct io_context *ioc) { }