1. 07 Oct, 2014 1 commit
    • Jaegeuk Kim's avatar
      f2fs: support atomic writes · 88b88a66
      Jaegeuk Kim authored
      This patch introduces a very limited functionality for atomic write support.
      In order to support atomic write, this patch adds two ioctls:
       o F2FS_IOC_START_ATOMIC_WRITE
       o F2FS_IOC_COMMIT_ATOMIC_WRITE
      
      The database engine should be aware of the following sequence.
      1. open
       -> ioctl(F2FS_IOC_START_ATOMIC_WRITE);
      2. writes
        : all the written data will be treated as atomic pages.
      3. commit
       -> ioctl(F2FS_IOC_COMMIT_ATOMIC_WRITE);
        : this flushes all the data blocks to the disk, which will be shown all or
        nothing by f2fs recovery procedure.
      4. repeat to #2.
      
      The IO pattens should be:
      
        ,- START_ATOMIC_WRITE                  ,- COMMIT_ATOMIC_WRITE
       CP | D D D D D D | FSYNC | D D D D | FSYNC ...
                            `- COMMIT_ATOMIC_WRITE
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      88b88a66
  2. 06 Oct, 2014 1 commit
  3. 30 Sep, 2014 7 commits
  4. 23 Sep, 2014 15 commits
    • Jaegeuk Kim's avatar
      f2fs: use more free segments until SSR is activated · 95dd8973
      Jaegeuk Kim authored
      Previously, f2fs activates SSR if the # of free segments reaches to the # of
      overprovisioned segments.
      In this case, SSR starts to use dirty segments only, so that the overprovisoned
      space cannot be selected for new data.
      This means that we have no chance to utilizae the overprovisioned space at all.
      
      This patch fixes that by allowing LFS allocations until the # of free segments
      reaches to the last threshold, reserved space.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      95dd8973
    • Jaegeuk Kim's avatar
      f2fs: change the ipu_policy option to enable combinations · 9b5f136f
      Jaegeuk Kim authored
      This patch changes the ipu_policy setting to use any combination of orthogonal policies.
      Signed-off-by: default avatarChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      9b5f136f
    • Chao Yu's avatar
      f2fs: fix to search whole dirty segmap when get_victim · 210f41bc
      Chao Yu authored
      In ->get_victim we get max_search value from dirty_i->nr_dirty without
      protection of seglist_lock, after that, nr_dirty can be increased/decreased
      before we hold seglist_lock lock.
      Then in main loop we attempt to traverse all dirty section one time to find
      victim section, but it's not accurate to use max_search as the total loop count,
      because we might lose checking several sections or check sections redundantly
      for the case of nr_dirty are increased or decreased previously.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      210f41bc
    • Chao Yu's avatar
      f2fs: fix to clean previous mount option when remount_fs · 26666c8a
      Chao Yu authored
      In manual of mount, we descript remount as below:
      
      "mount -o remount,rw /dev/foo /dir
      After  this call all old mount options are replaced and arbitrary stuff from
      fstab is ignored, except the loop= option which is internally generated and
      maintained by the mount command."
      
      Previously f2fs do not clear up old mount options when remount_fs, so we have no
      chance of disabling previous option (e.g. flush_merge). Fix it.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      26666c8a
    • Chao Yu's avatar
      f2fs: skip punching hole in special condition · 14cecc5c
      Chao Yu authored
      Now punching hole in directory is not supported in f2fs, so let's limit file
      type in punch_hole().
      
      In addition, in punch_hole if offset is exceed file size, we should skip
      punching hole.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      14cecc5c
    • Chao Yu's avatar
      f2fs: support large sector size · 55cf9cb6
      Chao Yu authored
      Block size in f2fs is 4096 bytes, so theoretically, f2fs can support 4096 bytes
      sector device at maximum. But now f2fs only support 512 bytes size sector, so
      block device such as zRAM which uses page cache as its block storage space will
      not be mounted successfully as mismatch between sector size of zRAM and sector
      size of f2fs supported.
      
      In this patch we support large sector size in f2fs, so block device with sector
      size of 512/1024/2048/4096 bytes can be supported in f2fs.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      55cf9cb6
    • Chao Yu's avatar
      f2fs: fix to truncate blocks past EOF in ->setattr · 09db6a2e
      Chao Yu authored
      By using FALLOC_FL_KEEP_SIZE in ->fallocate of f2fs, we can fallocate block past
      EOF without changing i_size of inode. These blocks past EOF will not be
      truncated in ->setattr as we truncate them only when change the file size.
      
      We should give a chance to truncate blocks out of filesize in setattr().
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      09db6a2e
    • Jaegeuk Kim's avatar
      f2fs: update i_size when __allocate_data_block · 976e4c50
      Jaegeuk Kim authored
      The f2fs_direct_IO uses __allocate_data_block, but inside the allocation path,
      we should update i_size at the changed time to update its inode page.
      Otherwise, we can get wrong i_size after roll-forward recovery.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      976e4c50
    • Jaegeuk Kim's avatar
      f2fs: use MAX_BIO_BLOCKS(sbi) · 90a893c7
      Jaegeuk Kim authored
      This patch cleans up a simple macro.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      90a893c7
    • Jaegeuk Kim's avatar
      f2fs: remove redundant operation during roll-forward recovery · c52e1b10
      Jaegeuk Kim authored
      If same data is updated multiple times, we don't need to redo whole the
      operations.
      Let's just update the lastest one.
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      c52e1b10
    • Jaegeuk Kim's avatar
      f2fs: do not skip latest inode information · 19c9c466
      Jaegeuk Kim authored
      In f2fs_sync_file, if there is no written appended writes, it skips
      to write its node blocks.
      But, if there is up-to-date inode page, we should write it to update
      its metadata during the roll-forward recovery.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      19c9c466
    • Jaegeuk Kim's avatar
      f2fs: fix roll-forward missing scenarios · 441ac5cb
      Jaegeuk Kim authored
      We can summarize the roll forward recovery scenarios as follows.
      
      [Term] F: fsync_mark, D: dentry_mark
      
      1. inode(x) | CP | inode(x) | dnode(F)
      -> Update the latest inode(x).
      
      2. inode(x) | CP | inode(F) | dnode(F)
      -> No problem.
      
      3. inode(x) | CP | dnode(F) | inode(x)
      -> Recover to the latest dnode(F), and drop the last inode(x)
      
      4. inode(x) | CP | dnode(F) | inode(F)
      -> No problem.
      
      5. CP | inode(x) | dnode(F)
      -> The inode(DF) was missing. Should drop this dnode(F).
      
      6. CP | inode(DF) | dnode(F)
      -> No problem.
      
      7. CP | dnode(F) | inode(DF)
      -> If f2fs_iget fails, then goto next to find inode(DF).
      
      8. CP | dnode(F) | inode(x)
      -> If f2fs_iget fails, then goto next to find inode(DF).
         But it will fail due to no inode(DF).
      
      So, this patch adds some missing points such as #1, #5, #7, and #8.
      Signed-off-by: default avatarHuang Ying <ying.huang@intel.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      441ac5cb
    • Jaegeuk Kim's avatar
      f2fs: fix conditions to remain recovery information in f2fs_sync_file · 88bd02c9
      Jaegeuk Kim authored
      This patch revisited whole the recovery information during the f2fs_sync_file.
      
      In this patch, there are three information to make a decision.
      
      a) IS_CHECKPOINTED,	/* is it checkpointed before? */
      b) HAS_FSYNCED_INODE,	/* is the inode fsynced before? */
      c) HAS_LAST_FSYNC,	/* has the latest node fsync mark? */
      
      And, the scenarios for our rule are based on:
      
      [Term] F: fsync_mark, D: dentry_mark
      
      1. inode(x) | CP | inode(x) | dnode(F)
      2. inode(x) | CP | inode(F) | dnode(F)
      3. inode(x) | CP | dnode(F) | inode(x) | inode(F)
      4. inode(x) | CP | dnode(F) | inode(F)
      5. CP | inode(x) | dnode(F) | inode(DF)
      6. CP | inode(DF) | dnode(F)
      7. CP | dnode(F) | inode(DF)
      8. CP | dnode(F) | inode(x) | inode(DF)
      
      For example, #3, the three conditions should be changed as follows.
      
         inode(x) | CP | dnode(F) | inode(x) | inode(F)
      a)    x       o      o          o          o
      b)    x       x      x          x          o
      c)    x       o      o          x          o
      
      If f2fs_sync_file stops   ------^,
       it should write inode(F)    --------------^
      
      So, the need_inode_block_update should return true, since
       c) get_nat_flag(e, HAS_LAST_FSYNC), is false.
      
      For example, #8,
            CP | alloc | dnode(F) | inode(x) | inode(DF)
      a)    o      x        x          x          x
      b)    x               x          x          o
      c)    o               o          x          o
      
      If f2fs_sync_file stops   -------^,
       it should write inode(DF)    --------------^
      
      Note that, the roll-forward policy should follow this rule, which means,
      if there are any missing blocks, we doesn't need to recover that inode.
      Signed-off-by: default avatarHuang Ying <ying.huang@intel.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      88bd02c9
    • Jaegeuk Kim's avatar
      f2fs: introduce a flag to represent each nat entry information · 7ef35e3b
      Jaegeuk Kim authored
      This patch introduces a flag in the nat entry structure to merge various
      information such as checkpointed and fsync_done marks.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      7ef35e3b
    • Jaegeuk Kim's avatar
      f2fs: use meta_inode cache to improve roll-forward speed · 4c521f49
      Jaegeuk Kim authored
      Previously, all the dnode pages should be read during the roll-forward recovery.
      Even worsely, whole the chain was traversed twice.
      This patch removes that redundant and costly read operations by using page cache
      of meta_inode and readahead function as well.
      Reviewed-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      4c521f49
  5. 16 Sep, 2014 5 commits
  6. 11 Sep, 2014 1 commit
  7. 09 Sep, 2014 10 commits
    • Jaegeuk Kim's avatar
      f2fs: fix negative value for lseek offset · 0b4c5afd
      Jaegeuk Kim authored
      If application throws negative value of lseek with SEEK_DATA|SEEK_HOLE,
      previous f2fs went into BUG_ON in get_dnode_of_data, which was reported
      by Tommi Rantala.
      
      He could make a simple code to detect this having:
      	lseek(fd, -17595150933902LL, SEEK_DATA);
      
      This patch should resolve that bug.
      Reported-by: default avatarTommi Rentala <tt.rantala@gmail.com>
      [Jaegeuk Kim: relocate the condition as suggested by Chao]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      0b4c5afd
    • Huang Ying's avatar
      f2fs: avoid node page to be written twice in gc_node_segment · 9a01b56b
      Huang Ying authored
      In gc_node_segment, if node page gc is run concurrently with node page
      writeback, and check_valid_map and get_node_page run after page locked
      and before cur_valid_map is updated as below, it is possible for the
      page to be written twice unnecessarily.
      
      			sync_node_pages
      			  try_lock_page
      			  ...
      check_valid_map		  f2fs_write_node_page
      			    ...
      			    write_node_page
      			      do_write_page
      			        allocate_data_block
      				  ...
      				  refresh_sit_entry /* update cur_valid_map */
      				  ...
      			    ...
      			    unlock_page
      get_node_page
      ...
      set_page_dirty
      ...
      f2fs_put_page
        unlock_page
      
      This can be solved via calling check_valid_map after get_node_page again.
      Signed-off-by: default avatarHuang, Ying <ying.huang@intel.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      9a01b56b
    • Gu Zheng's avatar
      f2fs: use lock-less list(llist) to simplify the flush cmd management · 721bd4d5
      Gu Zheng authored
      We use flush cmd control to collect many flush cmds, and flush them
      together. In this case, we use two list to manage the flush cmds
      (collect and dispatch), and one spin lock is used to protect this.
      In fact, the lock-less list(llist) is very suitable to this case,
      and we use simplify this routine.
      
      -
      v2:
      -use llist_for_each_entry_safe to fix possible use-after-free issue.
      -remove the unused field from struct flush_cmd.
      Thanks for Yu's suggestion.
      -
      Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      721bd4d5
    • Chao Yu's avatar
      f2fs: refactor flush_sit_entries codes for reducing SIT writes · 184a5cd2
      Chao Yu authored
      In commit aec71382 ("f2fs: refactor flush_nat_entries codes for reducing NAT
      writes"), we descripte the issue as below:
      
      "Although building NAT journal in cursum reduce the read/write work for NAT
      block, but previous design leave us lower performance when write checkpoint
      frequently for these cases:
      1. if journal in cursum has already full, it's a bit of waste that we flush all
         nat entries to page for persistence, but not to cache any entries.
      2. if journal in cursum is not full, we fill nat entries to journal util
         journal is full, then flush the left dirty entries to disk without merge
         journaled entries, so these journaled entries may be flushed to disk at next
         checkpoint but lost chance to flushed last time."
      
      Actually, we have the same problem in using SIT journal area.
      
      In this patch, firstly we will update sit journal with dirty entries as many as
      possible. Secondly if there is no space in sit journal, we will remove all
      entries in journal and walk through the whole dirty entry bitmap of sit,
      accounting dirty sit entries located in same SIT block to sit entry set. All
      entry sets are linked to list sit_entry_set in sm_info, sorted ascending order
      by count of entries in set. Later we flush entries in set which have fewest
      entries into journal as many as we can, and then flush dense set with merged
      entries to disk.
      
      In this way we can use sit journal area more effectively, also we will reduce
      SIT update, result in gaining in performance and saving lifetime of flash
      device.
      
      In my testing environment, it shows this patch can help to reduce SIT block
      update obviously.
      
      virtual machine + hard disk:
      fsstress -p 20 -n 400 -l 5
      		sit page num	cp count	sit pages/cp
      based		2006.50		1349.75		1.486
      patched		1566.25		1463.25		1.070
      
      Our latency of merging op is small when handling a great number of dirty SIT
      entries in flush_sit_entries:
      latency(ns)	dirty sit count
      36038		2151
      49168		2123
      37174		2232
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      184a5cd2
    • Chao Yu's avatar
      f2fs: remove unneeded sit_i in macro SIT_BLOCK_OFFSET/START_SEGNO · d3a14afd
      Chao Yu authored
      sit_i in macro SIT_BLOCK_OFFSET/START_SEGNO is not used, remove it.
      Signed-off-by: default avatarChao Yu <chao2.yu@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      d3a14afd
    • Jaegeuk Kim's avatar
      f2fs: need fsck.f2fs if the recovery was failed · b0c44f05
      Jaegeuk Kim authored
      If the roll-forward recovery was failed, we'd better conduct fsck.f2fs.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      b0c44f05
    • Jaegeuk Kim's avatar
      f2fs: handle bug cases by letting fsck.f2fs initiate · ec325b52
      Jaegeuk Kim authored
      This patch adds to handle corner buggy cases for fsck.f2fs.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      ec325b52
    • Jaegeuk Kim's avatar
      f2fs: add BUG cases to initiate fsck.f2fs · 05796763
      Jaegeuk Kim authored
      This patch replaces BUG cases with f2fs_bug_on to remain fsck.f2fs information.
      And it implements some void functions to initiate fsck.f2fs too.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      05796763
    • Jaegeuk Kim's avatar
      f2fs: need fsck.f2fs when f2fs_bug_on is triggered · 9850cf4a
      Jaegeuk Kim authored
      If any f2fs_bug_on is triggered, fsck.f2fs is needed.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      9850cf4a
    • Jaegeuk Kim's avatar
      f2fs: retain inconsistency information to initiate fsck.f2fs · 2ae4c673
      Jaegeuk Kim authored
      This patch adds sbi->need_fsck to conduct fsck.f2fs later.
      This flag can only be removed by fsck.f2fs.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk@kernel.org>
      2ae4c673