dm log: update dm io interface
This patch ports dm-log.c to the new dm-io interface in order to make it scalable to have a large number of persistent dirty logs active in parallel. Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com> Cc: Milan Broz <mbroz@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
committed by
Linus Torvalds
parent
6cca1e7af5
commit
5d234d1e03
@@ -149,6 +149,8 @@ struct log_c {
|
|||||||
FORCESYNC, /* Force a sync to happen */
|
FORCESYNC, /* Force a sync to happen */
|
||||||
} sync;
|
} sync;
|
||||||
|
|
||||||
|
struct dm_io_request io_req;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disk log fields
|
* Disk log fields
|
||||||
*/
|
*/
|
||||||
@@ -200,13 +202,20 @@ static void header_from_disk(struct log_header *core, struct log_header *disk)
|
|||||||
core->nr_regions = le64_to_cpu(disk->nr_regions);
|
core->nr_regions = le64_to_cpu(disk->nr_regions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rw_header(struct log_c *lc, int rw)
|
||||||
|
{
|
||||||
|
lc->io_req.bi_rw = rw;
|
||||||
|
lc->io_req.mem.ptr.vma = lc->disk_header;
|
||||||
|
lc->io_req.notify.fn = NULL;
|
||||||
|
|
||||||
|
return dm_io(&lc->io_req, 1, &lc->header_location, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static int read_header(struct log_c *log)
|
static int read_header(struct log_c *log)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
unsigned long ebits;
|
|
||||||
|
|
||||||
r = dm_io_sync_vm(1, &log->header_location, READ,
|
r = rw_header(log, READ);
|
||||||
log->disk_header, &ebits);
|
|
||||||
if (r)
|
if (r)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@@ -234,11 +243,8 @@ static int read_header(struct log_c *log)
|
|||||||
|
|
||||||
static inline int write_header(struct log_c *log)
|
static inline int write_header(struct log_c *log)
|
||||||
{
|
{
|
||||||
unsigned long ebits;
|
|
||||||
|
|
||||||
header_to_disk(&log->header, log->disk_header);
|
header_to_disk(&log->header, log->disk_header);
|
||||||
return dm_io_sync_vm(1, &log->header_location, WRITE,
|
return rw_header(log, WRITE);
|
||||||
log->disk_header, &ebits);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------
|
/*----------------------------------------------------------------
|
||||||
@@ -257,6 +263,7 @@ static int create_log_context(struct dirty_log *log, struct dm_target *ti,
|
|||||||
uint32_t region_size;
|
uint32_t region_size;
|
||||||
unsigned int region_count;
|
unsigned int region_count;
|
||||||
size_t bitset_size, buf_size;
|
size_t bitset_size, buf_size;
|
||||||
|
int r;
|
||||||
|
|
||||||
if (argc < 1 || argc > 2) {
|
if (argc < 1 || argc > 2) {
|
||||||
DMWARN("wrong number of arguments to mirror log");
|
DMWARN("wrong number of arguments to mirror log");
|
||||||
@@ -326,6 +333,15 @@ static int create_log_context(struct dirty_log *log, struct dm_target *ti,
|
|||||||
buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
|
buf_size = dm_round_up((LOG_OFFSET << SECTOR_SHIFT) +
|
||||||
bitset_size, ti->limits.hardsect_size);
|
bitset_size, ti->limits.hardsect_size);
|
||||||
lc->header_location.count = buf_size >> SECTOR_SHIFT;
|
lc->header_location.count = buf_size >> SECTOR_SHIFT;
|
||||||
|
lc->io_req.mem.type = DM_IO_VMA;
|
||||||
|
lc->io_req.client = dm_io_client_create(dm_div_up(buf_size,
|
||||||
|
PAGE_SIZE));
|
||||||
|
if (IS_ERR(lc->io_req.client)) {
|
||||||
|
r = PTR_ERR(lc->io_req.client);
|
||||||
|
DMWARN("couldn't allocate disk io client");
|
||||||
|
kfree(lc);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
lc->disk_header = vmalloc(buf_size);
|
lc->disk_header = vmalloc(buf_size);
|
||||||
if (!lc->disk_header) {
|
if (!lc->disk_header) {
|
||||||
@@ -426,6 +442,7 @@ static void disk_dtr(struct dirty_log *log)
|
|||||||
|
|
||||||
dm_put_device(lc->ti, lc->log_dev);
|
dm_put_device(lc->ti, lc->log_dev);
|
||||||
vfree(lc->disk_header);
|
vfree(lc->disk_header);
|
||||||
|
dm_io_client_destroy(lc->io_req.client);
|
||||||
destroy_log_context(lc);
|
destroy_log_context(lc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user