diff options
-rw-r--r-- | drivers/md/dm-exception-store.c | 32 |
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 | */ |
297 | static struct disk_exception *get_exception(struct pstore *ps, uint32_t index) | 297 | static 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 | ||
305 | static int read_exception(struct pstore *ps, | 304 | static 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 | ||
321 | static int write_exception(struct pstore *ps, | 314 | static 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 |