1. 20 3月, 2013 1 次提交
  2. 12 2月, 2013 3 次提交
    • J
      f2fs: avoid balanc_fs during evict_inode · d4686d56
      Jaegeuk Kim 提交于
      1. Background
      
      Previously, if f2fs tries to move data blocks of an *evicting* inode during the
      cleaning process, it stops the process incompletely and then restarts the whole
      process, since it needs a locked inode to grab victim data pages in its address
      space. In order to get a locked inode, iget_locked() by f2fs_iget() is normally
      used, but, it waits if the inode is on freeing.
      
      So, here is a deadlock scenario.
      1. f2fs_evict_inode()       <- inode "A"
        2. f2fs_balance_fs()
          3. f2fs_gc()
            4. gc_data_segment()
              5. f2fs_iget()      <- inode "A" too!
      
      If step #1 and #5 treat a same inode "A", step #5 would fall into deadlock since
      the inode "A" is on freeing. In order to resolve this, f2fs_iget_nowait() which
      skips __wait_on_freeing_inode() was introduced in step #5, and stops f2fs_gc()
      to complete f2fs_evict_inode().
      
      1. f2fs_evict_inode()           <- inode "A"
        2. f2fs_balance_fs()
          3. f2fs_gc()
            4. gc_data_segment()
              5. f2fs_iget_nowait()   <- inode "A", then stop f2fs_gc() w/ -ENOENT
      
      2. Problem and Solution
      
      In the above scenario, however, f2fs cannot finish f2fs_evict_inode() only if:
       o there are not enough free sections, and
       o f2fs_gc() tries to move data blocks of the *evicting* inode repeatedly.
      
      So, the final solution is to use f2fs_iget() and remove f2fs_balance_fs() in
      f2fs_evict_inode().
      The f2fs_evict_inode() actually truncates all the data and node blocks, which
      means that it doesn't produce any dirty node pages accordingly.
      So, we don't need to do f2fs_balance_fs() in practical.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      d4686d56
    • C
      f2fs: add un/freeze_fs into super_operations · d6212a5f
      Changman Lee 提交于
      This patch supports ioctl FIFREEZE and FITHAW to snapshot filesystem.
      Before calling f2fs_freeze, all writers would be suspended and sync_fs
      would be completed. So no f2fs has to do something.
      Just background gc operation should be skipped due to generate dirty
      nodes and data until unfreeze.
      Signed-off-by: NChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      d6212a5f
    • C
      f2fs: save device node number into f2fs_inode · 7d79e75f
      Changman Lee 提交于
      This patch stores inode->i_rdev into on-disk inode structure.
      
      Alun reported that:
       aspire tmp # mount -t f2fs /dev/sdb mnt
       aspire tmp # mknod mnt/sda1 b 8 1
       aspire tmp # mknod mnt/null c 1 3
       aspire tmp # mknod mnt/console c 5 1
       aspire tmp # ls -l mnt
       total 2
       crw-r--r-- 1 root root 5, 1 Jan 22 18:44 console
       crw-r--r-- 1 root root 1, 3 Jan 22 18:44 null
       brw-r--r-- 1 root root 8, 1 Jan 22 18:44 sda1
       aspire tmp # umount mnt
       aspire tmp # mount -t f2fs /dev/sdb mnt
       aspire tmp # ls -l mnt
       total 2
       crw-r--r-- 1 root root 0, 0 Jan 22 18:44 console
       crw-r--r-- 1 root root 0, 0 Jan 22 18:44 null
       brw-r--r-- 1 root root 0, 0 Jan 22 18:44 sda1
      
      In this report, f2fs lost the major/minor numbers of device files after umount.
      The reason was revealed that f2fs does not store the inode->i_rdev to the
      on-disk inode data structure.
      
      So, as the other file systems do, f2fs also stores i_rdev into the i_addr fields
      in on-disk inode structure without any on-disk layout changes.
      Note that, this bug is limited to device files made by mknod().
      Reported-and-Tested-by: NAlun Jones <alun.linux@ty-penguin.org.uk>
      Signed-off-by: NChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      7d79e75f
  3. 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
  4. 26 12月, 2012 1 次提交
    • J
      f2fs: fix handling errors got by f2fs_write_inode · 398b1ac5
      Jaegeuk Kim 提交于
      Ruslan reported that f2fs hangs with an infinite loop in f2fs_sync_file():
      
      	while (sync_node_pages(sbi, inode->i_ino, &wbc) == 0)
      		f2fs_write_inode(inode, NULL);
      
      The reason was revealed that the cold flag is not set even thought this inode is
      a normal file. Therefore, sync_node_pages() skips to write node blocks since it
      only writes cold node blocks.
      
      The cold flag is stored to the node_footer in node block, and whenever a new
      node page is allocated, it is set according to its file type, file or directory.
      
      But, after sudden-power-off, when recovering the inode page, f2fs doesn't recover
      its cold flag.
      
      So, let's assign the cold flag in more right places.
      
      One more thing:
      If f2fs_write_inode() returns an error due to whatever situations, there would
      be no dirty node pages so that sync_node_pages() returns zero.
      (i.e., zero means nothing was written.)
      Reported-by: NRuslan N. Marchenko <me@ruff.mobi>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      398b1ac5
  5. 11 12月, 2012 3 次提交
    • J
      f2fs: fix tracking parent inode number · 6666e6aa
      Jaegeuk Kim 提交于
      Previously, f2fs didn't track the parent inode number correctly which is stored
      in each f2fs_inode. In the case of the following scenario, a bug can be occured.
      
      Let's suppose there are one directory, "/b", and two files, "/a" and "/b/a".
       - pino of "/a" is ROOT_INO.
       - pino of "/b/a" is DIR_B_INO.
      
      Then,
       # sync
        : The inode pages of "/a" and "/b/a" contain the parent inode numbers as
          ROOT_INO and DIR_B_INO respectively.
       # mv /a /b/a
        : The parent inode number of "/a" should be changed to DIR_B_INO, but f2fs
          didn't do that. Ref. f2fs_set_link().
      
      In order to fix this clearly, I added i_pino in f2fs_inode_info, and whenever
      it needs to be changed like in f2fs_add_link() and f2fs_set_link(), it is
      updated temporarily in f2fs_inode_info.
      
      And later, f2fs_write_inode() stores the latest information to the inode pages.
      For power-off-recovery, f2fs_sync_file() triggers simply f2fs_write_inode().
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      6666e6aa
    • 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 core inode operations · 19f99cee
      Jaegeuk Kim 提交于
      This adds core functions to get, read, write, and evict an inode.
      Signed-off-by: NChangman Lee <cm224.lee@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      19f99cee