Btrfs: change reserved_extents to an atomic_t
PATCH 1/1 Btrfs: change reserved_extents to an atomic_t
We track delayed allocation per inodes via 2 counters, one is outstanding_extents and reserved_extents. Outstanding_extents is already an atomic_t, but reserved_extents is not and is protected by a spinlock. So convert this to an atomic_t and instead of using a spinlock, use atomic_cmpxchg when releasing delalloc bytes. This makes our inode 72 bytes smaller, and reduces locking overhead (albiet it was minimal to begin with). Thanks,
Signed-off-by Josef Bacik <[email protected]>
--- fs/btrfs/btrfs_inode.h | 3 +-- fs/btrfs/extent-tree.c | 41 +++++++++++++++++++++++++---------------- fs/btrfs/inode.c | 5 ++--- 3 files changed, 28 insertions(+), 21 deletions(-)
fs/btrfs/btrfs_inode.h +1 -2
@@ -136,9 +136,8 @@ struct btrfs_inode {* items we think we'll end up using, and reserved_extents is the number * of extent items we've reserved metadata for. */ -spinlock_t accounting_lock;atomic_t outstanding_extents; -int reserved_extents; +atomic_t reserved_extents;/* * ordered_data_close is set by truncate when a file that used
fs/btrfs/extent-tree.c +25 -16
76 lines not on this page · raw message
fs/btrfs/inode.c +2 -3
@@ -6495,9 +6495,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) ei->index_cnt = (u64)-1 ; ei->last_unlink_trans =0 ; -spin_lock_init (&ei->accounting_lock);atomic_set (&ei->outstanding_extents,0 ); - ei->reserved_extents =0 ; +atomic_set (&ei->reserved_extents,0 ); ei->ordered_data_close =0 ; ei->orphan_meta_reserved =0 ;
@@ -6533,7 +6532,7 @@ void btrfs_destroy_inode(struct inode *inode)WARN_ON (!list_empty (&inode->i_dentry));WARN_ON (inode->i_data.nrpages);WARN_ON (atomic_read (&BTRFS_I (inode)->outstanding_extents)); -WARN_ON (BTRFS_I (inode)->reserved_extents); +WARN_ON (atomic_read (&BTRFS_I (inode)->reserved_extents));/* * This can happen where we create an inode, but somebody else also
Signature · 1 line
1.6.6.1