diff options
author | Josef Bacik <josef@redhat.com> | 2011-01-25 16:30:38 -0500 |
---|---|---|
committer | Josef Bacik <josef@redhat.com> | 2011-03-17 14:21:18 -0400 |
commit | 57a45ced94fe48a701361d64230fc16eefa189dd (patch) | |
tree | 8f0cfe52ba0b3fb8a6ed3cc5d3e7449369b0b9a5 /fs/btrfs/inode.c | |
parent | 4a64001f0047956e283f7ada9843dfc3f3b5d8c8 (diff) |
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 <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/inode.c')
-rw-r--r-- | fs/btrfs/inode.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 9007bbd01dbf..d97b69afbbfb 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
@@ -6632,9 +6632,8 @@ struct inode *btrfs_alloc_inode(struct super_block *sb) | |||
6632 | ei->index_cnt = (u64)-1; | 6632 | ei->index_cnt = (u64)-1; |
6633 | ei->last_unlink_trans = 0; | 6633 | ei->last_unlink_trans = 0; |
6634 | 6634 | ||
6635 | spin_lock_init(&ei->accounting_lock); | ||
6636 | atomic_set(&ei->outstanding_extents, 0); | 6635 | atomic_set(&ei->outstanding_extents, 0); |
6637 | ei->reserved_extents = 0; | 6636 | atomic_set(&ei->reserved_extents, 0); |
6638 | 6637 | ||
6639 | ei->ordered_data_close = 0; | 6638 | ei->ordered_data_close = 0; |
6640 | ei->orphan_meta_reserved = 0; | 6639 | ei->orphan_meta_reserved = 0; |
@@ -6670,7 +6669,7 @@ void btrfs_destroy_inode(struct inode *inode) | |||
6670 | WARN_ON(!list_empty(&inode->i_dentry)); | 6669 | WARN_ON(!list_empty(&inode->i_dentry)); |
6671 | WARN_ON(inode->i_data.nrpages); | 6670 | WARN_ON(inode->i_data.nrpages); |
6672 | WARN_ON(atomic_read(&BTRFS_I(inode)->outstanding_extents)); | 6671 | WARN_ON(atomic_read(&BTRFS_I(inode)->outstanding_extents)); |
6673 | WARN_ON(BTRFS_I(inode)->reserved_extents); | 6672 | WARN_ON(atomic_read(&BTRFS_I(inode)->reserved_extents)); |
6674 | 6673 | ||
6675 | /* | 6674 | /* |
6676 | * This can happen where we create an inode, but somebody else also | 6675 | * This can happen where we create an inode, but somebody else also |