• Andrew Morton's avatar
    [PATCH] fix umount dataloss problem · eb657e38
    Andrew Morton authored
    address_spaces have a `dirtied_when' jiffies field which records the time at
    which the mapping was first dirtied.  This is used for the periodic writeback
    (kupdate) function.  It is also used to prevent livelocks in the writeback
    code: don't try to write back objects which were dirtied after
    sync_sb_inodes() was called.
    
    It used to be the case that dirtied_when == 0 had magical properties, so
    there is code in there which avoids accidentally setting dirtied_when to zero
    at jiffy wrap time.  We just set it to jiffies|1.
    
    Unfortunately, jiffies|1 is in the future.  So under some rare timing
    circumstances (inode dirtied within one jiffy of umount) the livelock
    avoidance code in sync_sb_inodes() can accidentally trigger and we fail to
    write an inode out, resulting in filesytem corruption on ext2-style
    filesystems.  Normally, nobody dirties a file within a millisecond of umount,
    so it was not noticed.
    
    It is no longer the case that (address_space.dirtied_when == 0) has special
    meaning, so we can just remove all that code and fix the bug.
    eb657e38
fs-writeback.c 16.8 KB