Skip to content

Commit

Permalink
btrfs: add comments to barriers before waitqueue_active
Browse files Browse the repository at this point in the history
Reduce number of undocumented barriers out there.

Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
kdave committed Oct 10, 2015
1 parent 33a9eca commit a83342a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions fs/btrfs/compression.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,9 @@ static void free_workspace(int type, struct list_head *workspace)
btrfs_compress_op[idx]->free_workspace(workspace);
atomic_dec(alloc_workspace);
wake:
/*
* Make sure counter is updated before we wake up waiters.
*/
smp_mb();
if (waitqueue_active(workspace_wait))
wake_up(workspace_wait);
Expand Down
3 changes: 1 addition & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -10363,8 +10363,7 @@ void btrfs_end_write_no_snapshoting(struct btrfs_root *root)
{
percpu_counter_dec(&root->subv_writers->counter);
/*
* Make sure counter is updated before we wake up
* waiters.
* Make sure counter is updated before we wake up waiters.
*/
smp_mb();
if (waitqueue_active(&root->subv_writers->wait))
Expand Down
3 changes: 3 additions & 0 deletions fs/btrfs/locking.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ void btrfs_tree_unlock(struct extent_buffer *eb)
if (blockers) {
WARN_ON(atomic_read(&eb->spinning_writers));
atomic_dec(&eb->blocking_writers);
/*
* Make sure counter is updated before we wake up waiters.
*/
smp_mb();
if (waitqueue_active(&eb->write_lock_wq))
wake_up(&eb->write_lock_wq);
Expand Down
6 changes: 6 additions & 0 deletions fs/btrfs/ordered-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ int btrfs_dec_test_first_ordered_pending(struct inode *inode,

if (entry->bytes_left == 0) {
ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);
/*
* Implicit memory barrier after test_and_set_bit
*/
if (waitqueue_active(&entry->wait))
wake_up(&entry->wait);
} else {
Expand Down Expand Up @@ -409,6 +412,9 @@ int btrfs_dec_test_ordered_pending(struct inode *inode,

if (entry->bytes_left == 0) {
ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);
/*
* Implicit memory barrier after test_and_set_bit
*/
if (waitqueue_active(&entry->wait))
wake_up(&entry->wait);
} else {
Expand Down
3 changes: 3 additions & 0 deletions fs/btrfs/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,9 @@ static int __btrfs_end_transaction(struct btrfs_trans_handle *trans,
atomic_dec(&cur_trans->num_writers);
extwriter_counter_dec(cur_trans, trans->type);

/*
* Make sure counter is updated before we wake up waiters.
*/
smp_mb();
if (waitqueue_active(&cur_trans->writer_wait))
wake_up(&cur_trans->writer_wait);
Expand Down

0 comments on commit a83342a

Please sign in to comment.