Commit 6cca1e7a authored by Heinz Mauelshagen's avatar Heinz Mauelshagen Committed by Linus Torvalds

dm exception store: update dm io interface

This patch ports dm-exception-store.c to the new, scalable dm_io() interface.

It replaces dm_io_get()/dm_io_put() by
dm_io_client_create()/dm_io_client_destroy() calls and
dm_io_sync_vm() by dm_io() to achive this.
Signed-off-by: default avatarHeinz Mauelshagen <hjm@redhat.com>
Cc: Milan Broz <mbroz@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 373a392b
/* /*
* dm-snapshot.c * dm-exception-store.c
* *
* Copyright (C) 2001-2002 Sistina Software (UK) Limited. * Copyright (C) 2001-2002 Sistina Software (UK) Limited.
* Copyright (C) 2006 Red Hat GmbH
* *
* This file is released under the GPL. * This file is released under the GPL.
*/ */
...@@ -123,6 +124,7 @@ struct pstore { ...@@ -123,6 +124,7 @@ struct pstore {
atomic_t pending_count; atomic_t pending_count;
uint32_t callback_count; uint32_t callback_count;
struct commit_callback *callbacks; struct commit_callback *callbacks;
struct dm_io_client *io_client;
}; };
static inline unsigned int sectors_to_pages(unsigned int sectors) static inline unsigned int sectors_to_pages(unsigned int sectors)
...@@ -159,14 +161,20 @@ static void free_area(struct pstore *ps) ...@@ -159,14 +161,20 @@ static void free_area(struct pstore *ps)
*/ */
static int chunk_io(struct pstore *ps, uint32_t chunk, int rw) static int chunk_io(struct pstore *ps, uint32_t chunk, int rw)
{ {
struct io_region where; struct io_region where = {
unsigned long bits; .bdev = ps->snap->cow->bdev,
.sector = ps->snap->chunk_size * chunk,
where.bdev = ps->snap->cow->bdev; .count = ps->snap->chunk_size,
where.sector = ps->snap->chunk_size * chunk; };
where.count = ps->snap->chunk_size; struct dm_io_request io_req = {
.bi_rw = rw,
return dm_io_sync_vm(1, &where, rw, ps->area, &bits); .mem.type = DM_IO_VMA,
.mem.ptr.vma = ps->area,
.client = ps->io_client,
.notify.fn = NULL,
};
return dm_io(&io_req, 1, &where, NULL);
} }
/* /*
...@@ -213,17 +221,18 @@ static int read_header(struct pstore *ps, int *new_snapshot) ...@@ -213,17 +221,18 @@ static int read_header(struct pstore *ps, int *new_snapshot)
chunk_size_supplied = 0; chunk_size_supplied = 0;
} }
r = dm_io_get(sectors_to_pages(ps->snap->chunk_size)); ps->io_client = dm_io_client_create(sectors_to_pages(ps->snap->
if (r) chunk_size));
return r; if (IS_ERR(ps->io_client))
return PTR_ERR(ps->io_client);
r = alloc_area(ps); r = alloc_area(ps);
if (r) if (r)
goto bad1; return r;
r = chunk_io(ps, 0, READ); r = chunk_io(ps, 0, READ);
if (r) if (r)
goto bad2; goto bad;
dh = (struct disk_header *) ps->area; dh = (struct disk_header *) ps->area;
...@@ -235,7 +244,7 @@ static int read_header(struct pstore *ps, int *new_snapshot) ...@@ -235,7 +244,7 @@ static int read_header(struct pstore *ps, int *new_snapshot)
if (le32_to_cpu(dh->magic) != SNAP_MAGIC) { if (le32_to_cpu(dh->magic) != SNAP_MAGIC) {
DMWARN("Invalid or corrupt snapshot"); DMWARN("Invalid or corrupt snapshot");
r = -ENXIO; r = -ENXIO;
goto bad2; goto bad;
} }
*new_snapshot = 0; *new_snapshot = 0;
...@@ -252,27 +261,22 @@ static int read_header(struct pstore *ps, int *new_snapshot) ...@@ -252,27 +261,22 @@ static int read_header(struct pstore *ps, int *new_snapshot)
(unsigned long long)ps->snap->chunk_size); (unsigned long long)ps->snap->chunk_size);
/* We had a bogus chunk_size. Fix stuff up. */ /* We had a bogus chunk_size. Fix stuff up. */
dm_io_put(sectors_to_pages(ps->snap->chunk_size));
free_area(ps); free_area(ps);
ps->snap->chunk_size = chunk_size; ps->snap->chunk_size = chunk_size;
ps->snap->chunk_mask = chunk_size - 1; ps->snap->chunk_mask = chunk_size - 1;
ps->snap->chunk_shift = ffs(chunk_size) - 1; ps->snap->chunk_shift = ffs(chunk_size) - 1;
r = dm_io_get(sectors_to_pages(chunk_size)); r = dm_io_client_resize(sectors_to_pages(ps->snap->chunk_size),
ps->io_client);
if (r) if (r)
return r; return r;
r = alloc_area(ps); r = alloc_area(ps);
if (r) return r;
goto bad1;
return 0;
bad2: bad:
free_area(ps); free_area(ps);
bad1:
dm_io_put(sectors_to_pages(ps->snap->chunk_size));
return r; return r;
} }
...@@ -405,7 +409,7 @@ static void persistent_destroy(struct exception_store *store) ...@@ -405,7 +409,7 @@ static void persistent_destroy(struct exception_store *store)
{ {
struct pstore *ps = get_info(store); struct pstore *ps = get_info(store);
dm_io_put(sectors_to_pages(ps->snap->chunk_size)); dm_io_client_destroy(ps->io_client);
vfree(ps->callbacks); vfree(ps->callbacks);
free_area(ps); free_area(ps);
kfree(ps); kfree(ps);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment