<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux.git/fs/f2fs/node.c, branch v3.10</title>
<subtitle>Linux kernel source tree</subtitle>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/'/>
<entry>
<title>f2fs: cover free_nid management with spin_lock</title>
<updated>2013-05-08T10:54:22+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk.kim@samsung.com</email>
</author>
<published>2013-05-07T11:47:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=59bbd474abb9dd6a0c1a74df758ec29c7a8b150f'/>
<id>59bbd474abb9dd6a0c1a74df758ec29c7a8b150f</id>
<content type='text'>
After build_free_nids() searches free nid candidates from nat pages and
current journal blocks, it checks all the candidates if they are allocated
so that the nat cache has its nid with an allocated block address.

In this procedure, previously we used
    list_for_each_entry_safe(fnid, next_fnid, &amp;nm_i-&gt;free_nid_list, list).
But, this is not covered by free_nid_list_lock, resulting in null pointer bug.

This patch moves this checking routine inside add_free_nid() in order not to use
the spin_lock.

Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
After build_free_nids() searches free nid candidates from nat pages and
current journal blocks, it checks all the candidates if they are allocated
so that the nat cache has its nid with an allocated block address.

In this procedure, previously we used
    list_for_each_entry_safe(fnid, next_fnid, &amp;nm_i-&gt;free_nid_list, list).
But, this is not covered by free_nid_list_lock, resulting in null pointer bug.

This patch moves this checking routine inside add_free_nid() in order not to use
the spin_lock.

Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: optimize scan_nat_page()</title>
<updated>2013-05-08T10:54:22+00:00</updated>
<author>
<name>Haicheng Li</name>
<email>haicheng.li@linux.intel.com</email>
</author>
<published>2013-05-06T15:15:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=23d38844276680abbf33624f56b6779d43f53633'/>
<id>23d38844276680abbf33624f56b6779d43f53633</id>
<content type='text'>
When nm_i-&gt;fcnt &gt; 2 * MAX_FREE_NIDS, stop scanning other NAT entries.

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
[Jaegeuk Kim: fix handling the return value of add_free_nid()]
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When nm_i-&gt;fcnt &gt; 2 * MAX_FREE_NIDS, stop scanning other NAT entries.

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
[Jaegeuk Kim: fix handling the return value of add_free_nid()]
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: code cleanup for scan_nat_page() and build_free_nids()</title>
<updated>2013-05-08T10:54:21+00:00</updated>
<author>
<name>Haicheng Li</name>
<email>haicheng.li@linux.intel.com</email>
</author>
<published>2013-05-06T15:15:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=8760952d92b2fd2310fac340ff5bcdf3ada500d7'/>
<id>8760952d92b2fd2310fac340ff5bcdf3ada500d7</id>
<content type='text'>
This patch does two cleanups:
1. remove unused variable "fcnt" in build_free_nids().
2. make scan_nat_page() as void type and remove useless variable "fcnt".

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch does two cleanups:
1. remove unused variable "fcnt" in build_free_nids().
2. make scan_nat_page() as void type and remove useless variable "fcnt".

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: bugfix for alloc_nid_failed()</title>
<updated>2013-05-08T10:54:20+00:00</updated>
<author>
<name>Haicheng Li</name>
<email>haicheng.li@linux.intel.com</email>
</author>
<published>2013-05-06T15:15:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=95630cbadc3588abff24a4b1989b72c943b27512'/>
<id>95630cbadc3588abff24a4b1989b72c943b27512</id>
<content type='text'>
Directly drop the free_nid cache when nm_i-&gt;fcnt &gt; 2 * MAX_FREE_NIDS

Since there is NOT nmi-&gt;free_nid_list_lock spinlock protection between
a sequential calling of alloc_nid() and alloc_nid_failed(), some other
threads may already add new free_nid to the free_nid_list during this
period.

We need to make sure nmi-&gt;fcnt is never &gt; 2 * MAX_FREE_NIDS.

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
[Jaegeuk Kim: fit the coding style]
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Directly drop the free_nid cache when nm_i-&gt;fcnt &gt; 2 * MAX_FREE_NIDS

Since there is NOT nmi-&gt;free_nid_list_lock spinlock protection between
a sequential calling of alloc_nid() and alloc_nid_failed(), some other
threads may already add new free_nid to the free_nid_list during this
period.

We need to make sure nmi-&gt;fcnt is never &gt; 2 * MAX_FREE_NIDS.

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
[Jaegeuk Kim: fit the coding style]
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: modify the number of issued pages to merge IOs</title>
<updated>2013-04-30T03:07:32+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk.kim@samsung.com</email>
</author>
<published>2013-04-29T07:58:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=ac5d156c78a68b39955ee9b09498ba93831c77d7'/>
<id>ac5d156c78a68b39955ee9b09498ba93831c77d7</id>
<content type='text'>
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: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: fix inconsistent using of NM_WOUT_THRESHOLD</title>
<updated>2013-04-30T03:07:32+00:00</updated>
<author>
<name>Haicheng Li</name>
<email>haicheng.li@linux.intel.com</email>
</author>
<published>2013-04-28T11:16:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=6cac3759ce118a87103ce4342e6de98215d01787'/>
<id>6cac3759ce118a87103ce4342e6de98215d01787</id>
<content type='text'>
try_to_free_nats() is usually called with parameter nr_shrink as
	"nm_i-&gt;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-&gt;nat_cnt &lt; 2 * NM_WOUT_THRESHOLD)"
, which will ignore the free_nats requests when
	NM_WOUT_THRESHOLD &lt; nm_i-&gt;nat_cnt &lt; 2 * NM_WOUT_THRESHOLD

So fix the threshold check condition.

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
try_to_free_nats() is usually called with parameter nr_shrink as
	"nm_i-&gt;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-&gt;nat_cnt &lt; 2 * NM_WOUT_THRESHOLD)"
, which will ignore the free_nats requests when
	NM_WOUT_THRESHOLD &lt; nm_i-&gt;nat_cnt &lt; 2 * NM_WOUT_THRESHOLD

So fix the threshold check condition.

Signed-off-by: Haicheng Li &lt;haicheng.li@linux.intel.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: check truncation of mapping after lock_page</title>
<updated>2013-04-29T02:19:32+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk.kim@samsung.com</email>
</author>
<published>2013-04-26T02:55:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=afcb7ca01f47b0481e0b248d1542d0934fa70767'/>
<id>afcb7ca01f47b0481e0b248d1542d0934fa70767</id>
<content type='text'>
We call lock_page when we need to update a page after readpage.
Between grab and lock page, the page can be truncated by other thread.
So, we should check the page after lock_page whether it was truncated or not.

Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We call lock_page when we need to update a page after readpage.
Between grab and lock page, the page can be truncated by other thread.
So, we should check the page after lock_page whether it was truncated or not.

Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: enhance alloc_nid and build_free_nids flows</title>
<updated>2013-04-29T02:19:21+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk.kim@samsung.com</email>
</author>
<published>2013-04-25T07:05:51+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=55008d845d233396ed374473da4613cee691aa03'/>
<id>55008d845d233396ed374473da4613cee691aa03</id>
<content type='text'>
In order to avoid build_free_nid lock contention, let's change the order of
function calls as follows.

At first, check whether there is enough free nids.
 - If available, just get a free nid with spin_lock without any overhead.
 - Otherwise, conduct build_free_nids.
  : scan nat pages, journal nat entries, and nat cache entries.

We should consider carefullly not to serve free nids intermediately made by
build_free_nids.
We can get stable free nids only after build_free_nids is done.

Reviewed-by: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In order to avoid build_free_nid lock contention, let's change the order of
function calls as follows.

At first, check whether there is enough free nids.
 - If available, just get a free nid with spin_lock without any overhead.
 - Otherwise, conduct build_free_nids.
  : scan nat pages, journal nat entries, and nat cache entries.

We should consider carefullly not to serve free nids intermediately made by
build_free_nids.
We can get stable free nids only after build_free_nids is done.

Reviewed-by: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: check nid == 0 in add_free_nid</title>
<updated>2013-04-26T01:35:13+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk.kim@samsung.com</email>
</author>
<published>2013-04-25T04:21:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=9198aceb53a493d1be0f3a5a1ce13c07a6fdcd26'/>
<id>9198aceb53a493d1be0f3a5a1ce13c07a6fdcd26</id>
<content type='text'>
It is more obvious that add_free_nid checks whether the free nid is zero or not.

Reviewed-by: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It is more obvious that add_free_nid checks whether the free nid is zero or not.

Reviewed-by: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>f2fs: give a chance to merge IOs by IO scheduler</title>
<updated>2013-04-26T01:35:10+00:00</updated>
<author>
<name>Jaegeuk Kim</name>
<email>jaegeuk.kim@samsung.com</email>
</author>
<published>2013-04-24T04:19:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.tavy.me/linux.git/commit/?id=c718379b6b0954a04a153d7e5dc8b3136a301ee6'/>
<id>c718379b6b0954a04a153d7e5dc8b3136a301ee6</id>
<content type='text'>
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
&lt;idle&gt; : block_rq_complete: 8,16 R () 1519616 + 8 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1519848 + 8 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1520432 + 96 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1520536 + 104 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1521008 + 112 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1521440 + 152 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1521688 + 144 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1522128 + 192 [0]
&lt;idle&gt; : 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: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
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
&lt;idle&gt; : block_rq_complete: 8,16 R () 1519616 + 8 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1519848 + 8 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1520432 + 96 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1520536 + 104 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1521008 + 112 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1521440 + 152 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1521688 + 144 [0]
&lt;idle&gt; : block_rq_complete: 8,16 R () 1522128 + 192 [0]
&lt;idle&gt; : 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: Namjae Jeon &lt;namjae.jeon@samsung.com&gt;
Signed-off-by: Jaegeuk Kim &lt;jaegeuk.kim@samsung.com&gt;
</pre>
</div>
</content>
</entry>
</feed>
