Re: [PATCH] btrfs: oops in device_list_add()

2019-01-28 Thread Anand Jain
On 1/27/19 12:58 PM, Al Viro wrote: alloc_fs_devices() can return ERR_PTR(-ENOMEM), so dereferencing its result before the check for IS_ERR() is a bad idea... Fixes: d1a63002829a4 Signed-off-by: Al Viro nice catch. Reviewed-by: Anand Jain --- diff --git a/fs/btrfs/volumes.c b/

Re: [PATCH -next] btrfs: remove unused function btrfs_sysfs_feature_update

2019-01-28 Thread David Sterba
On Thu, Jan 17, 2019 at 04:48:28PM +0800, YueHaibing wrote: > There are no in-tree callers. I'd rather see the code fixed, the patch that used the function was reverted because it was not safe to call sysfs from various contexts. I have some wip.

Re: [PATCH] btrfs: oops in device_list_add()

2019-01-28 Thread David Sterba
On Sun, Jan 27, 2019 at 04:58:00AM +, Al Viro wrote: > alloc_fs_devices() can return ERR_PTR(-ENOMEM), so > dereferencing its result before the check for IS_ERR() is > a bad idea... > > Fixes: d1a63002829a4 > Signed-off-by: Al Viro Thanks, added to 5.0-rc queue.

Re: RAID56 Warning on "multiple serious data-loss bugs"

2019-01-28 Thread Supercilious Dude
On Mon, 28 Jan 2019 at 01:18, Qu Wenruo wrote: > > So for current upstream kernel, there should be no major problem despite > write hole. Can you please elaborate on the implications of the write-hole? Does it mean that the transaction currently in-flight might be lost but the filesystem is othe

[PATCH AUTOSEL 4.19 168/258] btrfs: use tagged writepage to mitigate livelock of snapshot

2019-01-28 Thread Sasha Levin
From: Ethan Lien [ Upstream commit 3cd24c698004d2f7668e0eb9fc1f096f533c791b ] Snapshot is expected to be fast. But if there are writers steadily creating dirty pages in our subvolume, the snapshot may take a very long time to complete. To fix the problem, we use tagged writepage for snapshot flu

Re: RAID56 Warning on "multiple serious data-loss bugs"

2019-01-28 Thread Adam Borowski
On Mon, Jan 28, 2019 at 03:23:28PM +, Supercilious Dude wrote: > On Mon, 28 Jan 2019 at 01:18, Qu Wenruo wrote: > > > > So for current upstream kernel, there should be no major problem despite > > write hole. > > > Can you please elaborate on the implications of the write-hole? Does > it mea

[PATCH] btrfs: clean up pending block groups when transaction commit aborts

2019-01-28 Thread David Sterba
The fstests generic/475 stresses transaction aborts and can reveal space accounting or use-after-free bugs regarding block goups. In this case the pending block groups that remain linked to the structures after transaction commit aborts in the middle. The corrupted slabs lead to failures in follo

Re: [PATCH] btrfs: clean up pending block groups when transaction commit aborts

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 18:45 ч., David Sterba wrote: > The fstests generic/475 stresses transaction aborts and can reveal > space accounting or use-after-free bugs regarding block goups. > > In this case the pending block groups that remain linked to the > structures after transaction commit aborts in

[PATCH AUTOSEL 4.14 104/170] btrfs: harden agaist duplicate fsid on scanned devices

2019-01-28 Thread Sasha Levin
From: Anand Jain [ Upstream commit a9261d4125c97ce8624e9941b75dee1b43ad5df9 ] It's not that impossible to imagine that a device OR a btrfs image is copied just by using the dd or the cp command. Which in case both the copies of the btrfs will have the same fsid. If on the system with automount e

[PATCH AUTOSEL 4.19 161/258] btrfs: reada: reorder dev-replace locks before radix tree preload

2019-01-28 Thread Sasha Levin
From: David Sterba [ Upstream commit ceb21a8db48559fd0809e03c4df9eb37743d9170 ] The device-replace read lock is going to use rw semaphore in followup commits. The semaphore might sleep which is not possible in the radix tree preload section. The lock nesting is now: * device replace * radix t

[PATCH AUTOSEL 4.19 160/258] btrfs: harden agaist duplicate fsid on scanned devices

2019-01-28 Thread Sasha Levin
From: Anand Jain [ Upstream commit a9261d4125c97ce8624e9941b75dee1b43ad5df9 ] It's not that impossible to imagine that a device OR a btrfs image is copied just by using the dd or the cp command. Which in case both the copies of the btrfs will have the same fsid. If on the system with automount e

[PATCH AUTOSEL 4.20 200/304] btrfs: use tagged writepage to mitigate livelock of snapshot

2019-01-28 Thread Sasha Levin
From: Ethan Lien [ Upstream commit 3cd24c698004d2f7668e0eb9fc1f096f533c791b ] Snapshot is expected to be fast. But if there are writers steadily creating dirty pages in our subvolume, the snapshot may take a very long time to complete. To fix the problem, we use tagged writepage for snapshot flu

[PATCH AUTOSEL 4.20 191/304] btrfs: harden agaist duplicate fsid on scanned devices

2019-01-28 Thread Sasha Levin
From: Anand Jain [ Upstream commit a9261d4125c97ce8624e9941b75dee1b43ad5df9 ] It's not that impossible to imagine that a device OR a btrfs image is copied just by using the dd or the cp command. Which in case both the copies of the btrfs will have the same fsid. If on the system with automount e

[PATCH AUTOSEL 4.20 192/304] btrfs: reada: reorder dev-replace locks before radix tree preload

2019-01-28 Thread Sasha Levin
From: David Sterba [ Upstream commit ceb21a8db48559fd0809e03c4df9eb37743d9170 ] The device-replace read lock is going to use rw semaphore in followup commits. The semaphore might sleep which is not possible in the radix tree preload section. The lock nesting is now: * device replace * radix t

Re: [Patch v5 0/7] btrfs: qgroup: Delay subtree scan to reduce overhead

2019-01-28 Thread David Sterba
On Wed, Jan 23, 2019 at 03:15:11PM +0800, Qu Wenruo wrote: > Qu Wenruo (6): > btrfs: relocation: Delay reloc tree deletion after merge_reloc_roots() > btrfs: qgroup: Refactor btrfs_qgroup_trace_subtree_swap() > btrfs: qgroup: Introduce per-root swapped blocks infrastructure > btrfs: qgroup:

Re: [PATCH 5/6 v2] btrfs: merge btrfs_find_device() and find_device()

2019-01-28 Thread David Sterba
On Sat, Jan 19, 2019 at 02:48:55PM +0800, Anand Jain wrote: > Both btrfs_find_device() and find_device() does the same things expect > that latter function is not keen in seed device in the scan-context. So > merge them. > > Signed-off-by: Anand Jain I can't find a reply that this has been merge

Re: [PATCH] btrfs: clean up pending block groups when transaction commit aborts

2019-01-28 Thread David Sterba
On Mon, Jan 28, 2019 at 06:57:41PM +0200, Nikolay Borisov wrote: > > +static void btrfs_cleanup_pending_block_groups(struct btrfs_trans_handle > > *trans) > > +{ > > + struct btrfs_fs_info *fs_info = trans->fs_info; > > + struct btrfs_block_group_cache *block_group; > > + > > + w

[PATCH 09/11] btrfs: change set_level() to bound the level passed in

2019-01-28 Thread Dennis Zhou
Currently, the only user of set_level() is zlib which sets an internal workspace parameter. As level is now plumbed into get_workspace(), this can be handled there rather than separately. This repurposes set_level() to bound the level passed in so it can be used when setting the mounts compression

[PATCH 11/11] btrfs: add zstd compression level support

2019-01-28 Thread Dennis Zhou
Zstd compression requires different amounts of memory for each level of compression. The prior patches implemented indirection to allow for each compression type to manage their workspaces independently. This patch uses this indirection to implement compression level support for zstd. As mentioned

[PATCH 10/11] btrfs: zstd use the passed through level instead of default

2019-01-28 Thread Dennis Zhou
Zstd currently only supports the default level of compression. This patch switches to using the level passed in for btrfs zstd configuration. Zstd workspaces now keep track of the requested level as this can differ from the size of the workspace. Signed-off-by: Dennis Zhou --- fs/btrfs/zstd.c |

[PATCH 08/11] btrfs: plumb level through the compression interface

2019-01-28 Thread Dennis Zhou
Zlib compression supports multiple levels, but doesn't require changing in how a workspace itself is created and managed. Zstd introduces a different memory requirement such that higher levels of compression require more memory. This requires changes in how the alloc()/get() methods work for zstd.

[PATCH 06/11] btrfs: add compression interface in (get/put)_workspace()

2019-01-28 Thread Dennis Zhou
There are two levels of workspace management. First, alloc()/free() which are responsible for actually creating and destroy workspaces. Second, at a higher level, get()/put() which is the compression code asking for a workspace from a workspace_manager. The compression code shouldn't really care h

[PATCH 07/11] btrfs: move to fn pointers for get/put workspaces

2019-01-28 Thread Dennis Zhou
The previous patch added generic helpers for get_workspace() and put_workspace(). Now, we can migrate ownership of the workspace_manager to be in the compression type code as the compression code itself doesn't care beyond being able to get a workspace. The init/cleanup and get/put methods are abst

[PATCH 05/11] btrfs: add helper methods for workspace manager init and cleanup

2019-01-28 Thread Dennis Zhou
Workspace manager init and cleanup code is open coded inside a for loop over the compression types. This forces each compression type to rely on the same workspace manager implementation. This patch creates helper methods that will be the generic implementation for btrfs workspace management. Sign

[PATCH 04/11] btrfs: unify compression ops with workspace_manager

2019-01-28 Thread Dennis Zhou
Make the workspace_manager own the interface operations rather than managing index-paired arrays for the workspace_manager and compression operations. Signed-off-by: Dennis Zhou --- fs/btrfs/compression.c | 11 +++ 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/co

[PATCH 03/11] btrfs: manage heuristic workspace as index 0

2019-01-28 Thread Dennis Zhou
While the heuristic workspaces aren't really compression workspaces, they use the same interface for managing them. So rather than branching, let's just handle them once again as the index 0 compression type. Signed-off-by: Dennis Zhou --- fs/btrfs/compression.c | 107 +++---

[PATCH 02/11] btrfs: rename workspaces_list to workspace_manager

2019-01-28 Thread Dennis Zhou
This is in preparation for zstd compression levels. As each level will require different sized workspaces, workspaces_list is no longer a really fitting name. Signed-off-by: Dennis Zhou --- fs/btrfs/compression.c | 46 +- 1 file changed, 23 insertions(+),

[PATCH 00/11] btrfs: add zstd compression level support

2019-01-28 Thread Dennis Zhou
Hi everyone, This is a respin of [1] which aims to add zstd compression level support. V3 moves away from the using set_level() to resize workspaces in favor of just allocating a workspace of the appropriate level and using a timer to reclaim unused workspaces. Zstd compression requires different

[PATCH 01/11] btrfs: add macros for compression type and level

2019-01-28 Thread Dennis Zhou
It is very easy to miss places that rely on a certain bitshifting for decyphering the type_level overloading. Make macros handle this instead. Signed-off-by: Dennis Zhou --- fs/btrfs/compression.c | 2 +- fs/btrfs/compression.h | 3 +++ fs/btrfs/zlib.c| 2 +- 3 files changed, 5 insertion

Re: [PATCH 0/7] Abort cleanup fixes

2019-01-28 Thread David Sterba
On Wed, Nov 21, 2018 at 02:05:38PM -0500, Josef Bacik wrote: > A new xfstests that really hammers on transaction aborts (generic/495 I > think?) > uncovered a lot of random issues. Some of these were introduced with the new > delayed refs rsv patches, others were just exposed by them, such as the

Re: RAID56 Warning on "multiple serious data-loss bugs"

2019-01-28 Thread DanglingPointer
Thanks Qu! I thought as much from following the mailing list and your great work over the years! Would it be possible to get the wiki updated to reflect the current "real" status? From Qu's statement and perspective, there's no difference to other non-BTRFS software RAID56's out there that

Re: RAID56 Warning on "multiple serious data-loss bugs"

2019-01-28 Thread Remi Gauvin
On 2019-01-28 5:07 p.m., DanglingPointer wrote: > From Qu's statement and perspective, there's no difference to other > non-BTRFS software RAID56's out there that are marked as stable (except > ZFS). > Also there are no "multiple serious data-loss bugs". > Please do consider my proposal as it will

Re: RAID56 Warning on "multiple serious data-loss bugs"

2019-01-28 Thread Qu Wenruo
On 2019/1/29 上午6:07, DanglingPointer wrote: > Thanks Qu! > I thought as much from following the mailing list and your great work > over the years! > > Would it be possible to get the wiki updated to reflect the current > "real" status? > > From Qu's statement and perspective, there's no differe

[PATCH] btrfs-progs: balance: Sync the fs before balancing metadata chunks

2019-01-28 Thread Qu Wenruo
[BUG] Btrfs will report false ENOSPC balancing metadata chunk. The following script can easily reproduce it: #!/bin/bash dev=/dev/test/test mnt=/mnt/btrfs umount $dev &> /dev/null umount $mnt &> /dev/null mkfs.btrfs -f $dev mount $dev $mnt btrfs subv create $mnt/subv for ((i =

[PATCH v2] btrfs: Test if btrfs will commit too many transaction for balance

2019-01-28 Thread Qu Wenruo
Kernel commit 64403612b73a ("btrfs: rework btrfs_check_space_for_delayed_refs") is introducing a regression for btrfs balance performance. Since that commit will cause btrfs to commit transaction for nothing during transaction, it will slow balance dramatically even we only need to relocate severa

Re: [PATCH 11/11] btrfs: add zstd compression level support

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 23:24 ч., Dennis Zhou wrote: > Zstd compression requires different amounts of memory for each level of > compression. The prior patches implemented indirection to allow for each > compression type to manage their workspaces independently. This patch > uses this indirection to impl

Re: [PATCH 01/11] btrfs: add macros for compression type and level

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 23:24 ч., Dennis Zhou wrote: > It is very easy to miss places that rely on a certain bitshifting for > decyphering the type_level overloading. Make macros handle this instead. > > Signed-off-by: Dennis Zhou Reviewed-by: Nikolay Borisov

Re: [PATCH 02/11] btrfs: rename workspaces_list to workspace_manager

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 23:24 ч., Dennis Zhou wrote: > This is in preparation for zstd compression levels. As each level will > require different sized workspaces, workspaces_list is no longer a > really fitting name. > > Signed-off-by: Dennis Zhou Reviewed-by: Nikolay Borisov > --- > fs/btrfs/comp

[PATCH] btrfs: Test if btrfs will report false ENOSPC error balnacing small metadata chunk

2019-01-28 Thread Qu Wenruo
This is a long existing bug, caused by over-estimated metadata space_info::bytes_may_use. There is one purposed patch for btrfs-progs to fix it, titled: "btrfs-progs: balance: Sync the fs before balancing metadata chunks" The test case itself is almost the same as btrfs/181, which use small files

Re: [PATCH 03/11] btrfs: manage heuristic workspace as index 0

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 23:24 ч., Dennis Zhou wrote: > While the heuristic workspaces aren't really compression workspaces, > they use the same interface for managing them. So rather than branching, > let's just handle them once again as the index 0 compression type. > > Signed-off-by: Dennis Zhou Rev

Re: [PATCH 04/11] btrfs: unify compression ops with workspace_manager

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 23:24 ч., Dennis Zhou wrote: > Make the workspace_manager own the interface operations rather than > managing index-paired arrays for the workspace_manager and compression > operations. > > Signed-off-by: Dennis Zhou Reviewed-by: Nikolay Borisov > --- > fs/btrfs/compression.

Re: [PATCH 05/11] btrfs: add helper methods for workspace manager init and cleanup

2019-01-28 Thread Nikolay Borisov
On 28.01.19 г. 23:24 ч., Dennis Zhou wrote: > Workspace manager init and cleanup code is open coded inside a for loop > over the compression types. This forces each compression type to rely on > the same workspace manager implementation. This patch creates helper > methods that will be the gener