Skip to content

Commit da9cf50

Browse files
committed
md: avoid spinlock problem in blk_throtl_exit
blk_throtl_exit assumes that ->queue_lock still exists, so make sure that it does. To do this, we stop redirecting ->queue_lock to conf->device_lock and leave it pointing where it is initialised - __queue_lock. As the blk_plug functions check the ->queue_lock is held, we now take that spin_lock explicitly around the plug functions. We don't need the locking, just the warning removal. This is needed for any kernel with the blk_throtl code, which is which is 2.6.37 and later. Cc: stable@kernel.org Signed-off-by: NeilBrown <neilb@suse.de>
1 parent 8f5f02c commit da9cf50

6 files changed

Lines changed: 8 additions & 9 deletions

File tree

‎drivers/md/linear.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ static int linear_run (mddev_t *mddev)
216216

217217
if (md_check_no_bitmap(mddev))
218218
return -EINVAL;
219-
mddev->queue->queue_lock = &mddev->queue->__queue_lock;
220219
conf = linear_conf(mddev, mddev->raid_disks);
221220

222221
if (!conf)

‎drivers/md/multipath.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,6 @@ static int multipath_run (mddev_t *mddev)
435435
* bookkeeping area. [whatever we allocate in multipath_run(),
436436
* should be freed in multipath_stop()]
437437
*/
438-
mddev->queue->queue_lock = &mddev->queue->__queue_lock;
439438

440439
conf = kzalloc(sizeof(multipath_conf_t), GFP_KERNEL);
441440
mddev->private = conf;

‎drivers/md/raid0.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,6 @@ static int raid0_run(mddev_t *mddev)
361361
if (md_check_no_bitmap(mddev))
362362
return -EINVAL;
363363
blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
364-
mddev->queue->queue_lock = &mddev->queue->__queue_lock;
365364

366365
/* if private is not null, we are here after takeover */
367366
if (mddev->private == NULL) {

‎drivers/md/raid1.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,10 @@ static int flush_pending_writes(conf_t *conf)
593593
if (conf->pending_bio_list.head) {
594594
struct bio *bio;
595595
bio = bio_list_get(&conf->pending_bio_list);
596+
/* Only take the spinlock to quiet a warning */
597+
spin_lock(conf->mddev->queue->queue_lock);
596598
blk_remove_plug(conf->mddev->queue);
599+
spin_unlock(conf->mddev->queue->queue_lock);
597600
spin_unlock_irq(&conf->device_lock);
598601
/* flush any pending bitmap writes to
599602
* disk before proceeding w/ I/O */
@@ -959,7 +962,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
959962
atomic_inc(&r1_bio->remaining);
960963
spin_lock_irqsave(&conf->device_lock, flags);
961964
bio_list_add(&conf->pending_bio_list, mbio);
962-
blk_plug_device(mddev->queue);
965+
blk_plug_device_unlocked(mddev->queue);
963966
spin_unlock_irqrestore(&conf->device_lock, flags);
964967
}
965968
r1_bio_write_done(r1_bio, bio->bi_vcnt, behind_pages, behind_pages != NULL);
@@ -2021,7 +2024,6 @@ static int run(mddev_t *mddev)
20212024
if (IS_ERR(conf))
20222025
return PTR_ERR(conf);
20232026

2024-
mddev->queue->queue_lock = &conf->device_lock;
20252027
list_for_each_entry(rdev, &mddev->disks, same_set) {
20262028
disk_stack_limits(mddev->gendisk, rdev->bdev,
20272029
rdev->data_offset << 9);

‎drivers/md/raid10.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,10 @@ static int flush_pending_writes(conf_t *conf)
662662
if (conf->pending_bio_list.head) {
663663
struct bio *bio;
664664
bio = bio_list_get(&conf->pending_bio_list);
665+
/* Spinlock only taken to quiet a warning */
666+
spin_lock(conf->mddev->queue->queue_lock);
665667
blk_remove_plug(conf->mddev->queue);
668+
spin_unlock(conf->mddev->queue->queue_lock);
666669
spin_unlock_irq(&conf->device_lock);
667670
/* flush any pending bitmap writes to disk
668671
* before proceeding w/ I/O */
@@ -971,7 +974,7 @@ static int make_request(mddev_t *mddev, struct bio * bio)
971974
atomic_inc(&r10_bio->remaining);
972975
spin_lock_irqsave(&conf->device_lock, flags);
973976
bio_list_add(&conf->pending_bio_list, mbio);
974-
blk_plug_device(mddev->queue);
977+
blk_plug_device_unlocked(mddev->queue);
975978
spin_unlock_irqrestore(&conf->device_lock, flags);
976979
}
977980

@@ -2304,8 +2307,6 @@ static int run(mddev_t *mddev)
23042307
if (!conf)
23052308
goto out;
23062309

2307-
mddev->queue->queue_lock = &conf->device_lock;
2308-
23092310
mddev->thread = conf->thread;
23102311
conf->thread = NULL;
23112312

‎drivers/md/raid5.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5204,7 +5204,6 @@ static int run(mddev_t *mddev)
52045204

52055205
mddev->queue->backing_dev_info.congested_data = mddev;
52065206
mddev->queue->backing_dev_info.congested_fn = raid5_congested;
5207-
mddev->queue->queue_lock = &conf->device_lock;
52085207
mddev->queue->unplug_fn = raid5_unplug_queue;
52095208

52105209
chunk_size = mddev->chunk_sectors << 9;

0 commit comments

Comments
 (0)