Skip to content

Commit

Permalink
btrfs: open code btrfs_dev_replace_clear_lock_blocking
Browse files Browse the repository at this point in the history
There's a single caller and the function name does not say it's actually
taking the lock, so open coding makes it more explicit.

For now, btrfs_dev_replace_read_lock is used instead of read_lock so
it's paired with the unlocking wrapper in the same block.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
  • Loading branch information
David Sterba committed Oct 15, 2018
1 parent 3280f87 commit 7fb2ece
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
12 changes: 0 additions & 12 deletions fs/btrfs/dev-replace.c
Original file line number Diff line number Diff line change
Expand Up @@ -998,18 +998,6 @@ void btrfs_dev_replace_set_lock_blocking(
read_unlock(&dev_replace->lock);
}

/* acquire read lock and dec blocking cnt */
void btrfs_dev_replace_clear_lock_blocking(
struct btrfs_dev_replace *dev_replace)
{
/* only set blocking for read lock */
ASSERT(atomic_read(&dev_replace->blocking_readers) > 0);
read_lock(&dev_replace->lock);
/* Barrier implied by atomic_dec_and_test */
if (atomic_dec_and_test(&dev_replace->blocking_readers))
cond_wake_up_nomb(&dev_replace->read_lock_wq);
}

void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info)
{
percpu_counter_inc(&fs_info->bio_counter);
Expand Down
2 changes: 0 additions & 2 deletions fs/btrfs/dev-replace.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ void btrfs_dev_replace_read_unlock(struct btrfs_dev_replace *dev_replace);
void btrfs_dev_replace_write_lock(struct btrfs_dev_replace *dev_replace);
void btrfs_dev_replace_write_unlock(struct btrfs_dev_replace *dev_replace);
void btrfs_dev_replace_set_lock_blocking(struct btrfs_dev_replace *dev_replace);
void btrfs_dev_replace_clear_lock_blocking(
struct btrfs_dev_replace *dev_replace);

static inline void btrfs_dev_replace_stats_inc(atomic64_t *stat_value)
{
Expand Down
6 changes: 5 additions & 1 deletion fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -5904,7 +5904,11 @@ static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
}
out:
if (dev_replace_is_ongoing) {
btrfs_dev_replace_clear_lock_blocking(dev_replace);
ASSERT(atomic_read(&dev_replace->blocking_readers) > 0);
btrfs_dev_replace_read_lock(dev_replace);
/* Barrier implied by atomic_dec_and_test */
if (atomic_dec_and_test(&dev_replace->blocking_readers))
cond_wake_up_nomb(&dev_replace->read_lock_wq);
btrfs_dev_replace_read_unlock(dev_replace);
}
free_extent_map(em);
Expand Down

0 comments on commit 7fb2ece

Please sign in to comment.