Open code btrfs_ordered_inode_tree in btrfs_inode
David Sterba
maintainercover Open code btrfs_ordered_inode_tree in btrfs_inode
The structure btrfs_ordered_inode_tree can be open coded, namely to get rid of the hole that in turn appears in btrfs_inode.
David Sterba (2):
btrfs: open code btrfs_ordered_inode_tree in btrfs_inode
btrfs: reorder btrfs_inode to fill gaps
fs/btrfs/btrfs_inode.h | 20 ++++--- fs/btrfs/inode.c | 8 ++- fs/btrfs/ordered-data.c | 122 ++++++++++++++++++---------------------- fs/btrfs/ordered-data.h | 15 ----- fs/btrfs/tree-log.c | 4 +- 5 files changed, 72 insertions(+), 97 deletions(-)
Signature · 1 line
2.41.0
David Sterba
maintainerPATCH 1/2 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.
--- fs/btrfs/btrfs_inode.h | 4 +- fs/btrfs/inode.c | 8 ++- fs/btrfs/ordered-data.c | 122 ++++++++++++++++++---------------------- fs/btrfs/ordered-data.h | 15 ----- fs/btrfs/tree-log.c | 4 +- 5 files changed, 64 insertions(+), 89 deletions(-)
fs/btrfs/btrfs_inode.h +3 -1
@@ -114,7 +114,9 @@ struct btrfs_inode {struct mutex log_mutex;/* 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 * to write all the delalloc pages to disk, and this list is used
fs/btrfs/inode.c +5 -3
@@ -8011,11 +8011,11 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,EXTENT_LOCKED |EXTENT_DO_ACCOUNTING | 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); ordered->truncated_len =min (ordered->truncated_len, 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
@@ -8497,7 +8497,9 @@ struct inode *btrfs_alloc_inode(struct super_block *sb)extent_io_tree_init (fs_info, &ei->file_extent_tree,IO_TREE_INODE_FILE_EXTENT );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->delayed_iput);RB_CLEAR_NODE (&ei->rb_node);
fs/btrfs/ordered-data.c +54 -68
352 lines not on this page · raw message
fs/btrfs/ordered-data.h +0 -15
@@ -6,13 +6,6 @@#ifndef 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 {/* * Logical start address and length for of the blocks covered by
@@ -155,14 +148,6 @@ struct btrfs_ordered_extent {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_ordered_io (struct btrfs_ordered_extent *ordered_extent);
fs/btrfs/tree-log.c +2 -2
@@ -4917,12 +4917,12 @@ static int btrfs_log_changed_extents(struct btrfs_trans_handle *trans,set_bit (BTRFS_ORDERED_LOGGED , &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)) {set_bit (BTRFS_ORDERED_PENDING , &ordered->flags);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); }
Signature · 1 line
2.41.0
David Sterba
maintainerPATCH 2/2 btrfs: reorder btrfs_inode to fill gaps
In reply to David SterbaPrevious commit created a hole in struct btrfs_inode, we can move outstanding_extents there. This reduces size by 8 bytes from 1120 to 1112 on a release config.
--- fs/btrfs/btrfs_inode.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
fs/btrfs/btrfs_inode.h +8 -8
@@ -113,6 +113,14 @@ struct btrfs_inode {/* held while logging the inode in tree-log.c */ struct mutex log_mutex; +/* +* Counters to keep track of the number of extent item's we may use due +* to delalloc and such. outstanding_extents is the number of extent +* items we think we'll end up using, and reserved_extents is the number +* of extent items we've reserved metadata for. +*/ +unsigned outstanding_extents; +/* used to order data wrt metadata */ spinlock_t ordered_tree_lock;struct rb_root ordered_tree;
@@ -236,14 +244,6 @@ struct btrfs_inode {/* Read-only compatibility flags, upper half of inode_item::flags */ u32 ro_flags; -/* -* Counters to keep track of the number of extent item's we may use due -* to delalloc and such. outstanding_extents is the number of extent -* items we think we'll end up using, and reserved_extents is the number -* of extent items we've reserved metadata for. -*/ -unsigned outstanding_extents; -struct btrfs_block_rsv block_rsv;struct btrfs_delayed_node *delayed_node;
Signature · 1 line
2.41.0