aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/loop.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 16:39:11 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-17 16:39:11 -0500
commit9228ff90387e276ad67b10c0eb525c9d6a57d5e9 (patch)
treee7c87b68daba7cf7ca4c342c6b52165bd78fbe16 /drivers/block/loop.c
parent9360b53661a2c7754517b2925580055bacc8ec38 (diff)
parentd2ec180c23a5a1bfe34d8638b0342a47c00cf70f (diff)
Merge branch 'for-3.8/drivers' of git://git.kernel.dk/linux-block
Pull block driver update from Jens Axboe: "Now that the core bits are in, here are the driver bits for 3.8. The branch contains: - A huge pile of drbd bits that were dumped from the 3.7 merge window. Following that, it was both made perfectly clear that there is going to be no more over-the-wall pulls and how the situation on individual pulls can be improved. - A few cleanups from Akinobu Mita for drbd and cciss. - Queue improvement for loop from Lukas. This grew into adding a generic interface for waiting/checking an even with a specific lock, allowing this to be pulled out of md and now loop and drbd is also using it. - A few fixes for xen back/front block driver from Roger Pau Monne. - Partition improvements from Stephen Warren, allowing partiion UUID to be used as an identifier." * 'for-3.8/drivers' of git://git.kernel.dk/linux-block: (609 commits) drbd: update Kconfig to match current dependencies drbd: Fix drbdsetup wait-connect, wait-sync etc... commands drbd: close race between drbd_set_role and drbd_connect drbd: respect no-md-barriers setting also when changed online via disk-options drbd: Remove obsolete check drbd: fixup after wait_even_lock_irq() addition to generic code loop: Limit the number of requests in the bio list wait: add wait_event_lock_irq() interface xen-blkfront: free allocated page xen-blkback: move free persistent grants code block: partition: msdos: provide UUIDs for partitions init: reduce PARTUUID min length to 1 from 36 block: store partition_meta_info.uuid as a string cciss: use check_signature() cciss: cleanup bitops usage drbd: use copy_highpage drbd: if the replication link breaks during handshake, keep retrying drbd: check return of kmalloc in receive_uuids drbd: Broadcast sync progress no more often than once per second drbd: don't try to clear bits once the disk has failed ...
Diffstat (limited to 'drivers/block/loop.c')
-rw-r--r--drivers/block/loop.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index 54046e51160a..ae1251270624 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -463,6 +463,7 @@ out:
463 */ 463 */
464static void loop_add_bio(struct loop_device *lo, struct bio *bio) 464static void loop_add_bio(struct loop_device *lo, struct bio *bio)
465{ 465{
466 lo->lo_bio_count++;
466 bio_list_add(&lo->lo_bio_list, bio); 467 bio_list_add(&lo->lo_bio_list, bio);
467} 468}
468 469
@@ -471,6 +472,7 @@ static void loop_add_bio(struct loop_device *lo, struct bio *bio)
471 */ 472 */
472static struct bio *loop_get_bio(struct loop_device *lo) 473static struct bio *loop_get_bio(struct loop_device *lo)
473{ 474{
475 lo->lo_bio_count--;
474 return bio_list_pop(&lo->lo_bio_list); 476 return bio_list_pop(&lo->lo_bio_list);
475} 477}
476 478
@@ -489,6 +491,10 @@ static void loop_make_request(struct request_queue *q, struct bio *old_bio)
489 goto out; 491 goto out;
490 if (unlikely(rw == WRITE && (lo->lo_flags & LO_FLAGS_READ_ONLY))) 492 if (unlikely(rw == WRITE && (lo->lo_flags & LO_FLAGS_READ_ONLY)))
491 goto out; 493 goto out;
494 if (lo->lo_bio_count >= q->nr_congestion_on)
495 wait_event_lock_irq(lo->lo_req_wait,
496 lo->lo_bio_count < q->nr_congestion_off,
497 lo->lo_lock);
492 loop_add_bio(lo, old_bio); 498 loop_add_bio(lo, old_bio);
493 wake_up(&lo->lo_event); 499 wake_up(&lo->lo_event);
494 spin_unlock_irq(&lo->lo_lock); 500 spin_unlock_irq(&lo->lo_lock);
@@ -546,6 +552,8 @@ static int loop_thread(void *data)
546 continue; 552 continue;
547 spin_lock_irq(&lo->lo_lock); 553 spin_lock_irq(&lo->lo_lock);
548 bio = loop_get_bio(lo); 554 bio = loop_get_bio(lo);
555 if (lo->lo_bio_count < lo->lo_queue->nr_congestion_off)
556 wake_up(&lo->lo_req_wait);
549 spin_unlock_irq(&lo->lo_lock); 557 spin_unlock_irq(&lo->lo_lock);
550 558
551 BUG_ON(!bio); 559 BUG_ON(!bio);
@@ -873,6 +881,7 @@ static int loop_set_fd(struct loop_device *lo, fmode_t mode,
873 lo->transfer = transfer_none; 881 lo->transfer = transfer_none;
874 lo->ioctl = NULL; 882 lo->ioctl = NULL;
875 lo->lo_sizelimit = 0; 883 lo->lo_sizelimit = 0;
884 lo->lo_bio_count = 0;
876 lo->old_gfp_mask = mapping_gfp_mask(mapping); 885 lo->old_gfp_mask = mapping_gfp_mask(mapping);
877 mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS)); 886 mapping_set_gfp_mask(mapping, lo->old_gfp_mask & ~(__GFP_IO|__GFP_FS));
878 887
@@ -1673,6 +1682,7 @@ static int loop_add(struct loop_device **l, int i)
1673 lo->lo_number = i; 1682 lo->lo_number = i;
1674 lo->lo_thread = NULL; 1683 lo->lo_thread = NULL;
1675 init_waitqueue_head(&lo->lo_event); 1684 init_waitqueue_head(&lo->lo_event);
1685 init_waitqueue_head(&lo->lo_req_wait);
1676 spin_lock_init(&lo->lo_lock); 1686 spin_lock_init(&lo->lo_lock);
1677 disk->major = LOOP_MAJOR; 1687 disk->major = LOOP_MAJOR;
1678 disk->first_minor = i << part_shift; 1688 disk->first_minor = i << part_shift;