1. 04 Aug, 2015 2 commits
  2. 25 Jul, 2015 1 commit
    • Jaegeuk Kim's avatar
      f2fs: call set_page_dirty to attach i_wb for cgroup · 6282adbf
      Jaegeuk Kim authored
      The cgroup attaches inode->i_wb via mark_inode_dirty and when set_page_writeback
      is called, __inc_wb_stat() updates i_wb's stat.
      
      So, we need to explicitly call set_page_dirty->__mark_inode_dirty in prior to
      any writebacking pages.
      
      This patch should resolve the following kernel panic reported by Andreas Reis.
      
      https://bugzilla.kernel.org/show_bug.cgi?id=101801
      
      --- Comment #2 from Andreas Reis <andreas.reis@gmail.com> ---
      BUG: unable to handle kernel NULL pointer dereference at 00000000000000a8
      IP: [<ffffffff8149deea>] __percpu_counter_add+0x1a/0x90
      PGD 2951ff067 PUD 2df43f067 PMD 0
      Oops: 0000 [#1] PREEMPT SMP
      Modules linked in:
      CPU: 7 PID: 10356 Comm: gcc Tainted: G        W       4.2.0-1-cu #1
      
      
      Hardware name: Gigabyte Technology Co., Ltd. G1.Sniper M5/G1.Sniper M5, BIOS
      T01 02/03/2015
      task: ffff880295044f80 ti: ffff880295140000 task.ti: ffff880295140000
      RIP: 0010:[<ffffffff8149deea>]  [<ffffffff8149deea>]
      __percpu_counter_add+0x1a/0x90
      RSP: 0018:ffff880295143ac8  EFLAGS: 00010082
      RAX: 0000000000000003 RBX: ffffea000a526d40 RCX: 0000000000000001
      RDX: 0000000000000020 RSI: 0000000000000001 RDI: 0000000000000088
      RBP: ffff880295143ae8 R08: 0000000000000000 R09: ffff88008f69bb30
      R10: 00000000fffffffa R11: 0000000000000000 R12: 0000000000000088
      R13: 0000000000000001 R14: ffff88041d099000 R15: ffff880084a205d0
      FS:  00007f8549374700(0000) GS:ffff88042f3c0000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 00000000000000a8 CR3: 000000033e1d5000 CR4: 00000000001406e0
      DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      Stack:
       0000000000000000 ffffea000a526d40 ffff880084a20738 ffff880084a20750
       ffff880295143b48 ffffffff811cc91e ffff880000000000 0000000000000296
       0000000000000000 ffff880417090198 0000000000000000 ffffea000a526d40
      Call Trace:
       [<ffffffff811cc91e>] __test_set_page_writeback+0xde/0x1d0
       [<ffffffff813fee87>] do_write_data_page+0xe7/0x3a0
       [<ffffffff813faeea>] gc_data_segment+0x5aa/0x640
       [<ffffffff813fb0b8>] do_garbage_collect+0x138/0x150
       [<ffffffff813fb3fe>] f2fs_gc+0x1be/0x3e0
       [<ffffffff81405541>] f2fs_balance_fs+0x81/0x90
       [<ffffffff813ee357>] f2fs_unlink+0x47/0x1d0
       [<ffffffff81239329>] vfs_unlink+0x109/0x1b0
       [<ffffffff8123e3d7>] do_unlinkat+0x287/0x2c0
       [<ffffffff8123ebc6>] SyS_unlink+0x16/0x20
       [<ffffffff81942e2e>] entry_SYSCALL_64_fastpath+0x12/0x71
      Code: 41 5e 5d c3 0f 1f 00 66 2e 0f 1f 84 00 00 00 00 00 55 48 89 e5 41 55 49
      89 f5 41 54 49 89 fc 53 48 83 ec 08 65 ff 05 e6 d9 b6 7e <48> 8b 47 20 48 63 ca
      65 8b 18 48 63 db 48 01 f3 48 39 cb 7d 0a
      RIP  [<ffffffff8149deea>] __percpu_counter_add+0x1a/0x90
       RSP <ffff880295143ac8>
      CR2: 00000000000000a8
      ---[ end trace 5132449a58ed93a3 ]---
      note: gcc[10356] exited with preempt_count 2
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      6282adbf
  3. 12 Jun, 2015 1 commit
    • Chao Yu's avatar
      f2fs: do not trim preallocated blocks when truncating after i_size · 3c454145
      Chao Yu authored
      
      
      When we perform generic/092 in xfstests, output is like below:
      
           XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
           0: [0..10239]: data
           0: [0..10239]: data
          -1: [10240..20479]: unwritten
          +1: [10240..14335]: unwritten
      
      This is because with this testcase, we redefine the regulation for
      truncate in perallocated space past i_size as below:
      
      "There was some confused about what the fs was supposed to do when you
      truncate at i_size with preallocated space past i_size. We decided on the
      following things.
      
      1) truncate(i_size) will trim all blocks past i_size.
      2) truncate(x) where x > i_size will not trim all blocks past i_size.
      "
      
      This method is used in xfs, and then ext4/btrfs will follow the rule.
      
      This patch fixes to follow the new rule for f2fs.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      3c454145
  4. 09 Jun, 2015 1 commit
  5. 08 Jun, 2015 1 commit
  6. 02 Jun, 2015 2 commits
    • Chao Yu's avatar
      f2fs: support FALLOC_FL_INSERT_RANGE · f62185d0
      Chao Yu authored
      FALLOC_FL_INSERT_RANGE flag for ->fallocate was introduced in commit
      dd46c787
      
       ("fs: Add support FALLOC_FL_INSERT_RANGE for fallocate").
      
      The effect of FALLOC_FL_INSERT_RANGE command is the opposite of
      FALLOC_FL_COLLAPSE_RANGE, if this command was performed, all data from
      offset to EOF in our file will be shifted to right as given length, and
      then range [offset, offset + length] becomes a hole.
      
      This command is useful for our user who wants to add some data in the
      middle of the file, for example: video/music editor will insert a keyframe
      in specified position of media file, with this command we can easily create
      a hole for inserting without removing original data.
      
      This patch introduces f2fs_insert_range() to support FALLOC_FL_INSERT_RANGE.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarYuan Zhong <yuan.mark.zhong@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      f62185d0
    • Chao Yu's avatar
      f2fs: hide common code in f2fs_replace_block · 528e3459
      Chao Yu authored
      
      
      This patch clean up codes through:
      1.rename f2fs_replace_block to __f2fs_replace_block().
      2.introduce new f2fs_replace_block() to include __f2fs_replace_block()
      and some common related codes around __f2fs_replace_block().
      
      Then, newly introduced function f2fs_replace_block can be used by
      following patch.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      528e3459
  7. 01 Jun, 2015 1 commit
  8. 28 May, 2015 9 commits
    • Jaegeuk Kim's avatar
      f2fs crypto: add filename encryption for roll-forward recovery · e7d55452
      Jaegeuk Kim authored
      
      
      This patch adds a bit flag to indicate whether or not i_name in the inode
      is encrypted.
      
      If this name is encrypted, we can't do recover_dentry during roll-forward.
      So, f2fs_sync_file() needs to do checkpoint, if this will be needed in future.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      e7d55452
    • Jaegeuk Kim's avatar
      f2fs crypto: add encryption support in read/write paths · 4375a336
      Jaegeuk Kim authored
      
      
      This patch adds encryption support in read and write paths.
      
      Note that, in f2fs, we need to consider cleaning operation.
      In cleaning procedure, we must avoid encrypting and decrypting written blocks.
      So, this patch implements move_encrypted_block().
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      4375a336
    • Jaegeuk Kim's avatar
      f2fs crypto: activate encryption support for fs APIs · fcc85a4d
      Jaegeuk Kim authored
      
      
      This patch activates the following APIs for encryption support.
      
      The rules quoted by ext4 are:
       - An unencrypted directory may contain encrypted or unencrypted files
         or directories.
       - All files or directories in a directory must be protected using the
         same key as their containing directory.
       - Encrypted inode for regular file should not have inline_data.
       - Encrypted symlink and directory may have inline_data and inline_dentry.
      
      This patch activates the following APIs.
      1. f2fs_link              : validate context
      2. f2fs_lookup            :      ''
      3. f2fs_rename            :      ''
      4. f2fs_create/f2fs_mkdir : inherit its dir's context
      5. f2fs_direct_IO         : do buffered io for regular files
      6. f2fs_open              : check encryption info
      7. f2fs_file_mmap         :      ''
      8. f2fs_setattr           :      ''
      9. f2fs_file_write_iter   :      ''           (Called by sys_io_submit)
      10. f2fs_fallocate        : do not support fcollapse
      11. f2fs_evict_inode      : free_encryption_info
      Signed-off-by: default avatarMichael Halcrow <mhalcrow@google.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      fcc85a4d
    • Jaegeuk Kim's avatar
      f2fs crypto: add encryption policy and password salt support · f424f664
      Jaegeuk Kim authored
      
      
      This patch adds encryption policy and password salt support through ioctl
      implementation.
      
      It adds three ioctls:
       F2FS_IOC_SET_ENCRYPTION_POLICY,
       F2FS_IOC_GET_ENCRYPTION_POLICY,
       F2FS_IOC_GET_ENCRYPTION_PWSALT, which use xattr operations.
      
      Note that, these definition and codes are taken from ext4 crypto support.
      For f2fs, xattr operations and on-disk flags for superblock and inode were
      changed.
      Signed-off-by: default avatarMichael Halcrow <mhalcrow@google.com>
      Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
      Signed-off-by: default avatarIldar Muslukhov <muslukhovi@gmail.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      f424f664
    • Chao Yu's avatar
      f2fs: support FALLOC_FL_ZERO_RANGE · 75cd4e09
      Chao Yu authored
      
      
      Now, FALLOC_FL_ZERO_RANGE flag in ->fallocate is supported in ext4/xfs.
      
      In commit, the semantics of this flag is descripted as following:"
      1) Make sure that both offset and len are block size aligned.
      2) Update the i_size of inode by len bytes.
      3) Compute the file's logical block number against offset. If the computed
         block number is not the starting block of the extent, split the extent
         such that the block number is the starting block of the extent.
      4) Shift all the extents which are lying between
         [offset, last allocated extent] towards right by len bytes. This step
         will make a hole of len bytes at offset."
      
      This patch implements fallocate's FALLOC_FL_ZERO_RANGE for f2fs.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      75cd4e09
    • Chao Yu's avatar
      f2fs: support FALLOC_FL_COLLAPSE_RANGE · b4ace337
      Chao Yu authored
      
      
      Now, FALLOC_FL_COLLAPSE_RANGE flag in ->fallocate is supported in ext4/xfs.
      
      In commit, the semantics of this flag is descripted as following:"
      1) It collapses the range lying between offset and length by removing any
         data blocks which are present in this range and than updates all the
         logical offsets of extents beyond "offset + len" to nullify the hole
         created by removing blocks. In short, it does not leave a hole.
      2) It should be used exclusively. No other fallocate flag in combination.
      3) Offset and length supplied to fallocate should be fs block size aligned
         in case of xfs and ext4.
      4) Collaspe range does not work beyond i_size."
      
      This patch implements fallocate's FALLOC_FL_COLLAPSE_RANGE for f2fs.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b4ace337
    • Jaegeuk Kim's avatar
      f2fs: split find_data_page according to specific purposes · 43f3eae1
      Jaegeuk Kim authored
      
      
      This patch splits find_data_page as follows.
      
      1. f2fs_gc
       - use get_read_data_page() with read only
      
      2. find_in_level
       - use find_data_page without locked page
      
      3. truncate_partial_page
       - In the case cache_only mode, just drop cached page.
       - Ohterwise, use get_lock_data_page() and guarantee to truncate
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      43f3eae1
    • Jaegeuk Kim's avatar
      f2fs: add sbi and page pointer in f2fs_io_info · 05ca3632
      Jaegeuk Kim authored
      
      
      This patch adds f2fs_sb_info and page pointers in f2fs_io_info structure.
      With this change, we can reduce a lot of parameters for IO functions.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      05ca3632
    • Jaegeuk Kim's avatar
      f2fs: add f2fs_may_inline_{data, dentry} · 01b960e9
      Jaegeuk Kim authored
      
      
      This patch adds f2fs_may_inline_data and f2fs_may_inline_dentry.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      01b960e9
  9. 07 May, 2015 1 commit
  10. 15 Apr, 2015 1 commit
  11. 12 Apr, 2015 1 commit
  12. 10 Apr, 2015 5 commits
    • Chao Yu's avatar
      f2fs: split set_data_blkaddr from f2fs_update_extent_cache · 216a620a
      Chao Yu authored
      
      
      Split __set_data_blkaddr from f2fs_update_extent_cache for readability.
      
      Additionally rename __set_data_blkaddr to set_data_blkaddr for exporting.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      216a620a
    • Jaegeuk Kim's avatar
      f2fs: avoid punch_hole overhead when releasing volatile data · 3c6c2beb
      Jaegeuk Kim authored
      
      
      This patch is to avoid some punch_hole overhead when releasing volatile data.
      If volatile data was not written yet, we just can make the first page as zero.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      3c6c2beb
    • Chao Yu's avatar
      f2fs: fix to truncate inline data past EOF · 0bfcfcca
      Chao Yu authored
      
      
      Previously if inode is with inline data, we will try to invalid partial inline
      data in page #0 when we truncate size of inode in truncate_partial_data_page().
      And then we set page #0 to dirty, after this we can synchronize inode page with
      page #0 at ->writepage().
      
      But sometimes we will fail to operate page #0 in truncate_partial_data_page()
      due to below reason:
      a) if offset is zero, we will skip setting page #0 to dirty.
      b) if page #0 is not uptodate, we will fail to update it as it has no mapping
      data.
      
      So with following operations, we will meet recent data which should be
      truncated.
      
      1.write inline data to file
      2.sync first data page to inode page
      3.truncate file size to 0
      4.truncate file size to max_inline_size
      5.echo 1 > /proc/sys/vm/drop_caches
      6.read file --> meet original inline data which is remained in inode page.
      
      This patch renames truncate_inline_data() to truncate_inline_inode() for code
      readability, then use truncate_inline_inode() to truncate inline data in inode
      page in truncate_blocks() and truncate page #0 in truncate_partial_data_page()
      for fixing.
      
      v2:
       o truncate partially #0 page in truncate_partial_data_page to avoid keeping
         old data in #0 page.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0bfcfcca
    • Jaegeuk Kim's avatar
      f2fs: clear append/update flags once fsync is done · cff28521
      Jaegeuk Kim authored
      
      
      When fsync is done through checkpoint, previous f2fs missed to clear append
      and update flag. This patch fixes to clear them.
      
      This was originally catched by Changman Lee before.
      Signed-off-by: default avatarChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      cff28521
    • Jaegeuk Kim's avatar
      f2fs: support fs shutdown · 1abff93d
      Jaegeuk Kim authored
      
      
      This patch introduces a generic ioctl for fs shutdown, which was used by xfs.
      
      If this shutdown is triggered, filesystem stops any further IOs according to the
      following options.
      
      1. FS_GOING_DOWN_FULLSYNC
       : this will flush all the data and dentry blocks, and do checkpoint before
         shutdown.
      
      2. FS_GOING_DOWN_METASYNC
       : this will do checkpoint before shutdown.
      
      3. FS_GOING_DOWN_NOSYNC
       : this will trigger shutdown as is.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      1abff93d
  13. 03 Mar, 2015 1 commit
    • Chao Yu's avatar
      f2fs: introduce universal lookup/update interface for extent cache · 7e4dde79
      Chao Yu authored
      
      
      In this patch, we do these jobs:
      1. rename {check,update}_extent_cache to {lookup,update}_extent_info;
      2. introduce universal lookup/update interface of extent cache:
      f2fs_{lookup,update}_extent_cache including above two real functions, then
      export them to function callers.
      
      So after above cleanup, we can add new rb-tree based extent cache into exported
      interfaces.
      
      v2:
       o remove "f2fs_" for inner function {lookup,update}_extent_info suggested by
         Jaegeuk Kim.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7e4dde79
  14. 12 Feb, 2015 4 commits
    • Jaegeuk Kim's avatar
      f2fs: introduce macros to convert bytes and blocks in f2fs · f7ef9b83
      Jaegeuk Kim authored
      
      
      This patch adds two macros for transition between byte and block offsets.
      Currently, f2fs only supports 4KB blocks, so use the default size for now.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      f7ef9b83
    • Chao Yu's avatar
      f2fs: avoid data offset overflow when lseeking huge file · 2e023174
      Chao Yu authored
      
      
      xfstest generic/285 complains our issue in lseeking huge file.
      
      Here is the detail output of generic/285:
      "./check -f2fs tests/generic/285
      Ran: generic/285
      Failures: generic/285
      Failed 1 of 1 tests
      
      10. Test a huge file for offset overflow
      10.01 SEEK_HOLE expected 65536 or 8589934592, got 65536.          succ
      10.02 SEEK_HOLE expected 65536 or 8589934592, got 65536.          succ
      10.03 SEEK_DATA expected 0 or 0, got 0.                           succ
      10.04 SEEK_DATA expected 1 or 1, got 1.                           succ
      10.05 SEEK_HOLE expected 8589934592 or 8589934592, got 0.         FAIL
      10.06 SEEK_DATA expected 8589869056 or 8589869056, got 8589869056. succ
      10.07 SEEK_DATA expected 8589869057 or 8589869057, got 8589869057. succ
      10.08 SEEK_DATA expected 8589869056 or 8589869056, got 4294901760. FAIL"
      
      The reason of this issue is:
      We will calculate current offset through left shifting page-offset with
      PAGE_CACHE_SHIFT bits, but our page-offset is a type of unsigned long, its size
      is 4 bytes in 32-bits machine.
      
      So if our page-offset is bigger than (1 << 32 / pagesize - 1), result of left
      shifting will overflow.
      
      Let's fix this issue by casting type of page-offset to type of current offset:
      loff_t.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2e023174
    • Chao Yu's avatar
      f2fs: add F2FS_IOC_GETVERSION support · d49f3e89
      Chao Yu authored
      
      
      In this patch we add the FS_IOC_GETVERSION ioctl for getting i_generation from
      inode, after that, users can list file's generation number by using "lsattr -v".
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      d49f3e89
    • Jaegeuk Kim's avatar
      f2fs: avoid infinite loop on cp_error · 871f599f
      Jaegeuk Kim authored
      
      
      If cp_error is set, we should avoid all the infinite loop.
      In f2fs_sync_file, there is a hole, and this patch fixes that.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      871f599f
  15. 10 Feb, 2015 1 commit
  16. 10 Jan, 2015 3 commits
  17. 08 Dec, 2014 3 commits
  18. 01 Dec, 2014 1 commit
  19. 11 Nov, 2014 1 commit
    • Jaegeuk Kim's avatar
      f2fs: convert inline_data when i_size becomes large · 92dffd01
      Jaegeuk Kim authored
      
      
      If i_size becomes large outside of MAX_INLINE_DATA, we shoud convert the inode.
      Otherwise, we can make some dirty pages during the truncation, and those pages
      will be written through f2fs_write_data_page.
      At that moment, the inode has still inline_data, so that it tries to write non-
      zero pages into inline_data area.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      92dffd01