Lines Matching defs:inode

31  * Initialize the extent tree @tree.  Should be called for each new inode or
80 static void dec_evictable_extent_maps(struct btrfs_inode *inode)
82 struct btrfs_fs_info *fs_info = inode->root->fs_info;
84 if (!btrfs_is_testing(fs_info) && is_fstree(btrfs_root_id(inode->root)))
235 static void try_merge_map(struct btrfs_inode *inode, struct extent_map *em)
237 struct extent_map_tree *tree = &inode->extent_tree;
271 dec_evictable_extent_maps(inode);
286 dec_evictable_extent_maps(inode);
293 * @inode: the inode from which we are unpinning an extent range
299 * to the generation that actually added the file item to the inode so we know
306 int unpin_extent_cache(struct btrfs_inode *inode, u64 start, u64 len, u64 gen)
308 struct btrfs_fs_info *fs_info = inode->root->fs_info;
309 struct extent_map_tree *tree = &inode->extent_tree;
318 "no extent map found for inode %llu (root %lld) when unpinning extent range [%llu, %llu), generation %llu",
319 btrfs_ino(inode), btrfs_root_id(inode->root),
327 "found extent map for inode %llu (root %lld) with unexpected start offset %llu when unpinning extent range [%llu, %llu), generation %llu",
328 btrfs_ino(inode), btrfs_root_id(inode->root),
337 try_merge_map(inode, em);
346 void clear_em_logging(struct btrfs_inode *inode, struct extent_map *em)
348 lockdep_assert_held_write(&inode->extent_tree.lock);
352 try_merge_map(inode, em);
355 static inline void setup_extent_mapping(struct btrfs_inode *inode,
364 list_add(&em->list, &inode->extent_tree.modified_extents);
366 try_merge_map(inode, em);
370 * Add a new extent map to an inode's extent map tree.
372 * @inode: the target inode
377 * Insert @em into the @inode's extent map tree or perform a simple
382 static int add_extent_mapping(struct btrfs_inode *inode,
385 struct extent_map_tree *tree = &inode->extent_tree;
386 struct btrfs_root *root = inode->root;
396 setup_extent_mapping(inode, em, modified);
467 * Remove an extent_map from its inode's extent tree.
469 * @inode: the inode the extent map belongs to
472 * Remove @em from the extent tree of @inode. No reference counts are dropped,
475 void remove_extent_mapping(struct btrfs_inode *inode, struct extent_map *em)
477 struct extent_map_tree *tree = &inode->extent_tree;
487 dec_evictable_extent_maps(inode);
490 static void replace_extent_mapping(struct btrfs_inode *inode,
495 struct extent_map_tree *tree = &inode->extent_tree;
506 setup_extent_mapping(inode, new, modified);
535 static noinline int merge_extent_mapping(struct btrfs_inode *inode,
569 return add_extent_mapping(inode, em, 0);
573 * Add extent mapping into an inode's extent map tree.
575 * @inode: target inode
583 * Insert @em_in into the inode's extent map tree. In case there is an
592 int btrfs_add_extent_mapping(struct btrfs_inode *inode,
597 struct btrfs_fs_info *fs_info = inode->root->fs_info;
606 ret = add_extent_mapping(inode, em, 0);
614 existing = search_extent_mapping(&inode->extent_tree, start, len);
635 ret = merge_extent_mapping(inode, existing, em, start);
657 static void drop_all_extent_maps_fast(struct btrfs_inode *inode)
659 struct extent_map_tree *tree = &inode->extent_tree;
669 remove_extent_mapping(inode, em);
679 * @inode: The target inode.
687 * The caller should have locked an appropriate file range in the inode's io
690 void btrfs_drop_extent_map_range(struct btrfs_inode *inode, u64 start, u64 end,
696 struct extent_map_tree *em_tree = &inode->extent_tree;
702 drop_all_extent_maps_fast(inode);
799 replace_extent_mapping(inode, em, split, modified);
840 replace_extent_mapping(inode, em, split, modified);
844 ret = add_extent_mapping(inode, split, modified);
848 btrfs_set_inode_full_sync(inode);
871 * modified extents, then we must mark the inode for a
877 btrfs_set_inode_full_sync(inode);
879 remove_extent_mapping(inode, em);
901 * Replace a range in the inode's extent map tree with a new extent map.
903 * @inode: The target inode.
904 * @new_em: The new extent map to add to the inode's extent map tree.
908 * Drops all the extent maps in the inode's extent map tree that intersect the
910 * The caller should have locked an appropriate file range in the inode's io
913 int btrfs_replace_extent_map_range(struct btrfs_inode *inode,
918 struct extent_map_tree *tree = &inode->extent_tree;
924 * The caller has locked an appropriate file range in the inode's io
932 btrfs_drop_extent_map_range(inode, new_em->start, end, false);
934 ret = add_extent_mapping(inode, new_em, modified);
947 int split_extent_map(struct btrfs_inode *inode, u64 start, u64 len, u64 pre,
950 struct extent_map_tree *em_tree = &inode->extent_tree;
969 lock_extent(&inode->io_tree, start, start + len - 1, NULL);
998 replace_extent_mapping(inode, em, split_pre, 1);
1015 add_extent_mapping(inode, split_mid, 1);
1024 unlock_extent(&inode->io_tree, start, start + len - 1, NULL);
1031 static long btrfs_scan_inode(struct btrfs_inode *inode, long *scanned, long nr_to_scan)
1033 const u64 cur_fs_gen = btrfs_get_fs_generation(inode->root->fs_info);
1034 struct extent_map_tree *tree = &inode->extent_tree;
1039 * Take the mmap lock so that we serialize with the inode logging phase
1040 * of fsync because we may need to set the full sync flag on the inode,
1042 * extents. If we set the full sync flag in the inode while an fsync is
1045 * during inode logging it sees the flag set and uses the subvolume tree
1057 if (!down_read_trylock(&inode->i_mmap_lock))
1073 * If the inode is in the list of modified extents (new) and its
1080 btrfs_set_inode_full_sync(inode);
1082 remove_extent_mapping(inode, em);
1083 trace_btrfs_extent_map_shrinker_remove_em(inode, em);
1100 up_read(&inode->i_mmap_lock);
1108 struct btrfs_inode *inode;
1112 inode = btrfs_find_first_inode(root, min_ino);
1113 while (inode) {
1114 nr_dropped += btrfs_scan_inode(inode, scanned, nr_to_scan);
1116 min_ino = btrfs_ino(inode) + 1;
1117 fs_info->extent_map_shrinker_last_ino = btrfs_ino(inode);
1118 iput(&inode->vfs_inode);
1124 inode = btrfs_find_first_inode(root, min_ino);
1127 if (inode) {
1132 * inode if there is one or we will find out this was the last
1139 * that when processing the next root we start from its first inode.