diff options
author | Josef Bacik <josef@redhat.com> | 2012-01-13 12:09:22 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2012-01-16 15:29:43 -0500 |
commit | f248679e86fead40cc78e724c7181d6bec1a2046 (patch) | |
tree | 88abeee0b2a87c0f0377509525c92d3c9ec15a15 /fs/btrfs/extent-tree.c | |
parent | 8c2a3ca20f6233677ac3222c6506174010eb414f (diff) |
Btrfs: add a delalloc mutex to inodes for delalloc reservations
I was using i_mutex for this, but we're getting bogus lockdep warnings by doing
that and theres no real way to get rid of those, so just stop using i_mutex to
protect delalloc metadata reservations and use a delalloc mutex instead. This
shouldn't be contended often at all, only if you are writing and mmap writing to
the file at the same time. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 556f9aa25bb7..e0ad5f0f895e 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -4345,12 +4345,11 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) | |||
4345 | /* Need to be holding the i_mutex here if we aren't free space cache */ | 4345 | /* Need to be holding the i_mutex here if we aren't free space cache */ |
4346 | if (btrfs_is_free_space_inode(root, inode)) | 4346 | if (btrfs_is_free_space_inode(root, inode)) |
4347 | flush = 0; | 4347 | flush = 0; |
4348 | else | ||
4349 | WARN_ON(!mutex_is_locked(&inode->i_mutex)); | ||
4350 | 4348 | ||
4351 | if (flush && btrfs_transaction_in_commit(root->fs_info)) | 4349 | if (flush && btrfs_transaction_in_commit(root->fs_info)) |
4352 | schedule_timeout(1); | 4350 | schedule_timeout(1); |
4353 | 4351 | ||
4352 | mutex_lock(&BTRFS_I(inode)->delalloc_mutex); | ||
4354 | num_bytes = ALIGN(num_bytes, root->sectorsize); | 4353 | num_bytes = ALIGN(num_bytes, root->sectorsize); |
4355 | 4354 | ||
4356 | spin_lock(&BTRFS_I(inode)->lock); | 4355 | spin_lock(&BTRFS_I(inode)->lock); |
@@ -4405,6 +4404,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) | |||
4405 | btrfs_ino(inode), | 4404 | btrfs_ino(inode), |
4406 | to_free, 0); | 4405 | to_free, 0); |
4407 | } | 4406 | } |
4407 | mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); | ||
4408 | return ret; | 4408 | return ret; |
4409 | } | 4409 | } |
4410 | 4410 | ||
@@ -4415,6 +4415,7 @@ int btrfs_delalloc_reserve_metadata(struct inode *inode, u64 num_bytes) | |||
4415 | } | 4415 | } |
4416 | BTRFS_I(inode)->reserved_extents += nr_extents; | 4416 | BTRFS_I(inode)->reserved_extents += nr_extents; |
4417 | spin_unlock(&BTRFS_I(inode)->lock); | 4417 | spin_unlock(&BTRFS_I(inode)->lock); |
4418 | mutex_unlock(&BTRFS_I(inode)->delalloc_mutex); | ||
4418 | 4419 | ||
4419 | if (to_reserve) | 4420 | if (to_reserve) |
4420 | trace_btrfs_space_reservation(root->fs_info,"delalloc", | 4421 | trace_btrfs_space_reservation(root->fs_info,"delalloc", |