<feed xmlns='http://www.w3.org/2005/Atom'>
<title>wireguard-linux/drivers/md/bcache/bset.c, branch jd/unified-crypt-queue</title>
<subtitle>WireGuard for the Linux kernel</subtitle>
<id>https://git.zx2c4.com/wireguard-linux/atom/drivers/md/bcache/bset.c?h=jd%2Funified-crypt-queue</id>
<link rel='self' href='https://git.zx2c4.com/wireguard-linux/atom/drivers/md/bcache/bset.c?h=jd%2Funified-crypt-queue'/>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/'/>
<updated>2020-01-23T18:40:02Z</updated>
<entry>
<title>bcache: add code comments for state-&gt;pool in __btree_sort()</title>
<updated>2020-01-23T18:40:02Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2020-01-23T17:01:36Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=7a0bc2a8966040d54289b64842d55e2cf4343ad9'/>
<id>urn:sha1:7a0bc2a8966040d54289b64842d55e2cf4343ad9</id>
<content type='text'>
To explain the pages allocated from mempool state-&gt;pool can be
swapped in __btree_sort(), because state-&gt;pool is a page pool,
which allocates pages by alloc_pages() indeed.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: don't export symbols</title>
<updated>2019-11-13T22:42:51Z</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2019-11-13T08:03:26Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=15fbb2312f32cf99bd8e0247ac0240c9bce0ba47'/>
<id>urn:sha1:15fbb2312f32cf99bd8e0247ac0240c9bce0ba47</id>
<content type='text'>
None of the exported bcache symbols are actually used anywhere.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: add code comment bch_keylist_pop() and bch_keylist_pop_front()</title>
<updated>2019-11-13T22:42:50Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2019-11-13T08:03:20Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=06c1526da97dd0022973de3fc41b79b2d431b435'/>
<id>urn:sha1:06c1526da97dd0022973de3fc41b79b2d431b435</id>
<content type='text'>
This patch adds simple code comments for bch_keylist_pop() and
bch_keylist_pop_front() in bset.c, to make the code more easier to
be understand.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: make bset_search_tree() be more understandable</title>
<updated>2019-06-28T13:39:15Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2019-06-28T11:59:41Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=944a4f340a65c21ee311d2d3e617034bef9d0b25'/>
<id>urn:sha1:944a4f340a65c21ee311d2d3e617034bef9d0b25</id>
<content type='text'>
The purpose of following code in bset_search_tree() is to avoid a branch
instruction,
 994         if (likely(f-&gt;exponent != 127))
 995                 n = j * 2 + (((unsigned int)
 996                               (f-&gt;mantissa -
 997                                bfloat_mantissa(search, f))) &gt;&gt; 31);
 998         else
 999                 n = (bkey_cmp(tree_to_bkey(t, j), search) &gt; 0)
1000                         ? j * 2
1001                         : j * 2 + 1;

This piece of code is not very clear to understand, even when I tried to
add code comment for it, I made mistake. This patch removes the implict
bit operation and uses explicit branch to calculate next location in
binary tree search.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: remove unncessary code in bch_btree_keys_init()</title>
<updated>2019-06-28T13:39:15Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2019-06-28T11:59:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=bd9026c8a7f33ebe25543b7b7e6276b49db60f7e'/>
<id>urn:sha1:bd9026c8a7f33ebe25543b7b7e6276b49db60f7e</id>
<content type='text'>
Function bch_btree_keys_init() initializes b-&gt;set[].size and
b-&gt;set[].data to zero. As the code comments indicates, these code indeed
is unncessary, because both struct btree_keys and struct bset_tree are
nested embedded into struct btree, when struct btree is filled with 0
bits by kzalloc() in mca_bucket_alloc(), b-&gt;set[].size and
b-&gt;set[].data are initialized to 0 (a.k.a NULL) already.

This patch removes the redundant code, and add comments in
bch_btree_keys_init() and mca_bucket_alloc() to explain why it's safe.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: remove unnecessary prefetch() in bset_search_tree()</title>
<updated>2019-06-28T13:39:14Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2019-06-28T11:59:31Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=f960facb399ece6ff88a7a2d4b4a5515e3a467a0'/>
<id>urn:sha1:f960facb399ece6ff88a7a2d4b4a5515e3a467a0</id>
<content type='text'>
In function bset_search_tree(), when p &gt;= t-&gt;size, t-&gt;tree[0] will be
prefetched by the following code piece,
 974                 unsigned int p = n &lt;&lt; 4;
 975
 976                 p &amp;= ((int) (p - t-&gt;size)) &gt;&gt; 31;
 977
 978                 prefetch(&amp;t-&gt;tree[p]);

The purpose of the above code is to avoid a branch instruction, but
when p &gt;= t-&gt;size, prefetch(&amp;t-&gt;tree[0]) has no positive performance
contribution at all. This patch avoids the unncessary prefetch by only
calling prefetch() when p &lt; t-&gt;size.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: fix stack corruption by PRECEDING_KEY()</title>
<updated>2019-06-13T09:09:14Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2019-06-09T22:13:34Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=31b90956b124240aa8c63250243ae1a53585c5e2'/>
<id>urn:sha1:31b90956b124240aa8c63250243ae1a53585c5e2</id>
<content type='text'>
Recently people report bcache code compiled with gcc9 is broken, one of
the buggy behavior I observe is that two adjacent 4KB I/Os should merge
into one but they don't. Finally it turns out to be a stack corruption
caused by macro PRECEDING_KEY().

See how PRECEDING_KEY() is defined in bset.h,
437 #define PRECEDING_KEY(_k)                                       \
438 ({                                                              \
439         struct bkey *_ret = NULL;                               \
440                                                                 \
441         if (KEY_INODE(_k) || KEY_OFFSET(_k)) {                  \
442                 _ret = &amp;KEY(KEY_INODE(_k), KEY_OFFSET(_k), 0);  \
443                                                                 \
444                 if (!_ret-&gt;low)                                 \
445                         _ret-&gt;high--;                           \
446                 _ret-&gt;low--;                                    \
447         }                                                       \
448                                                                 \
449         _ret;                                                   \
450 })

At line 442, _ret points to address of a on-stack variable combined by
KEY(), the life range of this on-stack variable is in line 442-446,
once _ret is returned to bch_btree_insert_key(), the returned address
points to an invalid stack address and this address is overwritten in
the following called bch_btree_iter_init(). Then argument 'search' of
bch_btree_iter_init() points to some address inside stackframe of
bch_btree_iter_init(), exact address depends on how the compiler
allocates stack space. Now the stack is corrupted.

Fixes: 0eacac22034c ("bcache: PRECEDING_KEY()")
Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Reviewed-by: Rolf Fokkens &lt;rolf@rolffokkens.nl&gt;
Reviewed-by: Pierre JUHEN &lt;pierre.juhen@orange.fr&gt;
Tested-by: Shenghui Wang &lt;shhuiw@foxmail.com&gt;
Tested-by: Pierre JUHEN &lt;pierre.juhen@orange.fr&gt;
Cc: Kent Overstreet &lt;kent.overstreet@gmail.com&gt;
Cc: Nix &lt;nix@esperi.org.uk&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: fix code comments style</title>
<updated>2018-08-11T21:46:42Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2018-08-11T05:19:55Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=3be11dbab67a3ed28358a950671de9b8e7fb5a02'/>
<id>urn:sha1:3be11dbab67a3ed28358a950671de9b8e7fb5a02</id>
<content type='text'>
This patch fixes 3 style issues warned by checkpatch.pl,
- Comment lines are not aligned
- Comments use "/*" on subsequent lines
- Comment lines use a trailing "*/"

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Reviewed-by: Shenghui Wang &lt;shhuiw@foxmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: replace printk() by pr_*() routines</title>
<updated>2018-08-11T21:46:41Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2018-08-11T05:19:49Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=6ae63e3501c493616612b90be26b35a6084fc75d'/>
<id>urn:sha1:6ae63e3501c493616612b90be26b35a6084fc75d</id>
<content type='text'>
There are still many places in bcache use printk to display kernel
message, which are suggested to be preplaced by pr_*() routines like
pr_err(), pr_info(), or pr_notice().

This patch replaces all printk() with a proper pr_*() routine for
bcache code.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Reviewed-by: Shenghui Wang &lt;shhuiw@foxmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
<entry>
<title>bcache: style fixes for lines over 80 characters</title>
<updated>2018-08-11T21:46:41Z</updated>
<author>
<name>Coly Li</name>
<email>colyli@suse.de</email>
</author>
<published>2018-08-11T05:19:47Z</published>
<link rel='alternate' type='text/html' href='https://git.zx2c4.com/wireguard-linux/commit/?id=b0d30981c05f32d8cc032b209408ca3224f05f36'/>
<id>urn:sha1:b0d30981c05f32d8cc032b209408ca3224f05f36</id>
<content type='text'>
This patch fixes the lines over 80 characters into more lines, to minimize
warnings by checkpatch.pl. There are still some lines exceed 80 characters,
but it is better to be a single line and I don't change them.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Reviewed-by: Shenghui Wang &lt;shhuiw@foxmail.com&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
</content>
</entry>
</feed>
