Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Mark McLoughlin and committed by
Linus Torvalds
e4ff496d f9cea4f7

+8 -24
+8 -24
drivers/md/dm-exception-store.c
··· 296 296 */ 297 297 static struct disk_exception *get_exception(struct pstore *ps, uint32_t index) 298 298 { 299 - if (index >= ps->exceptions_per_area) 300 - return NULL; 299 + BUG_ON(index >= ps->exceptions_per_area); 301 300 302 301 return ((struct disk_exception *) ps->area) + index; 303 302 } 304 303 305 - static int read_exception(struct pstore *ps, 306 - uint32_t index, struct disk_exception *result) 304 + static void read_exception(struct pstore *ps, 305 + uint32_t index, struct disk_exception *result) 307 306 { 308 - struct disk_exception *e; 309 - 310 - e = get_exception(ps, index); 311 - if (!e) 312 - return -EINVAL; 307 + struct disk_exception *e = get_exception(ps, index); 313 308 314 309 /* copy it */ 315 310 result->old_chunk = le64_to_cpu(e->old_chunk); 316 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, 322 - uint32_t index, struct disk_exception *de) 314 + static void write_exception(struct pstore *ps, 315 + uint32_t index, struct disk_exception *de) 323 316 { 324 - struct disk_exception *e; 325 - 326 - e = get_exception(ps, index); 327 - if (!e) 328 - return -EINVAL; 317 + struct disk_exception *e = get_exception(ps, index); 329 318 330 319 /* copy it */ 331 320 e->old_chunk = cpu_to_le64(de->old_chunk); 332 321 e->new_chunk = cpu_to_le64(de->new_chunk); 333 - 334 - return 0; 335 322 } 336 323 337 324 /* ··· 336 349 *full = 1; 337 350 338 351 for (i = 0; i < ps->exceptions_per_area; i++) { 339 - r = read_exception(ps, i, &de); 340 - 341 - if (r) 342 - return r; 352 + read_exception(ps, i, &de); 343 353 344 354 /* 345 355 * If the new_chunk is pointing at the start of