Lines Matching defs:inode
37 #include "inode-map.h"
90 /* Mask out flags that are inappropriate for the given type of inode. */
91 static unsigned int btrfs_mask_fsflags_for_type(struct inode *inode,
94 if (S_ISDIR(inode->i_mode))
96 else if (S_ISREG(inode->i_mode))
103 * Export internal inode flags to the format expected by the FS_IOC_GETFLAGS
134 * Update inode->i_flags based on the btrfs internal flags.
136 void btrfs_sync_inode_flags_to_i_flags(struct inode *inode)
138 struct btrfs_inode *binode = BTRFS_I(inode);
152 set_mask_bits(&inode->i_flags,
198 struct inode *inode = file_inode(file);
199 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
200 struct btrfs_inode *binode = BTRFS_I(inode);
208 if (!inode_owner_or_capable(inode))
221 inode_lock(inode);
222 fsflags = btrfs_mask_fsflags_for_type(inode, fsflags);
225 ret = vfs_ioc_setflags_prepare(inode, old_fsflags, fsflags);
259 if (S_ISREG(inode->i_mode)) {
265 if (inode->i_size == 0)
275 if (S_ISREG(inode->i_mode)) {
276 if (inode->i_size == 0)
294 if (IS_SWAPFILE(inode)) {
310 * 1 for inode item
320 ret = btrfs_set_prop(trans, inode, "btrfs.compression", comp,
327 ret = btrfs_set_prop(trans, inode, "btrfs.compression", NULL,
336 btrfs_sync_inode_flags_to_i_flags(inode);
337 inode_inc_iversion(inode);
338 inode->i_ctime = current_time(inode);
339 ret = btrfs_update_inode(trans, root, inode);
344 inode_unlock(inode);
350 * Translate btrfs internal inode flags to xflags as expected by the
394 * Set the xflags from the internal inode flags. The remaining items of fsxattr
411 struct inode *inode = file_inode(file);
412 struct btrfs_inode *binode = BTRFS_I(inode);
420 if (!inode_owner_or_capable(inode))
440 inode_lock(inode);
443 old_i_flags = inode->i_flags;
447 ret = vfs_ioc_fssetxattr_check(inode, &old_fa, &fa);
472 /* 1 item for the inode */
479 btrfs_sync_inode_flags_to_i_flags(inode);
480 inode_inc_iversion(inode);
481 inode->i_ctime = current_time(inode);
482 ret = btrfs_update_inode(trans, root, inode);
489 inode->i_flags = old_i_flags;
492 inode_unlock(inode);
500 struct inode *inode = file_inode(file);
502 return put_user(inode->i_generation, arg);
577 static noinline int create_subvol(struct inode *dir,
592 struct inode *inode;
652 inode_item = &root_item->inode;
722 /* We potentially lose an unused inode item here */
777 inode = btrfs_lookup_dentry(dir, dentry);
778 if (IS_ERR(inode))
779 return PTR_ERR(inode);
780 d_instantiate(dentry, inode);
791 static int create_snapshot(struct btrfs_root *root, struct inode *dir,
796 struct inode *inode;
831 * 1 - parent dir inode
873 inode = btrfs_lookup_dentry(d_inode(dentry->d_parent), dentry);
874 if (IS_ERR(inode)) {
875 ret = PTR_ERR(inode);
879 d_instantiate(dentry, inode);
918 static int btrfs_may_delete(struct inode *dir, struct dentry *victim, int isdir)
951 static inline int btrfs_may_create(struct inode *dir, struct dentry *child)
971 struct inode *dir = d_inode(parent->dentry);
1066 static int check_defrag_in_cache(struct inode *inode, u64 offset, u32 thresh)
1068 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
1070 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
1100 struct inode *inode, u64 newer_than,
1109 u64 ino = btrfs_ino(BTRFS_I(inode));
1136 check_defrag_in_cache(inode, min_key.offset, thresh)) {
1159 static struct extent_map *defrag_lookup_extent(struct inode *inode, u64 start)
1161 struct extent_map_tree *em_tree = &BTRFS_I(inode)->extent_tree;
1162 struct extent_io_tree *io_tree = &BTRFS_I(inode)->io_tree;
1180 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, start, len);
1190 static bool defrag_check_next_extent(struct inode *inode, struct extent_map *em)
1196 if (em->start + em->len >= i_size_read(inode))
1199 next = defrag_lookup_extent(inode, em->start + em->len);
1210 static int should_defrag_range(struct inode *inode, u64 start, u32 thresh,
1228 em = defrag_lookup_extent(inode, start);
1241 next_mergeable = defrag_check_next_extent(inode, em);
1282 static int cluster_pages_for_defrag(struct inode *inode,
1288 u64 isize = i_size_read(inode);
1301 gfp_t mask = btrfs_alloc_write_mask(inode->i_mapping);
1309 ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
1314 tree = &BTRFS_I(inode)->io_tree;
1320 page = find_or_create_page(inode->i_mapping,
1330 ordered = btrfs_lookup_ordered_extent(BTRFS_I(inode),
1345 if (page->mapping != inode->i_mapping) {
1363 if (page->mapping != inode->i_mapping) {
1375 if (!(inode->i_sb->s_flags & SB_ACTIVE))
1388 lock_extent_bits(&BTRFS_I(inode)->io_tree,
1395 * before locking the inode and then, if it should, we trigger a sync
1396 * page cache readahead - we lock the inode only after that to avoid
1398 * other file ranges. But before we were able to get the inode lock,
1401 * for that here, where we have the inode and the range locked, and bail
1408 em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, search_start,
1424 clear_extent_bit(&BTRFS_I(inode)->io_tree, page_start,
1429 spin_lock(&BTRFS_I(inode)->lock);
1430 btrfs_mod_outstanding_extents(BTRFS_I(inode), 1);
1431 spin_unlock(&BTRFS_I(inode)->lock);
1432 btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
1437 set_extent_defrag(&BTRFS_I(inode)->io_tree, page_start, page_end - 1,
1440 unlock_extent_cached(&BTRFS_I(inode)->io_tree,
1451 btrfs_delalloc_release_extents(BTRFS_I(inode), page_cnt << PAGE_SHIFT);
1456 unlock_extent_cached(&BTRFS_I(inode)->io_tree,
1463 btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
1465 btrfs_delalloc_release_extents(BTRFS_I(inode), page_cnt << PAGE_SHIFT);
1471 int btrfs_defrag_file(struct inode *inode, struct file *file,
1475 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
1476 struct btrfs_root *root = BTRFS_I(inode)->root;
1479 u64 isize = i_size_read(inode);
1520 file_ra_state_init(ra, inode->i_mapping);
1540 ret = find_new_extents(root, inode, newer_than,
1561 if (i < inode->i_mapping->writeback_index)
1562 inode->i_mapping->writeback_index = i;
1565 (i < DIV_ROUND_UP(i_size_read(inode), PAGE_SIZE))) {
1570 if (!(inode->i_sb->s_flags & SB_ACTIVE))
1579 if (!should_defrag_range(inode, (u64)i << PAGE_SHIFT,
1603 page_cache_sync_readahead(inode->i_mapping, ra,
1608 inode_lock(inode);
1609 if (IS_SWAPFILE(inode)) {
1613 BTRFS_I(inode)->defrag_compress = compress_type;
1614 ret = cluster_pages_for_defrag(inode, pages, i, cluster);
1617 inode_unlock(inode);
1622 balance_dirty_pages_ratelimited(inode->i_mapping);
1623 inode_unlock(inode);
1635 ret = find_new_extents(root, inode, newer_than,
1655 filemap_flush(inode->i_mapping);
1657 &BTRFS_I(inode)->runtime_flags))
1658 filemap_flush(inode->i_mapping);
1671 inode_lock(inode);
1672 BTRFS_I(inode)->defrag_compress = BTRFS_COMPRESS_NONE;
1673 inode_unlock(inode);
1684 struct inode *inode = file_inode(file);
1685 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
1689 struct btrfs_root *root = BTRFS_I(inode)->root;
1857 struct inode *src_inode;
1877 * to the subvolume inode, otherwise the permission
1983 struct inode *inode = file_inode(file);
1984 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
1985 struct btrfs_root *root = BTRFS_I(inode)->root;
1989 if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FIRST_FREE_OBJECTID)
2006 struct inode *inode = file_inode(file);
2007 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
2008 struct btrfs_root *root = BTRFS_I(inode)->root;
2014 if (!inode_owner_or_capable(inode))
2021 if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FIRST_FREE_OBJECTID) {
2249 static noinline int search_ioctl(struct inode *inode,
2254 struct btrfs_fs_info *info = btrfs_sb(inode->i_sb);
2272 /* search the root of the inode that was passed */
2273 root = btrfs_grab_root(BTRFS_I(inode)->root);
2319 struct inode *inode;
2333 inode = file_inode(file);
2334 ret = search_ioctl(inode, &sk, &buf_size, uargs->buf);
2353 struct inode *inode;
2372 inode = file_inode(file);
2373 ret = search_ioctl(inode, &args.key, &buf_size,
2472 static int btrfs_search_path_in_tree_user(struct inode *inode,
2475 struct btrfs_fs_info *fs_info = BTRFS_I(inode)->root->fs_info;
2476 struct super_block *sb = inode->i_sb;
2477 struct btrfs_key upper_limit = BTRFS_I(inode)->location;
2478 u64 treeid = BTRFS_I(inode)->root->root_key.objectid;
2488 struct inode *temp_inode;
2568 * btrfs_iget() needs to lookup the inode from its root
2645 struct inode *inode;
2652 inode = file_inode(file);
2659 args->treeid = BTRFS_I(inode)->root->root_key.objectid;
2671 ret = btrfs_search_path_in_tree(BTRFS_I(inode)->root->fs_info,
2690 * 2. Path construction will be stopped at the inode number which corresponds
2692 * exist under fd's inode, -EACCES will be returned.
2698 struct inode *inode;
2705 inode = file_inode(file);
2708 BTRFS_I(inode)->location.objectid != BTRFS_FIRST_FREE_OBJECTID) {
2717 ret = btrfs_search_path_in_tree_user(inode, args);
2739 struct inode *inode;
2753 inode = file_inode(file);
2754 fs_info = BTRFS_I(inode)->root->fs_info;
2756 /* Get root_item of inode's subvolume */
2757 key.objectid = BTRFS_I(inode)->root->root_key.objectid;
2846 * Return ROOT_REF information of the subvolume containing this inode
2857 struct inode *inode;
2873 inode = file_inode(file);
2874 root = BTRFS_I(inode)->root->fs_info->tree_root;
2875 objectid = BTRFS_I(inode)->root->root_key.objectid;
2950 struct inode *dir = d_inode(parent);
2951 struct inode *inode;
3078 inode = d_inode(dentry);
3079 dest = BTRFS_I(inode)->root;
3109 err = inode_permission(inode, MAY_WRITE | MAY_EXEC);
3119 if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FIRST_FREE_OBJECTID) {
3124 inode_lock(inode);
3126 inode_unlock(inode);
3149 struct inode *inode = file_inode(file);
3150 struct btrfs_root *root = BTRFS_I(inode)->root;
3163 switch (inode->i_mode & S_IFMT) {
3178 inode_permission(inode, MAY_WRITE)) {
3254 struct inode *inode = file_inode(file);
3255 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
3307 struct inode *inode = file_inode(file);
3308 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
3442 struct inode *inode = file_inode(file);
3443 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
3444 struct btrfs_root *root = BTRFS_I(inode)->root;
4209 struct inode *inode = file_inode(file);
4210 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4250 struct inode *inode = file_inode(file);
4251 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4252 struct btrfs_root *root = BTRFS_I(inode)->root;
4303 struct inode *inode = file_inode(file);
4304 struct btrfs_root *root = BTRFS_I(inode)->root;
4358 struct inode *inode = file_inode(file);
4359 struct btrfs_root *root = BTRFS_I(inode)->root;
4406 struct inode *inode = file_inode(file);
4407 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4475 struct inode *inode = file_inode(file);
4476 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4477 struct btrfs_root *root = BTRFS_I(inode)->root;
4480 struct timespec64 ct = current_time(inode);
4484 if (!inode_owner_or_capable(inode))
4493 if (btrfs_ino(BTRFS_I(inode)) != BTRFS_FIRST_FREE_OBJECTID) {
4663 struct inode *inode = file_inode(file);
4664 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4665 struct btrfs_root *root = BTRFS_I(inode)->root;
4806 struct inode *inode = file_inode(file);
4807 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4808 struct btrfs_root *root = BTRFS_I(inode)->root;
4913 struct inode *inode = file_inode(file);
4914 struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
4915 struct btrfs_root *root = BTRFS_I(inode)->root;
4987 ret = btrfs_sync_fs(inode->i_sb, 1);