<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/fs/btrfs/dev-replace.c, branch linux-4.4.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-4.4.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2019-07-10T07:56:44Z</updated>
<entry>
<title>btrfs: Ensure replaced device doesn't have pending chunk allocation</title>
<updated>2019-07-10T07:56:44Z</updated>
<author>
<name>Nikolay Borisov</name>
</author>
<published>2019-05-17T07:44:25Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=986543fcf50c8a3681be44cac42dc498fe25ab34'/>
<id>urn:sha1:986543fcf50c8a3681be44cac42dc498fe25ab34</id>
<content type='text'>
commit debd1c065d2037919a7da67baf55cc683fee09f0 upstream.

Recent FITRIM work, namely bbbf7243d62d ("btrfs: combine device update
operations during transaction commit") combined the way certain
operations are recoded in a transaction. As a result an ASSERT was added
in dev_replace_finish to ensure the new code works correctly.
Unfortunately I got reports that it's possible to trigger the assert,
meaning that during a device replace it's possible to have an unfinished
chunk allocation on the source device.

This is supposed to be prevented by the fact that a transaction is
committed before finishing the replace oepration and alter acquiring the
chunk mutex. This is not sufficient since by the time the transaction is
committed and the chunk mutex acquired it's possible to allocate a chunk
depending on the workload being executed on the replaced device. This
bug has been present ever since device replace was introduced but there
was never code which checks for it.

The correct way to fix is to ensure that there is no pending device
modification operation when the chunk mutex is acquire and if there is
repeat transaction commit. Unfortunately it's not possible to just
exclude the source device from btrfs_fs_devices::dev_alloc_list since
this causes ENOSPC to be hit in transaction commit.

Fixing that in another way would need to add special cases to handle the
last writes and forbid new ones. The looped transaction fix is more
obvious, and can be easily backported. The runtime of dev-replace is
long so there's no noticeable delay caused by that.

Reported-by: David Sterba &lt;dsterba@suse.com&gt;
Fixes: 391cd9df81ac ("Btrfs: fix unprotected alloc list insertion during the finishing procedure of replace")
CC: stable@vger.kernel.org # 4.4+
Signed-off-by: Nikolay Borisov &lt;nborisov@suse.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>btrfs: cleanup, stop casting for extent_map-&gt;lookup everywhere</title>
<updated>2019-01-16T21:16:06Z</updated>
<author>
<name>Jeff Mahoney</name>
</author>
<published>2015-06-03T14:55:48Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=67405a1e780c38b54c980a47f1cd5d9b633a60f2'/>
<id>urn:sha1:67405a1e780c38b54c980a47f1cd5d9b633a60f2</id>
<content type='text'>
commit 95617d69326ce386c95e33db7aeb832b45ee9f8f upstream.

Overloading extent_map-&gt;bdev to struct map_lookup * might have started out
as a means to an end, but it's a pattern that's used all over the place
now. Let's get rid of the casting and just add a union instead.

Signed-off-by: Jeff Mahoney &lt;jeffm@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Ben Hutchings &lt;ben.hutchings@codethink.co.uk&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>btrfs: replace: Reset on-disk dev stats value after replace</title>
<updated>2018-09-15T07:40:40Z</updated>
<author>
<name>Misono Tomohiro</name>
</author>
<published>2018-07-31T07:20:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=accb3e424b8b6b9fa51b77fcf7e6673f40d182a6'/>
<id>urn:sha1:accb3e424b8b6b9fa51b77fcf7e6673f40d182a6</id>
<content type='text'>
[ Upstream commit 1e7e1f9e3aba00c9b9c323bfeeddafe69ff21ff6 ]

on-disk devs stats value is updated in btrfs_run_dev_stats(),
which is called during commit transaction, if device-&gt;dev_stats_ccnt
is not zero.

Since current replace operation does not touch dev_stats_ccnt,
on-disk dev stats value is not updated. Therefore "btrfs device stats"
may return old device's value after umount/mount
(Example: See "btrfs ins dump-t -t DEV $DEV" after btrfs/100 finish).

Fix this by just incrementing dev_stats_ccnt in
btrfs_dev_replace_finishing() when replace is succeeded and this will
update the values.

Signed-off-by: Misono Tomohiro &lt;misono.tomohiro@jp.fujitsu.com&gt;
Reviewed-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
Signed-off-by: Sasha Levin &lt;alexander.levin@microsoft.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>Merge branch 'fix/waitqueue-barriers' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4</title>
<updated>2015-10-12T23:24:40Z</updated>
<author>
<name>Chris Mason</name>
</author>
<published>2015-10-12T23:24:40Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=6db4a7335dd701a0e20275440ee057d3db2a7ae3'/>
<id>urn:sha1:6db4a7335dd701a0e20275440ee057d3db2a7ae3</id>
<content type='text'>
</content>
</entry>
<entry>
<title>Merge branch 'anand/sysfs-updates-v4.3-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.4</title>
<updated>2015-10-12T23:24:15Z</updated>
<author>
<name>Chris Mason</name>
</author>
<published>2015-10-12T23:24:15Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=62fb50ab7c903357c92cef2f7677235b92ac575f'/>
<id>urn:sha1:62fb50ab7c903357c92cef2f7677235b92ac575f</id>
<content type='text'>
Signed-off-by: Chris Mason &lt;clm@fb.com&gt;
</content>
</entry>
<entry>
<title>btrfs: remove waitqueue_active check from btrfs_rm_dev_replace_unblocked</title>
<updated>2015-10-10T16:16:38Z</updated>
<author>
<name>David Sterba</name>
</author>
<published>2015-10-10T16:16:38Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=730d9ec36bf27e87805aee6ebf462071735e31f9'/>
<id>urn:sha1:730d9ec36bf27e87805aee6ebf462071735e31f9</id>
<content type='text'>
Normally the waitqueue_active would need a barrier, but this is not
necessary here because it's not a performance sensitive context and we
can call wake_up directly.

Suggested-by: Chris Mason &lt;clm@fb.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>btrfs: switch message printers to _in_rcu variants</title>
<updated>2015-10-08T09:07:55Z</updated>
<author>
<name>David Sterba</name>
</author>
<published>2015-10-08T07:01:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=ecaeb14b912a3be55530aeec4e81c7243f5ceb5d'/>
<id>urn:sha1:ecaeb14b912a3be55530aeec4e81c7243f5ceb5d</id>
<content type='text'>
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>Btrfs: move kobj stuff out of dev_replace lock range</title>
<updated>2015-10-01T16:07:59Z</updated>
<author>
<name>Liu Bo</name>
</author>
<published>2015-08-14T10:33:07Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=73416dab235e5ff030e3b3c61da0cd6ced324fc9'/>
<id>urn:sha1:73416dab235e5ff030e3b3c61da0cd6ced324fc9</id>
<content type='text'>
To avoid deadlock described in commit 084b6e7c7607 ("btrfs: Fix a
lockdep warning when running xfstest."), we should move kobj stuff out
of dev_replace lock range.

  "It is because the btrfs_kobj_{add/rm}_device() will call memory
  allocation with GFP_KERNEL,
  which may flush fs page cache to free space, waiting for it self to do
  the commit, causing the deadlock.

  To solve the problem, move btrfs_kobj_{add/rm}_device() out of the
  dev_replace lock range, also involing split the
  btrfs_rm_dev_replace_srcdev() function into remove and free parts.

  Now only btrfs_rm_dev_replace_remove_srcdev() is called in dev_replace
  lock range, and kobj_{add/rm} and btrfs_rm_dev_replace_free_srcdev() are
  called out of the lock range."

Signed-off-by: Liu Bo &lt;bo.li.liu@oracle.com&gt;
Signed-off-by: Anand Jain &lt;anand.jain@oracle.com&gt;
[added lockup description]
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>Btrfs: kernel operation should come after user input has been verified</title>
<updated>2015-10-01T15:45:10Z</updated>
<author>
<name>Anand Jain</name>
</author>
<published>2015-08-14T10:33:02Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9e271ae27e4407388c5b25c747abc25c07838b0b'/>
<id>urn:sha1:9e271ae27e4407388c5b25c747abc25c07838b0b</id>
<content type='text'>
By general rule of thumb there shouldn't be any way that user land
could trigger a kernel operation just by sending wrong arguments.

Here do commit cleanups after user input has been verified.

Signed-off-by: Anand Jain &lt;anand.jain@oracle.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
<entry>
<title>Btrfs: rename btrfs_kobj_rm_device to btrfs_sysfs_rm_device_link</title>
<updated>2015-09-29T14:29:59Z</updated>
<author>
<name>Anand Jain</name>
</author>
<published>2015-08-14T10:32:49Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=325760404820e070bb20be0ce57e8d684d69a2ac'/>
<id>urn:sha1:325760404820e070bb20be0ce57e8d684d69a2ac</id>
<content type='text'>
Signed-off-by: Anand Jain &lt;anand.jain@oracle.com&gt;
Signed-off-by: David Sterba &lt;dsterba@suse.com&gt;
</content>
</entry>
</feed>
