提交 3d6ae7bb 编写于 作者: N Nikolay Borisov 提交者: David Sterba

btrfs: make btrfs_orphan_del take btrfs_inode

Signed-off-by: NNikolay Borisov <nborisov@suse.com>
Signed-off-by: NDavid Sterba <dsterba@suse.com>
上级 7ab7956e
...@@ -3271,20 +3271,20 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode) ...@@ -3271,20 +3271,20 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, struct inode *inode)
* item for this particular inode. * item for this particular inode.
*/ */
static int btrfs_orphan_del(struct btrfs_trans_handle *trans, static int btrfs_orphan_del(struct btrfs_trans_handle *trans,
struct inode *inode) struct btrfs_inode *inode)
{ {
struct btrfs_root *root = BTRFS_I(inode)->root; struct btrfs_root *root = inode->root;
int delete_item = 0; int delete_item = 0;
int release_rsv = 0; int release_rsv = 0;
int ret = 0; int ret = 0;
spin_lock(&root->orphan_lock); spin_lock(&root->orphan_lock);
if (test_and_clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, if (test_and_clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags)) &inode->runtime_flags))
delete_item = 1; delete_item = 1;
if (test_and_clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, if (test_and_clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&BTRFS_I(inode)->runtime_flags)) &inode->runtime_flags))
release_rsv = 1; release_rsv = 1;
spin_unlock(&root->orphan_lock); spin_unlock(&root->orphan_lock);
...@@ -3292,11 +3292,11 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans, ...@@ -3292,11 +3292,11 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans,
atomic_dec(&root->orphan_inodes); atomic_dec(&root->orphan_inodes);
if (trans) if (trans)
ret = btrfs_del_orphan_item(trans, root, ret = btrfs_del_orphan_item(trans, root,
btrfs_ino(BTRFS_I(inode))); btrfs_ino(inode));
} }
if (release_rsv) if (release_rsv)
btrfs_orphan_release_metadata(BTRFS_I(inode)); btrfs_orphan_release_metadata(inode);
return ret; return ret;
} }
...@@ -3467,7 +3467,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -3467,7 +3467,7 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
ret = btrfs_truncate(inode); ret = btrfs_truncate(inode);
if (ret) if (ret)
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
} else { } else {
nr_unlink++; nr_unlink++;
} }
...@@ -5012,7 +5012,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -5012,7 +5012,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
/* To get a stable disk_i_size */ /* To get a stable disk_i_size */
err = btrfs_wait_ordered_range(inode, 0, (u64)-1); err = btrfs_wait_ordered_range(inode, 0, (u64)-1);
if (err) { if (err) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
return err; return err;
} }
...@@ -5024,11 +5024,11 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr) ...@@ -5024,11 +5024,11 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
*/ */
trans = btrfs_join_transaction(root); trans = btrfs_join_transaction(root);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
return ret; return ret;
} }
i_size_write(inode, BTRFS_I(inode)->disk_i_size); i_size_write(inode, BTRFS_I(inode)->disk_i_size);
err = btrfs_orphan_del(trans, inode); err = btrfs_orphan_del(trans, BTRFS_I(inode));
if (err) if (err)
btrfs_abort_transaction(trans, err); btrfs_abort_transaction(trans, err);
btrfs_end_transaction(trans); btrfs_end_transaction(trans);
...@@ -5190,7 +5190,7 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5190,7 +5190,7 @@ void btrfs_evict_inode(struct inode *inode)
goto no_delete; goto no_delete;
if (is_bad_inode(inode)) { if (is_bad_inode(inode)) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
goto no_delete; goto no_delete;
} }
/* do we really want it for ->i_nlink > 0 and zero btrfs_root_refs? */ /* do we really want it for ->i_nlink > 0 and zero btrfs_root_refs? */
...@@ -5213,13 +5213,13 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5213,13 +5213,13 @@ void btrfs_evict_inode(struct inode *inode)
ret = btrfs_commit_inode_delayed_inode(BTRFS_I(inode)); ret = btrfs_commit_inode_delayed_inode(BTRFS_I(inode));
if (ret) { if (ret) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
goto no_delete; goto no_delete;
} }
rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP); rsv = btrfs_alloc_block_rsv(fs_info, BTRFS_BLOCK_RSV_TEMP);
if (!rsv) { if (!rsv) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
goto no_delete; goto no_delete;
} }
rsv->size = min_size; rsv->size = min_size;
...@@ -5261,14 +5261,14 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5261,14 +5261,14 @@ void btrfs_evict_inode(struct inode *inode)
btrfs_warn(fs_info, btrfs_warn(fs_info,
"Could not get space for a delete, will truncate on mount %d", "Could not get space for a delete, will truncate on mount %d",
ret); ret);
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
btrfs_free_block_rsv(fs_info, rsv); btrfs_free_block_rsv(fs_info, rsv);
goto no_delete; goto no_delete;
} }
trans = btrfs_join_transaction(root); trans = btrfs_join_transaction(root);
if (IS_ERR(trans)) { if (IS_ERR(trans)) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
btrfs_free_block_rsv(fs_info, rsv); btrfs_free_block_rsv(fs_info, rsv);
goto no_delete; goto no_delete;
} }
...@@ -5294,7 +5294,7 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5294,7 +5294,7 @@ void btrfs_evict_inode(struct inode *inode)
if (ret) { if (ret) {
ret = btrfs_commit_transaction(trans); ret = btrfs_commit_transaction(trans);
if (ret) { if (ret) {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
btrfs_free_block_rsv(fs_info, rsv); btrfs_free_block_rsv(fs_info, rsv);
goto no_delete; goto no_delete;
} }
...@@ -5323,9 +5323,9 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5323,9 +5323,9 @@ void btrfs_evict_inode(struct inode *inode)
*/ */
if (ret == 0) { if (ret == 0) {
trans->block_rsv = root->orphan_block_rsv; trans->block_rsv = root->orphan_block_rsv;
btrfs_orphan_del(trans, inode); btrfs_orphan_del(trans, BTRFS_I(inode));
} else { } else {
btrfs_orphan_del(NULL, inode); btrfs_orphan_del(NULL, BTRFS_I(inode));
} }
trans->block_rsv = &fs_info->trans_block_rsv; trans->block_rsv = &fs_info->trans_block_rsv;
...@@ -6534,7 +6534,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, ...@@ -6534,7 +6534,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
* If new hard link count is 1, it's a file created * If new hard link count is 1, it's a file created
* with open(2) O_TMPFILE flag. * with open(2) O_TMPFILE flag.
*/ */
err = btrfs_orphan_del(trans, inode); err = btrfs_orphan_del(trans, BTRFS_I(inode));
if (err) if (err)
goto fail; goto fail;
} }
...@@ -9167,7 +9167,7 @@ static int btrfs_truncate(struct inode *inode) ...@@ -9167,7 +9167,7 @@ static int btrfs_truncate(struct inode *inode)
if (ret == 0 && inode->i_nlink > 0) { if (ret == 0 && inode->i_nlink > 0) {
trans->block_rsv = root->orphan_block_rsv; trans->block_rsv = root->orphan_block_rsv;
ret = btrfs_orphan_del(trans, inode); ret = btrfs_orphan_del(trans, BTRFS_I(inode));
if (ret) if (ret)
err = ret; err = ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册