]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
Btrfs: walk compressed pages based on the nr_pages count instead of bytes
authorChris Mason <chris.mason@oracle.com>
Thu, 30 Oct 2008 17:22:14 +0000 (13:22 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 30 Oct 2008 17:22:14 +0000 (13:22 -0400)
The byte walk counting was awkward and error prone.  This uses the
number of pages sent the higher layer to build bios.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/compression.c
fs/btrfs/inode.c

index c5470367ca5c2907d16a4580d5106e875d132b18..9adaa79adad90c2041ca90c744b7c4653ed58532 100644 (file)
@@ -296,7 +296,7 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
 
        /* create and submit bios for the compressed pages */
        bytes_left = compressed_len;
-       while(bytes_left > 0) {
+       for (page_index = 0; page_index < cb->nr_pages; page_index++) {
                page = compressed_pages[page_index];
                page->mapping = inode->i_mapping;
                if (bio->bi_size)
@@ -324,7 +324,10 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
                        bio->bi_end_io = end_compressed_bio_write;
                        bio_add_page(bio, page, PAGE_CACHE_SIZE, 0);
                }
-               page_index++;
+               if (bytes_left < PAGE_CACHE_SIZE) {
+                       printk("bytes left %lu compress len %lu nr %lu\n",
+                              bytes_left, cb->compressed_len, cb->nr_pages);
+               }
                bytes_left -= PAGE_CACHE_SIZE;
                first_byte += PAGE_CACHE_SIZE;
        }
index 9797592dc86b7c7b8398a18f61a892d70a86c24d..6739424c0fe683b40fa076a9c438c4d8a0bed63a 100644 (file)
@@ -338,7 +338,7 @@ again:
        if (!btrfs_test_flag(inode, NOCOMPRESS) &&
            btrfs_test_opt(root, COMPRESS)) {
                WARN_ON(pages);
-               pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
+               pages = kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
 
                /* we want to make sure the amount of IO required to satisfy
                 * a random read is reasonably small, so we limit the size