btrfs: fixup/remove module.h usage as required
[deliverable/linux.git] / fs / btrfs / extent_io.c
index 66f999b97cbbbf81b4d5c3cf1d8ed9a058712e62..f173c5af64610de66597cce1e38ac493729d6125 100644 (file)
@@ -4,7 +4,6 @@
 #include <linux/mm.h>
 #include <linux/pagemap.h>
 #include <linux/page-flags.h>
-#include <linux/module.h>
 #include <linux/spinlock.h>
 #include <linux/blkdev.h>
 #include <linux/swap.h>
@@ -2686,7 +2685,7 @@ static int __extent_read_full_page(struct extent_io_tree *tree,
 
                iosize = min(extent_map_end(em) - cur, end - cur + 1);
                cur_end = min(extent_map_end(em) - 1, end);
-               iosize = (iosize + blocksize - 1) & ~((u64)blocksize - 1);
+               iosize = ALIGN(iosize, blocksize);
                if (this_bio_flag & EXTENT_BIO_COMPRESSED) {
                        disk_io_size = em->block_len;
                        sector = em->block_start >> 9;
@@ -2977,7 +2976,7 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
                BUG_ON(extent_map_end(em) <= cur);
                BUG_ON(end < cur);
                iosize = min(extent_map_end(em) - cur, end - cur + 1);
-               iosize = (iosize + blocksize - 1) & ~((u64)blocksize - 1);
+               iosize = ALIGN(iosize, blocksize);
                sector = (em->block_start + extent_offset) >> 9;
                bdev = em->bdev;
                block_start = em->block_start;
@@ -3664,7 +3663,7 @@ int extent_invalidatepage(struct extent_io_tree *tree,
        u64 end = start + PAGE_CACHE_SIZE - 1;
        size_t blocksize = page->mapping->host->i_sb->s_blocksize;
 
-       start += (offset + blocksize - 1) & ~(blocksize - 1);
+       start += ALIGN(offset, blocksize);
        if (start > end)
                return 0;
 
@@ -3783,7 +3782,7 @@ static struct extent_map *get_extent_skip_holes(struct inode *inode,
                len = last - offset;
                if (len == 0)
                        break;
-               len = (len + sectorsize - 1) & ~(sectorsize - 1);
+               len = ALIGN(len, sectorsize);
                em = get_extent(inode, NULL, 0, offset, len, 0);
                if (IS_ERR_OR_NULL(em))
                        return em;
@@ -3981,8 +3980,6 @@ static void __free_extent_buffer(struct extent_buffer *eb)
        list_del(&eb->leak_list);
        spin_unlock_irqrestore(&leak_lock, flags);
 #endif
-       if (eb->pages && eb->pages != eb->inline_pages)
-               kfree(eb->pages);
        kmem_cache_free(extent_buffer_cache, eb);
 }
 
@@ -4023,19 +4020,12 @@ static struct extent_buffer *__alloc_extent_buffer(struct extent_io_tree *tree,
        atomic_set(&eb->refs, 1);
        atomic_set(&eb->io_pages, 0);
 
-       if (len > MAX_INLINE_EXTENT_BUFFER_SIZE) {
-               struct page **pages;
-               int num_pages = (len + PAGE_CACHE_SIZE - 1) >>
-                       PAGE_CACHE_SHIFT;
-               pages = kzalloc(num_pages, mask);
-               if (!pages) {
-                       __free_extent_buffer(eb);
-                       return NULL;
-               }
-               eb->pages = pages;
-       } else {
-               eb->pages = eb->inline_pages;
-       }
+       /*
+        * Sanity checks, currently the maximum is 64k covered by 16x 4k pages
+        */
+       BUILD_BUG_ON(BTRFS_MAX_METADATA_BLOCKSIZE
+               > MAX_INLINE_EXTENT_BUFFER_SIZE);
+       BUG_ON(len > MAX_INLINE_EXTENT_BUFFER_SIZE);
 
        return eb;
 }
This page took 0.026553 seconds and 5 git commands to generate.