Lines Matching defs:inode
19 #include "inode-map.h"
47 static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
57 struct inode *inode = NULL;
85 inode = btrfs_iget_path(fs_info->sb, location.objectid, root, path);
88 if (IS_ERR(inode))
89 return inode;
91 mapping_set_gfp_mask(inode->i_mapping,
92 mapping_gfp_constraint(inode->i_mapping,
95 return inode;
98 struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
102 struct inode *inode = NULL;
106 if (block_group->inode)
107 inode = igrab(block_group->inode);
109 if (inode)
110 return inode;
112 inode = __lookup_free_space_inode(fs_info->tree_root, path,
114 if (IS_ERR(inode))
115 return inode;
118 if (!((BTRFS_I(inode)->flags & flags) == flags)) {
119 btrfs_info(fs_info, "Old style space inode found, converting.");
120 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM |
126 block_group->inode = igrab(inode);
131 return inode;
216 /* 1 for slack space, 1 for updating the inode */
231 struct inode *inode)
233 struct btrfs_root *root = BTRFS_I(inode)->root;
263 btrfs_i_size_write(BTRFS_I(inode), 0);
264 truncate_pagecache(inode, 0);
270 ret = btrfs_truncate_inode_items(trans, root, inode,
275 ret = btrfs_update_inode(trans, root, inode);
286 static void readahead_cache(struct inode *inode)
295 file_ra_state_init(ra, inode->i_mapping);
296 last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;
298 page_cache_sync_readahead(inode->i_mapping, ra, NULL, 0, last_index);
303 static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
309 num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
311 if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FREE_INO_OBJECTID)
326 io_ctl->fs_info = btrfs_sb(inode->i_sb);
328 io_ctl->inode = inode;
377 struct inode *inode = io_ctl->inode;
378 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
382 page = find_or_create_page(inode->i_mapping, i, mask);
391 if (page->mapping != inode->i_mapping) {
392 btrfs_err(BTRFS_I(inode)->root->fs_info,
398 btrfs_err(BTRFS_I(inode)->root->fs_info,
454 "space cache generation (%llu) does not match inode (%llu)",
666 static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
684 if (!i_size_read(inode))
709 if (!BTRFS_I(inode)->generation) {
716 if (BTRFS_I(inode)->generation != generation) {
718 "free space inode generation (%llu) did not match free space cache generation (%llu)",
719 BTRFS_I(inode)->generation, generation);
726 ret = io_ctl_init(&io_ctl, inode, 0);
730 readahead_cache(inode);
849 struct inode *inode;
880 * cache's inode item from the root tree. If this inode item is located
885 * It's safe to read the inode item using the commit root because
889 * we will never try to read their inode item while the fs is mounted.
891 inode = lookup_free_space_inode(block_group, path);
892 if (IS_ERR(inode)) {
897 /* We may have converted the inode and made the cache invalid. */
906 ret = __load_free_space_cache(fs_info->tree_root, inode, ctl,
937 iput(inode);
1021 struct inode *inode,
1036 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1048 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0,
1049 inode->i_size - 1, EXTENT_DELALLOC, 0,
1056 BTRFS_I(inode)->generation = trans->transid;
1139 static int flush_dirty_cache(struct inode *inode)
1143 ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
1145 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1161 cleanup_write_cache_enospc(struct inode *inode,
1166 unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
1167 i_size_read(inode) - 1, cached_state);
1177 struct inode *inode = io_ctl->inode;
1179 if (!inode)
1183 ret = flush_dirty_cache(inode);
1188 ret = update_cache_item(trans, root, inode, path, offset,
1192 invalidate_inode_pages2(inode->i_mapping);
1193 BTRFS_I(inode)->generation = 0;
1199 btrfs_update_inode(trans, root, inode);
1220 io_ctl->inode = NULL;
1221 iput(inode);
1246 * __btrfs_write_out_cache - write out cached info to an inode
1247 * @root - the root the inode belongs to
1256 static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
1269 if (!i_size_read(inode))
1273 ret = io_ctl_init(io_ctl, inode, 1);
1284 BTRFS_I(inode)->generation = 0;
1297 lock_extent_bits(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
1338 ret = btrfs_dirty_pages(BTRFS_I(inode), io_ctl->pages,
1339 io_ctl->num_pages, 0, i_size_read(inode),
1353 unlock_extent_cached(&BTRFS_I(inode)->io_tree, 0,
1354 i_size_read(inode) - 1, &cached_state);
1359 * the cache and the inode
1364 ret = btrfs_fdatawrite_range(inode, 0, (u64)-1);
1376 cleanup_write_cache_enospc(inode, io_ctl, &cached_state);
1383 io_ctl->inode = NULL;
1386 invalidate_inode_pages2(inode->i_mapping);
1387 BTRFS_I(inode)->generation = 0;
1389 btrfs_update_inode(trans, root, inode);
1391 iput(inode);
1401 struct inode *inode;
1411 inode = lookup_free_space_inode(block_group, path);
1412 if (IS_ERR(inode))
1415 ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl,
1425 block_group->io_ctl.inode = NULL;
1426 iput(inode);
1431 * to wait for IO and put the inode
3840 * smallest inode number in the item.
3842 * Note: the returned inode number may not be the smallest one in
3889 struct inode *lookup_free_ino_inode(struct btrfs_root *root,
3892 struct inode *inode = NULL;
3896 inode = igrab(root->ino_cache_inode);
3898 if (inode)
3899 return inode;
3901 inode = __lookup_free_space_inode(root, path, 0);
3902 if (IS_ERR(inode))
3903 return inode;
3907 root->ino_cache_inode = igrab(inode);
3910 return inode;
3925 struct inode *inode;
3943 inode = lookup_free_ino_inode(root, path);
3944 if (IS_ERR(inode))
3947 if (root_gen != BTRFS_I(inode)->generation)
3950 ret = __load_free_space_cache(root, inode, ctl, path, 0);
3957 iput(inode);
3966 struct inode *inode)
3978 ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl, trans);
3983 * inode.c:btrfs_finish_ordered_io(), regardless of it finishing
3992 btrfs_delalloc_release_metadata(BTRFS_I(inode),
3993 inode->i_size, true);