aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-ioc.c
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 /block/blk-ioc.c
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>
Diffstat (limited to 'block/blk-ioc.c')
-rw-r--r--block/blk-ioc.c30
1 files changed, 26 insertions, 4 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",