<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/md/bcache/super.c, branch linux-4.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.1.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.1.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2018-05-23T01:36:29Z</updated>
<entry>
<title>bcache: stop writeback thread after detaching</title>
<updated>2018-05-23T01:36:29Z</updated>
<author>
<name>Tang Junhui</name>
</author>
<published>2018-01-08T20:21:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=14384db155b8ebd01a2a3d33a717b87f5125e8e7'/>
<id>urn:sha1:14384db155b8ebd01a2a3d33a717b87f5125e8e7</id>
<content type='text'>
[ Upstream commit 8d29c4426b9f8afaccf28de414fde8a722b35fdf ]

Currently, when a cached device detaching from cache, writeback thread is
not stopped, and writeback_rate_update work is not canceled. For example,
after the following command:
echo 1 &gt;/sys/block/sdb/bcache/detach
you can still see the writeback thread. Then you attach the device to the
cache again, bcache will create another writeback thread, for example,
after below command:
echo  ba0fb5cd-658a-4533-9806-6ce166d883b9 &gt; /sys/block/sdb/bcache/attach
then you will see 2 writeback threads.
This patch stops writeback thread and cancels writeback_rate_update work
when cached device detaching from cache.

Compare with patch v1, this v2 patch moves code down into the register
lock for safety in case of any future changes as Coly and Mike suggested.

[edit by mlyle: commit log spelling/formatting]

Signed-off-by: Tang Junhui &lt;tang.junhui@zte.com.cn&gt;
Reviewed-by: Michael Lyle &lt;mlyle@lyle.org&gt;
Signed-off-by: Michael Lyle &lt;mlyle@lyle.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
</content>
</entry>
<entry>
<title>bcache: don't attach backing with duplicate UUID</title>
<updated>2018-03-21T03:49:50Z</updated>
<author>
<name>Michael Lyle</name>
</author>
<published>2018-03-05T21:41:55Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b5369b906e8b3adc308668c9479325bf01f7b113'/>
<id>urn:sha1:b5369b906e8b3adc308668c9479325bf01f7b113</id>
<content type='text'>
[ Upstream commit 86755b7a96faed57f910f9e6b8061e019ac1ec08 ]

This can happen e.g. during disk cloning.

This is an incomplete fix: it does not catch duplicate UUIDs earlier
when things are still unattached.  It does not unregister the device.
Further changes to cope better with this are planned but conflict with
Coly's ongoing improvements to handling device errors.  In the meantime,
one can manually stop the device after this has happened.

Attempts to attach a duplicate device result in:

[  136.372404] loop: module loaded
[  136.424461] bcache: register_bdev() registered backing device loop0
[  136.424464] bcache: bch_cached_dev_attach() Tried to attach loop0 but duplicate UUID already attached

My test procedure is:

  dd if=/dev/sdb1 of=imgfile bs=1024 count=262144
  losetup -f imgfile

Signed-off-by: Michael Lyle &lt;mlyle@lyle.org&gt;
Reviewed-by: Tang Junhui &lt;tang.junhui@zte.com.cn&gt;
Cc: &lt;stable@vger.kernel.org&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
</content>
</entry>
<entry>
<title>bcache: explicitly destroy mutex while exiting</title>
<updated>2018-01-17T17:55:39Z</updated>
<author>
<name>Liang Chen</name>
</author>
<published>2017-10-30T21:46:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a7a5473af8b85c8604b5ae5bbbd3e3c077584436'/>
<id>urn:sha1:a7a5473af8b85c8604b5ae5bbbd3e3c077584436</id>
<content type='text'>
[ Upstream commit 330a4db89d39a6b43f36da16824eaa7a7509d34d ]

mutex_destroy does nothing most of time, but it's better to call
it to make the code future proof and it also has some meaning
for like mutex debug.

As Coly pointed out in a previous review, bcache_exit() may not be
able to handle all the references properly if userspace registers
cache and backing devices right before bch_debug_init runs and
bch_debug_init failes later. So not exposing userspace interface
until everything is ready to avoid that issue.

Signed-off-by: Liang Chen &lt;liangchen.linux@gmail.com&gt;
Reviewed-by: Michael Lyle &lt;mlyle@lyle.org&gt;
Reviewed-by: Coly Li &lt;colyli@suse.de&gt;
Reviewed-by: Eric Wheeler &lt;bcache@linux.ewheeler.net&gt;
Signed-off-by: Jens Axboe &lt;axboe@kernel.dk&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
</content>
</entry>
<entry>
<title>bcache: Make gc wakeup sane, remove set_task_state()</title>
<updated>2018-01-17T17:24:33Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2016-10-27T03:31:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=30f378e4208a34b767e1e7ef89644f4dd5e455d9'/>
<id>urn:sha1:30f378e4208a34b767e1e7ef89644f4dd5e455d9</id>
<content type='text'>
[ Upstream commit be628be09563f8f6e81929efbd7cf3f45c344416 ]

Signed-off-by: Kent Overstreet &lt;kent.overstreet@gmail.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
</content>
</entry>
<entry>
<title>bcache: fix for gc and write-back race</title>
<updated>2017-10-04T11:43:04Z</updated>
<author>
<name>Tang Junhui</name>
</author>
<published>2017-09-06T06:25:59Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ce04caa126bc701fe4e3d59b49962f9a99e9c6c8'/>
<id>urn:sha1:ce04caa126bc701fe4e3d59b49962f9a99e9c6c8</id>
<content type='text'>
[ Upstream commit 9baf30972b5568d8b5bc8b3c46a6ec5b58100463 ]

gc and write-back get raced (see the email "bcache get stucked" I sended
before):
gc thread                               write-back thread
|                                       |bch_writeback_thread()
|bch_gc_thread()                        |
|                                       |==&gt;read_dirty()
|==&gt;bch_btree_gc()                      |
|==&gt;btree_root() //get btree root       |
|                //node write locker    |
|==&gt;bch_btree_gc_root()                 |
|                                       |==&gt;read_dirty_submit()
|                                       |==&gt;write_dirty()
|                                       |==&gt;continue_at(cl,
|                                       |               write_dirty_finish,
|                                       |               system_wq);
|                                       |==&gt;write_dirty_finish()//excute
|                                       |               //in system_wq
|                                       |==&gt;bch_btree_insert()
|                                       |==&gt;bch_btree_map_leaf_nodes()
|                                       |==&gt;__bch_btree_map_nodes()
|                                       |==&gt;btree_root //try to get btree
|                                       |              //root node read
|                                       |              //lock
|                                       |-----stuck here
|==&gt;bch_btree_set_root()
|==&gt;bch_journal_meta()
|==&gt;bch_journal()
|==&gt;journal_try_write()
|==&gt;journal_write_unlocked() //journal_full(&amp;c-&gt;journal)
|                            //condition satisfied
|==&gt;continue_at(cl, journal_write, system_wq); //try to excute
|                               //journal_write in system_wq
|                               //but work queue is excuting
|                               //write_dirty_finish()
|==&gt;closure_sync(); //wait journal_write execute
|                   //over and wake up gc,
|-------------stuck here
|==&gt;release root node write locker

This patch alloc a separate work-queue for write-back thread to avoid such
race.

(Commit log re-organized by Coly Li to pass checkpatch.pl checking)

Signed-off-by: Tang Junhui &lt;tang.junhui@zte.com.cn&gt;
Acked-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: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>bcache: Fix leak of bdev reference</title>
<updated>2017-10-04T11:43:04Z</updated>
<author>
<name>Jan Kara</name>
</author>
<published>2017-09-06T06:25:51Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cc54420aece1e8a493c8b7ea9ae3c44d69d294ee'/>
<id>urn:sha1:cc54420aece1e8a493c8b7ea9ae3c44d69d294ee</id>
<content type='text'>
[ Upstream commit 4b758df21ee7081ab41448d21d60367efaa625b3 ]

If blkdev_get_by_path() in register_bcache() fails, we try to lookup the
block device using lookup_bdev() to detect which situation we are in to
properly report error. However we never drop the reference returned to
us from lookup_bdev(). Fix that.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Acked-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: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>bcache: initialize dirty stripes in flash_dev_run()</title>
<updated>2017-10-04T11:43:04Z</updated>
<author>
<name>Tang Junhui</name>
</author>
<published>2017-09-06T17:28:53Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=0e7650e143ca094427677397301bfb7ef1baab96'/>
<id>urn:sha1:0e7650e143ca094427677397301bfb7ef1baab96</id>
<content type='text'>
[ Upstream commit 175206cf9ab63161dec74d9cd7f9992e062491f5 ]

bcache uses a Proportion-Differentiation Controller algorithm to control
writeback rate to cached devices. In the PD controller algorithm, dirty
stripes of thin flash device should not be counted in, because flash only
volumes never write back dirty data.

Currently dirty stripe counter for thin flash device is not initialized
when the thin flash device starts. Which means the following calculation
in PD controller will reference an undefined dirty stripes number, and
all cached devices attached to the same cache set where the thin flash
device lies on may have an inaccurate writeback rate.

This patch calles bch_sectors_dirty_init() in flash_dev_run(), to
correctly initialize dirty stripe counter when the thin flash device
starts to run. This patch also does following parameter data type change,
 -void bch_sectors_dirty_init(struct cached_dev *dc);
 +void bch_sectors_dirty_init(struct bcache_device *);
to call this function conveniently in flash_dev_run().

(Commit log is composed by Coly Li)

Signed-off-by: Tang Junhui &lt;tang.junhui@zte.com.cn&gt;
Reviewed-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: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>bcache: RESERVE_PRIO is too small by one when prio_buckets() is a power of two.</title>
<updated>2016-08-31T23:21:09Z</updated>
<author>
<name>Kent Overstreet</name>
</author>
<published>2016-08-18T01:21:24Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cb515bdff8293136e97dd5370d0a094d3074ab21'/>
<id>urn:sha1:cb515bdff8293136e97dd5370d0a094d3074ab21</id>
<content type='text'>
[ Upstream commit acc9cf8c66c66b2cbbdb4a375537edee72be64df ]

This patch fixes a cachedev registration-time allocation deadlock.
This can deadlock on boot if your initrd auto-registeres bcache devices:

Allocator thread:
[  720.727614] INFO: task bcache_allocato:3833 blocked for more than 120 seconds.
[  720.732361]  [&lt;ffffffff816eeac7&gt;] schedule+0x37/0x90
[  720.732963]  [&lt;ffffffffa05192b8&gt;] bch_bucket_alloc+0x188/0x360 [bcache]
[  720.733538]  [&lt;ffffffff810e6950&gt;] ? prepare_to_wait_event+0xf0/0xf0
[  720.734137]  [&lt;ffffffffa05302bd&gt;] bch_prio_write+0x19d/0x340 [bcache]
[  720.734715]  [&lt;ffffffffa05190bf&gt;] bch_allocator_thread+0x3ff/0x470 [bcache]
[  720.735311]  [&lt;ffffffff816ee41c&gt;] ? __schedule+0x2dc/0x950
[  720.735884]  [&lt;ffffffffa0518cc0&gt;] ? invalidate_buckets+0x980/0x980 [bcache]

Registration thread:
[  720.710403] INFO: task bash:3531 blocked for more than 120 seconds.
[  720.715226]  [&lt;ffffffff816eeac7&gt;] schedule+0x37/0x90
[  720.715805]  [&lt;ffffffffa05235cd&gt;] __bch_btree_map_nodes+0x12d/0x150 [bcache]
[  720.716409]  [&lt;ffffffffa0522d30&gt;] ? bch_btree_insert_check_key+0x1c0/0x1c0 [bcache]
[  720.717008]  [&lt;ffffffffa05236e4&gt;] bch_btree_insert+0xf4/0x170 [bcache]
[  720.717586]  [&lt;ffffffff810e6950&gt;] ? prepare_to_wait_event+0xf0/0xf0
[  720.718191]  [&lt;ffffffffa0527d9a&gt;] bch_journal_replay+0x14a/0x290 [bcache]
[  720.718766]  [&lt;ffffffff810cc90d&gt;] ? ttwu_do_activate.constprop.94+0x5d/0x70
[  720.719369]  [&lt;ffffffff810cf684&gt;] ? try_to_wake_up+0x1d4/0x350
[  720.719968]  [&lt;ffffffffa05317d0&gt;] run_cache_set+0x580/0x8e0 [bcache]
[  720.720553]  [&lt;ffffffffa053302e&gt;] register_bcache+0xe2e/0x13b0 [bcache]
[  720.721153]  [&lt;ffffffff81354cef&gt;] kobj_attr_store+0xf/0x20
[  720.721730]  [&lt;ffffffff812a2dad&gt;] sysfs_kf_write+0x3d/0x50
[  720.722327]  [&lt;ffffffff812a225a&gt;] kernfs_fop_write+0x12a/0x180
[  720.722904]  [&lt;ffffffff81225177&gt;] __vfs_write+0x37/0x110
[  720.723503]  [&lt;ffffffff81228048&gt;] ? __sb_start_write+0x58/0x110
[  720.724100]  [&lt;ffffffff812cedb3&gt;] ? security_file_permission+0x23/0xa0
[  720.724675]  [&lt;ffffffff812258a9&gt;] vfs_write+0xa9/0x1b0
[  720.725275]  [&lt;ffffffff8102479c&gt;] ? do_audit_syscall_entry+0x6c/0x70
[  720.725849]  [&lt;ffffffff81226755&gt;] SyS_write+0x55/0xd0
[  720.726451]  [&lt;ffffffff8106a390&gt;] ? do_page_fault+0x30/0x80
[  720.727045]  [&lt;ffffffff816f2cae&gt;] system_call_fastpath+0x12/0x71

The fifo code in upstream bcache can't use the last element in the buffer,
which was the cause of the bug: if you asked for a power of two size,
it'd give you a fifo that could hold one less than what you asked for
rather than allocating a buffer twice as big.

Signed-off-by: Kent Overstreet &lt;kent.overstreet@gmail.com&gt;
Tested-by: Eric Wheeler &lt;bcache@linux.ewheeler.net&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>bcache: register_bcache(): call blkdev_put() when cache_alloc() fails</title>
<updated>2016-08-31T23:21:09Z</updated>
<author>
<name>Eric Wheeler</name>
</author>
<published>2016-06-17T22:01:54Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=220360d6ac0e1ef0cf364028c26f44ac99c306c4'/>
<id>urn:sha1:220360d6ac0e1ef0cf364028c26f44ac99c306c4</id>
<content type='text'>
[ Upstream commit d9dc1702b297ec4a6bb9c0326a70641b322ba886 ]

register_cache() is supposed to return an error string on error so that
register_bcache() will will blkdev_put and cleanup other user counters,
but it does not set 'char *err' when cache_alloc() fails (eg, due to
memory pressure) and thus register_bcache() performs no cleanup.

register_bcache() &lt;----------\  &lt;- no jump to err_close, no blkdev_put()
   |                         |
   +-&gt;register_cache()       |  &lt;- fails to set char *err
         |                   |
         +-&gt;cache_alloc() ---/  &lt;- returns error

This patch sets `char *err` for this failure case so that register_cache()
will cause register_bcache() to correctly jump to err_close and do
cleanup.  This was tested under OOM conditions that triggered the bug.

Signed-off-by: Eric Wheeler &lt;bcache@linux.ewheeler.net&gt;
Cc: Kent Overstreet &lt;kent.overstreet@gmail.com&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin &lt;alexander.levin@verizon.com&gt;
</content>
</entry>
<entry>
<title>bcache: fix cache_set_flush() NULL pointer dereference on OOM</title>
<updated>2016-04-18T12:50:50Z</updated>
<author>
<name>Eric Wheeler</name>
</author>
<published>2016-03-07T23:17:50Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d09a05998d79dcfaa25de84624dce9f806fe4e7c'/>
<id>urn:sha1:d09a05998d79dcfaa25de84624dce9f806fe4e7c</id>
<content type='text'>
[ Upstream commit f8b11260a445169989d01df75d35af0f56178f95 ]

When bch_cache_set_alloc() fails to kzalloc the cache_set, the
asyncronous closure handling tries to dereference a cache_set that
hadn't yet been allocated inside of cache_set_flush() which is called
by __cache_set_unregister() during cleanup.  This appears to happen only
during an OOM condition on bcache_register.

Signed-off-by: Eric Wheeler &lt;bcache@linux.ewheeler.net&gt;
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin &lt;sasha.levin@oracle.com&gt;
</content>
</entry>
</feed>
