• A
    ext4: Fix race between migration and mmap write · 267e4db9
    Aneesh Kumar K.V 提交于
    Fail migrate if we allocated new blocks via mmap write.
    
    If we write to holes in the file via mmap, we end up allocating
    new blocks. This block allocation happens without taking inode->i_mutex.
    Since migrate is protected by i_mutex and migrate expects that no
    new blocks get allocated during migrate, fail migrate if new blocks
    get allocated.
    
    We can't take inode->i_mutex in the mmap write path because that
    would result in a locking order violation between i_mutex and mmap_sem.
    Also adding a separate rw_sempahore for protection is really high overhead
    for a rare operation such as migrate.
    Signed-off-by: NAneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
    Acked-by: NJan Kara <jack@suse.cz>
    Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
    267e4db9
migrate.c 15.3 KB