Commit 54c65371 authored by David Sterba's avatar David Sterba

btrfs: open code btrfs_ordered_inode_tree in btrfs_inode

The structure btrfs_ordered_inode_tree is used only in one place, in
btrfs_inode. The structure itself has a 4 byte hole which is wasted
space.

Move the btrfs_ordered_inode_tree members to btrfs_inode with a common
prefix 'ordered_tree_' where the hole can be utilized and shrink inode
size.
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent cb6cbab7
...@@ -114,7 +114,9 @@ struct btrfs_inode { ...@@ -114,7 +114,9 @@ struct btrfs_inode {
struct mutex log_mutex; struct mutex log_mutex;
/* used to order data wrt metadata */ /* used to order data wrt metadata */
struct btrfs_ordered_inode_tree ordered_tree; spinlock_t ordered_tree_lock;
struct rb_root ordered_tree;
struct rb_node *ordered_tree_last;
/* list of all the delalloc inodes in the FS. There are times we need /* list of all the delalloc inodes in the FS. There are times we need
* to write all the delalloc pages to disk, and this list is used * to write all the delalloc pages to disk, and this list is used
......
...@@ -8011,11 +8011,11 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset, ...@@ -8011,11 +8011,11 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
EXTENT_LOCKED | EXTENT_DO_ACCOUNTING | EXTENT_LOCKED | EXTENT_DO_ACCOUNTING |
EXTENT_DEFRAG, &cached_state); EXTENT_DEFRAG, &cached_state);
spin_lock_irq(&inode->ordered_tree.lock); spin_lock_irq(&inode->ordered_tree_lock);
set_bit(BTRFS_ORDERED_TRUNCATED, &ordered->flags); set_bit(BTRFS_ORDERED_TRUNCATED, &ordered->flags);
ordered->truncated_len = min(ordered->truncated_len, ordered->truncated_len = min(ordered->truncated_len,
cur - ordered->file_offset); cur - ordered->file_offset);
spin_unlock_irq(&inode->ordered_tree.lock); spin_unlock_irq(&inode->ordered_tree_lock);
/* /*
* If the ordered extent has finished, we're safe to delete all * If the ordered extent has finished, we're safe to delete all
...@@ -8497,7 +8497,9 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) ...@@ -8497,7 +8497,9 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)
extent_io_tree_init(fs_info, &ei->file_extent_tree, extent_io_tree_init(fs_info, &ei->file_extent_tree,
IO_TREE_INODE_FILE_EXTENT); IO_TREE_INODE_FILE_EXTENT);
mutex_init(&ei->log_mutex); mutex_init(&ei->log_mutex);
btrfs_ordered_inode_tree_init(&ei->ordered_tree); spin_lock_init(&ei->ordered_tree_lock);
ei->ordered_tree = RB_ROOT;
ei->ordered_tree_last = NULL;
INIT_LIST_HEAD(&ei->delalloc_inodes); INIT_LIST_HEAD(&ei->delalloc_inodes);
INIT_LIST_HEAD(&ei->delayed_iput); INIT_LIST_HEAD(&ei->delayed_iput);
RB_CLEAR_NODE(&ei->rb_node); RB_CLEAR_NODE(&ei->rb_node);
......
...@@ -124,25 +124,24 @@ static int range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset, ...@@ -124,25 +124,24 @@ static int range_overlaps(struct btrfs_ordered_extent *entry, u64 file_offset,
* look find the first ordered struct that has this offset, otherwise * look find the first ordered struct that has this offset, otherwise
* the first one less than this offset * the first one less than this offset
*/ */
static inline struct rb_node *tree_search(struct btrfs_ordered_inode_tree *tree, static inline struct rb_node *ordered_tree_search(struct btrfs_inode *inode,
u64 file_offset) u64 file_offset)
{ {
struct rb_root *root = &tree->tree;
struct rb_node *prev = NULL; struct rb_node *prev = NULL;
struct rb_node *ret; struct rb_node *ret;
struct btrfs_ordered_extent *entry; struct btrfs_ordered_extent *entry;
if (tree->last) { if (inode->ordered_tree_last) {
entry = rb_entry(tree->last, struct btrfs_ordered_extent, entry = rb_entry(inode->ordered_tree_last, struct btrfs_ordered_extent,
rb_node); rb_node);
if (in_range(file_offset, entry->file_offset, entry->num_bytes)) if (in_range(file_offset, entry->file_offset, entry->num_bytes))
return tree->last; return inode->ordered_tree_last;
} }
ret = __tree_search(root, file_offset, &prev); ret = __tree_search(&inode->ordered_tree, file_offset, &prev);
if (!ret) if (!ret)
ret = prev; ret = prev;
if (ret) if (ret)
tree->last = ret; inode->ordered_tree_last = ret;
return ret; return ret;
} }
...@@ -209,7 +208,6 @@ static struct btrfs_ordered_extent *alloc_ordered_extent( ...@@ -209,7 +208,6 @@ static struct btrfs_ordered_extent *alloc_ordered_extent(
static void insert_ordered_extent(struct btrfs_ordered_extent *entry) static void insert_ordered_extent(struct btrfs_ordered_extent *entry)
{ {
struct btrfs_inode *inode = BTRFS_I(entry->inode); struct btrfs_inode *inode = BTRFS_I(entry->inode);
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct rb_node *node; struct rb_node *node;
...@@ -222,13 +220,14 @@ static void insert_ordered_extent(struct btrfs_ordered_extent *entry) ...@@ -222,13 +220,14 @@ static void insert_ordered_extent(struct btrfs_ordered_extent *entry)
/* One ref for the tree. */ /* One ref for the tree. */
refcount_inc(&entry->refs); refcount_inc(&entry->refs);
spin_lock_irq(&tree->lock); spin_lock_irq(&inode->ordered_tree_lock);
node = tree_insert(&tree->tree, entry->file_offset, &entry->rb_node); node = tree_insert(&inode->ordered_tree, entry->file_offset,
&entry->rb_node);
if (node) if (node)
btrfs_panic(fs_info, -EEXIST, btrfs_panic(fs_info, -EEXIST,
"inconsistency in ordered tree at offset %llu", "inconsistency in ordered tree at offset %llu",
entry->file_offset); entry->file_offset);
spin_unlock_irq(&tree->lock); spin_unlock_irq(&inode->ordered_tree_lock);
spin_lock(&root->ordered_extent_lock); spin_lock(&root->ordered_extent_lock);
list_add_tail(&entry->root_extent_list, list_add_tail(&entry->root_extent_list,
...@@ -288,12 +287,11 @@ struct btrfs_ordered_extent *btrfs_alloc_ordered_extent( ...@@ -288,12 +287,11 @@ struct btrfs_ordered_extent *btrfs_alloc_ordered_extent(
void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry, void btrfs_add_ordered_sum(struct btrfs_ordered_extent *entry,
struct btrfs_ordered_sum *sum) struct btrfs_ordered_sum *sum)
{ {
struct btrfs_ordered_inode_tree *tree; struct btrfs_inode *inode = BTRFS_I(entry->inode);
tree = &BTRFS_I(entry->inode)->ordered_tree; spin_lock_irq(&inode->ordered_tree_lock);
spin_lock_irq(&tree->lock);
list_add_tail(&sum->list, &entry->list); list_add_tail(&sum->list, &entry->list);
spin_unlock_irq(&tree->lock); spin_unlock_irq(&inode->ordered_tree_lock);
} }
static void finish_ordered_fn(struct btrfs_work *work) static void finish_ordered_fn(struct btrfs_work *work)
...@@ -311,7 +309,7 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered, ...@@ -311,7 +309,7 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
struct btrfs_inode *inode = BTRFS_I(ordered->inode); struct btrfs_inode *inode = BTRFS_I(ordered->inode);
struct btrfs_fs_info *fs_info = inode->root->fs_info; struct btrfs_fs_info *fs_info = inode->root->fs_info;
lockdep_assert_held(&inode->ordered_tree.lock); lockdep_assert_held(&inode->ordered_tree_lock);
if (page) { if (page) {
ASSERT(page->mapping); ASSERT(page->mapping);
...@@ -379,9 +377,9 @@ bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered, ...@@ -379,9 +377,9 @@ bool btrfs_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
trace_btrfs_finish_ordered_extent(inode, file_offset, len, uptodate); trace_btrfs_finish_ordered_extent(inode, file_offset, len, uptodate);
spin_lock_irqsave(&inode->ordered_tree.lock, flags); spin_lock_irqsave(&inode->ordered_tree_lock, flags);
ret = can_finish_ordered_extent(ordered, page, file_offset, len, uptodate); ret = can_finish_ordered_extent(ordered, page, file_offset, len, uptodate);
spin_unlock_irqrestore(&inode->ordered_tree.lock, flags); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags);
if (ret) if (ret)
btrfs_queue_ordered_fn(ordered); btrfs_queue_ordered_fn(ordered);
...@@ -405,7 +403,6 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, ...@@ -405,7 +403,6 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
struct page *page, u64 file_offset, struct page *page, u64 file_offset,
u64 num_bytes, bool uptodate) u64 num_bytes, bool uptodate)
{ {
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
struct rb_node *node; struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL; struct btrfs_ordered_extent *entry = NULL;
unsigned long flags; unsigned long flags;
...@@ -415,13 +412,13 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, ...@@ -415,13 +412,13 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
file_offset + num_bytes - 1, file_offset + num_bytes - 1,
uptodate); uptodate);
spin_lock_irqsave(&tree->lock, flags); spin_lock_irqsave(&inode->ordered_tree_lock, flags);
while (cur < file_offset + num_bytes) { while (cur < file_offset + num_bytes) {
u64 entry_end; u64 entry_end;
u64 end; u64 end;
u32 len; u32 len;
node = tree_search(tree, cur); node = ordered_tree_search(inode, cur);
/* No ordered extents at all */ /* No ordered extents at all */
if (!node) if (!node)
break; break;
...@@ -468,13 +465,13 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode, ...@@ -468,13 +465,13 @@ void btrfs_mark_ordered_io_finished(struct btrfs_inode *inode,
len = end + 1 - cur; len = end + 1 - cur;
if (can_finish_ordered_extent(entry, page, cur, len, uptodate)) { if (can_finish_ordered_extent(entry, page, cur, len, uptodate)) {
spin_unlock_irqrestore(&tree->lock, flags); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags);
btrfs_queue_ordered_fn(entry); btrfs_queue_ordered_fn(entry);
spin_lock_irqsave(&tree->lock, flags); spin_lock_irqsave(&inode->ordered_tree_lock, flags);
} }
cur += len; cur += len;
} }
spin_unlock_irqrestore(&tree->lock, flags); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags);
} }
/* /*
...@@ -498,19 +495,18 @@ bool btrfs_dec_test_ordered_pending(struct btrfs_inode *inode, ...@@ -498,19 +495,18 @@ bool btrfs_dec_test_ordered_pending(struct btrfs_inode *inode,
struct btrfs_ordered_extent **cached, struct btrfs_ordered_extent **cached,
u64 file_offset, u64 io_size) u64 file_offset, u64 io_size)
{ {
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
struct rb_node *node; struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL; struct btrfs_ordered_extent *entry = NULL;
unsigned long flags; unsigned long flags;
bool finished = false; bool finished = false;
spin_lock_irqsave(&tree->lock, flags); spin_lock_irqsave(&inode->ordered_tree_lock, flags);
if (cached && *cached) { if (cached && *cached) {
entry = *cached; entry = *cached;
goto have_entry; goto have_entry;
} }
node = tree_search(tree, file_offset); node = ordered_tree_search(inode, file_offset);
if (!node) if (!node)
goto out; goto out;
...@@ -541,7 +537,7 @@ bool btrfs_dec_test_ordered_pending(struct btrfs_inode *inode, ...@@ -541,7 +537,7 @@ bool btrfs_dec_test_ordered_pending(struct btrfs_inode *inode,
refcount_inc(&entry->refs); refcount_inc(&entry->refs);
trace_btrfs_ordered_extent_dec_test_pending(inode, entry); trace_btrfs_ordered_extent_dec_test_pending(inode, entry);
} }
spin_unlock_irqrestore(&tree->lock, flags); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags);
return finished; return finished;
} }
...@@ -579,7 +575,6 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry) ...@@ -579,7 +575,6 @@ void btrfs_put_ordered_extent(struct btrfs_ordered_extent *entry)
void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode, void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode,
struct btrfs_ordered_extent *entry) struct btrfs_ordered_extent *entry)
{ {
struct btrfs_ordered_inode_tree *tree;
struct btrfs_root *root = btrfs_inode->root; struct btrfs_root *root = btrfs_inode->root;
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
struct rb_node *node; struct rb_node *node;
...@@ -610,16 +605,15 @@ void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode, ...@@ -610,16 +605,15 @@ void btrfs_remove_ordered_extent(struct btrfs_inode *btrfs_inode,
percpu_counter_add_batch(&fs_info->ordered_bytes, -entry->num_bytes, percpu_counter_add_batch(&fs_info->ordered_bytes, -entry->num_bytes,
fs_info->delalloc_batch); fs_info->delalloc_batch);
tree = &btrfs_inode->ordered_tree; spin_lock_irq(&btrfs_inode->ordered_tree_lock);
spin_lock_irq(&tree->lock);
node = &entry->rb_node; node = &entry->rb_node;
rb_erase(node, &tree->tree); rb_erase(node, &btrfs_inode->ordered_tree);
RB_CLEAR_NODE(node); RB_CLEAR_NODE(node);
if (tree->last == node) if (btrfs_inode->ordered_tree_last == node)
tree->last = NULL; btrfs_inode->ordered_tree_last = NULL;
set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags); set_bit(BTRFS_ORDERED_COMPLETE, &entry->flags);
pending = test_and_clear_bit(BTRFS_ORDERED_PENDING, &entry->flags); pending = test_and_clear_bit(BTRFS_ORDERED_PENDING, &entry->flags);
spin_unlock_irq(&tree->lock); spin_unlock_irq(&btrfs_inode->ordered_tree_lock);
/* /*
* The current running transaction is waiting on us, we need to let it * The current running transaction is waiting on us, we need to let it
...@@ -876,14 +870,12 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len) ...@@ -876,14 +870,12 @@ int btrfs_wait_ordered_range(struct inode *inode, u64 start, u64 len)
struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *inode, struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *inode,
u64 file_offset) u64 file_offset)
{ {
struct btrfs_ordered_inode_tree *tree;
struct rb_node *node; struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL; struct btrfs_ordered_extent *entry = NULL;
unsigned long flags; unsigned long flags;
tree = &inode->ordered_tree; spin_lock_irqsave(&inode->ordered_tree_lock, flags);
spin_lock_irqsave(&tree->lock, flags); node = ordered_tree_search(inode, file_offset);
node = tree_search(tree, file_offset);
if (!node) if (!node)
goto out; goto out;
...@@ -895,7 +887,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *ino ...@@ -895,7 +887,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *ino
trace_btrfs_ordered_extent_lookup(inode, entry); trace_btrfs_ordered_extent_lookup(inode, entry);
} }
out: out:
spin_unlock_irqrestore(&tree->lock, flags); spin_unlock_irqrestore(&inode->ordered_tree_lock, flags);
return entry; return entry;
} }
...@@ -905,15 +897,13 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *ino ...@@ -905,15 +897,13 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_extent(struct btrfs_inode *ino
struct btrfs_ordered_extent *btrfs_lookup_ordered_range( struct btrfs_ordered_extent *btrfs_lookup_ordered_range(
struct btrfs_inode *inode, u64 file_offset, u64 len) struct btrfs_inode *inode, u64 file_offset, u64 len)
{ {
struct btrfs_ordered_inode_tree *tree;
struct rb_node *node; struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL; struct btrfs_ordered_extent *entry = NULL;
tree = &inode->ordered_tree; spin_lock_irq(&inode->ordered_tree_lock);
spin_lock_irq(&tree->lock); node = ordered_tree_search(inode, file_offset);
node = tree_search(tree, file_offset);
if (!node) { if (!node) {
node = tree_search(tree, file_offset + len); node = ordered_tree_search(inode, file_offset + len);
if (!node) if (!node)
goto out; goto out;
} }
...@@ -937,7 +927,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range( ...@@ -937,7 +927,7 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range(
refcount_inc(&entry->refs); refcount_inc(&entry->refs);
trace_btrfs_ordered_extent_lookup_range(inode, entry); trace_btrfs_ordered_extent_lookup_range(inode, entry);
} }
spin_unlock_irq(&tree->lock); spin_unlock_irq(&inode->ordered_tree_lock);
return entry; return entry;
} }
...@@ -948,13 +938,12 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range( ...@@ -948,13 +938,12 @@ struct btrfs_ordered_extent *btrfs_lookup_ordered_range(
void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode, void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode,
struct list_head *list) struct list_head *list)
{ {
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
struct rb_node *n; struct rb_node *n;
ASSERT(inode_is_locked(&inode->vfs_inode)); ASSERT(inode_is_locked(&inode->vfs_inode));
spin_lock_irq(&tree->lock); spin_lock_irq(&inode->ordered_tree_lock);
for (n = rb_first(&tree->tree); n; n = rb_next(n)) { for (n = rb_first(&inode->ordered_tree); n; n = rb_next(n)) {
struct btrfs_ordered_extent *ordered; struct btrfs_ordered_extent *ordered;
ordered = rb_entry(n, struct btrfs_ordered_extent, rb_node); ordered = rb_entry(n, struct btrfs_ordered_extent, rb_node);
...@@ -967,7 +956,7 @@ void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode, ...@@ -967,7 +956,7 @@ void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode,
refcount_inc(&ordered->refs); refcount_inc(&ordered->refs);
trace_btrfs_ordered_extent_lookup_for_logging(inode, ordered); trace_btrfs_ordered_extent_lookup_for_logging(inode, ordered);
} }
spin_unlock_irq(&tree->lock); spin_unlock_irq(&inode->ordered_tree_lock);
} }
/* /*
...@@ -977,13 +966,11 @@ void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode, ...@@ -977,13 +966,11 @@ void btrfs_get_ordered_extents_for_logging(struct btrfs_inode *inode,
struct btrfs_ordered_extent * struct btrfs_ordered_extent *
btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset) btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset)
{ {
struct btrfs_ordered_inode_tree *tree;
struct rb_node *node; struct rb_node *node;
struct btrfs_ordered_extent *entry = NULL; struct btrfs_ordered_extent *entry = NULL;
tree = &inode->ordered_tree; spin_lock_irq(&inode->ordered_tree_lock);
spin_lock_irq(&tree->lock); node = ordered_tree_search(inode, file_offset);
node = tree_search(tree, file_offset);
if (!node) if (!node)
goto out; goto out;
...@@ -991,7 +978,7 @@ btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset) ...@@ -991,7 +978,7 @@ btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset)
refcount_inc(&entry->refs); refcount_inc(&entry->refs);
trace_btrfs_ordered_extent_lookup_first(inode, entry); trace_btrfs_ordered_extent_lookup_first(inode, entry);
out: out:
spin_unlock_irq(&tree->lock); spin_unlock_irq(&inode->ordered_tree_lock);
return entry; return entry;
} }
...@@ -1007,15 +994,14 @@ btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset) ...@@ -1007,15 +994,14 @@ btrfs_lookup_first_ordered_extent(struct btrfs_inode *inode, u64 file_offset)
struct btrfs_ordered_extent *btrfs_lookup_first_ordered_range( struct btrfs_ordered_extent *btrfs_lookup_first_ordered_range(
struct btrfs_inode *inode, u64 file_offset, u64 len) struct btrfs_inode *inode, u64 file_offset, u64 len)
{ {
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
struct rb_node *node; struct rb_node *node;
struct rb_node *cur; struct rb_node *cur;
struct rb_node *prev; struct rb_node *prev;
struct rb_node *next; struct rb_node *next;
struct btrfs_ordered_extent *entry = NULL; struct btrfs_ordered_extent *entry = NULL;
spin_lock_irq(&tree->lock); spin_lock_irq(&inode->ordered_tree_lock);
node = tree->tree.rb_node; node = inode->ordered_tree.rb_node;
/* /*
* Here we don't want to use tree_search() which will use tree->last * Here we don't want to use tree_search() which will use tree->last
* and screw up the search order. * and screw up the search order.
...@@ -1069,7 +1055,7 @@ struct btrfs_ordered_extent *btrfs_lookup_first_ordered_range( ...@@ -1069,7 +1055,7 @@ struct btrfs_ordered_extent *btrfs_lookup_first_ordered_range(
trace_btrfs_ordered_extent_lookup_first_range(inode, entry); trace_btrfs_ordered_extent_lookup_first_range(inode, entry);
} }
spin_unlock_irq(&tree->lock); spin_unlock_irq(&inode->ordered_tree_lock);
return entry; return entry;
} }
...@@ -1148,7 +1134,6 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent( ...@@ -1148,7 +1134,6 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent(
struct btrfs_ordered_extent *ordered, u64 len) struct btrfs_ordered_extent *ordered, u64 len)
{ {
struct btrfs_inode *inode = BTRFS_I(ordered->inode); struct btrfs_inode *inode = BTRFS_I(ordered->inode);
struct btrfs_ordered_inode_tree *tree = &inode->ordered_tree;
struct btrfs_root *root = inode->root; struct btrfs_root *root = inode->root;
struct btrfs_fs_info *fs_info = root->fs_info; struct btrfs_fs_info *fs_info = root->fs_info;
u64 file_offset = ordered->file_offset; u64 file_offset = ordered->file_offset;
...@@ -1188,13 +1173,13 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent( ...@@ -1188,13 +1173,13 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent(
refcount_inc(&new->refs); refcount_inc(&new->refs);
spin_lock_irq(&root->ordered_extent_lock); spin_lock_irq(&root->ordered_extent_lock);
spin_lock(&tree->lock); spin_lock(&inode->ordered_tree_lock);
/* Remove from tree once */ /* Remove from tree once */
node = &ordered->rb_node; node = &ordered->rb_node;
rb_erase(node, &tree->tree); rb_erase(node, &inode->ordered_tree);
RB_CLEAR_NODE(node); RB_CLEAR_NODE(node);
if (tree->last == node) if (inode->ordered_tree_last == node)
tree->last = NULL; inode->ordered_tree_last = NULL;
ordered->file_offset += len; ordered->file_offset += len;
ordered->disk_bytenr += len; ordered->disk_bytenr += len;
...@@ -1225,18 +1210,19 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent( ...@@ -1225,18 +1210,19 @@ struct btrfs_ordered_extent *btrfs_split_ordered_extent(
} }
/* Re-insert the node */ /* Re-insert the node */
node = tree_insert(&tree->tree, ordered->file_offset, &ordered->rb_node); node = tree_insert(&inode->ordered_tree, ordered->file_offset,
&ordered->rb_node);
if (node) if (node)
btrfs_panic(fs_info, -EEXIST, btrfs_panic(fs_info, -EEXIST,
"zoned: inconsistency in ordered tree at offset %llu", "zoned: inconsistency in ordered tree at offset %llu",
ordered->file_offset); ordered->file_offset);
node = tree_insert(&tree->tree, new->file_offset, &new->rb_node); node = tree_insert(&inode->ordered_tree, new->file_offset, &new->rb_node);
if (node) if (node)
btrfs_panic(fs_info, -EEXIST, btrfs_panic(fs_info, -EEXIST,
"zoned: inconsistency in ordered tree at offset %llu", "zoned: inconsistency in ordered tree at offset %llu",
new->file_offset); new->file_offset);
spin_unlock(&tree->lock); spin_unlock(&inode->ordered_tree_lock);
list_add_tail(&new->root_extent_list, &root->ordered_extents); list_add_tail(&new->root_extent_list, &root->ordered_extents);
root->nr_ordered_extents++; root->nr_ordered_extents++;
......
...@@ -6,13 +6,6 @@ ...@@ -6,13 +6,6 @@
#ifndef BTRFS_ORDERED_DATA_H #ifndef BTRFS_ORDERED_DATA_H
#define BTRFS_ORDERED_DATA_H #define BTRFS_ORDERED_DATA_H
/* one of these per inode */
struct btrfs_ordered_inode_tree {
spinlock_t lock;
struct rb_root tree;
struct rb_node *last;
};
struct btrfs_ordered_sum { struct btrfs_ordered_sum {
/* /*
* Logical start address and length for of the blocks covered by * Logical start address and length for of the blocks covered by
...@@ -155,14 +148,6 @@ struct btrfs_ordered_extent { ...@@ -155,14 +148,6 @@ struct btrfs_ordered_extent {
struct list_head bioc_list; struct list_head bioc_list;
}; };
static inline void
btrfs_ordered_inode_tree_init(struct btrfs_ordered_inode_tree *t)
{
spin_lock_init(&t->lock);
t->tree = RB_ROOT;
t->last = NULL;
}
int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent); int btrfs_finish_one_ordered(struct btrfs_ordered_extent *ordered_extent);
int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent); int btrfs_finish_ordered_io(struct btrfs_ordered_extent *ordered_extent);
......
...@@ -4917,12 +4917,12 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans, ...@@ -4917,12 +4917,12 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,
set_bit(BTRFS_ORDERED_LOGGED, &ordered->flags); set_bit(BTRFS_ORDERED_LOGGED, &ordered->flags);
if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) { if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) {
spin_lock_irq(&inode->ordered_tree.lock); spin_lock_irq(&inode->ordered_tree_lock);
if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) { if (!test_bit(BTRFS_ORDERED_COMPLETE, &ordered->flags)) {
set_bit(BTRFS_ORDERED_PENDING, &ordered->flags); set_bit(BTRFS_ORDERED_PENDING, &ordered->flags);
atomic_inc(&trans->transaction->pending_ordered); atomic_inc(&trans->transaction->pending_ordered);
} }
spin_unlock_irq(&inode->ordered_tree.lock); spin_unlock_irq(&inode->ordered_tree_lock);
} }
btrfs_put_ordered_extent(ordered); btrfs_put_ordered_extent(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