Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252803
b: refs/heads/master
c: bda8efe
h: refs/heads/master
i:
  252801: 95e39e9
  252799: fe87ed7
v: v3
  • Loading branch information
Mikulas Patocka authored and Alasdair G Kergon committed May 29, 2011
1 parent 94643bf commit bfb232c
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: d04714580f12379fcf7a0f799e86c92b96dd4e1f
refs/heads/master: bda8efec5c706a672e0714d341a342e811f0262a
27 changes: 5 additions & 22 deletions trunk/drivers/md/dm-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#define DM_MSG_PREFIX "io"

#define DM_IO_MAX_REGIONS BITS_PER_LONG
#define MIN_IOS 16
#define MIN_BIOS 16

struct dm_io_client {
mempool_t *pool;
Expand All @@ -40,34 +42,22 @@ struct io {

static struct kmem_cache *_dm_io_cache;

/*
* io contexts are only dynamically allocated for asynchronous
* io. Since async io is likely to be the majority of io we'll
* have the same number of io contexts as bios! (FIXME: must reduce this).
*/

static unsigned int pages_to_ios(unsigned int pages)
{
return 4 * pages; /* too many ? */
}

/*
* Create a client with mempool and bioset.
*/
struct dm_io_client *dm_io_client_create(unsigned num_pages)
struct dm_io_client *dm_io_client_create(void)
{
unsigned ios = pages_to_ios(num_pages);
struct dm_io_client *client;

client = kmalloc(sizeof(*client), GFP_KERNEL);
if (!client)
return ERR_PTR(-ENOMEM);

client->pool = mempool_create_slab_pool(ios, _dm_io_cache);
client->pool = mempool_create_slab_pool(MIN_IOS, _dm_io_cache);
if (!client->pool)
goto bad;

client->bios = bioset_create(16, 0);
client->bios = bioset_create(MIN_BIOS, 0);
if (!client->bios)
goto bad;

Expand All @@ -81,13 +71,6 @@ struct dm_io_client *dm_io_client_create(unsigned num_pages)
}
EXPORT_SYMBOL(dm_io_client_create);

int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client)
{
return mempool_resize(client->pool, pages_to_ios(num_pages),
GFP_KERNEL);
}
EXPORT_SYMBOL(dm_io_client_resize);

void dm_io_client_destroy(struct dm_io_client *client)
{
mempool_destroy(client->pool);
Expand Down
2 changes: 1 addition & 1 deletion trunk/drivers/md/dm-kcopyd.c
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ int dm_kcopyd_client_create(unsigned min_pages,
if (r)
goto bad_client_pages;

kc->io_client = dm_io_client_create(min_pages);
kc->io_client = dm_io_client_create();
if (IS_ERR(kc->io_client)) {
r = PTR_ERR(kc->io_client);
goto bad_io_client;
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/md/dm-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,7 @@ static int create_log_context(struct dm_dirty_log *log, struct dm_target *ti,

lc->io_req.mem.type = DM_IO_VMA;
lc->io_req.notify.fn = NULL;
lc->io_req.client = dm_io_client_create(dm_div_up(buf_size,
PAGE_SIZE));
lc->io_req.client = dm_io_client_create();
if (IS_ERR(lc->io_req.client)) {
r = PTR_ERR(lc->io_req.client);
DMWARN("couldn't allocate disk io client");
Expand Down
3 changes: 1 addition & 2 deletions trunk/drivers/md/dm-raid1.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#define DM_MSG_PREFIX "raid1"

#define MAX_RECOVERY 1 /* Maximum number of regions recovered in parallel. */
#define DM_IO_PAGES 64
#define DM_KCOPYD_PAGES 64

#define DM_RAID1_HANDLE_ERRORS 0x01
Expand Down Expand Up @@ -887,7 +886,7 @@ static struct mirror_set *alloc_context(unsigned int nr_mirrors,
return NULL;
}

ms->io_client = dm_io_client_create(DM_IO_PAGES);
ms->io_client = dm_io_client_create();
if (IS_ERR(ms->io_client)) {
ti->error = "Error creating dm_io client";
mempool_destroy(ms->read_record_pool);
Expand Down
13 changes: 1 addition & 12 deletions trunk/drivers/md/dm-snap-persistent.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,6 @@ struct pstore {
struct workqueue_struct *metadata_wq;
};

static unsigned sectors_to_pages(unsigned sectors)
{
return DIV_ROUND_UP(sectors, PAGE_SIZE >> 9);
}

static int alloc_area(struct pstore *ps)
{
int r = -ENOMEM;
Expand Down Expand Up @@ -318,8 +313,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)
chunk_size_supplied = 0;
}

ps->io_client = dm_io_client_create(sectors_to_pages(ps->store->
chunk_size));
ps->io_client = dm_io_client_create();
if (IS_ERR(ps->io_client))
return PTR_ERR(ps->io_client);

Expand Down Expand Up @@ -368,11 +362,6 @@ static int read_header(struct pstore *ps, int *new_snapshot)
return r;
}

r = dm_io_client_resize(sectors_to_pages(ps->store->chunk_size),
ps->io_client);
if (r)
return r;

r = alloc_area(ps);
return r;

Expand Down
3 changes: 1 addition & 2 deletions trunk/include/linux/dm-io.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ struct dm_io_request {
*
* Create/destroy may block.
*/
struct dm_io_client *dm_io_client_create(unsigned num_pages);
int dm_io_client_resize(unsigned num_pages, struct dm_io_client *client);
struct dm_io_client *dm_io_client_create(void);
void dm_io_client_destroy(struct dm_io_client *client);

/*
Expand Down

0 comments on commit bfb232c

Please sign in to comment.