]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
btrfs: Make btrfs_drop_extent_cache take btrfs_inode
authorNikolay Borisov <n.borisov.lkml@gmail.com>
Mon, 20 Feb 2017 11:50:45 +0000 (13:50 +0200)
committerDavid Sterba <dsterba@suse.com>
Tue, 28 Feb 2017 10:30:08 +0000 (11:30 +0100)
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.h
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/relocation.c
fs/btrfs/tests/inode-tests.c

index 5246cbe4c17f83919d5d350ac5e111cccb366ada..4db18e5dc8f90804980c64f9e608da1a9250a18b 100644 (file)
@@ -3219,7 +3219,7 @@ int btrfs_add_inode_defrag(struct btrfs_trans_handle *trans,
 int btrfs_run_defrag_inodes(struct btrfs_fs_info *fs_info);
 void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info);
 int btrfs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
-void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
+void btrfs_drop_extent_cache(struct btrfs_inode *inode, u64 start, u64 end,
                             int skip_pinned);
 extern const struct file_operations btrfs_file_operations;
 int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
index dd1b56504e1044891e3a19bf654097667146cba6..5df1de43aace4a00aa5f59e55c414ffc135f84f1 100644 (file)
@@ -529,13 +529,13 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages,
  * this drops all the extents in the cache that intersect the range
  * [start, end].  Existing extents are split as required.
  */
-void btrfs_drop_extent_cache(struct inode *inode, u64 start, u64 end,
+void btrfs_drop_extent_cache(struct btrfs_inode *inode, u64 start, u64 end,
                             int skip_pinned)
 {
        struct extent_map *em;
        struct extent_map *split = NULL;
        struct extent_map *split2 = NULL;
-       struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
+       struct extent_map_tree *em_tree = &inode->extent_tree;
        u64 len = end - start + 1;
        u64 gen;
        int ret;
@@ -720,7 +720,7 @@ int __btrfs_drop_extents(struct btrfs_trans_handle *trans,
        int leafs_visited = 0;
 
        if (drop_cache)
-               btrfs_drop_extent_cache(inode, start, end - 1, 0);
+               btrfs_drop_extent_cache(BTRFS_I(inode), start, end - 1, 0);
 
        if (start >= BTRFS_I(inode)->disk_i_size && !replace_extent)
                modify_tree = 0;
@@ -2297,7 +2297,7 @@ out:
 
        hole_em = alloc_extent_map();
        if (!hole_em) {
-               btrfs_drop_extent_cache(inode, offset, end - 1, 0);
+               btrfs_drop_extent_cache(BTRFS_I(inode), offset, end - 1, 0);
                set_bit(BTRFS_INODE_NEEDS_FULL_SYNC,
                        &BTRFS_I(inode)->runtime_flags);
        } else {
@@ -2314,7 +2314,8 @@ out:
                hole_em->generation = trans->transid;
 
                do {
-                       btrfs_drop_extent_cache(inode, offset, end - 1, 0);
+                       btrfs_drop_extent_cache(BTRFS_I(inode), offset,
+                                       end - 1, 0);
                        write_lock(&em_tree->lock);
                        ret = add_extent_mapping(em_tree, hole_em, 1);
                        write_unlock(&em_tree->lock);
index c396533fd3e52b43aa145922eacdd6861ca8a326..c2383a442ff80a7213e7ec1f00692b8e8f2fdfdc 100644 (file)
@@ -317,7 +317,7 @@ static noinline int cow_file_range_inline(struct btrfs_root *root,
 
        set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(inode)->runtime_flags);
        btrfs_delalloc_release_metadata(BTRFS_I(inode), end + 1 - start);
-       btrfs_drop_extent_cache(inode, start, aligned_end - 1, 0);
+       btrfs_drop_extent_cache(BTRFS_I(inode), start, aligned_end - 1, 0);
 out:
        /*
         * Don't forget to free the reserved space, as for inlined extent
@@ -807,7 +807,8 @@ retry:
                                                BTRFS_ORDERED_COMPRESSED,
                                                async_extent->compress_type);
                if (ret) {
-                       btrfs_drop_extent_cache(inode, async_extent->start,
+                       btrfs_drop_extent_cache(BTRFS_I(inode),
+                                               async_extent->start,
                                                async_extent->start +
                                                async_extent->ram_size - 1, 0);
                        goto out_free_reserve;
@@ -972,7 +973,8 @@ static noinline int cow_file_range(struct inode *inode,
               btrfs_super_total_bytes(fs_info->super_copy));
 
        alloc_hint = get_extent_allocation_hint(inode, start, num_bytes);
-       btrfs_drop_extent_cache(inode, start, start + num_bytes - 1, 0);
+       btrfs_drop_extent_cache(BTRFS_I(inode), start,
+                       start + num_bytes - 1, 0);
 
        while (disk_num_bytes > 0) {
                unsigned long op;
@@ -1040,7 +1042,7 @@ out:
        return ret;
 
 out_drop_extent_cache:
-       btrfs_drop_extent_cache(inode, start, start + ram_size - 1, 0);
+       btrfs_drop_extent_cache(BTRFS_I(inode), start, start + ram_size - 1, 0);
 out_reserve:
        btrfs_dec_block_group_reservations(fs_info, ins.objectid);
        btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 1);
@@ -2931,7 +2933,7 @@ out:
                clear_extent_uptodate(io_tree, start, end, NULL, GFP_NOFS);
 
                /* Drop the cache for the part of the extent we didn't write. */
-               btrfs_drop_extent_cache(inode, start, end, 0);
+               btrfs_drop_extent_cache(BTRFS_I(inode), start, end, 0);
 
                /*
                 * If the ordered extent had an IOERR or something else went
@@ -4337,7 +4339,7 @@ int btrfs_truncate_inode_items(struct btrfs_trans_handle *trans,
         */
        if (test_bit(BTRFS_ROOT_REF_COWS, &root->state) ||
            root == fs_info->tree_root)
-               btrfs_drop_extent_cache(inode, ALIGN(new_size,
+               btrfs_drop_extent_cache(BTRFS_I(inode), ALIGN(new_size,
                                        fs_info->sectorsize),
                                        (u64)-1, 0);
 
@@ -4865,7 +4867,7 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
                                                hole_size);
                        if (err)
                                break;
-                       btrfs_drop_extent_cache(inode, cur_offset,
+                       btrfs_drop_extent_cache(BTRFS_I(inode), cur_offset,
                                                cur_offset + hole_size - 1, 0);
                        hole_em = alloc_extent_map();
                        if (!hole_em) {
@@ -4891,7 +4893,8 @@ int btrfs_cont_expand(struct inode *inode, loff_t oldsize, loff_t size)
                                write_unlock(&em_tree->lock);
                                if (err != -EEXIST)
                                        break;
-                               btrfs_drop_extent_cache(inode, cur_offset,
+                               btrfs_drop_extent_cache(BTRFS_I(inode),
+                                                       cur_offset,
                                                        cur_offset +
                                                        hole_size - 1, 0);
                        }
@@ -7164,7 +7167,7 @@ static struct extent_map *btrfs_create_dio_extent(struct inode *inode,
        if (ret) {
                if (em) {
                        free_extent_map(em);
-                       btrfs_drop_extent_cache(inode, start,
+                       btrfs_drop_extent_cache(BTRFS_I(inode), start,
                                                start + len - 1, 0);
                }
                em = ERR_PTR(ret);
@@ -7531,7 +7534,7 @@ static struct extent_map *create_io_em(struct inode *inode, u64 start, u64 len,
        }
 
        do {
-               btrfs_drop_extent_cache(inode, em->start,
+               btrfs_drop_extent_cache(BTRFS_I(inode), em->start,
                                em->start + em->len - 1, 0);
                write_lock(&em_tree->lock);
                ret = add_extent_mapping(em_tree, em, 1);
@@ -9280,7 +9283,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
 void btrfs_test_destroy_inode(struct inode *inode)
 {
-       btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
+       btrfs_drop_extent_cache(BTRFS_I(inode), 0, (u64)-1, 0);
        kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
 }
 #endif
@@ -9335,7 +9338,7 @@ void btrfs_destroy_inode(struct inode *inode)
        }
        btrfs_qgroup_check_reserved_leak(inode);
        inode_tree_del(inode);
-       btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
+       btrfs_drop_extent_cache(BTRFS_I(inode), 0, (u64)-1, 0);
 free:
        call_rcu(&inode->i_rcu, btrfs_i_callback);
 }
@@ -10328,7 +10331,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
                        break;
                }
 
-               btrfs_drop_extent_cache(inode, cur_offset,
+               btrfs_drop_extent_cache(BTRFS_I(inode), cur_offset,
                                        cur_offset + ins.offset -1, 0);
 
                em = alloc_extent_map();
@@ -10355,7 +10358,7 @@ static int __btrfs_prealloc_file_range(struct inode *inode, int mode,
                        write_unlock(&em_tree->lock);
                        if (ret != -EEXIST)
                                break;
-                       btrfs_drop_extent_cache(inode, cur_offset,
+                       btrfs_drop_extent_cache(BTRFS_I(inode), cur_offset,
                                                cur_offset + ins.offset - 1,
                                                0);
                }
index 86f993c958bae7895ccf6722c0aa7db408ebbf0a..bc2e03a2569e777a2e41e6bfe2a90aefaa8558fb 100644 (file)
@@ -3359,7 +3359,7 @@ static void clone_update_extent_map(struct inode *inode,
                        free_extent_map(em);
                        break;
                }
-               btrfs_drop_extent_cache(inode, em->start,
+               btrfs_drop_extent_cache(BTRFS_I(inode), em->start,
                                        em->start + em->len - 1, 0);
        }
 
index e6470890ce26b04fab4d5d5bd3e3795e5f1d5c78..e48625413fcb90ad9fcafab3e078d956cf6a34e9 100644 (file)
@@ -1714,8 +1714,8 @@ int replace_file_extents(struct btrfs_trans_handle *trans,
                                if (!ret)
                                        continue;
 
-                               btrfs_drop_extent_cache(inode, key.offset, end,
-                                                       1);
+                               btrfs_drop_extent_cache(BTRFS_I(inode),
+                                               key.offset,     end, 1);
                                unlock_extent(&BTRFS_I(inode)->io_tree,
                                              key.offset, end);
                        }
@@ -2130,7 +2130,7 @@ static int invalidate_extent_cache(struct btrfs_root *root,
 
                /* the lock_extent waits for readpage to complete */
                lock_extent(&BTRFS_I(inode)->io_tree, start, end);
-               btrfs_drop_extent_cache(inode, start, end, 1);
+               btrfs_drop_extent_cache(BTRFS_I(inode), start, end, 1);
                unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
        }
        return 0;
@@ -3161,7 +3161,7 @@ int setup_extent_mapping(struct inode *inode, u64 start, u64 end,
                        free_extent_map(em);
                        break;
                }
-               btrfs_drop_extent_cache(inode, start, end, 0);
+               btrfs_drop_extent_cache(BTRFS_I(inode), start, end, 0);
        }
        unlock_extent(&BTRFS_I(inode)->io_tree, start, end);
        return ret;
index 4d0f038e14f1f7d1ca58d80c940c0a244738a550..924bcbf4327528490162b97fbce2e0365ea5fc75 100644 (file)
@@ -293,7 +293,7 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
                goto out;
        }
        free_extent_map(em);
-       btrfs_drop_extent_cache(inode, 0, (u64)-1, 0);
+       btrfs_drop_extent_cache(BTRFS_I(inode), 0, (u64)-1, 0);
 
        /*
         * All of the magic numbers are based on the mapping setup in