diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2014-01-13 19:13:05 -0500 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2014-01-14 23:23:03 -0500 |
commit | 55b082e614e219fb5199a6f93e648ed35d3c96d5 (patch) | |
tree | a2707e62bdd914e9651e78cde6cb55a5f0b88d7f /drivers/md/dm-bufio.c | |
parent | 55494bf2947dccdf2d98b62374fea7365dfead84 (diff) |
dm snapshot: use dm-bufio prefetch
This patch modifies dm-snapshot so that it prefetches the buffers when
loading the exceptions.
The number of buffers read ahead is specified in the DM_PREFETCH_CHUNKS
macro. The current value for DM_PREFETCH_CHUNKS (12) was found to
provide the best performance on a single 15k SCSI spindle. In the
future we may modify this default or make it configurable.
Also, introduce the function dm_bufio_set_minimum_buffers to setup
bufio's number of internal buffers before freeing happens. dm-bufio may
hold more buffers if enough memory is available. There is no guarantee
that the specified number of buffers will be available - if you need a
guarantee, use the argument reserved_buffers for
dm_bufio_client_create.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-bufio.c')
-rw-r--r-- | drivers/md/dm-bufio.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index d86593721915..9ed42125514b 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c | |||
@@ -104,6 +104,8 @@ struct dm_bufio_client { | |||
104 | struct list_head reserved_buffers; | 104 | struct list_head reserved_buffers; |
105 | unsigned need_reserved_buffers; | 105 | unsigned need_reserved_buffers; |
106 | 106 | ||
107 | unsigned minimum_buffers; | ||
108 | |||
107 | struct hlist_head *cache_hash; | 109 | struct hlist_head *cache_hash; |
108 | wait_queue_head_t free_buffer_wait; | 110 | wait_queue_head_t free_buffer_wait; |
109 | 111 | ||
@@ -861,8 +863,8 @@ static void __get_memory_limit(struct dm_bufio_client *c, | |||
861 | buffers = dm_bufio_cache_size_per_client >> | 863 | buffers = dm_bufio_cache_size_per_client >> |
862 | (c->sectors_per_block_bits + SECTOR_SHIFT); | 864 | (c->sectors_per_block_bits + SECTOR_SHIFT); |
863 | 865 | ||
864 | if (buffers < DM_BUFIO_MIN_BUFFERS) | 866 | if (buffers < c->minimum_buffers) |
865 | buffers = DM_BUFIO_MIN_BUFFERS; | 867 | buffers = c->minimum_buffers; |
866 | 868 | ||
867 | *limit_buffers = buffers; | 869 | *limit_buffers = buffers; |
868 | *threshold_buffers = buffers * DM_BUFIO_WRITEBACK_PERCENT / 100; | 870 | *threshold_buffers = buffers * DM_BUFIO_WRITEBACK_PERCENT / 100; |
@@ -1372,6 +1374,12 @@ void dm_bufio_forget(struct dm_bufio_client *c, sector_t block) | |||
1372 | } | 1374 | } |
1373 | EXPORT_SYMBOL(dm_bufio_forget); | 1375 | EXPORT_SYMBOL(dm_bufio_forget); |
1374 | 1376 | ||
1377 | void dm_bufio_set_minimum_buffers(struct dm_bufio_client *c, unsigned n) | ||
1378 | { | ||
1379 | c->minimum_buffers = n; | ||
1380 | } | ||
1381 | EXPORT_SYMBOL(dm_bufio_set_minimum_buffers); | ||
1382 | |||
1375 | unsigned dm_bufio_get_block_size(struct dm_bufio_client *c) | 1383 | unsigned dm_bufio_get_block_size(struct dm_bufio_client *c) |
1376 | { | 1384 | { |
1377 | return c->block_size; | 1385 | return c->block_size; |
@@ -1568,6 +1576,8 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign | |||
1568 | INIT_LIST_HEAD(&c->reserved_buffers); | 1576 | INIT_LIST_HEAD(&c->reserved_buffers); |
1569 | c->need_reserved_buffers = reserved_buffers; | 1577 | c->need_reserved_buffers = reserved_buffers; |
1570 | 1578 | ||
1579 | c->minimum_buffers = DM_BUFIO_MIN_BUFFERS; | ||
1580 | |||
1571 | init_waitqueue_head(&c->free_buffer_wait); | 1581 | init_waitqueue_head(&c->free_buffer_wait); |
1572 | c->async_write_error = 0; | 1582 | c->async_write_error = 0; |
1573 | 1583 | ||