1. 04 9月, 2014 1 次提交
  2. 20 8月, 2014 1 次提交
  3. 02 6月, 2014 1 次提交
    • J
      f2fs: fix recursive lock by f2fs_setxattr · d631abda
      Jaegeuk Kim 提交于
      This patch should resolve the following recursive lock.
      
      [<ffffffff8135a9c3>] call_rwsem_down_write_failed+0x13/0x20
      [<ffffffffa01749dc>] f2fs_setxattr+0x5c/0xa0 [f2fs]
      [<ffffffffa0174c99>] __f2fs_set_acl+0x1b9/0x340 [f2fs]
      [<ffffffffa017515a>] f2fs_init_acl+0x4a/0xcb [f2fs]
      [<ffffffffa0159abe>] __f2fs_add_link+0x26e/0x780 [f2fs]
      [<ffffffffa015d4d8>] f2fs_mkdir+0xb8/0x150 [f2fs]
      [<ffffffff811cebd7>] vfs_mkdir+0xb7/0x160
      [<ffffffff811cf89b>] SyS_mkdir+0xab/0xe0
      [<ffffffff817244bf>] tracesys+0xe1/0xe6
      [<ffffffffffffffff>] 0xffffffffffffffff
      
      The call path indicates:
      - f2fs_add_link
         : down_write(&fi->i_sem);
      
       - init_inode_metadata
         - f2fs_init_acl
           - __f2fs_set_acl
             - f2fs_setxattr
               : down_write(&fi->i_sem);
      
      Here we should not call f2fs_setxattr, but __f2fs_setxattr.
      But __f2fs_setxattr is a static function in xattr.c, so that I found the other
      generic approach to use f2fs_setxattr.
      
      In f2fs_setxattr, the page pointer is only given from init_inode_metadata.
      So, this patch adds this condition to avoid this in f2fs_setxattr.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      d631abda
  4. 07 5月, 2014 4 次提交
  5. 01 4月, 2014 1 次提交
  6. 20 3月, 2014 2 次提交
    • J
      f2fs: avoid RECLAIM_FS-ON-W warning · 808a1d74
      Jaegeuk Kim 提交于
      This patch should resolve the following possible bug.
      
      RECLAIM_FS-ON-W at:
       mark_held_locks+0xb9/0x140
       lockdep_trace_alloc+0x85/0xf0
       __kmalloc+0x53/0x1d0
       read_all_xattrs+0x3d1/0x3f0 [f2fs]
       f2fs_getxattr+0x4f/0x100 [f2fs]
       f2fs_get_acl+0x4c/0x290 [f2fs]
       get_acl+0x4f/0x80
       posix_acl_create+0x72/0x180
       f2fs_init_acl+0x29/0xcc [f2fs]
       __f2fs_add_link+0x259/0x710 [f2fs]
       f2fs_create+0xad/0x1c0 [f2fs]
       vfs_create+0xed/0x150
       do_last+0xd36/0xed0
       path_openat+0xc5/0x680
       do_filp_open+0x43/0xa0
       do_sys_open+0x13c/0x230
       SyS_creat+0x1e/0x20
       system_call_fastpath+0x16/0x1b
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      808a1d74
    • J
      f2fs: introduce fi->i_sem to protect fi's info · d928bfbf
      Jaegeuk Kim 提交于
      This patch introduces fi->i_sem to protect fi's info that includes xattr_ver,
      pino, i_nlink.
      This enables to remove i_mutex during f2fs_sync_file, resulting in performance
      improvement when a number of fsync calls are triggered from many concurrent
      threads.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      d928bfbf
  7. 26 1月, 2014 1 次提交
  8. 23 12月, 2013 1 次提交
  9. 29 10月, 2013 2 次提交
  10. 07 10月, 2013 1 次提交
    • G
      f2fs: use rw_sem instead of fs_lock(locks mutex) · e479556b
      Gu Zheng 提交于
      The fs_locks is used to block other ops(ex, recovery) when doing checkpoint.
      And each other operate routine(besides checkpoint) needs to acquire a fs_lock,
      there is a terrible problem here, if these are too many concurrency threads acquiring
      fs_lock, so that they will block each other and may lead to some performance problem,
      but this is not the phenomenon we want to see.
      Though there are some optimization patches introduced to enhance the usage of fs_lock,
      but the thorough solution is using a *rw_sem* to replace the fs_lock.
      Checkpoint routine takes write_sem, and other ops take read_sem, so that we can block
      other ops(ex, recovery) when doing checkpoint, and other ops will not disturb each other,
      this can avoid the problem described above completely.
      Because of the weakness of rw_sem, the above change may introduce a potential problem
      that the checkpoint thread might get starved if other threads are intensively locking
      the read semaphore for I/O.(Pointed out by Xu Jin)
      In order to avoid this, a wait_list is introduced, the appending read semaphore ops
      will be dropped into the wait_list if checkpoint thread is waiting for write semaphore,
      and will be waked up when checkpoint thread gives up write semaphore.
      Thanks to Kim's previous review and test, and will be very glad to see other guys'
      performance tests about this patch.
      
      V2:
        -fix the potential starvation problem.
        -use more suitable func name suggested by Xu Jin.
      Signed-off-by: NGu Zheng <guz.fnst@cn.fujitsu.com>
      [Jaegeuk Kim: adjust minor coding standard]
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      e479556b
  11. 25 9月, 2013 1 次提交
    • R
      f2fs: don't GC or take an fs_lock from f2fs_initxattrs() · 52ab9560
      Russ Knize 提交于
      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: NRuss Knize <Russ.Knize@motorola.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      52ab9560
  12. 26 8月, 2013 2 次提交
    • J
      f2fs: support the inline xattrs · 65985d93
      Jaegeuk Kim 提交于
      0. modified inode structure
      --------------------------------------
      metadata (e.g., i_mtime, i_ctime, etc)
      --------------------------------------
      direct pointers [0 ~ 873]
      
      inline xattrs (200 bytes by default)
      
      indirect pointers [0 ~ 4]
      --------------------------------------
      node footer
      --------------------------------------
      
      1. setxattr flow
       - read_all_xattrs copies all the xattrs from inline and xattr node block.
       - handle xattr entries
       - write_all_xattrs copies modified xattrs into inline and xattr node block.
      
      2. getxattr flow
       - read_all_xattrs copies all the xattrs from inline and xattr node block.
       - check target entries
      
      3. Usage
       # mount -t f2fs -o inline_xattr $DEV $MNT
      
       Once mounted with the inline_xattr option, f2fs marks all the newly created
       files to reserve an amount of inline xattr space explicitly inside the inode
       block. Without the mount option, f2fs will not touch any existing files and
       newly created files as well.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      65985d93
    • J
      f2fs: introduce __find_xattr for readability · dd9cfe23
      Jaegeuk Kim 提交于
      The __find_xattr is to search the wanted xattr entry starting from the
      base_addr.
      
      If not found, the returned entry is the last empty xattr entry that can be
      allocated newly.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      dd9cfe23
  13. 12 8月, 2013 1 次提交
    • J
      f2fs: should cover i_xattr_nid with its xattr node page lock · 479bd73a
      Jaegeuk Kim 提交于
      Previously, f2fs_setxattr assigns i_xattr_nid in the inode page inconsistently.
      
      The scenario is:
      
      = Thread 1 =         = Thread 2 =     = fi->i_xattr_nid =  = on-disk nid =
      
      f2fs_setxattr                                   0                 0
        new_node_page                                 X                 0
                         sync_inode_page              X                 X
                         checkpoint                   X                 X -.
          grab_cache_page                             X                 X  |
      --> allocate a new xattr node block or -ENOSPC      <----------------'
      
      At this moment, the checkpoint stores inconsistent data where the inode has
      i_xattr_nid but actual xattr node block is not allocated yet.
      
      So, we should assign the real i_xattr_nid only after its xattr node block is
      allocated.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      479bd73a
  14. 09 8月, 2013 2 次提交
  15. 11 6月, 2013 1 次提交
    • J
      f2fs: support xattr security labels · 8ae8f162
      Jaegeuk Kim 提交于
      This patch adds the support of security labels for f2fs, which will be used
      by Linus Security Models (LSMs).
      
      Quote from http://en.wikipedia.org/wiki/Linux_Security_Modules:
      "Linux Security Modules (LSM) is a framework that allows the Linux kernel to
      support a variety of computer security models while avoiding favoritism toward
      any single security implementation. The framework is licensed under the terms of
      the GNU General Public License and is standard part of the Linux kernel since
      Linux 2.6. AppArmor, SELinux, Smack and TOMOYO Linux are the currently accepted
      modules in the official kernel.".
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      8ae8f162
  16. 03 6月, 2013 1 次提交
  17. 09 4月, 2013 1 次提交
    • J
      f2fs: introduce a new global lock scheme · 39936837
      Jaegeuk Kim 提交于
      In the previous version, f2fs uses global locks according to the usage types,
      such as directory operations, block allocation, block write, and so on.
      
      Reference the following lock types in f2fs.h.
      enum lock_type {
      	RENAME,		/* for renaming operations */
      	DENTRY_OPS,	/* for directory operations */
      	DATA_WRITE,	/* for data write */
      	DATA_NEW,	/* for data allocation */
      	DATA_TRUNC,	/* for data truncate */
      	NODE_NEW,	/* for node allocation */
      	NODE_TRUNC,	/* for node truncate */
      	NODE_WRITE,	/* for node write */
      	NR_LOCK_TYPE,
      };
      
      In that case, we lose the performance under the multi-threading environment,
      since every types of operations must be conducted one at a time.
      
      In order to address the problem, let's share the locks globally with a mutex
      array regardless of any types.
      So, let users grab a mutex and perform their jobs in parallel as much as
      possbile.
      
      For this, I propose a new global lock scheme as follows.
      
      0. Data structure
       - f2fs_sb_info -> mutex_lock[NR_GLOBAL_LOCKS]
       - f2fs_sb_info -> node_write
      
      1. mutex_lock_op(sbi)
       - try to get an avaiable lock from the array.
       - returns the index of the gottern lock variable.
      
      2. mutex_unlock_op(sbi, index of the lock)
       - unlock the given index of the lock.
      
      3. mutex_lock_all(sbi)
       - grab all the locks in the array before the checkpoint.
      
      4. mutex_unlock_all(sbi)
       - release all the locks in the array after checkpoint.
      
      5. block_operations()
       - call mutex_lock_all()
       - sync_dirty_dir_inodes()
       - grab node_write
       - sync_node_pages()
      
      Note that,
       the pairs of mutex_lock_op()/mutex_unlock_op() and
       mutex_lock_all()/mutex_unlock_all() should be used together.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      39936837
  18. 20 3月, 2013 1 次提交
  19. 11 1月, 2013 1 次提交
    • J
      f2fs: add f2fs_balance_fs in several interfaces · 7d82db83
      Jaegeuk Kim 提交于
      The f2fs_balance_fs() is to check the number of free sections and decide whether
      it needs to conduct cleaning or not. If there are not enough free sections, the
      cleaning job should be started.
      
      In order to control an amount of free sections even under high utilization, f2fs
      should call f2fs_balance_fs at all the VFS interfaces that are able to produce
      dirty pages.
      This patch adds the function calls in the missing interfaces as follows.
      
      1. f2fs_setxattr()
      The f2fs_setxattr() produces dirty node pages so that we should call
      f2fs_balance_fs() either likewise doing in other VFS interfaces such as
      f2fs_lookup(), f2fs_mkdir(), and so on.
      
      2. f2fs_sync_file()
      We should guarantee serving free sections for syncing metadata during fsync.
      Previously, there is no space check before triggering checkpoint and
      sync_node_pages.
      Therefore, if a bunch of fsync calls are triggered under 100% of FS utilization,
      f2fs is able to be faced with no free sections, resulting in BUG_ON().
      
      3. f2fs_sync_fs()
      Before calling write_checkpoint(), we should guarantee that there are minimum
      free sections.
      
      4. f2fs_write_inode()
      f2fs_write_inode() is also able to produce dirty node pages.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      7d82db83
  20. 28 12月, 2012 1 次提交
  21. 11 12月, 2012 3 次提交
    • J
      f2fs: resolve build failures · 573ea5fc
      Jaegeuk Kim 提交于
      There exist two build failures reported by Randy Dunlap as follows.
      
      (on i386)
       a. (config-r8857)
      	ERROR: "f2fs_xattr_advise_handler" [fs/f2fs/f2fs.ko] undefined!
      
      Key configs in (config-r8857) are as follows.
       CONFIG_F2FS_FS=m
       # CONFIG_F2FS_STAT_FS is not set
       CONFIG_F2FS_FS_XATTR=y
       # CONFIG_F2FS_FS_POSIX_ACL is not set
      
      The error was occurred due to the function location that we made a mistake.
      Recently we added a new functionality for users to indicate cold files
      explicitly through xattr operations (i.e., f2fs_xattr_advise_handler).
      
      This handler should have been added in xattr.c instead of acl.c in order
      to avoid an undefined operation like in this case where XATTR is set and
      ACL is not set.
      
       b. (config-r8855)
      	fs/f2fs/file.c: In function 'f2fs_vm_page_mkwrite':
      	fs/f2fs/file.c:97:2: error: implicit declaration of function
      	'block_page_mkwrite_return'
      
      Key config in (config-r8855) is CONFIG_BLOCK.
      
      Obviously, f2fs works on top of the block device so that we should consider
      carefully a sort of config dependencies.
      
      The reason why this error was occurred was that f2fs_vm_page_mkwrite() calls
      block_page_mkwrite_return() which is enalbed only if CONFIG_BLOCK is set.
      Reported-by: NRandy Dunlap <rdunlap@xenotime.net>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      Acked-by: NRandy Dunlap <rdunlap@xenotime.net>
      573ea5fc
    • J
      f2fs: adjust kernel coding style · 0a8165d7
      Jaegeuk Kim 提交于
      As pointed out by Randy Dunlap, this patch removes all usage of "/**" for comment
      blocks. Instead, just use "/*".
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      0a8165d7
    • J
      f2fs: add xattr and acl functionalities · af48b85b
      Jaegeuk Kim 提交于
      This implements xattr and acl functionalities.
      
      - F2FS uses a node page to contain use extended attributes.
      Signed-off-by: NChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      af48b85b