Commit c64c2bd8 authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason

Btrfs: don't take inode delalloc mutex if we're a free space inode

This confuses and angers lockdep even though it's ok.  We don't really need
the lock for free space inodes since only the transaction committer will be
reserving space.  Thanks,
Signed-off-by: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 1135d6df
...@@ -4535,16 +4535,25 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) ...@@ -4535,16 +4535,25 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
int extra_reserve = 0; int extra_reserve = 0;
enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL; enum btrfs_reserve_flush_enum flush = BTRFS_RESERVE_FLUSH_ALL;
int ret; int ret;
bool delalloc_lock = true;
/* Need to be holding the i_mutex here if we aren't free space cache */ /* If we are a free space inode we need to not flush since we will be in
if (btrfs_is_free_space_inode(inode)) * the middle of a transaction commit. We also don't need the delalloc
* mutex since we won't race with anybody. We need this mostly to make
* lockdep shut its filthy mouth.
*/
if (btrfs_is_free_space_inode(inode)) {
flush = BTRFS_RESERVE_NO_FLUSH; flush = BTRFS_RESERVE_NO_FLUSH;
delalloc_lock = false;
}
if (flush != BTRFS_RESERVE_NO_FLUSH && if (flush != BTRFS_RESERVE_NO_FLUSH &&
btrfs_transaction_in_commit(root->fs_info)) btrfs_transaction_in_commit(root->fs_info))
schedule_timeout(1); schedule_timeout(1);
if (delalloc_lock)
mutex_lock(&BTRFS_I(inode)->delalloc_mutex); mutex_lock(&BTRFS_I(inode)->delalloc_mutex);
num_bytes = ALIGN(num_bytes, root->sectorsize); num_bytes = ALIGN(num_bytes, root->sectorsize);
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&BTRFS_I(inode)->lock);
...@@ -4577,6 +4586,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) ...@@ -4577,6 +4586,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
spin_lock(&BTRFS_I(inode)->lock); spin_lock(&BTRFS_I(inode)->lock);
calc_csum_metadata_size(inode, num_bytes, 0); calc_csum_metadata_size(inode, num_bytes, 0);
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&BTRFS_I(inode)->lock);
if (delalloc_lock)
mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); mutex_unlock(&BTRFS_I(inode)->delalloc_mutex);
return ret; return ret;
} }
...@@ -4616,6 +4626,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) ...@@ -4616,6 +4626,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
btrfs_qgroup_free(root, num_bytes + btrfs_qgroup_free(root, num_bytes +
nr_extents * root->leafsize); nr_extents * root->leafsize);
} }
if (delalloc_lock)
mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); mutex_unlock(&BTRFS_I(inode)->delalloc_mutex);
return ret; return ret;
} }
...@@ -4628,6 +4639,8 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) ...@@ -4628,6 +4639,8 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes)
} }
BTRFS_I(inode)->reserved_extents += nr_extents; BTRFS_I(inode)->reserved_extents += nr_extents;
spin_unlock(&BTRFS_I(inode)->lock); spin_unlock(&BTRFS_I(inode)->lock);
if (delalloc_lock)
mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); mutex_unlock(&BTRFS_I(inode)->delalloc_mutex);
if (to_reserve) if (to_reserve)
......
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