• J
    [PATCH] dm: fix rh_dec()/rh_inc() race in dm-raid1.c · 844e8d90
    Jun'ichi Nomura 提交于
    Fix another bug in dm-raid1.c that the dirty region may stay in or be moved
    to clean list and freed while in use.
    
    It happens as follows:
    
       CPU0                                   CPU1
       ------------------------------------------------------------------------------
       rh_dec()
         if (atomic_dec_and_test(pending))
            <the region is still marked dirty>
                                              rh_inc()
                                                if the region is clean
                                                   mark the region dirty
                                                   and remove from clean list
            mark the region clean
            and move to clean list
                                                      atomic_inc(pending)
    
    At this stage, the region is in clean list and will be mistakenly reclaimed
    by rh_update_states() later.
    Signed-off-by: NJun'ichi Nomura <j-nomura@ce.jp.nec.com>
    Signed-off-by: NAndrew Morton <akpm@osdl.org>
    Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
    844e8d90
dm-raid1.c 28.4 KB