History

block: use an atomic_t for mq_freeze_depth

lockdep gets unhappy about the not disabling irqs when using the queue_lock around it. Instead of trying to fix that up just switch to an atomic_t and get rid of the lock.

Christoph Hellwig committed 11 years ago

Commit 4ecd4fe1 parent 5b3f3412 files · +11 −15Browse files

Unified · Split

2 files
  1. block/blk-mq.c +10 −14
  2. include/linux/blkdev.h +1 −1
block/blk-mq.c+10−14
@@ -89,7 +89,8 @@ static int blk_mq_queue_enter(struct request_queue *q, gfp_t gfp) · 88 unmodified lines
89 return -EBUSY;89 return -EBUSY;
90 90
91 ret = wait_event_interruptible(q->mq_freeze_wq,91 ret = wait_event_interruptible(q->mq_freeze_wq,
92 !q->mq_freeze_depth || blk_queue_dying(q));92 !atomic_read(&q->mq_freeze_depth) ||
93 blk_queue_dying(q));
93 if (blk_queue_dying(q))94 if (blk_queue_dying(q))
94 return -ENODEV;95 return -ENODEV;
95 if (ret)96 if (ret)
@@ -112,13 +113,10 @@ static void blk_mq_usage_counter_release(struct percpu_ref *ref) · 16 unmodified lines
112 113
113void blk_mq_freeze_queue_start(struct request_queue *q)114void blk_mq_freeze_queue_start(struct request_queue *q)
114{115{
115 bool freeze;116 int freeze_depth;
116 117
117 spin_lock_irq(q->queue_lock);118 freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
118 freeze = !q->mq_freeze_depth++;119 if (freeze_depth == 1) {
119 spin_unlock_irq(q->queue_lock);
120
121 if (freeze) {
122 percpu_ref_kill(&q->mq_usage_counter);120 percpu_ref_kill(&q->mq_usage_counter);
123 blk_mq_run_hw_queues(q, false);121 blk_mq_run_hw_queues(q, false);
124 }122 }
@@ -143,13 +141,11 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue); · 18 unmodified lines
143 141
144void blk_mq_unfreeze_queue(struct request_queue *q)142void blk_mq_unfreeze_queue(struct request_queue *q)
145{143{
146 bool wake;144 int freeze_depth;
147 145
148 spin_lock_irq(q->queue_lock);146 freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
149 wake = !--q->mq_freeze_depth;147 WARN_ON_ONCE(freeze_depth < 0);
150 WARN_ON_ONCE(q->mq_freeze_depth < 0);148 if (!freeze_depth) {
151 spin_unlock_irq(q->queue_lock);
152 if (wake) {
153 percpu_ref_reinit(&q->mq_usage_counter);149 percpu_ref_reinit(&q->mq_usage_counter);
154 wake_up_all(&q->mq_freeze_wq);150 wake_up_all(&q->mq_freeze_wq);
155 }151 }
@@ -2081,7 +2077,7 @@ void blk_mq_free_queue(struct request_queue *q) · 1925 unmodified lines
2081/* Basically redo blk_mq_init_queue with queue frozen */2077/* Basically redo blk_mq_init_queue with queue frozen */
2082static void blk_mq_queue_reinit(struct request_queue *q)2078static void blk_mq_queue_reinit(struct request_queue *q)
2083{2079{
2084 WARN_ON_ONCE(!q->mq_freeze_depth);2080 WARN_ON_ONCE(!atomic_read(&q->mq_freeze_depth));
2085 2081
2086 blk_mq_sysfs_unregister(q);2082 blk_mq_sysfs_unregister(q);
2087 2083
include/linux/blkdev.h+1−1
@@ -444,7 +444,7 @@ struct request_queue { · 443 unmodified lines
444 struct mutex sysfs_lock;444 struct mutex sysfs_lock;
445 445
446 int bypass_depth;446 int bypass_depth;
447 int mq_freeze_depth;447 atomic_t mq_freeze_depth;
448 448
449#if defined(CONFIG_BLK_DEV_BSG)449#if defined(CONFIG_BLK_DEV_BSG)
450 bsg_job_fn *bsg_job_fn;450 bsg_job_fn *bsg_job_fn;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t