<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/md/bcache/bset.c, branch linux-5.8.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.8.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.8.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2020-08-21T11:14:56Z</updated>
<entry>
<title>bcache: allocate meta data pages as compound pages</title>
<updated>2020-08-21T11:14:56Z</updated>
<author>
<name>Coly Li</name>
</author>
<published>2020-07-25T12:00:16Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d024010903677831608d7a0c166c3de7921de848'/>
<id>urn:sha1:d024010903677831608d7a0c166c3de7921de848</id>
<content type='text'>
commit 5fe48867856367142d91a82f2cbf7a57a24cbb70 upstream.

There are some meta data of bcache are allocated by multiple pages,
and they are used as bio bv_page for I/Os to the cache device. for
example cache_set-&gt;uuids, cache-&gt;disk_buckets, journal_write-&gt;data,
bset_tree-&gt;data.

For such meta data memory, all the allocated pages should be treated
as a single memory block. Then the memory management and underlying I/O
code can treat them more clearly.

This patch adds __GFP_COMP flag to all the location allocating &gt;0 order
pages for the above mentioned meta data. Then their pages are treated
as compound pages now.

Signed-off-by: Coly Li &lt;colyli@suse.de&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>bcache: Convert pr_&lt;level&gt; uses to a more typical style</title>
<updated>2020-05-27T11:19:36Z</updated>
<author>
<name>Joe Perches</name>
</author>
<published>2020-05-27T04:01:52Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=46f5aa8806e34f2e48de852cc7db2c74c3a5cd8d'/>
<id>urn:sha1:46f5aa8806e34f2e48de852cc7db2c74c3a5cd8d</id>
<content type='text'>
Remove the trailing newline from the define of pr_fmt and add newlines
to the uses.

Miscellanea:

o Convert bch_bkey_dump from multiple uses of pr_err to pr_cont
  as the earlier conversion was inappropriate done causing multiple
  lines to be emitted where only a single output line was desired
o Use vsprintf extension %pV in bch_cache_set_error to avoid multiple
  line output where only a single line output was desired
o Coalesce formats

Fixes: 6ae63e3501c4 ("bcache: replace printk() by pr_*() routines")

Signed-off-by: Joe Perches &lt;joe@perches.com&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 comments for state-&gt;pool in __btree_sort()</title>
<updated>2020-01-23T18:40:02Z</updated>
<author>
<name>Coly Li</name>
</author>
<published>2020-01-23T17:01:36Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2019-11-13T08:03:26Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2019-11-13T08:03:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2019-06-28T11:59:41Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2019-06-28T11:59:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2019-06-28T11:59:31Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2019-06-09T22:13:34Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</author>
<published>2018-08-11T05:19:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/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>
</feed>
