Commit 7b40b695 authored by Omar Sandoval's avatar Omar Sandoval Committed by David Sterba

Btrfs: get rid of BTRFS_INODE_HAS_ORPHAN_ITEM

Now that we don't add orphan items for truncate, there can't be races on
adding or deleting an orphan item, so this bit is unnecessary.
Reviewed-by: default avatarNikolay Borisov <nborisov@suse.com>
Signed-off-by: default avatarOmar Sandoval <osandov@fb.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent f7e9e8fc
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#define BTRFS_INODE_ORPHAN_META_RESERVED 1 #define BTRFS_INODE_ORPHAN_META_RESERVED 1
#define BTRFS_INODE_DUMMY 2 #define BTRFS_INODE_DUMMY 2
#define BTRFS_INODE_IN_DEFRAG 3 #define BTRFS_INODE_IN_DEFRAG 3
#define BTRFS_INODE_HAS_ORPHAN_ITEM 4
#define BTRFS_INODE_HAS_ASYNC_EXTENT 5 #define BTRFS_INODE_HAS_ASYNC_EXTENT 5
#define BTRFS_INODE_NEEDS_FULL_SYNC 6 #define BTRFS_INODE_NEEDS_FULL_SYNC 6
#define BTRFS_INODE_COPY_EVERYTHING 7 #define BTRFS_INODE_COPY_EVERYTHING 7
......
...@@ -3359,7 +3359,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, ...@@ -3359,7 +3359,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
struct btrfs_root *root = 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;
bool insert = false;
int ret; int ret;
if (!root->orphan_block_rsv) { if (!root->orphan_block_rsv) {
...@@ -3369,10 +3368,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, ...@@ -3369,10 +3368,6 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
return -ENOMEM; return -ENOMEM;
} }
if (!test_and_set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&inode->runtime_flags))
insert = true;
if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED, if (!test_and_set_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&inode->runtime_flags)) &inode->runtime_flags))
reserve = 1; reserve = 1;
...@@ -3386,8 +3381,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, ...@@ -3386,8 +3381,7 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
block_rsv = NULL; block_rsv = NULL;
} }
if (insert) atomic_inc(&root->orphan_inodes);
atomic_inc(&root->orphan_inodes);
spin_unlock(&root->orphan_lock); spin_unlock(&root->orphan_lock);
/* grab metadata reservation from transaction handle */ /* grab metadata reservation from transaction handle */
...@@ -3403,36 +3397,28 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans, ...@@ -3403,36 +3397,28 @@ int btrfs_orphan_add(struct btrfs_trans_handle *trans,
atomic_dec(&root->orphan_inodes); atomic_dec(&root->orphan_inodes);
clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
&inode->runtime_flags); &inode->runtime_flags);
if (insert)
clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&inode->runtime_flags);
return ret; return ret;
} }
} }
/* insert an orphan item to track this unlinked file */ /* insert an orphan item to track this unlinked file */
if (insert) { ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode));
ret = btrfs_insert_orphan_item(trans, root, btrfs_ino(inode)); if (ret) {
if (ret) { if (reserve) {
if (reserve) { clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, &inode->runtime_flags);
&inode->runtime_flags); btrfs_orphan_release_metadata(inode);
btrfs_orphan_release_metadata(inode); }
} /*
/* * btrfs_orphan_commit_root may race with us and set
* btrfs_orphan_commit_root may race with us and set * ->orphan_block_rsv to zero, in order to avoid that,
* ->orphan_block_rsv to zero, in order to avoid that, * decrease ->orphan_inodes after everything is done.
* decrease ->orphan_inodes after everything is done. */
*/ atomic_dec(&root->orphan_inodes);
atomic_dec(&root->orphan_inodes); if (ret != -EEXIST) {
if (ret != -EEXIST) { btrfs_abort_transaction(trans, ret);
clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, return ret;
&inode->runtime_flags);
btrfs_abort_transaction(trans, ret);
return ret;
}
} }
ret = 0;
} }
return 0; return 0;
...@@ -3446,14 +3432,9 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans, ...@@ -3446,14 +3432,9 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans,
struct btrfs_inode *inode) struct btrfs_inode *inode)
{ {
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
int delete_item = 0;
int ret = 0; int ret = 0;
if (test_and_clear_bit(BTRFS_INODE_HAS_ORPHAN_ITEM, if (trans)
&inode->runtime_flags))
delete_item = 1;
if (delete_item && trans)
ret = btrfs_del_orphan_item(trans, root, btrfs_ino(inode)); ret = btrfs_del_orphan_item(trans, root, btrfs_ino(inode));
if (test_and_clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED, if (test_and_clear_bit(BTRFS_INODE_ORPHAN_META_RESERVED,
...@@ -3465,8 +3446,7 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans, ...@@ -3465,8 +3446,7 @@ static int btrfs_orphan_del(struct btrfs_trans_handle *trans,
* to zero, in order to avoid that, decrease ->orphan_inodes after * to zero, in order to avoid that, decrease ->orphan_inodes after
* everything is done. * everything is done.
*/ */
if (delete_item) atomic_dec(&root->orphan_inodes);
atomic_dec(&root->orphan_inodes);
return ret; return ret;
} }
...@@ -3624,12 +3604,6 @@ int btrfs_orphan_cleanup(struct btrfs_root *root) ...@@ -3624,12 +3604,6 @@ int btrfs_orphan_cleanup(struct btrfs_root *root)
continue; continue;
} }
/*
* add this inode to the orphan list so btrfs_orphan_del does
* the proper thing when we hit it
*/
set_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags);
atomic_inc(&root->orphan_inodes); atomic_inc(&root->orphan_inodes);
nr_unlink++; nr_unlink++;
...@@ -5527,11 +5501,8 @@ void btrfs_evict_inode(struct inode *inode) ...@@ -5527,11 +5501,8 @@ void btrfs_evict_inode(struct inode *inode)
btrfs_free_io_failure_record(BTRFS_I(inode), 0, (u64)-1); btrfs_free_io_failure_record(BTRFS_I(inode), 0, (u64)-1);
if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags)) { if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags))
BUG_ON(test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags));
goto no_delete; goto no_delete;
}
if (inode->i_nlink > 0) { if (inode->i_nlink > 0) {
BUG_ON(btrfs_root_refs(&root->root_item) != 0 && BUG_ON(btrfs_root_refs(&root->root_item) != 0 &&
...@@ -9442,13 +9413,6 @@ void btrfs_destroy_inode(struct inode *inode) ...@@ -9442,13 +9413,6 @@ void btrfs_destroy_inode(struct inode *inode)
if (!root) if (!root)
goto free; goto free;
if (test_bit(BTRFS_INODE_HAS_ORPHAN_ITEM,
&BTRFS_I(inode)->runtime_flags)) {
btrfs_info(fs_info, "inode %llu still on the orphan list",
btrfs_ino(BTRFS_I(inode)));
atomic_dec(&root->orphan_inodes);
}
while (1) { while (1) {
ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1); ordered = btrfs_lookup_first_ordered_extent(inode, (u64)-1);
if (!ordered) if (!ordered)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment