diff options
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index f935fad17838..be854649c51b 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -585,9 +585,27 @@ cont: | |||
585 | will_compress = 0; | 585 | will_compress = 0; |
586 | } else { | 586 | } else { |
587 | num_bytes = total_in; | 587 | num_bytes = total_in; |
588 | *num_added += 1; | ||
589 | |||
590 | /* | ||
591 | * The async work queues will take care of doing actual | ||
592 | * allocation on disk for these compressed pages, and | ||
593 | * will submit them to the elevator. | ||
594 | */ | ||
595 | add_async_extent(async_cow, start, num_bytes, | ||
596 | total_compressed, pages, nr_pages_ret, | ||
597 | compress_type); | ||
598 | |||
599 | if (start + num_bytes < end) { | ||
600 | start += num_bytes; | ||
601 | pages = NULL; | ||
602 | cond_resched(); | ||
603 | goto again; | ||
604 | } | ||
605 | return; | ||
588 | } | 606 | } |
589 | } | 607 | } |
590 | if (!will_compress && pages) { | 608 | if (pages) { |
591 | /* | 609 | /* |
592 | * the compression code ran but failed to make things smaller, | 610 | * the compression code ran but failed to make things smaller, |
593 | * free any pages it allocated and our page pointer array | 611 | * free any pages it allocated and our page pointer array |
@@ -607,43 +625,23 @@ cont: | |||
607 | BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; | 625 | BTRFS_I(inode)->flags |= BTRFS_INODE_NOCOMPRESS; |
608 | } | 626 | } |
609 | } | 627 | } |
610 | if (will_compress) { | ||
611 | *num_added += 1; | ||
612 | |||
613 | /* the async work queues will take care of doing actual | ||
614 | * allocation on disk for these compressed pages, | ||
615 | * and will submit them to the elevator. | ||
616 | */ | ||
617 | add_async_extent(async_cow, start, num_bytes, | ||
618 | total_compressed, pages, nr_pages_ret, | ||
619 | compress_type); | ||
620 | |||
621 | if (start + num_bytes < end) { | ||
622 | start += num_bytes; | ||
623 | pages = NULL; | ||
624 | cond_resched(); | ||
625 | goto again; | ||
626 | } | ||
627 | } else { | ||
628 | cleanup_and_bail_uncompressed: | 628 | cleanup_and_bail_uncompressed: |
629 | /* | 629 | /* |
630 | * No compression, but we still need to write the pages in | 630 | * No compression, but we still need to write the pages in the file |
631 | * the file we've been given so far. redirty the locked | 631 | * we've been given so far. redirty the locked page if it corresponds |
632 | * page if it corresponds to our extent and set things up | 632 | * to our extent and set things up for the async work queue to run |
633 | * for the async work queue to run cow_file_range to do | 633 | * cow_file_range to do the normal delalloc dance. |
634 | * the normal delalloc dance | 634 | */ |
635 | */ | 635 | if (page_offset(locked_page) >= start && |
636 | if (page_offset(locked_page) >= start && | 636 | page_offset(locked_page) <= end) |
637 | page_offset(locked_page) <= end) { | 637 | __set_page_dirty_nobuffers(locked_page); |
638 | __set_page_dirty_nobuffers(locked_page); | 638 | /* unlocked later on in the async handlers */ |
639 | /* unlocked later on in the async handlers */ | 639 | |
640 | } | 640 | if (redirty) |
641 | if (redirty) | 641 | extent_range_redirty_for_io(inode, start, end); |
642 | extent_range_redirty_for_io(inode, start, end); | 642 | add_async_extent(async_cow, start, end - start + 1, 0, NULL, 0, |
643 | add_async_extent(async_cow, start, end - start + 1, | 643 | BTRFS_COMPRESS_NONE); |
644 | 0, NULL, 0, BTRFS_COMPRESS_NONE); | 644 | *num_added += 1; |
645 | *num_added += 1; | ||
646 | } | ||
647 | 645 | ||
648 | return; | 646 | return; |
649 | 647 | ||