1. 01 Oct, 2016 6 commits
    • Jaegeuk Kim's avatar
      f2fs: handle errors during recover_orphan_inodes · d41065e2
      Jaegeuk Kim authored
      This patch fixes to handle EIO during recover_orphan_inode() given the below
      panic.
      
      F2FS-fs : inject IO error in f2fs_read_end_io+0xe6/0x100 [f2fs]
      ------------[ cut here ]------------
      RIP: 0010:[<ffffffffc0b244e3>]  [<ffffffffc0b244e3>] f2fs_evict_inode+0x433/0x470 [f2fs]
      RSP: 0018:ffff92f8b7fb7c30  EFLAGS: 00010246
      RAX: ffff92fb88a13500 RBX: ffff92f890566ea0 RCX: 00000000fd3c255c
      RDX: 0000000000000001 RSI: ffff92fb88a13d90 RDI: ffff92fb8ee127e8
      RBP: ffff92f8b7fb7c58 R08: 0000000000000001 R09: ffff92fb88a13d58
      R10: 000000005a6a9373 R11: 0000000000000001 R12: 00000000fffffffb
      R13: ffff92fb8ee12000 R14: 00000000000034ca R15: ffff92fb8ee12620
      FS:  00007f1fefd8e880(0000) GS:ffff92fb95600000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00007fc211d34cdb CR3: 000000012d43a000 CR4: 00000000001406e0
      Stack:
       ffff92f890566ea0 ffff92f890567078 ffffffffc0b5a0c0 ffff92f890566f28
       ffff92fb888b2000 ffff92f8b7fb7c80 ffffffffbc27ff55 ffff92f890566ea0
       ffff92fb8bf10000 ffffffffc0b5a0c0 ffff92f8b7fb7cb0 ffffffffbc28090d
      Call Trace:
       [<ffffffffbc27ff55>] evict+0xc5/0x1a0
       [<ffffffffbc28090d>] iput+0x1ad/0x2c0
       [<ffffffffc0b3304c>] recover_orphan_inodes+0x10c/0x2e0 [f2fs]
       [<ffffffffc0b2e0f4>] f2fs_fill_super+0x884/0x1150 [f2fs]
       [<ffffffffbc2644ac>] mount_bdev+0x18c/0x1c0
       [<ffffffffc0b2d870>] ? f2fs_commit_super+0x100/0x100 [f2fs]
       [<ffffffffc0b2a755>] f2fs_mount+0x15/0x20 [f2fs]
       [<ffffffffbc264e49>] mount_fs+0x39/0x170
       [<ffffffffbc28555b>] vfs_kern_mount+0x6b/0x160
       [<ffffffffbc2881df>] do_mount+0x1cf/0xd00
       [<ffffffffbc287f2c>] ? copy_mount_options+0xac/0x170
       [<ffffffffbc289003>] SyS_mount+0x83/0xd0
       [<ffffffffbc8ee880>] entry_SYSCALL_64_fastpath+0x23/0xc1
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      d41065e2
    • Jaegeuk Kim's avatar
      f2fs: avoid gc in cp_error case · 646e759a
      Jaegeuk Kim authored
      Otherwise, we can hit
      	f2fs_bug_on(sbi, !PageUptodate(sum_page));
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      646e759a
    • Jaegeuk Kim's avatar
      f2fs: should put_page for summary page · f6fe2be3
      Jaegeuk Kim authored
      We should call put_page for preloaded summary pages in do_garbage_collect.
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      f6fe2be3
    • Jaegeuk Kim's avatar
      f2fs: assign return value in f2fs_gc · 2956e450
      Jaegeuk Kim authored
      This patch adds a return value of write_checkpoint for f2fs_gc.
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2956e450
    • Weichao Guo's avatar
      f2fs: add customized migrate_page callback · 5b7a487c
      Weichao Guo authored
      This patch improves the migration of dirty pages and allows migrating atomic
      written pages that F2FS uses in Page Cache. Instead of the fallback releasing
      page path, it provides better performance for memory compaction, CMA and other
      users of memory page migrating. For dirty pages, there is no need to write back
      first when migrating. For an atomic written page before committing, we can
      migrate the page and update the related 'inmem_pages' list at the same time.
      Signed-off-by: default avatarWeichao Guo <guoweichao@huawei.com>
      Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: fix some coding style]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      5b7a487c
    • Chao Yu's avatar
      f2fs: introduce cp_lock to protect updating of ckpt_flags · aaec2b1d
      Chao Yu authored
      This patch introduces spinlock to protect updating process of ckpt_flags
      field in struct f2fs_checkpoint, it avoids incorrectly updating in race
      condition.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: add __is_set_ckpt_flags likewise __set_ckpt_flags]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      aaec2b1d
  2. 30 Sep, 2016 3 commits
  3. 22 Sep, 2016 5 commits
  4. 15 Sep, 2016 1 commit
  5. 14 Sep, 2016 2 commits
  6. 13 Sep, 2016 4 commits
  7. 12 Sep, 2016 4 commits
  8. 08 Sep, 2016 13 commits
    • Jaegeuk Kim's avatar
      f2fs: no need to make zeros beyond i_size · 68f31393
      Jaegeuk Kim authored
      We don't need to make zeros beyond i_size, since we already wrote that through
      NEW_ADDR case.
      Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      68f31393
    • Chao Yu's avatar
      f2fs: fix to detect temporary name of multimedia file · 7732c26a
      Chao Yu authored
      Some applications may create multimeida file with temporary name like
      '*.jpg.tmp' or '*.mp4.tmp', then rename to '*.jpg' or '*.mp4'.
      
      Now, f2fs can only detect multimedia filename with specified format:
      "filename + '.' + extension", so it will make f2fs missing to detect
      multimedia file with special temporary name, result in failing to set
      cold flag on file.
      
      This patch enhances detection flow for enabling lookup extension in the
      middle of temporary filename.
      Reported-by: default avatarXue Liu <liuxueliu.liu@huawei.com>
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7732c26a
    • Chao Yu's avatar
      f2fs: fix minor typo · 6ab2a308
      Chao Yu authored
      Correct typo from 'destory' to 'destroy'.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      6ab2a308
    • Jaegeuk Kim's avatar
      f2fs: set dentry bits on random location in memory · 6bf6b267
      Jaegeuk Kim authored
      This fixes pointer panic when using inline_dentry, which was triggered when
      backporting to 3.10.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      6bf6b267
    • Chao Yu's avatar
      f2fs: fix to set superblock dirty correctly · c2a080ae
      Chao Yu authored
      tests/generic/251 of fstest suit complains us with below message:
      
      ------------[ cut here ]------------
      invalid opcode: 0000 [#1] PREEMPT SMP
      CPU: 2 PID: 7698 Comm: fstrim Tainted: G           O    4.7.0+ #21
      task: e9f4e000 task.stack: e7262000
      EIP: 0060:[<f89fcefe>] EFLAGS: 00010202 CPU: 2
      EIP is at write_checkpoint+0xfde/0x1020 [f2fs]
      EAX: f33eb300 EBX: eecac310 ECX: 00000001 EDX: ffff0001
      ESI: eecac000 EDI: eecac5f0 EBP: e7263dec ESP: e7263d18
       DS: 007b ES: 007b FS: 00d8 GS: 0033 SS: 0068
      CR0: 80050033 CR2: b76ab01c CR3: 2eb89de0 CR4: 000406f0
      Stack:
       00000001 a220fb7b e9f4e000 00000002 419ff2d3 b3a05151 00000002 e9f4e5d8
       e9f4e000 419ff2d3 b3a05151 eecac310 c10b8154 b3a05151 419ff2d3 c10b78bd
       e9f4e000 e9f4e000 e9f4e5d8 00000001 e9f4e000 ec409000 eecac2cc eecac288
      Call Trace:
       [<c10b8154>] ? __lock_acquire+0x3c4/0x760
       [<c10b78bd>] ? mark_held_locks+0x5d/0x80
       [<f8a10632>] f2fs_trim_fs+0x1c2/0x2e0 [f2fs]
       [<f89e9f56>] f2fs_ioctl+0x6b6/0x10b0 [f2fs]
       [<c13d51df>] ? __this_cpu_preempt_check+0xf/0x20
       [<c10b4281>] ? trace_hardirqs_off_caller+0x91/0x120
       [<f89e98a0>] ? __exchange_data_block+0xd30/0xd30 [f2fs]
       [<c120b2e1>] do_vfs_ioctl+0x81/0x7f0
       [<c11d57c5>] ? kmem_cache_free+0x245/0x2e0
       [<c1217840>] ? get_unused_fd_flags+0x40/0x40
       [<c1206eec>] ? putname+0x4c/0x50
       [<c11f631e>] ? do_sys_open+0x16e/0x1d0
       [<c1001990>] ? do_fast_syscall_32+0x30/0x1c0
       [<c13d51df>] ? __this_cpu_preempt_check+0xf/0x20
       [<c120baa8>] SyS_ioctl+0x58/0x80
       [<c1001a01>] do_fast_syscall_32+0xa1/0x1c0
       [<c178cc54>] sysenter_past_esp+0x45/0x74
      EIP: [<f89fcefe>] write_checkpoint+0xfde/0x1020 [f2fs] SS:ESP 0068:e7263d18
      ---[ end trace 4de95d7e6b3aa7c6 ]---
      
      The reason is: with below call stack, we will encounter BUG_ON during
      doing fstrim.
      
      Thread A				Thread B
      - write_checkpoint
       - do_checkpoint
      					- f2fs_write_inode
      					 - update_inode_page
      					  - update_inode
      					   - set_page_dirty
      					    - f2fs_set_node_page_dirty
      					     - inc_page_count
      					      - percpu_counter_inc
      					      - set_sbi_flag(SBI_IS_DIRTY)
        - clear_sbi_flag(SBI_IS_DIRTY)
      
      Thread C				Thread D
      - f2fs_write_node_page
       - set_node_addr
        - __set_nat_cache_dirty
         - nm_i->dirty_nat_cnt++
      					- do_vfs_ioctl
      					 - f2fs_ioctl
      					  - f2fs_trim_fs
      					   - write_checkpoint
      					    - f2fs_bug_on(nm_i->dirty_nat_cnt)
      
      Fix it by setting superblock dirty correctly in do_checkpoint and
      f2fs_write_node_page.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c2a080ae
    • Shuoran Liu's avatar
      f2fs: add roll-forward recovery process for encrypted dentry · e7ba108a
      Shuoran Liu authored
      Add roll-forward recovery process for encrypted dentry, so the first fsync
      issued to an encrypted file does not need writing checkpoint.
      
      This improves the performance of the following test at thousands of small
      files: open -> write -> fsync -> close
      Signed-off-by: default avatarShuoran Liu <liushuoran@huawei.com>
      Acked-by: default avatarChao Yu <yuchao0@huawei.com>
      [Jaegeuk Kim: modify kernel message to show encrypted names]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e7ba108a
    • Jaegeuk Kim's avatar
      f2fs: fix lost xattrs of directories · bbf156f7
      Jaegeuk Kim authored
      This patch enhances the xattr consistency of dirs from suddern power-cuts.
      
      Possible scenario would be:
      1. dir->setxattr used by per-file encryption
      2. file->setxattr goes into inline_xattr
      3. file->fsync
      
      In that case, we should do checkpoint for #1.
      Otherwise we'd lose dir's key information for the file given #2.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      bbf156f7
    • Chao Yu's avatar
      f2fs: support async discard · 275b66b0
      Chao Yu authored
      Like most filesystems, f2fs will issue discard command synchronously, so
      when user trigger fstrim through ioctl, multiple discard commands will be
      issued serially with sync mode, which makes poor performance.
      
      In this patch we try to support async discard, so that all discard
      commands can be issued and be waited for endio in batch to improve
      performance.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      275b66b0
    • Shuoran Liu's avatar
      f2fs: set encryption name flag in add inline entry path · 167451ef
      Shuoran Liu authored
      This patch sets encryption name flag in the add inline entry path
      if filename is encrypted.
      Signed-off-by: default avatarShuoran Liu <liushuoran@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      167451ef
    • Chao Yu's avatar
      f2fs crypto: avoid unneeded memory allocation in ->readdir · e06f86e6
      Chao Yu authored
      When decrypting dirents in ->readdir, fscrypt_fname_disk_to_usr won't
      change content of original encrypted dirent, we don't need to allocate
      additional buffer for storing mirror of it, so get rid of it.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e06f86e6
    • Chao Yu's avatar
      f2fs: fix to do security initialization of encrypted inode with original filename · 9421d570
      Chao Yu authored
      When creating new inode, security_inode_init_security will be called for
      initializing security info related to the inode, and filename is passed to
      security module, it helps security module such as SElinux to know which
      rule or label could be applied for the inode with specified name.
      
      Previously, if new inode is created as an encrypted one, f2fs will transfer
      encrypted filename to security module which may fail the check of security
      policy belong to the inode. So in order to this issue, alter to transfer
      original unencrypted filename instead.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      9421d570
    • Chao Yu's avatar
      f2fs: do in batch synchronously readahead during GC · 7ea984b0
      Chao Yu authored
      In order to enhance performance, we try to readahead node page during
      GC, but before loading node page we should get block address of node page
      which is stored in NAT table, so synchronously read of single NAT page
      block our readahead flow.
      
      f2fs_submit_page_bio: dev = (251,0), ino = 2, page_index = 0xa1e, oldaddr = 0xa1e, newaddr = 0xa1e, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x35e9, oldaddr = 0x72d7a, newaddr = 0x72d7a, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 2, page_index = 0xc1f, oldaddr = 0xc1f, newaddr = 0xc1f, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x389d, oldaddr = 0x72d7d, newaddr = 0x72d7d, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x3a82, oldaddr = 0x72d7f, newaddr = 0x72d7f, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x3bfa, oldaddr = 0x72d86, newaddr = 0x72d86, rw = READAHEAD ^H, type = NODE
      
      This patch adds one phase that do readahead NAT pages in batch before
      readahead node page for more effeciently.
      
      f2fs_submit_page_bio: dev = (251,0), ino = 2, page_index = 0x1952, oldaddr = 0x1952, newaddr = 0x1952, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc34, oldaddr = 0xc34, newaddr = 0xc34, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xa33, oldaddr = 0xa33, newaddr = 0xa33, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc30, oldaddr = 0xc30, newaddr = 0xc30, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc32, oldaddr = 0xc32, newaddr = 0xc32, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc26, oldaddr = 0xc26, newaddr = 0xc26, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xa2b, oldaddr = 0xa2b, newaddr = 0xa2b, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc23, oldaddr = 0xc23, newaddr = 0xc23, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc24, oldaddr = 0xc24, newaddr = 0xc24, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xa10, oldaddr = 0xa10, newaddr = 0xa10, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_mbio: dev = (251,0), ino = 2, page_index = 0xc2c, oldaddr = 0xc2c, newaddr = 0xc2c, rw = READ_SYNC(MP), type = META
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5db7, oldaddr = 0x6be00, newaddr = 0x6be00, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5db9, oldaddr = 0x6be17, newaddr = 0x6be17, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dbc, oldaddr = 0x6be1a, newaddr = 0x6be1a, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dc3, oldaddr = 0x6be20, newaddr = 0x6be20, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dc7, oldaddr = 0x6be24, newaddr = 0x6be24, rw = READAHEAD ^H, type = NODE
      f2fs_submit_page_bio: dev = (251,0), ino = 1, page_index = 0x5dc9, oldaddr = 0x6be25, newaddr = 0x6be25, rw = READAHEAD ^H, type = NODE
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7ea984b0
    • Chao Yu's avatar
      f2fs: schedule in between two continous batch discards · 74fa5f3d
      Chao Yu authored
      In batch discard approach of fstrim will grab/release gc_mutex lock
      repeatly, it makes contention of the lock becoming more intensive.
      
      So after one batch discards were issued in checkpoint and the lock
      was released, it's better to do schedule() to increase opportunity
      of grabbing gc_mutex lock for other competitors.
      Signed-off-by: default avatarChao Yu <yuchao0@huawei.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      74fa5f3d
  9. 30 Aug, 2016 2 commits