Loading fs/btrfs/btrfs_inode.h +9 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,15 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode) return container_of(inode, struct btrfs_inode, vfs_inode); } static inline u64 btrfs_ino(struct inode *inode) { u64 ino = BTRFS_I(inode)->location.objectid; if (ino <= BTRFS_FIRST_FREE_OBJECTID) ino = inode->i_ino; return ino; } static inline void btrfs_i_size_write(struct inode *inode, u64 size) { i_size_write(inode, size); Loading fs/btrfs/compression.c +3 −2 Original line number Diff line number Diff line Loading @@ -125,9 +125,10 @@ static int check_compressed_csum(struct inode *inode, kunmap_atomic(kaddr, KM_USER0); if (csum != *cb_sum) { printk(KERN_INFO "btrfs csum failed ino %lu " printk(KERN_INFO "btrfs csum failed ino %llu " "extent %llu csum %u " "wanted %u mirror %d\n", inode->i_ino, "wanted %u mirror %d\n", (unsigned long long)btrfs_ino(inode), (unsigned long long)disk_start, csum, *cb_sum, cb->mirror_num); ret = -EIO; Loading fs/btrfs/ctree.h +17 −12 Original line number Diff line number Diff line Loading @@ -105,6 +105,12 @@ struct btrfs_ordered_sum; /* For storing free space cache */ #define BTRFS_FREE_SPACE_OBJECTID -11ULL /* * The inode number assigned to the special inode for sotring * free ino cache */ #define BTRFS_FREE_INO_OBJECTID -12ULL /* dummy objectid represents multiple objectids */ #define BTRFS_MULTIPLE_OBJECTIDS -255ULL Loading Loading @@ -830,9 +836,6 @@ struct btrfs_block_group_cache { u64 bytes_super; u64 flags; u64 sectorsize; int extents_thresh; int free_extents; int total_bitmaps; unsigned int ro:1; unsigned int dirty:1; unsigned int iref:1; Loading @@ -847,9 +850,7 @@ struct btrfs_block_group_cache { struct btrfs_space_info *space_info; /* free space cache stuff */ spinlock_t tree_lock; struct rb_root free_space_offset; u64 free_space; struct btrfs_free_space_ctl *free_space_ctl; /* block group cache stuff */ struct rb_node cache_node; Loading Loading @@ -1107,6 +1108,16 @@ struct btrfs_root { spinlock_t accounting_lock; struct btrfs_block_rsv *block_rsv; /* free ino cache stuff */ struct mutex fs_commit_mutex; struct btrfs_free_space_ctl *free_ino_ctl; enum btrfs_caching_type cached; spinlock_t cache_lock; wait_queue_head_t cache_wait; struct btrfs_free_space_ctl *free_ino_pinned; u64 cache_progress; struct inode *cache_inode; struct mutex log_mutex; wait_queue_head_t log_writer_wait; wait_queue_head_t log_commit_wait[2]; Loading Loading @@ -2413,12 +2424,6 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 offset); int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset); /* inode-map.c */ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, struct btrfs_root *fs_root, u64 dirid, u64 *objectid); int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid); /* inode-item.c */ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, Loading fs/btrfs/disk-io.c +19 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "locking.h" #include "tree-log.h" #include "free-space-cache.h" #include "inode-map.h" static struct extent_io_ops btree_extent_io_ops; static void end_workqueue_fn(struct btrfs_work *work); Loading Loading @@ -1326,6 +1327,19 @@ struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, if (IS_ERR(root)) return root; root->free_ino_ctl = kzalloc(sizeof(*root->free_ino_ctl), GFP_NOFS); if (!root->free_ino_ctl) goto fail; root->free_ino_pinned = kzalloc(sizeof(*root->free_ino_pinned), GFP_NOFS); if (!root->free_ino_pinned) goto fail; btrfs_init_free_ino_ctl(root); mutex_init(&root->fs_commit_mutex); spin_lock_init(&root->cache_lock); init_waitqueue_head(&root->cache_wait); set_anon_super(&root->anon_super, NULL); if (btrfs_root_refs(&root->root_item) == 0) { Loading Loading @@ -2404,12 +2418,15 @@ int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) if (btrfs_root_refs(&root->root_item) == 0) synchronize_srcu(&fs_info->subvol_srcu); __btrfs_remove_free_space_cache(root->free_ino_pinned); __btrfs_remove_free_space_cache(root->free_ino_ctl); free_fs_root(root); return 0; } static void free_fs_root(struct btrfs_root *root) { iput(root->cache_inode); WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); if (root->anon_super.s_dev) { down_write(&root->anon_super.s_umount); Loading @@ -2417,6 +2434,8 @@ static void free_fs_root(struct btrfs_root *root) } free_extent_buffer(root->node); free_extent_buffer(root->commit_root); kfree(root->free_ino_ctl); kfree(root->free_ino_pinned); kfree(root->name); kfree(root); } Loading fs/btrfs/export.c +14 −11 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, len = BTRFS_FID_SIZE_NON_CONNECTABLE; type = FILEID_BTRFS_WITHOUT_PARENT; fid->objectid = inode->i_ino; fid->objectid = btrfs_ino(inode); fid->root_objectid = BTRFS_I(inode)->root->objectid; fid->gen = inode->i_generation; Loading Loading @@ -178,13 +178,13 @@ static struct dentry *btrfs_get_parent(struct dentry *child) if (!path) return ERR_PTR(-ENOMEM); if (dir->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (btrfs_ino(dir) == BTRFS_FIRST_FREE_OBJECTID) { key.objectid = root->root_key.objectid; key.type = BTRFS_ROOT_BACKREF_KEY; key.offset = (u64)-1; root = root->fs_info->tree_root; } else { key.objectid = dir->i_ino; key.objectid = btrfs_ino(dir); key.type = BTRFS_INODE_REF_KEY; key.offset = (u64)-1; } Loading Loading @@ -244,6 +244,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, struct btrfs_key key; int name_len; int ret; u64 ino; if (!dir || !inode) return -EINVAL; Loading @@ -251,19 +252,21 @@ static int btrfs_get_name(struct dentry *parent, char *name, if (!S_ISDIR(dir->i_mode)) return -EINVAL; ino = btrfs_ino(inode); path = btrfs_alloc_path(); if (!path) return -ENOMEM; path->leave_spinning = 1; if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (ino == BTRFS_FIRST_FREE_OBJECTID) { key.objectid = BTRFS_I(inode)->root->root_key.objectid; key.type = BTRFS_ROOT_BACKREF_KEY; key.offset = (u64)-1; root = root->fs_info->tree_root; } else { key.objectid = inode->i_ino; key.offset = dir->i_ino; key.objectid = ino; key.offset = btrfs_ino(dir); key.type = BTRFS_INODE_REF_KEY; } Loading @@ -272,7 +275,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, btrfs_free_path(path); return ret; } else if (ret > 0) { if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (ino == BTRFS_FIRST_FREE_OBJECTID) { path->slots[0]--; } else { btrfs_free_path(path); Loading @@ -281,7 +284,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, } leaf = path->nodes[0]; if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (ino == BTRFS_FIRST_FREE_OBJECTID) { rref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref); name_ptr = (unsigned long)(rref + 1); Loading Loading
fs/btrfs/btrfs_inode.h +9 −0 Original line number Diff line number Diff line Loading @@ -166,6 +166,15 @@ static inline struct btrfs_inode *BTRFS_I(struct inode *inode) return container_of(inode, struct btrfs_inode, vfs_inode); } static inline u64 btrfs_ino(struct inode *inode) { u64 ino = BTRFS_I(inode)->location.objectid; if (ino <= BTRFS_FIRST_FREE_OBJECTID) ino = inode->i_ino; return ino; } static inline void btrfs_i_size_write(struct inode *inode, u64 size) { i_size_write(inode, size); Loading
fs/btrfs/compression.c +3 −2 Original line number Diff line number Diff line Loading @@ -125,9 +125,10 @@ static int check_compressed_csum(struct inode *inode, kunmap_atomic(kaddr, KM_USER0); if (csum != *cb_sum) { printk(KERN_INFO "btrfs csum failed ino %lu " printk(KERN_INFO "btrfs csum failed ino %llu " "extent %llu csum %u " "wanted %u mirror %d\n", inode->i_ino, "wanted %u mirror %d\n", (unsigned long long)btrfs_ino(inode), (unsigned long long)disk_start, csum, *cb_sum, cb->mirror_num); ret = -EIO; Loading
fs/btrfs/ctree.h +17 −12 Original line number Diff line number Diff line Loading @@ -105,6 +105,12 @@ struct btrfs_ordered_sum; /* For storing free space cache */ #define BTRFS_FREE_SPACE_OBJECTID -11ULL /* * The inode number assigned to the special inode for sotring * free ino cache */ #define BTRFS_FREE_INO_OBJECTID -12ULL /* dummy objectid represents multiple objectids */ #define BTRFS_MULTIPLE_OBJECTIDS -255ULL Loading Loading @@ -830,9 +836,6 @@ struct btrfs_block_group_cache { u64 bytes_super; u64 flags; u64 sectorsize; int extents_thresh; int free_extents; int total_bitmaps; unsigned int ro:1; unsigned int dirty:1; unsigned int iref:1; Loading @@ -847,9 +850,7 @@ struct btrfs_block_group_cache { struct btrfs_space_info *space_info; /* free space cache stuff */ spinlock_t tree_lock; struct rb_root free_space_offset; u64 free_space; struct btrfs_free_space_ctl *free_space_ctl; /* block group cache stuff */ struct rb_node cache_node; Loading Loading @@ -1107,6 +1108,16 @@ struct btrfs_root { spinlock_t accounting_lock; struct btrfs_block_rsv *block_rsv; /* free ino cache stuff */ struct mutex fs_commit_mutex; struct btrfs_free_space_ctl *free_ino_ctl; enum btrfs_caching_type cached; spinlock_t cache_lock; wait_queue_head_t cache_wait; struct btrfs_free_space_ctl *free_ino_pinned; u64 cache_progress; struct inode *cache_inode; struct mutex log_mutex; wait_queue_head_t log_writer_wait; wait_queue_head_t log_commit_wait[2]; Loading Loading @@ -2413,12 +2424,6 @@ int btrfs_del_orphan_item(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 offset); int btrfs_find_orphan_item(struct btrfs_root *root, u64 offset); /* inode-map.c */ int btrfs_find_free_objectid(struct btrfs_trans_handle *trans, struct btrfs_root *fs_root, u64 dirid, u64 *objectid); int btrfs_find_highest_inode(struct btrfs_root *fs_root, u64 *objectid); /* inode-item.c */ int btrfs_insert_inode_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, Loading
fs/btrfs/disk-io.c +19 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,7 @@ #include "locking.h" #include "tree-log.h" #include "free-space-cache.h" #include "inode-map.h" static struct extent_io_ops btree_extent_io_ops; static void end_workqueue_fn(struct btrfs_work *work); Loading Loading @@ -1326,6 +1327,19 @@ struct btrfs_root *btrfs_read_fs_root_no_name(struct btrfs_fs_info *fs_info, if (IS_ERR(root)) return root; root->free_ino_ctl = kzalloc(sizeof(*root->free_ino_ctl), GFP_NOFS); if (!root->free_ino_ctl) goto fail; root->free_ino_pinned = kzalloc(sizeof(*root->free_ino_pinned), GFP_NOFS); if (!root->free_ino_pinned) goto fail; btrfs_init_free_ino_ctl(root); mutex_init(&root->fs_commit_mutex); spin_lock_init(&root->cache_lock); init_waitqueue_head(&root->cache_wait); set_anon_super(&root->anon_super, NULL); if (btrfs_root_refs(&root->root_item) == 0) { Loading Loading @@ -2404,12 +2418,15 @@ int btrfs_free_fs_root(struct btrfs_fs_info *fs_info, struct btrfs_root *root) if (btrfs_root_refs(&root->root_item) == 0) synchronize_srcu(&fs_info->subvol_srcu); __btrfs_remove_free_space_cache(root->free_ino_pinned); __btrfs_remove_free_space_cache(root->free_ino_ctl); free_fs_root(root); return 0; } static void free_fs_root(struct btrfs_root *root) { iput(root->cache_inode); WARN_ON(!RB_EMPTY_ROOT(&root->inode_tree)); if (root->anon_super.s_dev) { down_write(&root->anon_super.s_umount); Loading @@ -2417,6 +2434,8 @@ static void free_fs_root(struct btrfs_root *root) } free_extent_buffer(root->node); free_extent_buffer(root->commit_root); kfree(root->free_ino_ctl); kfree(root->free_ino_pinned); kfree(root->name); kfree(root); } Loading
fs/btrfs/export.c +14 −11 Original line number Diff line number Diff line Loading @@ -32,7 +32,7 @@ static int btrfs_encode_fh(struct dentry *dentry, u32 *fh, int *max_len, len = BTRFS_FID_SIZE_NON_CONNECTABLE; type = FILEID_BTRFS_WITHOUT_PARENT; fid->objectid = inode->i_ino; fid->objectid = btrfs_ino(inode); fid->root_objectid = BTRFS_I(inode)->root->objectid; fid->gen = inode->i_generation; Loading Loading @@ -178,13 +178,13 @@ static struct dentry *btrfs_get_parent(struct dentry *child) if (!path) return ERR_PTR(-ENOMEM); if (dir->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (btrfs_ino(dir) == BTRFS_FIRST_FREE_OBJECTID) { key.objectid = root->root_key.objectid; key.type = BTRFS_ROOT_BACKREF_KEY; key.offset = (u64)-1; root = root->fs_info->tree_root; } else { key.objectid = dir->i_ino; key.objectid = btrfs_ino(dir); key.type = BTRFS_INODE_REF_KEY; key.offset = (u64)-1; } Loading Loading @@ -244,6 +244,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, struct btrfs_key key; int name_len; int ret; u64 ino; if (!dir || !inode) return -EINVAL; Loading @@ -251,19 +252,21 @@ static int btrfs_get_name(struct dentry *parent, char *name, if (!S_ISDIR(dir->i_mode)) return -EINVAL; ino = btrfs_ino(inode); path = btrfs_alloc_path(); if (!path) return -ENOMEM; path->leave_spinning = 1; if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (ino == BTRFS_FIRST_FREE_OBJECTID) { key.objectid = BTRFS_I(inode)->root->root_key.objectid; key.type = BTRFS_ROOT_BACKREF_KEY; key.offset = (u64)-1; root = root->fs_info->tree_root; } else { key.objectid = inode->i_ino; key.offset = dir->i_ino; key.objectid = ino; key.offset = btrfs_ino(dir); key.type = BTRFS_INODE_REF_KEY; } Loading @@ -272,7 +275,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, btrfs_free_path(path); return ret; } else if (ret > 0) { if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (ino == BTRFS_FIRST_FREE_OBJECTID) { path->slots[0]--; } else { btrfs_free_path(path); Loading @@ -281,7 +284,7 @@ static int btrfs_get_name(struct dentry *parent, char *name, } leaf = path->nodes[0]; if (inode->i_ino == BTRFS_FIRST_FREE_OBJECTID) { if (ino == BTRFS_FIRST_FREE_OBJECTID) { rref = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_root_ref); name_ptr = (unsigned long)(rref + 1); Loading