summaryrefslogtreecommitdiffstats
path: root/include/linux/loop.h
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2012-11-30 11:42:41 +0100
committerJens Axboe <axboe@kernel.dk>2012-11-30 11:48:05 +0100
commit7b5a35225b0d4fd779cf79d7624e63d1957f6c4d (patch)
tree5e2324e3b657b8ead9c0cdd58c6ed5d79f8e76f8 /include/linux/loop.h
parenteed8c02e680c04cd737e0a9cef74e68d8eb0cefa (diff)
downloadop-kernel-dev-7b5a35225b0d4fd779cf79d7624e63d1957f6c4d.zip
op-kernel-dev-7b5a35225b0d4fd779cf79d7624e63d1957f6c4d.tar.gz
loop: Limit the number of requests in the bio list
Currently there is not limitation of number of requests in the loop bio list. This can lead into some nasty situations when the caller spawns tons of bio requests taking huge amount of memory. This is even more obvious with discard where blkdev_issue_discard() will submit all bios for the range and wait for them to finish afterwards. On really big loop devices and slow backing file system this can lead to OOM situation as reported by Dave Chinner. With this patch we will wait in loop_make_request() if the number of bios in the loop bio list would exceed 'nr_congestion_on'. We'll wake up the process as we process the bios form the list. Some threshold hysteresis is in place to avoid high frequency oscillation. Signed-off-by: Lukas Czerner <lczerner@redhat.com> Reported-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/loop.h')
-rw-r--r--include/linux/loop.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/include/linux/loop.h b/include/linux/loop.h
index 6492181..460b60f 100644
--- a/include/linux/loop.h
+++ b/include/linux/loop.h
@@ -53,10 +53,13 @@ struct loop_device {
spinlock_t lo_lock;
struct bio_list lo_bio_list;
+ unsigned int lo_bio_count;
int lo_state;
struct mutex lo_ctl_mutex;
struct task_struct *lo_thread;
wait_queue_head_t lo_event;
+ /* wait queue for incoming requests */
+ wait_queue_head_t lo_req_wait;
struct request_queue *lo_queue;
struct gendisk *lo_disk;
OpenPOWER on IntegriCloud