···990990 btrfs_compress_op[idx]->free_workspace(workspace);991991 atomic_dec(total_ws);992992wake:993993- /*994994- * Make sure counter is updated before we wake up waiters.995995- */996996- smp_mb();997997- if (waitqueue_active(ws_wait))998998- wake_up(ws_wait);993993+ cond_wake_up(ws_wait);999994}10009951001996static void free_workspace(int type, struct list_head *ws)
+3-6
fs/btrfs/delayed-inode.c
···460460{461461 int seq = atomic_inc_return(&delayed_root->items_seq);462462463463- /*464464- * atomic_dec_return implies a barrier for waitqueue_active465465- */463463+ /* atomic_dec_return implies a barrier */466464 if ((atomic_dec_return(&delayed_root->items) <467467- BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&468468- waitqueue_active(&delayed_root->wait))469469- wake_up(&delayed_root->wait);465465+ BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0))466466+ cond_wake_up_nomb(&delayed_root->wait);470467}471468472469static void __btrfs_remove_delayed_item(struct btrfs_delayed_item *delayed_item)
+4-6
fs/btrfs/dev-replace.c
···10091009 ASSERT(atomic_read(&dev_replace->read_locks) > 0);10101010 ASSERT(atomic_read(&dev_replace->blocking_readers) > 0);10111011 read_lock(&dev_replace->lock);10121012- if (atomic_dec_and_test(&dev_replace->blocking_readers) &&10131013- waitqueue_active(&dev_replace->read_lock_wq))10141014- wake_up(&dev_replace->read_lock_wq);10121012+ /* Barrier implied by atomic_dec_and_test */10131013+ if (atomic_dec_and_test(&dev_replace->blocking_readers))10141014+ cond_wake_up_nomb(&dev_replace->read_lock_wq);10151015}1016101610171017void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info)···10221022void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount)10231023{10241024 percpu_counter_sub(&fs_info->bio_counter, amount);10251025-10261026- if (waitqueue_active(&fs_info->replace_wait))10271027- wake_up(&fs_info->replace_wait);10251025+ cond_wake_up_nomb(&fs_info->replace_wait);10281026}1029102710301028void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info)
+1-6
fs/btrfs/extent-tree.c
···1108111081void btrfs_end_write_no_snapshotting(struct btrfs_root *root)1108211082{1108311083 percpu_counter_dec(&root->subv_writers->counter);1108411084- /*1108511085- * Make sure counter is updated before we wake up waiters.1108611086- */1108711087- smp_mb();1108811088- if (waitqueue_active(&root->subv_writers->wait))1108911089- wake_up(&root->subv_writers->wait);1108411084+ cond_wake_up(&root->subv_writers->wait);1109011085}11091110861109211087int btrfs_start_write_no_snapshotting(struct btrfs_root *root)
+3-6
fs/btrfs/inode.c
···11561156 nr_pages = (async_cow->end - async_cow->start + PAGE_SIZE) >>11571157 PAGE_SHIFT;1158115811591159- /*11601160- * atomic_sub_return implies a barrier for waitqueue_active11611161- */11591159+ /* atomic_sub_return implies a barrier */11621160 if (atomic_sub_return(nr_pages, &fs_info->async_delalloc_pages) <11631163- 5 * SZ_1M &&11641164- waitqueue_active(&fs_info->async_submit_wait))11651165- wake_up(&fs_info->async_submit_wait);11611161+ 5 * SZ_1M)11621162+ cond_wake_up_nomb(&fs_info->async_submit_wait);1166116311671164 if (async_cow->inode)11681165 submit_compressed_extents(async_cow->inode, async_cow);
+11-23
fs/btrfs/locking.c
···6666 write_lock(&eb->lock);6767 WARN_ON(atomic_read(&eb->spinning_writers));6868 atomic_inc(&eb->spinning_writers);6969- /*7070- * atomic_dec_and_test implies a barrier for waitqueue_active7171- */7272- if (atomic_dec_and_test(&eb->blocking_writers) &&7373- waitqueue_active(&eb->write_lock_wq))7474- wake_up(&eb->write_lock_wq);6969+ /* atomic_dec_and_test implies a barrier */7070+ if (atomic_dec_and_test(&eb->blocking_writers))7171+ cond_wake_up_nomb(&eb->write_lock_wq);7572 } else if (rw == BTRFS_READ_LOCK_BLOCKING) {7673 BUG_ON(atomic_read(&eb->blocking_readers) == 0);7774 read_lock(&eb->lock);7875 atomic_inc(&eb->spinning_readers);7979- /*8080- * atomic_dec_and_test implies a barrier for waitqueue_active8181- */8282- if (atomic_dec_and_test(&eb->blocking_readers) &&8383- waitqueue_active(&eb->read_lock_wq))8484- wake_up(&eb->read_lock_wq);7676+ /* atomic_dec_and_test implies a barrier */7777+ if (atomic_dec_and_test(&eb->blocking_readers))7878+ cond_wake_up_nomb(&eb->read_lock_wq);8579 }8680}8781···215221 }216222 btrfs_assert_tree_read_locked(eb);217223 WARN_ON(atomic_read(&eb->blocking_readers) == 0);218218- /*219219- * atomic_dec_and_test implies a barrier for waitqueue_active220220- */221221- if (atomic_dec_and_test(&eb->blocking_readers) &&222222- waitqueue_active(&eb->read_lock_wq))223223- wake_up(&eb->read_lock_wq);224224+ /* atomic_dec_and_test implies a barrier */225225+ if (atomic_dec_and_test(&eb->blocking_readers))226226+ cond_wake_up_nomb(&eb->read_lock_wq);224227 atomic_dec(&eb->read_locks);225228}226229···266275 if (blockers) {267276 WARN_ON(atomic_read(&eb->spinning_writers));268277 atomic_dec(&eb->blocking_writers);269269- /*270270- * Make sure counter is updated before we wake up waiters.271271- */278278+ /* Use the lighter barrier after atomic */272279 smp_mb__after_atomic();273273- if (waitqueue_active(&eb->write_lock_wq))274274- wake_up(&eb->write_lock_wq);280280+ cond_wake_up_nomb(&eb->write_lock_wq);275281 } else {276282 WARN_ON(atomic_read(&eb->spinning_writers) != 1);277283 atomic_dec(&eb->spinning_writers);
+4-10
fs/btrfs/ordered-data.c
···343343344344 if (entry->bytes_left == 0) {345345 ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);346346- /*347347- * Implicit memory barrier after test_and_set_bit348348- */349349- if (waitqueue_active(&entry->wait))350350- wake_up(&entry->wait);346346+ /* test_and_set_bit implies a barrier */347347+ cond_wake_up_nomb(&entry->wait);351348 } else {352349 ret = 1;353350 }···407410408411 if (entry->bytes_left == 0) {409412 ret = test_and_set_bit(BTRFS_ORDERED_IO_DONE, &entry->flags);410410- /*411411- * Implicit memory barrier after test_and_set_bit412412- */413413- if (waitqueue_active(&entry->wait))414414- wake_up(&entry->wait);413413+ /* test_and_set_bit implies a barrier */414414+ cond_wake_up_nomb(&entry->wait);415415 } else {416416 ret = 1;417417 }
+1-6
fs/btrfs/transaction.c
···877877 atomic_dec(&cur_trans->num_writers);878878 extwriter_counter_dec(cur_trans, trans->type);879879880880- /*881881- * Make sure counter is updated before we wake up waiters.882882- */883883- smp_mb();884884- if (waitqueue_active(&cur_trans->writer_wait))885885- wake_up(&cur_trans->writer_wait);880880+ cond_wake_up(&cur_trans->writer_wait);886881 btrfs_put_transaction(cur_trans);887882888883 if (current->journal_info == trans)
+12-22
fs/btrfs/tree-log.c
···222222void btrfs_end_log_trans(struct btrfs_root *root)223223{224224 if (atomic_dec_and_test(&root->log_writers)) {225225- /*226226- * Implicit memory barrier after atomic_dec_and_test227227- */228228- if (waitqueue_active(&root->log_writer_wait))229229- wake_up(&root->log_writer_wait);225225+ /* atomic_dec_and_test implies a barrier */226226+ cond_wake_up_nomb(&root->log_writer_wait);230227 }231228}232229···2985298829862989 mutex_lock(&log_root_tree->log_mutex);29872990 if (atomic_dec_and_test(&log_root_tree->log_writers)) {29882988- /*29892989- * Implicit memory barrier after atomic_dec_and_test29902990- */29912991- if (waitqueue_active(&log_root_tree->log_writer_wait))29922992- wake_up(&log_root_tree->log_writer_wait);29912991+ /* atomic_dec_and_test implies a barrier */29922992+ cond_wake_up_nomb(&log_root_tree->log_writer_wait);29932993 }2994299429952995 if (ret) {···31103116 mutex_unlock(&log_root_tree->log_mutex);3111311731123118 /*31133113- * The barrier before waitqueue_active is needed so all the updates31143114- * above are seen by the woken threads. It might not be necessary, but31153115- * proving that seems to be hard.31193119+ * The barrier before waitqueue_active (in cond_wake_up) is needed so31203120+ * all the updates above are seen by the woken threads. It might not be31213121+ * necessary, but proving that seems to be hard.31163122 */31173117- smp_mb();31183118- if (waitqueue_active(&log_root_tree->log_commit_wait[index2]))31193119- wake_up(&log_root_tree->log_commit_wait[index2]);31233123+ cond_wake_up(&log_root_tree->log_commit_wait[index2]);31203124out:31213125 mutex_lock(&root->log_mutex);31223126 btrfs_remove_all_log_ctxs(root, index1, ret);···31233131 mutex_unlock(&root->log_mutex);3124313231253133 /*31263126- * The barrier before waitqueue_active is needed so all the updates31273127- * above are seen by the woken threads. It might not be necessary, but31283128- * proving that seems to be hard.31343134+ * The barrier before waitqueue_active (in cond_wake_up) is needed so31353135+ * all the updates above are seen by the woken threads. It might not be31363136+ * necessary, but proving that seems to be hard.31293137 */31303130- smp_mb();31313131- if (waitqueue_active(&root->log_commit_wait[index1]))31323132- wake_up(&root->log_commit_wait[index1]);31383138+ cond_wake_up(&root->log_commit_wait[index1]);31333139 return ret;31343140}31353141