• Chao Yu's avatar
    f2fs: avoid race in between atomic_read & atomic_inc · edd748e6
    Chao Yu authored
    Previously, we will miss merging flush command during fsync due to below
    race condition:
    
    Thread A 		Thread B		Thread C
    - f2fs_issue_flush
     - atomic_read(&issing_flush)
    			- f2fs_issue_flush
    			 - atomic_read(&issing_flush)
    						- f2fs_issue_flush
    						 - atomic_read(&issing_flush)
      - atomic_inc(&issing_flush)
    			  - atomic_inc(&issing_flush)
    						  - atomic_inc(&issing_flush)
       - submit_flush_wait
    			   - submit_flush_wait
    						   - submit_flush_wait
    
    It needs to use atomic_inc_return instead to avoid such race.
    Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
    edd748e6
segment.c 89.3 KB