• J. Bruce Fields's avatar
    svcrpc: ensure cache_check caller sees updated entry · fdef7aa5
    J. Bruce Fields authored
    Supposes cache_check runs simultaneously with an update on a different
    CPU:
    
    	cache_check			task doing update
    	^^^^^^^^^^^			^^^^^^^^^^^^^^^^^
    
    	1. test for CACHE_VALID		1'. set entry->data
    	   & !CACHE_NEGATIVE
    
    	2. use entry->data		2'. set CACHE_VALID
    
    If the two memory writes performed in step 1' and 2' appear misordered
    with respect to the reads in step 1 and 2, then the caller could get
    stale data at step 2 even though it saw CACHE_VALID set on the cache
    entry.
    
    Add memory barriers to prevent this.
    Reviewed-by: default avatarNeilBrown <neilb@suse.de>
    Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
    fdef7aa5
cache.c 42.9 KB