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
8989 return -EBUSY;
9090
9191 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));
9394 if (blk_queue_dying(q))
9495 return -ENODEV;
9596 if (ret)
@@ -112,13 +113,10 @@ static void blk_mq_usage_counter_release(struct percpu_ref *ref) · 16 unmodified lines
112113
113114 void blk_mq_freeze_queue_start(struct request_queue *q)
114115 {
115− bool freeze;
116+ int freeze_depth;
116117
117− spin_lock_irq(q->queue_lock);
118− freeze = !q->mq_freeze_depth++;
119− spin_unlock_irq(q->queue_lock);
120−
121− if (freeze) {
118+ freeze_depth = atomic_inc_return(&q->mq_freeze_depth);
119+ if (freeze_depth == 1) {
122120 percpu_ref_kill(&q->mq_usage_counter);
123121 blk_mq_run_hw_queues(q, false);
124122 }
@@ -143,13 +141,11 @@ EXPORT_SYMBOL_GPL(blk_mq_freeze_queue); · 18 unmodified lines
143141
144142 void blk_mq_unfreeze_queue(struct request_queue *q)
145143 {
146− bool wake;
144+ int freeze_depth;
147145
148− spin_lock_irq(q->queue_lock);
149− wake = !--q->mq_freeze_depth;
150− WARN_ON_ONCE(q->mq_freeze_depth < 0);
151− spin_unlock_irq(q->queue_lock);
152− if (wake) {
146+ freeze_depth = atomic_dec_return(&q->mq_freeze_depth);
147+ WARN_ON_ONCE(freeze_depth < 0);
148+ if (!freeze_depth) {
153149 percpu_ref_reinit(&q->mq_usage_counter);
154150 wake_up_all(&q->mq_freeze_wq);
155151 }
@@ -2081,7 +2077,7 @@ void blk_mq_free_queue(struct request_queue *q) · 1925 unmodified lines
20812077 /* Basically redo blk_mq_init_queue with queue frozen */
20822078 static void blk_mq_queue_reinit(struct request_queue *q)
20832079 {
2084− WARN_ON_ONCE(!q->mq_freeze_depth);
2080+ WARN_ON_ONCE(!atomic_read(&q->mq_freeze_depth));
20852081
20862082 blk_mq_sysfs_unregister(q);
20872083
include/linux/blkdev.h+1−1
@@ -444,7 +444,7 @@ struct request_queue { · 443 unmodified lines
444444 struct mutex sysfs_lock;
445445
446446 int bypass_depth;
447− int mq_freeze_depth;
447+ atomic_t mq_freeze_depth;
448448
449449 #if defined(CONFIG_BLK_DEV_BSG)
450450 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