1. 01 Jul, 2013 3 commits
    • Namjae Jeon's avatar
      f2fs: optimize the init_dirty_segmap function · 8736fbf0
      Namjae Jeon authored
      Optimize the while loop condition
      
      Since this condition will always be true and while loop will
      be terminated by the following condition in code:
      
      if (segno >= TOTAL_SEGS(sbi))
          break;
      Hence we can replace the while loop condition with while(1)
      instead of always checking for segno to be less than Total segs.
      
      Also we do not need to use TOTAL_SEGS() everytime. We can store
      this value in a local variable since this value is constant.
      Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: default avatarPankaj Kumar <pankaj.km@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      8736fbf0
    • Jaegeuk Kim's avatar
      f2fs: fix an endian conversion bug detected by sparse · 060dd67b
      Jaegeuk Kim authored
      This patch should fix the following bug reported by kbuild test robot.
      
      fs/f2fs/recovery.c:233:33: sparse: incorrect type in assignment
      (different base types)
      
      parse warnings: (new ones prefixed by >>)
      
      >> recovery.c:233: sparse: incorrect type in assignment (different base types)
         recovery.c:233:    expected unsigned int [unsigned] [assigned] ofs_in_node
         recovery.c:233:    got restricted __le16 [assigned] [usertype] ofs_in_node
      >> recovery.c:238: sparse: incorrect type in assignment (different base types)
         recovery.c:238:    expected unsigned int [unsigned] ofs_in_node
         recovery.c:238:    got restricted __le16 [assigned] [usertype] ofs_in_node
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      060dd67b
    • Jaegeuk Kim's avatar
      f2fs: fix crc endian conversion · 7e586fa0
      Jaegeuk Kim authored
      While calculating CRC for the checkpoint block, we use __u32, but when storing
      the crc value to the disk, we use __le32.
      
      Let's fix the inconsistency.
      Reported-and-Tested-by: default avatarOded Gabbay <ogabbay@advaoptical.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      7e586fa0
  2. 17 Jun, 2013 1 commit
    • Namjae Jeon's avatar
      f2fs: add remount_fs callback support · 696c018c
      Namjae Jeon authored
      Add the f2fs_remount function call which will be used
      during the filesystem remounting. This function
      will help us to change the mount options specific to
      f2fs.
      
      Also modify the f2fs background_gc mount option, which
      will allow the user to dynamically trun on/off the
      garbage collection in f2fs based on the background_gc
      value. If background_gc=on, Garbage collection will
      be turned off & if background_gc=off, Garbage collection
      will be truned on.
      
      By default the garbage collection is on in f2fs.
      
      Change Log:
      v2: Incorporated the review comments by Gu Zheng.
          Removing the restore part for VFS flags
          Updating comments with proper flag conditions
          Display GC background option as ON/OFF
          Revised conditions to stop GC in case of remount
      
      v1: Initial changes for adding remount_fs callback
      support.
      
      Cc: Gu Zheng <guz.fnst@cn.fujitsu.com>
      Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: default avatarPankaj Kumar <pankaj.km@samsung.com>
      Reviewed-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
      [Jaegeuk Kim: change /** with /* for the coding style]
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      696c018c
  3. 14 Jun, 2013 7 commits
  4. 11 Jun, 2013 4 commits
    • Jaegeuk Kim's avatar
      f2fs: sync dir->i_size with its block allocation · 699489bb
      Jaegeuk Kim authored
      If new dentry block is allocated and its i_size is updated, we should update
      its inode block together in order to sync i_size and its block allocation.
      Otherwise, we can loose additional dentry block due to the unconsistent i_size.
      
      Errorneous Scenario
      -------------------
      
      In the recovery routine,
       - recovery_dentry
       | - __f2fs_add_link
       | | - get_new_data_page
       | | | - i_size_write(new_i_size)
       | | | - mark_inode_dirty_sync(dir)
       | | - update_parent_metadata
       | | | - mark_inode_dirty(dir)
       |
       - write_checkpoint
         - sync_dirty_dir_inodes
           - filemap_flush(dentry_blocks)
             - f2fs_write_data_page
               - skip to write the last dentry block due to index < i_size
      
      In the above flow, new_i_size is not updated to its inode block so that the
      last dentry block will be lost accordingly.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      699489bb
    • Jaegeuk Kim's avatar
      f2fs: fix i_blocks translation on various types of files · 2d4d9fb5
      Jaegeuk Kim authored
      Basically an inode manages the number of allocated blocks with inode->i_blocks
      which is represented in a unit of sectors, not file system blocks.
      But, f2fs has used i_blocks in a unit of file system blocks, and f2fs_getattr
      translates it to the number of sectors when fstat is called.
      
      However, previously f2fs_file_inode_operations only has this, so this patch adds
      it to all the types of inode_operations.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      2d4d9fb5
    • Gu Zheng's avatar
      f2fs: set sb->s_fs_info before calling parse_options() · 5fb08372
      Gu Zheng authored
      In f2fs_fill_super(), set sb->s_fs_info before calling parse_options(), then we can get
      f2fs_sb_info via F2FS_SB(sb) in parse_options().
      So that the second argument "sbi" of func parse_options() is no longer needed.
      Signed-off-by: default avatarGu Zheng <guz.fnst@cn.fujitsu.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      5fb08372
    • Jaegeuk Kim's avatar
      f2fs: support xattr security labels · 8ae8f162
      Jaegeuk Kim authored
      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: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      8ae8f162
  5. 07 Jun, 2013 1 commit
    • Jaegeuk Kim's avatar
      f2fs: fix iget/iput of dir during recovery · 5deb8267
      Jaegeuk Kim authored
      It is possible that iput is skipped after iget during the recovery.
      
      In recover_dentry(),
       dir = f2fs_iget();
       ...
       if (de && inode->i_ino == le32_to_cpu(de->ino))
      	goto out;
      
      In this case, this dir is not able to be added in dirty_dir_inode_list.
      The actual linking is done only when set_page_dirty() is called.
      
      So let's add this newly got inode into the list explicitly, and put it at the
      end of the recovery routine.
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      5deb8267
  6. 06 Jun, 2013 1 commit
    • Namjae Jeon's avatar
      f2fs: reorganise the function get_victim_by_default · b2b3460a
      Namjae Jeon authored
      Fix the function get_victim_by_default, where it checks
      for the condition  that p.min_segno != NULL_SEGNO as
      shown:
      
      if (p.min_segno != NULL_SEGNO)
                 goto got_it;
      
      and if above condition is true then
      
      got_it:
              if (p.min_segno != NULL_SEGNO) {
      
      So this condition is being checked twice. Hence move the goto
      statement after the if condition so that duplication of condition
      check is avoided.
      
      Also this function makes a call to get_max_cost() to compute
      the max cost based on the f2fs_sbi_info and victim policy. Since
      get_max_cost depends on on three parameters of victim_sel_policy
      => alloc_mode, gc_mode & ofs_unit, once this victim policy is
      initialised, these value will not change till the execution
      time of get_victim_by_default() & also f2fs_sbi_info structure
      parameters will not change.
      
      Hence making calls to get_max_cost() in while loop does not seems to
      be a good point. Instead we can call it once in begining and store
      the results in local variable, which later can serve our purpose
      for comparing the cost with max cost inside the while loop.
      Signed-off-by: default avatarNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: default avatarPankaj Kumar <pankaj.km@samsung.com>
      Signed-off-by: default avatarJaegeuk Kim <jaegeuk.kim@samsung.com>
      b2b3460a
  7. 03 Jun, 2013 1 commit
  8. 28 May, 2013 22 commits