• Russ Knize's avatar
    f2fs: don't GC or take an fs_lock from f2fs_initxattrs() · 52ab9560
    Russ Knize authored
    f2fs_initxattrs() is called internally from within F2FS and should
    not call functions that are used by VFS handlers.  This avoids
    certain deadlocks:
    
    - vfs_create()
     - f2fs_create() <-- takes an fs_lock
      - f2fs_add_link()
       - __f2fs_add_link()
        - init_inode_metadata()
         - f2fs_init_security()
          - security_inode_init_security()
           - f2fs_initxattrs()
            - f2fs_setxattr() <-- also takes an fs_lock
    
    If the caller happens to grab the same fs_lock from the pool in both
    places, they will deadlock.  There are also deadlocks involving
    multiple threads and mutexes:
    
    - f2fs_write_begin()
     - f2fs_balance_fs() <-- takes gc_mutex
      - f2fs_gc()
       - write_checkpoint()
        - block_operations()
         - mutex_lock_all() <-- blocks trying to grab all fs_locks
    
    - f2fs_mkdir() <-- takes an fs_lock
     - __f2fs_add_link()
      - f2fs_init_security()
       - security_inode_init_security()
        - f2fs_initxattrs()
         - f2fs_setxattr()
          - f2fs_balance_fs() <-- blocks trying to take gc_mutex
    Signed-off-by: default avatarRuss Knize <Russ.Knize@motorola.com>
    Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
    52ab9560
xattr.c 14.4 KB