Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

btrfs: introduce conditional wakeup helpers

Add convenience wrappers for the waitqueue management that involves
memory barriers to prevent deadlocks. The helpers will let us remove
barriers and the necessary comments in several places.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>

+22
+22
fs/btrfs/ctree.h
··· 3755 3755 return 0; 3756 3756 } 3757 3757 3758 + static inline void cond_wake_up(struct wait_queue_head *wq) 3759 + { 3760 + /* 3761 + * This implies a full smp_mb barrier, see comments for 3762 + * waitqueue_active why. 3763 + */ 3764 + if (wq_has_sleeper(wq)) 3765 + wake_up(wq); 3766 + } 3767 + 3768 + static inline void cond_wake_up_nomb(struct wait_queue_head *wq) 3769 + { 3770 + /* 3771 + * Special case for conditional wakeup where the barrier required for 3772 + * waitqueue_active is implied by some of the preceding code. Eg. one 3773 + * of such atomic operations (atomic_dec_and_return, ...), or a 3774 + * unlock/lock sequence, etc. 3775 + */ 3776 + if (waitqueue_active(wq)) 3777 + wake_up(wq); 3778 + } 3779 + 3758 3780 #endif