]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/commitdiff
btrfs: calculate end of bio offset properly
authorChristoph Hellwig <hch@lst.de>
Fri, 25 Nov 2016 08:07:51 +0000 (09:07 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Nov 2016 12:45:20 +0000 (13:45 +0100)
Use the bvec offset and len members to prepare for multipage bvecs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/compression.c

index 1a618cb5370bdf5ea155e5d123e7b00f5581e7d7..ae4c000cbffcfcb6712ec82d6077e0906e631ea3 100644 (file)
@@ -445,6 +445,13 @@ int btrfs_submit_compressed_write(struct inode *inode, u64 start,
        return 0;
 }
 
+static u64 bio_end_offset(struct bio *bio)
+{
+       struct bio_vec *last = &bio->bi_io_vec[bio->bi_vcnt - 1];
+
+       return page_offset(last->bv_page) + last->bv_len + last->bv_offset;
+}
+
 static noinline int add_ra_bio_pages(struct inode *inode,
                                     u64 compressed_end,
                                     struct compressed_bio *cb)
@@ -463,8 +470,7 @@ static noinline int add_ra_bio_pages(struct inode *inode,
        u64 end;
        int misses = 0;
 
-       page = cb->orig_bio->bi_io_vec[cb->orig_bio->bi_vcnt - 1].bv_page;
-       last_offset = (page_offset(page) + PAGE_SIZE);
+       last_offset = bio_end_offset(cb->orig_bio);
        em_tree = &BTRFS_I(inode)->extent_tree;
        tree = &BTRFS_I(inode)->io_tree;