Lines Matching defs:inode

28 #include "inode-item.h"
78 static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
88 struct inode *inode = NULL;
116 inode = btrfs_iget_path(fs_info->sb, location.objectid, root, path);
119 if (IS_ERR(inode))
120 return inode;
122 mapping_set_gfp_mask(inode->i_mapping,
123 mapping_gfp_constraint(inode->i_mapping,
126 return inode;
129 struct inode *lookup_free_space_inode(struct btrfs_block_group *block_group,
133 struct inode *inode = NULL;
137 if (block_group->inode)
138 inode = igrab(block_group->inode);
140 if (inode)
141 return inode;
143 inode = __lookup_free_space_inode(fs_info->tree_root, path,
145 if (IS_ERR(inode))
146 return inode;
149 if (!((BTRFS_I(inode)->flags & flags) == flags)) {
150 btrfs_info(fs_info, "Old style space inode found, converting.");
151 BTRFS_I(inode)->flags |= BTRFS_INODE_NODATASUM |
157 block_group->inode = igrab(inode);
160 return inode;
238 * inode is an optional sink: if it is NULL, btrfs_remove_free_space_inode
239 * handles lookup, otherwise it takes ownership and iputs the inode.
240 * Don't reuse an inode pointer after passing it into this function.
243 struct inode *inode,
254 if (!inode)
255 inode = lookup_free_space_inode(block_group, path);
256 if (IS_ERR(inode)) {
257 if (PTR_ERR(inode) != -ENOENT)
258 ret = PTR_ERR(inode);
261 ret = btrfs_orphan_add(trans, BTRFS_I(inode));
263 btrfs_add_delayed_iput(BTRFS_I(inode));
266 clear_nlink(inode);
270 block_group->inode = NULL;
272 iput(inode);
277 btrfs_add_delayed_iput(BTRFS_I(inode));
297 struct inode *vfs_inode)
300 .inode = BTRFS_I(vfs_inode),
306 struct btrfs_inode *inode = BTRFS_I(vfs_inode);
307 struct btrfs_root *root = inode->root;
338 btrfs_i_size_write(inode, 0);
341 lock_extent(&inode->io_tree, 0, (u64)-1, &cached_state);
342 btrfs_drop_extent_map_range(inode, 0, (u64)-1, false);
350 inode_sub_bytes(&inode->vfs_inode, control.sub_bytes);
351 btrfs_inode_safe_disk_i_size_write(inode, control.last_size);
353 unlock_extent(&inode->io_tree, 0, (u64)-1, &cached_state);
357 ret = btrfs_update_inode(trans, root, inode);
368 static void readahead_cache(struct inode *inode)
373 file_ra_state_init(&ra, inode->i_mapping);
374 last_index = (i_size_read(inode) - 1) >> PAGE_SHIFT;
376 page_cache_sync_readahead(inode->i_mapping, &ra, NULL, 0, last_index);
379 static int io_ctl_init(struct btrfs_io_ctl *io_ctl, struct inode *inode,
384 num_pages = DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE);
397 io_ctl->fs_info = btrfs_sb(inode->i_sb);
398 io_ctl->inode = inode;
450 struct inode *inode = io_ctl->inode;
451 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
457 page = find_or_create_page(inode->i_mapping, i, mask);
475 if (page->mapping != inode->i_mapping) {
476 btrfs_err(BTRFS_I(inode)->root->fs_info,
482 btrfs_err(BTRFS_I(inode)->root->fs_info,
525 "space cache generation (%llu) does not match inode (%llu)",
733 static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
751 if (!i_size_read(inode))
776 if (!BTRFS_I(inode)->generation) {
783 if (BTRFS_I(inode)->generation != generation) {
785 "free space inode generation (%llu) did not match free space cache generation (%llu)",
786 BTRFS_I(inode)->generation, generation);
793 ret = io_ctl_init(&io_ctl, inode, 0);
797 readahead_cache(inode);
943 struct inode *inode;
981 * cache's inode item from the root tree. If this inode item is located
986 * It's safe to read the inode item using the commit root because
990 * we will never try to read their inode item while the fs is mounted.
992 inode = lookup_free_space_inode(block_group, path);
993 if (IS_ERR(inode)) {
998 /* We may have converted the inode and made the cache invalid. */
1008 * Reinitialize the class of struct inode's mapping->invalidate_lock for
1012 lockdep_set_class(&(&inode->i_data)->invalidate_lock,
1015 ret = __load_free_space_cache(fs_info->tree_root, inode, &tmp_ctl,
1063 iput(inode);
1147 struct inode *inode,
1162 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1174 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0,
1175 inode->i_size - 1, EXTENT_DELALLOC,
1182 BTRFS_I(inode)->generation = trans->transid;
1264 static int flush_dirty_cache(struct inode *inode)
1268 ret = btrfs_wait_ordered_range(inode, 0, (u64)-1);
1270 clear_extent_bit(&BTRFS_I(inode)->io_tree, 0, inode->i_size - 1,
1286 cleanup_write_cache_enospc(struct inode *inode,
1291 unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
1302 struct inode *inode = io_ctl->inode;
1304 if (!inode)
1308 ret = flush_dirty_cache(inode);
1313 ret = update_cache_item(trans, root, inode, path, offset,
1317 invalidate_inode_pages2(inode->i_mapping);
1318 BTRFS_I(inode)->generation = 0;
1324 btrfs_update_inode(trans, root, BTRFS_I(inode));
1345 io_ctl->inode = NULL;
1346 iput(inode);
1363 * Write out cached info to an inode.
1365 * @root: root the inode belongs to
1366 * @inode: freespace inode we are writing out
1376 static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
1389 if (!i_size_read(inode))
1393 ret = io_ctl_init(io_ctl, inode, 1);
1404 BTRFS_I(inode)->generation = 0;
1417 lock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
1458 ret = btrfs_dirty_pages(BTRFS_I(inode), io_ctl->pages,
1459 io_ctl->num_pages, 0, i_size_read(inode),
1473 unlock_extent(&BTRFS_I(inode)->io_tree, 0, i_size_read(inode) - 1,
1479 * the cache and the inode
1484 ret = btrfs_fdatawrite_range(inode, 0, (u64)-1);
1496 cleanup_write_cache_enospc(inode, io_ctl, &cached_state);
1503 io_ctl->inode = NULL;
1506 invalidate_inode_pages2(inode->i_mapping);
1507 BTRFS_I(inode)->generation = 0;
1509 btrfs_update_inode(trans, root, BTRFS_I(inode));
1511 iput(inode);
1521 struct inode *inode;
1531 inode = lookup_free_space_inode(block_group, path);
1532 if (IS_ERR(inode))
1535 ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl,
1545 block_group->io_ctl.inode = NULL;
1546 iput(inode);
1551 * to wait for IO and put the inode