• Alan Huang's avatar
    bcachefs: Fix lost wake up · e057a290
    Alan Huang authored
    If the reader acquires the read lock and then the writer enters the slow
    path, while the reader proceeds to the unlock path, the following scenario
    can occur without the change:
    
    writer: pcpu_read_count(lock) return 1 (so __do_six_trylock will return 0)
    reader: this_cpu_dec(*lock->readers)
    reader: smp_mb()
    reader: state = atomic_read(&lock->state) (there is no waiting flag set)
    writer: six_set_bitmask()
    
    then the writer will sleep forever.
    Signed-off-by: default avatarAlan Huang <mmpgouride@gmail.com>
    Signed-off-by: default avatarKent Overstreet <kent.overstreet@linux.dev>
    e057a290
six.c 23.6 KB