diff options
Diffstat (limited to 'drivers/md/dm-io.c')
| -rw-r--r-- | drivers/md/dm-io.c | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 76a5af00a26..2067288f61f 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c | |||
| @@ -19,6 +19,8 @@ | |||
| 19 | #define DM_MSG_PREFIX "io" | 19 | #define DM_MSG_PREFIX "io" |
| 20 | 20 | ||
| 21 | #define DM_IO_MAX_REGIONS BITS_PER_LONG | 21 | #define DM_IO_MAX_REGIONS BITS_PER_LONG |
| 22 | #define MIN_IOS 16 | ||
| 23 | #define MIN_BIOS 16 | ||
| 22 | 24 | ||
| 23 | struct dm_io_client { | 25 | struct dm_io_client { |
| 24 | mempool_t *pool; | 26 | mempool_t *pool; |
| @@ -41,33 +43,21 @@ struct io { | |||
| 41 | static struct kmem_cache *_dm_io_cache; | 43 | static struct kmem_cache *_dm_io_cache; |
| 42 | 44 | ||
| 43 | /* | 45 | /* |
| 44 | * io contexts are only dynamically allocated for asynchronous | ||
| 45 | * io. Since async io is likely to be the majority of io we'll | ||
| 46 | * have the same number of io contexts as bios! (FIXME: must reduce this). | ||
| 47 | */ | ||
| 48 | |||
| 49 | static unsigned int pages_to_ios(unsigned int pages) | ||
| 50 | { | ||
| 51 | return 4 * pages; /* too many ? */ | ||
| 52 | } | ||
| 53 | |||
| 54 | /* | ||
| 55 | * Create a client with mempool and bioset. | 46 | * Create a client with mempool and bioset. |
| 56 | */ | 47 | */ |
| 57 | struct dm_io_client *dm_io_client_create(unsigned num_pages) | 48 | struct dm_io_client *dm_io_client_create(void) |
| 58 | { | 49 | { |
| 59 | unsigned ios = pages_to_ios(num_pages); | ||
| 60 | struct dm_io_client *client; | 50 | struct dm_io_client *client; |
| 61 | 51 | ||
| 62 | client = kmalloc(sizeof(*client), GFP_KERNEL); | 52 | client = kmalloc(sizeof(*client), GFP_KERNEL); |
| 63 | if (!client) | 53 | if (!client) |
| 64 | return ERR_PTR(-ENOMEM); | 54 | return ERR_PTR(-ENOMEM); |
| 65 | 55 | ||
| 66 | client->pool = mempool_create_slab_pool(ios, _dm_io_cache); | 56 | client->pool = mempool_create_slab_pool(MIN_IOS, _dm_io_cache); |
| 67 | if (!client->pool) | 57 | if (!client->pool) |
| 68 | goto bad; | 58 | goto bad; |
| 69 | 59 | ||
| 70 | client->bios = bioset_create(16, 0); | 60 | client->bios = bioset_create(MIN_BIOS, 0); |
| 71 | if (!client->bios) | 61 | if (!client->bios) |
| 72 | goto bad; | 62 | goto bad; |
| 73 | 63 | ||
| @@ -81,13 +71,6 @@ struct dm_io_client *dm_io_client_create(unsigned num_pages) | |||
| 81 | } | 71 | } |
| 82 | EXPORT_SYMBOL(dm_io_client_create); | 72 | EXPORT_SYMBOL(dm_io_client_create); |
| 83 | 73 | ||
| 84 | int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client) | ||
| 85 | { | ||
| 86 | return mempool_resize(client->pool, pages_to_ios(num_pages), | ||
| 87 | GFP_KERNEL); | ||
| 88 | } | ||
| 89 | EXPORT_SYMBOL(dm_io_client_resize); | ||
| 90 | |||
| 91 | void dm_io_client_destroy(struct dm_io_client *client) | 74 | void dm_io_client_destroy(struct dm_io_client *client) |
| 92 | { | 75 | { |
| 93 | mempool_destroy(client->pool); | 76 | mempool_destroy(client->pool); |
