diff options
-rw-r--r-- | fs/hfsplus/extents.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/fs/hfsplus/extents.c b/fs/hfsplus/extents.c index 5849e3ef35cc..eba76eab6d62 100644 --- a/fs/hfsplus/extents.c +++ b/fs/hfsplus/extents.c | |||
@@ -329,6 +329,7 @@ static int hfsplus_free_extents(struct super_block *sb, | |||
329 | { | 329 | { |
330 | u32 count, start; | 330 | u32 count, start; |
331 | int i; | 331 | int i; |
332 | int err = 0; | ||
332 | 333 | ||
333 | hfsplus_dump_extent(extent); | 334 | hfsplus_dump_extent(extent); |
334 | for (i = 0; i < 8; extent++, i++) { | 335 | for (i = 0; i < 8; extent++, i++) { |
@@ -345,18 +346,33 @@ found: | |||
345 | for (;;) { | 346 | for (;;) { |
346 | start = be32_to_cpu(extent->start_block); | 347 | start = be32_to_cpu(extent->start_block); |
347 | if (count <= block_nr) { | 348 | if (count <= block_nr) { |
348 | hfsplus_block_free(sb, start, count); | 349 | err = hfsplus_block_free(sb, start, count); |
350 | if (err) { | ||
351 | printk(KERN_ERR "hfs: can't free extent\n"); | ||
352 | dprint(DBG_EXTENT, " start: %u count: %u\n", | ||
353 | start, count); | ||
354 | } | ||
349 | extent->block_count = 0; | 355 | extent->block_count = 0; |
350 | extent->start_block = 0; | 356 | extent->start_block = 0; |
351 | block_nr -= count; | 357 | block_nr -= count; |
352 | } else { | 358 | } else { |
353 | count -= block_nr; | 359 | count -= block_nr; |
354 | hfsplus_block_free(sb, start + count, block_nr); | 360 | err = hfsplus_block_free(sb, start + count, block_nr); |
361 | if (err) { | ||
362 | printk(KERN_ERR "hfs: can't free extent\n"); | ||
363 | dprint(DBG_EXTENT, " start: %u count: %u\n", | ||
364 | start, count); | ||
365 | } | ||
355 | extent->block_count = cpu_to_be32(count); | 366 | extent->block_count = cpu_to_be32(count); |
356 | block_nr = 0; | 367 | block_nr = 0; |
357 | } | 368 | } |
358 | if (!block_nr || !i) | 369 | if (!block_nr || !i) { |
359 | return 0; | 370 | /* |
371 | * Try to free all extents and | ||
372 | * return only last error | ||
373 | */ | ||
374 | return err; | ||
375 | } | ||
360 | i--; | 376 | i--; |
361 | extent--; | 377 | extent--; |
362 | count = be32_to_cpu(extent->block_count); | 378 | count = be32_to_cpu(extent->block_count); |