f2fs: don't GC or take an fs_lock from f2fs_initxattrs()
authorRuss Knize <Russ.Knize@motorola.com>
Tue, 24 Sep 2013 20:49:23 +0000 (15:49 -0500)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Wed, 25 Sep 2013 08:51:24 +0000 (17:51 +0900)
commit52ab956000214aa111254e52e5eac3d91bd7cf4b
treef449477dc83760d163de59e629f68bb74696b36c
parent885166c03c1d0ea6d79d707229340e3161ed1316
f2fs: don't GC or take an fs_lock from f2fs_initxattrs()

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: Russ Knize <Russ.Knize@motorola.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
fs/f2fs/xattr.c