1. 30 4月, 2013 2 次提交
    • J
      f2fs: modify the number of issued pages to merge IOs · ac5d156c
      Jaegeuk Kim 提交于
      When testing f2fs on an SSD, I found some 128 page IOs followed by 1 page IO
      were issued by f2fs_write_node_pages.
      This means that there were some mishandling flows which degrades performance.
      
      Previous f2fs_write_node_pages determines the number of pages to be written,
      nr_to_write, as follows.
      
      1. The bio_get_nr_vecs returns 129 pages.
      2. The bio_alloc makes a room for 128 pages.
      3. The initial 128 pages go into one bio.
      4. The existing bio is submitted, and a new bio is prepared for the last 1 page.
      5. Finally, sync_node_pages submits the last 1 page bio.
      
      The problem is from the use of bio_get_nr_vecs, so this patch replace it
      with max_hw_blocks using queue_max_sectors.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      ac5d156c
    • H
      f2fs: fix inconsistent using of NM_WOUT_THRESHOLD · 6cac3759
      Haicheng Li 提交于
      try_to_free_nats() is usually called with parameter nr_shrink as
      	"nm_i->nat_cnt - NM_WOUT_THRESHOLD"
      by flush_nat_entries() during checkpointing process.
      
      However, this is inconsistent with the actual threshold check as
      	"if (nm_i->nat_cnt < 2 * NM_WOUT_THRESHOLD)"
      , which will ignore the free_nats requests when
      	NM_WOUT_THRESHOLD < nm_i->nat_cnt < 2 * NM_WOUT_THRESHOLD
      
      So fix the threshold check condition.
      Signed-off-by: NHaicheng Li <haicheng.li@linux.intel.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      6cac3759
  2. 29 4月, 2013 2 次提交
  3. 26 4月, 2013 2 次提交
    • J
      f2fs: check nid == 0 in add_free_nid · 9198aceb
      Jaegeuk Kim 提交于
      It is more obvious that add_free_nid checks whether the free nid is zero or not.
      Reviewed-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      9198aceb
    • J
      f2fs: give a chance to merge IOs by IO scheduler · c718379b
      Jaegeuk Kim 提交于
      Previously, background GC submits many 4KB read requests to load victim blocks
      and/or its (i)node blocks.
      
      ...
      f2fs_gc : f2fs_readpage: ino = 1, page_index = 0xb61, blkaddr = 0x3b964ed
      f2fs_gc : block_rq_complete: 8,16 R () 499854968 + 8 [0]
      f2fs_gc : f2fs_readpage: ino = 1, page_index = 0xb6f, blkaddr = 0x3b964ee
      f2fs_gc : block_rq_complete: 8,16 R () 499854976 + 8 [0]
      f2fs_gc : f2fs_readpage: ino = 1, page_index = 0xb79, blkaddr = 0x3b964ef
      f2fs_gc : block_rq_complete: 8,16 R () 499854984 + 8 [0]
      ...
      
      However, by the fact that many IOs are sequential, we can give a chance to merge
      the IOs by IO scheduler.
      In order to do that, let's use blk_plug.
      
      ...
      f2fs_gc : f2fs_iget: ino = 143
      f2fs_gc : f2fs_readpage: ino = 143, page_index = 0x1c6, blkaddr = 0x2e6ee
      f2fs_gc : f2fs_iget: ino = 143
      f2fs_gc : f2fs_readpage: ino = 143, page_index = 0x1c7, blkaddr = 0x2e6ef
      <idle> : block_rq_complete: 8,16 R () 1519616 + 8 [0]
      <idle> : block_rq_complete: 8,16 R () 1519848 + 8 [0]
      <idle> : block_rq_complete: 8,16 R () 1520432 + 96 [0]
      <idle> : block_rq_complete: 8,16 R () 1520536 + 104 [0]
      <idle> : block_rq_complete: 8,16 R () 1521008 + 112 [0]
      <idle> : block_rq_complete: 8,16 R () 1521440 + 152 [0]
      <idle> : block_rq_complete: 8,16 R () 1521688 + 144 [0]
      <idle> : block_rq_complete: 8,16 R () 1522128 + 192 [0]
      <idle> : block_rq_complete: 8,16 R () 1523256 + 328 [0]
      ...
      
      Note that this issue should be addressed in checkpoint, and some readahead
      flows too.
      Reviewed-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      c718379b
  4. 23 4月, 2013 1 次提交
  5. 09 4月, 2013 1 次提交
    • J
      f2fs: introduce a new global lock scheme · 39936837
      Jaegeuk Kim 提交于
      In the previous version, f2fs uses global locks according to the usage types,
      such as directory operations, block allocation, block write, and so on.
      
      Reference the following lock types in f2fs.h.
      enum lock_type {
      	RENAME,		/* for renaming operations */
      	DENTRY_OPS,	/* for directory operations */
      	DATA_WRITE,	/* for data write */
      	DATA_NEW,	/* for data allocation */
      	DATA_TRUNC,	/* for data truncate */
      	NODE_NEW,	/* for node allocation */
      	NODE_TRUNC,	/* for node truncate */
      	NODE_WRITE,	/* for node write */
      	NR_LOCK_TYPE,
      };
      
      In that case, we lose the performance under the multi-threading environment,
      since every types of operations must be conducted one at a time.
      
      In order to address the problem, let's share the locks globally with a mutex
      array regardless of any types.
      So, let users grab a mutex and perform their jobs in parallel as much as
      possbile.
      
      For this, I propose a new global lock scheme as follows.
      
      0. Data structure
       - f2fs_sb_info -> mutex_lock[NR_GLOBAL_LOCKS]
       - f2fs_sb_info -> node_write
      
      1. mutex_lock_op(sbi)
       - try to get an avaiable lock from the array.
       - returns the index of the gottern lock variable.
      
      2. mutex_unlock_op(sbi, index of the lock)
       - unlock the given index of the lock.
      
      3. mutex_lock_all(sbi)
       - grab all the locks in the array before the checkpoint.
      
      4. mutex_unlock_all(sbi)
       - release all the locks in the array after checkpoint.
      
      5. block_operations()
       - call mutex_lock_all()
       - sync_dirty_dir_inodes()
       - grab node_write
       - sync_node_pages()
      
      Note that,
       the pairs of mutex_lock_op()/mutex_unlock_op() and
       mutex_lock_all()/mutex_unlock_all() should be used together.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      39936837
  6. 03 4月, 2013 3 次提交
  7. 31 3月, 2013 1 次提交
  8. 27 3月, 2013 1 次提交
  9. 20 3月, 2013 5 次提交
  10. 18 3月, 2013 7 次提交
  11. 12 2月, 2013 4 次提交
  12. 08 2月, 2013 2 次提交
  13. 22 1月, 2013 2 次提交
  14. 28 12月, 2012 2 次提交
    • J
      f2fs: clean up unused variables and return values · 2b50638d
      Jaegeuk Kim 提交于
      This patch cleans up a couple of unnecessary codes related to unused variables
      and return values.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      2b50638d
    • J
      f2fs: invalidate the node page if allocation is failed · 71e9fec5
      Jaegeuk Kim 提交于
      The new_node_page() is processed as the following procedure.
      
      1. A new node page is allocated.
      2. Set PageUptodate with proper footer information.
      3. Check if there is a free space for allocation
       4.a. If there is no space, f2fs returns with -ENOSPC.
       4.b. Otherwise, go next.
      
      In the case of step #4.a, f2fs remains a wrong node page in the page cache
      with the uptodate flag.
      
      Also, even though a new node page is allocated successfully, an error can be
      occurred afterwards due to allocation failure of the other data structures.
      In such a case, remove_inode_page() would be triggered, so that we have to
      clear uptodate flag in truncate_node() too.
      
      So, we should remove the uptodate flag, if allocation is failed.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      71e9fec5
  15. 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
  16. 11 12月, 2012 4 次提交
    • N
      f2fs: fix the compiler warning for uninitialized use of variable · be4124f8
      Namjae Jeon 提交于
      When CONFIG_CC_OPTIMIZE_FOR_SIZE is enabled in the kernel, -Os optimisation
      flag is passed to gcc for compilation, and somehow while trying to optimize
      the code, compiler is might not able to see the initialisation of variable
      ne struct variable inside the get_node_info() function and results into
      following warning:
      
      fs/f2fs/node.c: In function 'get_node_info':
      fs/f2fs/node.c:175:3: warning: 'ne.block_addr' may be used uninitialized in
      this function [-Wuninitialized]
      fs/f2fs/node.c:265:24: note: 'ne.block_addr' was declared here
      fs/f2fs/node.c:176:3: warning: 'ne.ino' may be used uninitialized in this
      function [-Wuninitialized]
      fs/f2fs/node.c:265:24: note: 'ne.ino' was declared here
      fs/f2fs/node.c:177:3: warning: 'ne.version' may be used uninitialized in
      this function [-Wuninitialized]
      fs/f2fs/node.c:265:24: note: 'ne.version' was declared here
      
      Hence, lets initialise the ne struct variable to zero, which will remove
      this warning and also doing this does not seems to making any impact on the
      code behavior.
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NPankaj Kumar <pankaj.km@samsung.com>
      be4124f8
    • 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: fix endian conversion bugs reported by sparse · 25ca923b
      Jaegeuk Kim 提交于
      This patch should resolve the bugs reported by the sparse tool.
      Initial reports were written by "kbuild test robot" managed by fengguang.wu.
      
      In my local machines, I've tested also by running:
      > make C=2 CF="-D__CHECK_ENDIAN__"
      
      Accordingly, I've found lots of warnings and bugs related to the endian
      conversion. And I've fixed all at this moment.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      25ca923b
    • J
      f2fs: add node operations · e05df3b1
      Jaegeuk Kim 提交于
      This adds specific functions to manage NAT pages, a cache for NAT entries, free
      nids, direct/indirect node blocks for indexing data, and address space for node
      pages.
      
      - The key information of an NAT entry consists of a node id and a block address.
      
      - An NAT page is composed of block addresses covered by a certain range of NAT
        entries, which is maintained by the address space of meta_inode.
      
      - A radix tree structure is used to cache NAT entries. The index for the tree
        is a node id.
      
      - When there is no free nid, F2FS should scan NAT entries to find new one. In
        order to avoid scanning frequently, F2FS manages a list containing a number of
        free nids in memory. Only when free nids in the list are exhausted, scanning
        process, build_free_nids(), is triggered.
      
      - F2FS has direct and indirect node blocks for indexing data. This patch adds
        fuctions related to the node block management such as getting, allocating, and
        truncating node blocks to index data.
      
      - In order to cache node blocks in memory, F2FS has a node_inode with an address
        space for node pages. This patch also adds the address space operations for
        node_inode.
      Signed-off-by: NJaegeuk Kim <jaegeuk.kim@samsung.com>
      e05df3b1