提交 73f2e545 编写于 作者: N Nikolay Borisov 提交者: David Sterba

btrfs: Make btrfs_orphan_add take btrfs_inode

Signed-off-by: NNikolay Borisov <nborisov@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 3d6ae7bb
...@@ -3174,7 +3174,8 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans, ...@@ -3174,7 +3174,8 @@ int btrfs_update_inode(struct btrfs_trans_handle *trans,
struct inode *inode); struct inode *inode);
int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans, int btrfs_update_inode_fallback(struct btrfs_trans_handle *trans,
struct btrfs_root *root, struct inode *inode); struct btrfs_root *root, struct inode *inode);
int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode); int btrfs_orphan_add(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode);
int btrfs_orphan_cleanup(struct btrfs_root *root); int btrfs_orphan_cleanup(struct btrfs_root *root);
void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
struct btrfs_root *root); struct btrfs_root *root);
......
...@@ -10337,7 +10337,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, ...@@ -10337,7 +10337,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
mutex_unlock(&trans->transaction->cache_write_mutex); mutex_unlock(&trans->transaction->cache_write_mutex);
if (!IS_ERR(inode)) { if (!IS_ERR(inode)) {
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, BTRFS_I(inode));
if (ret) { if (ret) {
btrfs_add_delayed_iput(inode); btrfs_add_delayed_iput(inode);
goto out; goto out;
......
...@@ -3172,10 +3172,11 @@ void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans, ...@@ -3172,10 +3172,11 @@ void btrfs_orphan_commit_root(struct btrfs_trans_handle *trans,
* NOTE: caller of this function should reserve 5 units of metadata for * NOTE: caller of this function should reserve 5 units of metadata for
* this function. * this function.
*/ */
int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) int btrfs_orphan_add(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode)
{ {
struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); struct btrfs_fs_info *fs_info = btrfs_sb(inode->vfs_inode.i_sb);
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = inode->root;
struct btrfs_block_rsv *block_rsv = NULL; struct btrfs_block_rsv *block_rsv = NULL;
int reserve = 0; int reserve = 0;
int insert = 0; int insert = 0;
...@@ -3197,7 +3198,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) ...@@ -3197,7 +3198,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
} }
if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags)) { &inode->runtime_flags)) {
#if 0 #if 0
/* /*
* For proper ENOSPC handling, we should do orphan * For proper ENOSPC handling, we should do orphan
...@@ -3214,39 +3215,38 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) ...@@ -3214,39 +3215,38 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
} }
if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED, if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&BTRFS_I(inode)->runtime_flags)) &inode->runtime_flags))
reserve = 1; reserve = 1;
spin_unlock(&root->orphan_lock); spin_unlock(&root->orphan_lock);
/* grab metadata reservation from transaction handle */ /* grab metadata reservation from transaction handle */
if (reserve) { if (reserve) {
ret = btrfs_orphan_reserve_metadata(trans, BTRFS_I(inode)); ret = btrfs_orphan_reserve_metadata(trans, inode);
ASSERT(!ret); ASSERT(!ret);
if (ret) { if (ret) {
atomic_dec(&root->orphan_inodes); atomic_dec(&root->orphan_inodes);
clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&BTRFS_I(inode)->runtime_flags); &inode->runtime_flags);
if (insert) if (insert)
clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags); &inode->runtime_flags);
return ret; return ret;
} }
} }
/* insert an orphan item to track this unlinked/truncated file */ /* insert an orphan item to track this unlinked/truncated file */
if (insert >= 1) { if (insert >= 1) {
ret = btrfs_insert_orphan_item(trans, root, ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
btrfs_ino(BTRFS_I(inode)));
if (ret) { if (ret) {
atomic_dec(&root->orphan_inodes); atomic_dec(&root->orphan_inodes);
if (reserve) { if (reserve) {
clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&BTRFS_I(inode)->runtime_flags); &inode->runtime_flags);
btrfs_orphan_release_metadata(BTRFS_I(inode)); btrfs_orphan_release_metadata(inode);
} }
if (ret != -EEXIST) { if (ret != -EEXIST) {
clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags); &inode->runtime_flags);
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
return ret; return ret;
} }
...@@ -3458,7 +3458,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -3458,7 +3458,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
ret = PTR_ERR(trans); ret = PTR_ERR(trans);
goto out; goto out;
} }
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, BTRFS_I(inode));
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
if (ret) { if (ret) {
iput(inode); iput(inode);
...@@ -4060,7 +4060,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry) ...@@ -4060,7 +4060,7 @@ static int btrfs_unlink(struct inode *dir, struct dentry *dentry)
goto out; goto out;
if (inode->i_nlink == 0) { if (inode->i_nlink == 0) {
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, BTRFS_I(inode));
if (ret) if (ret)
goto out; goto out;
} }
...@@ -4177,7 +4177,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry) ...@@ -4177,7 +4177,7 @@ static int btrfs_rmdir(struct inode *dir, struct dentry *dentry)
goto out; goto out;
} }
err = btrfs_orphan_add(trans, inode); err = btrfs_orphan_add(trans, BTRFS_I(inode));
if (err) if (err)
goto out; goto out;
...@@ -4992,7 +4992,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -4992,7 +4992,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
* so we need to guarantee from this point on that everything * so we need to guarantee from this point on that everything
* will be consistent. * will be consistent.
*/ */
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, BTRFS_I(inode));
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
if (ret) if (ret)
return ret; return ret;
...@@ -9865,7 +9865,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry, ...@@ -9865,7 +9865,8 @@ static int btrfs_rename(struct inode *old_dir, struct dentry *old_dentry,
new_dentry->d_name.len); new_dentry->d_name.len);
} }
if (!ret && new_inode->i_nlink == 0) if (!ret && new_inode->i_nlink == 0)
ret = btrfs_orphan_add(trans, d_inode(new_dentry)); ret = btrfs_orphan_add(trans,
BTRFS_I(d_inode(new_dentry)));
if (ret) { if (ret) {
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto out_fail; goto out_fail;
...@@ -10482,7 +10483,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode) ...@@ -10482,7 +10483,7 @@ static int btrfs_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
ret = btrfs_update_inode(trans, root, inode); ret = btrfs_update_inode(trans, root, inode);
if (ret) if (ret)
goto out_inode; goto out_inode;
ret = btrfs_orphan_add(trans, inode); ret = btrfs_orphan_add(trans, BTRFS_I(inode));
if (ret) if (ret)
goto out_inode; goto out_inode;
......
...@@ -4246,7 +4246,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info, ...@@ -4246,7 +4246,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
BUG_ON(IS_ERR(inode) || is_bad_inode(inode)); BUG_ON(IS_ERR(inode) || is_bad_inode(inode));
BTRFS_I(inode)->index_cnt = group->key.objectid; BTRFS_I(inode)->index_cnt = group->key.objectid;
err = btrfs_orphan_add(trans, inode); err = btrfs_orphan_add(trans, BTRFS_I(inode));
out: out:
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
btrfs_btree_balance_dirty(fs_info); btrfs_btree_balance_dirty(fs_info);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册