[PATCH] dm snapshot: make read and write exception functions void
read_exception() and write_exception() only return an error if supplied with an out-of-range index. If this ever happens it's the result of a bug in the calling code so we handle this with an assertion and remove the error handling in the callers. Signed-off-by: Mark McLoughlin <markmc@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
f9cea4f707
commit
e4ff496db7
1 changed files with 8 additions and 24 deletions
|
@ -296,42 +296,29 @@ static int write_header(struct pstore *ps)
|
||||||
*/
|
*/
|
||||||
static struct disk_exception *get_exception(struct pstore *ps, uint32_t index)
|
static struct disk_exception *get_exception(struct pstore *ps, uint32_t index)
|
||||||
{
|
{
|
||||||
if (index >= ps->exceptions_per_area)
|
BUG_ON(index >= ps->exceptions_per_area);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return ((struct disk_exception *) ps->area) + index;
|
return ((struct disk_exception *) ps->area) + index;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_exception(struct pstore *ps,
|
static void read_exception(struct pstore *ps,
|
||||||
uint32_t index, struct disk_exception *result)
|
uint32_t index, struct disk_exception *result)
|
||||||
{
|
{
|
||||||
struct disk_exception *e;
|
struct disk_exception *e = get_exception(ps, index);
|
||||||
|
|
||||||
e = get_exception(ps, index);
|
|
||||||
if (!e)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* copy it */
|
/* copy it */
|
||||||
result->old_chunk = le64_to_cpu(e->old_chunk);
|
result->old_chunk = le64_to_cpu(e->old_chunk);
|
||||||
result->new_chunk = le64_to_cpu(e->new_chunk);
|
result->new_chunk = le64_to_cpu(e->new_chunk);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int write_exception(struct pstore *ps,
|
static void write_exception(struct pstore *ps,
|
||||||
uint32_t index, struct disk_exception *de)
|
uint32_t index, struct disk_exception *de)
|
||||||
{
|
{
|
||||||
struct disk_exception *e;
|
struct disk_exception *e = get_exception(ps, index);
|
||||||
|
|
||||||
e = get_exception(ps, index);
|
|
||||||
if (!e)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* copy it */
|
/* copy it */
|
||||||
e->old_chunk = cpu_to_le64(de->old_chunk);
|
e->old_chunk = cpu_to_le64(de->old_chunk);
|
||||||
e->new_chunk = cpu_to_le64(de->new_chunk);
|
e->new_chunk = cpu_to_le64(de->new_chunk);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -349,10 +336,7 @@ static int insert_exceptions(struct pstore *ps, int *full)
|
||||||
*full = 1;
|
*full = 1;
|
||||||
|
|
||||||
for (i = 0; i < ps->exceptions_per_area; i++) {
|
for (i = 0; i < ps->exceptions_per_area; i++) {
|
||||||
r = read_exception(ps, i, &de);
|
read_exception(ps, i, &de);
|
||||||
|
|
||||||
if (r)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the new_chunk is pointing at the start of
|
* If the new_chunk is pointing at the start of
|
||||||
|
|
Loading…
Add table
Reference in a new issue