aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2006-10-03 04:15:26 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-03 11:04:14 -0400
commite4ff496db72473949ddfe29a37471969d2f1d4ee (patch)
treefdc7b0b6fa8ab68b5741e412ce3d0682afc22260
parentf9cea4f70734f743e0beb55552a9794fa5032645 (diff)
[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>
-rw-r--r--drivers/md/dm-exception-store.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/drivers/md/dm-exception-store.c b/drivers/md/dm-exception-store.c
index 8b4cd02f75a8..002417da1224 100644
--- a/drivers/md/dm-exception-store.c
+++ b/drivers/md/dm-exception-store.c
@@ -296,42 +296,29 @@ static int write_header(struct pstore *ps)
296 */ 296 */
297static struct disk_exception *get_exception(struct pstore *ps, uint32_t index) 297static struct disk_exception *get_exception(struct pstore *ps, uint32_t index)
298{ 298{
299 if (index >= ps->exceptions_per_area) 299 BUG_ON(index >= ps->exceptions_per_area);
300 return NULL;
301 300
302 return ((struct disk_exception *) ps->area) + index; 301 return ((struct disk_exception *) ps->area) + index;
303} 302}
304 303
305static int read_exception(struct pstore *ps, 304static void read_exception(struct pstore *ps,
306 uint32_t index, struct disk_exception *result) 305 uint32_t index, struct disk_exception *result)
307{ 306{
308 struct disk_exception *e; 307 struct disk_exception *e = get_exception(ps, index);
309
310 e = get_exception(ps, index);
311 if (!e)
312 return -EINVAL;
313 308
314 /* copy it */ 309 /* copy it */
315 result->old_chunk = le64_to_cpu(e->old_chunk); 310 result->old_chunk = le64_to_cpu(e->old_chunk);
316 result->new_chunk = le64_to_cpu(e->new_chunk); 311 result->new_chunk = le64_to_cpu(e->new_chunk);
317
318 return 0;
319} 312}
320 313
321static int write_exception(struct pstore *ps, 314static void write_exception(struct pstore *ps,
322 uint32_t index, struct disk_exception *de) 315 uint32_t index, struct disk_exception *de)
323{ 316{
324 struct disk_exception *e; 317 struct disk_exception *e = get_exception(ps, index);
325
326 e = get_exception(ps, index);
327 if (!e)
328 return -EINVAL;
329 318
330 /* copy it */ 319 /* copy it */
331 e->old_chunk = cpu_to_le64(de->old_chunk); 320 e->old_chunk = cpu_to_le64(de->old_chunk);
332 e->new_chunk = cpu_to_le64(de->new_chunk); 321 e->new_chunk = cpu_to_le64(de->new_chunk);
333
334 return 0;
335} 322}
336 323
337/* 324/*
@@ -349,10 +336,7 @@ static int insert_exceptions(struct pstore *ps, int *full)
349 *full = 1; 336 *full = 1;
350 337
351 for (i = 0; i < ps->exceptions_per_area; i++) { 338 for (i = 0; i < ps->exceptions_per_area; i++) {
352 r = read_exception(ps, i, &de); 339 read_exception(ps, i, &de);
353
354 if (r)
355 return r;
356 340
357 /* 341 /*
358 * If the new_chunk is pointing at the start of 342 * If the new_chunk is pointing at the start of