Loading fs/btrfs/btrfs_inode.h +5 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,11 @@ struct btrfs_inode { struct btrfs_block_group_cache *block_group; struct btrfs_key location; struct inode vfs_inode; /* * transid of the trans_handle that last modified this inode */ u64 last_trans; }; static inline struct btrfs_inode *BTRFS_I(struct inode *inode) { Loading fs/btrfs/ctree.h +1 −0 Original line number Diff line number Diff line Loading @@ -301,6 +301,7 @@ struct btrfs_fs_info { struct radix_tree_root extent_map_radix; struct radix_tree_root extent_ins_radix; u64 generation; u64 last_trans_committed; struct btrfs_transaction *running_transaction; struct btrfs_super_block *disk_super; struct btrfs_super_block super_copy; Loading fs/btrfs/disk-io.c +1 −0 Original line number Diff line number Diff line Loading @@ -435,6 +435,7 @@ struct btrfs_root *open_ctree(struct super_block *sb) INIT_LIST_HEAD(&fs_info->dead_roots); sb_set_blocksize(sb, 4096); fs_info->running_transaction = NULL; fs_info->last_trans_committed = 0; fs_info->tree_root = tree_root; fs_info->extent_root = extent_root; fs_info->sb = sb; Loading fs/btrfs/file.c +18 −4 Original line number Diff line number Diff line Loading @@ -694,22 +694,36 @@ static int btrfs_sync_file(struct file *file, { struct inode *inode = dentry->d_inode; struct btrfs_root *root = BTRFS_I(inode)->root; int ret; int ret = 0; struct btrfs_trans_handle *trans; /* * FIXME, use inode generation number to check if we can skip the * commit * check the transaction that last modified this inode * and see if its already been committed */ mutex_lock(&root->fs_info->fs_mutex); if (!BTRFS_I(inode)->last_trans) goto out; mutex_lock(&root->fs_info->trans_mutex); if (BTRFS_I(inode)->last_trans <= root->fs_info->last_trans_committed) { BTRFS_I(inode)->last_trans = 0; mutex_unlock(&root->fs_info->trans_mutex); goto out; } mutex_unlock(&root->fs_info->trans_mutex); /* * ok we haven't committed the transaction yet, lets do a commit */ trans = btrfs_start_transaction(root, 1); if (!trans) { ret = -ENOMEM; goto out; } ret = btrfs_commit_transaction(trans, root); mutex_unlock(&root->fs_info->fs_mutex); out: mutex_unlock(&root->fs_info->fs_mutex); return ret > 0 ? EIO : ret; } Loading fs/btrfs/inode.c +2 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,7 @@ static int btrfs_update_inode(struct btrfs_trans_handle *trans, fill_inode_item(inode_item, inode); btrfs_mark_buffer_dirty(path->nodes[0]); btrfs_set_inode_last_trans(trans, inode); ret = 0; failed: btrfs_release_path(root, path); Loading Loading @@ -2234,6 +2235,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) ei = kmem_cache_alloc(btrfs_inode_cachep, GFP_NOFS); if (!ei) return NULL; ei->last_trans = 0; return &ei->vfs_inode; } Loading Loading
fs/btrfs/btrfs_inode.h +5 −0 Original line number Diff line number Diff line Loading @@ -25,6 +25,11 @@ struct btrfs_inode { struct btrfs_block_group_cache *block_group; struct btrfs_key location; struct inode vfs_inode; /* * transid of the trans_handle that last modified this inode */ u64 last_trans; }; static inline struct btrfs_inode *BTRFS_I(struct inode *inode) { Loading
fs/btrfs/ctree.h +1 −0 Original line number Diff line number Diff line Loading @@ -301,6 +301,7 @@ struct btrfs_fs_info { struct radix_tree_root extent_map_radix; struct radix_tree_root extent_ins_radix; u64 generation; u64 last_trans_committed; struct btrfs_transaction *running_transaction; struct btrfs_super_block *disk_super; struct btrfs_super_block super_copy; Loading
fs/btrfs/disk-io.c +1 −0 Original line number Diff line number Diff line Loading @@ -435,6 +435,7 @@ struct btrfs_root *open_ctree(struct super_block *sb) INIT_LIST_HEAD(&fs_info->dead_roots); sb_set_blocksize(sb, 4096); fs_info->running_transaction = NULL; fs_info->last_trans_committed = 0; fs_info->tree_root = tree_root; fs_info->extent_root = extent_root; fs_info->sb = sb; Loading
fs/btrfs/file.c +18 −4 Original line number Diff line number Diff line Loading @@ -694,22 +694,36 @@ static int btrfs_sync_file(struct file *file, { struct inode *inode = dentry->d_inode; struct btrfs_root *root = BTRFS_I(inode)->root; int ret; int ret = 0; struct btrfs_trans_handle *trans; /* * FIXME, use inode generation number to check if we can skip the * commit * check the transaction that last modified this inode * and see if its already been committed */ mutex_lock(&root->fs_info->fs_mutex); if (!BTRFS_I(inode)->last_trans) goto out; mutex_lock(&root->fs_info->trans_mutex); if (BTRFS_I(inode)->last_trans <= root->fs_info->last_trans_committed) { BTRFS_I(inode)->last_trans = 0; mutex_unlock(&root->fs_info->trans_mutex); goto out; } mutex_unlock(&root->fs_info->trans_mutex); /* * ok we haven't committed the transaction yet, lets do a commit */ trans = btrfs_start_transaction(root, 1); if (!trans) { ret = -ENOMEM; goto out; } ret = btrfs_commit_transaction(trans, root); mutex_unlock(&root->fs_info->fs_mutex); out: mutex_unlock(&root->fs_info->fs_mutex); return ret > 0 ? EIO : ret; } Loading
fs/btrfs/inode.c +2 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,7 @@ static int btrfs_update_inode(struct btrfs_trans_handle *trans, fill_inode_item(inode_item, inode); btrfs_mark_buffer_dirty(path->nodes[0]); btrfs_set_inode_last_trans(trans, inode); ret = 0; failed: btrfs_release_path(root, path); Loading Loading @@ -2234,6 +2235,7 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) ei = kmem_cache_alloc(btrfs_inode_cachep, GFP_NOFS); if (!ei) return NULL; ei->last_trans = 0; return &ei->vfs_inode; } Loading