[PATCH v5 4/4] btrfs: Refactor find_free_extent() loops update into find_free_extent_update_loop()

2018-11-01 Thread Qu Wenruo
We have a complex loop design for find_free_extent(), that has different behavior for each loop, some even includes new chunk allocation. Instead of putting such a long code into find_free_extent() and makes it harder to read, just extract them into find_free_extent_update_loop(). With all the

[PATCH v5 2/4] btrfs: Refactor clustered extent allocation into find_free_extent_clustered()

2018-11-01 Thread Qu Wenruo
We have two main methods to find free extents inside a block group: 1) clustered allocation 2) unclustered allocation This patch will extract the clustered allocation into find_free_extent_clustered() to make it a little easier to read. Instead of jumping between different labels in

[PATCH v5 3/4] btrfs: Refactor unclustered extent allocation into find_free_extent_unclustered()

2018-11-01 Thread Qu Wenruo
This patch will extract unclsutered extent allocation code into find_free_extent_unclustered(). And this helper function will use return value to indicate what to do next. This should make find_free_extent() a little easier to read. Signed-off-by: Qu Wenruo Reviewed-by: Su Yue Reviewed-by:

[PATCH v5 0/4] btrfs: Refactor find_free_extent()

2018-11-01 Thread Qu Wenruo
Can be fetched from github: https://github.com/adam900710/linux/tree/refactor_find_free_extent Which is based on david's misc-4.20 branch. The base head is: commit 9084cb6a24bf5838a665af92ded1af8363f9e563 (david/misc-4.20) Author: Filipe Manana Date: Mon Oct 22 10:43:06 2018 +0100 Btrfs:

[PATCH v5 1/4] btrfs: Introduce find_free_extent_ctl structure for later rework

2018-11-01 Thread Qu Wenruo
Instead of tons of different local variables in find_free_extent(), extract them into find_free_extent_ctl structure, and add better explanation for them. Some modification may looks redundant, but will later greatly simplify function parameter list during find_free_extent() refactor. Also add

Re: btrfs partition is broken, cannot restore anything

2018-11-01 Thread Qu Wenruo
On 2018/11/2 上午4:40, Attila Vangel wrote: > Hi, > > Somehow my btrfs partition got broken. I use Arch, so my kernel is > quite new (4.18.x). > I don't remember exactly the sequence of events. At some point it was > accessible in read-only, but unfortunately I did not take backup > immediately.

Re: [PATCH v4 0/4] btrfs: Refactor find_free_extent()

2018-11-01 Thread Qu Wenruo
On 2018/11/2 上午2:54, David Sterba wrote: > On Wed, Oct 17, 2018 at 02:56:02PM +0800, Qu Wenruo wrote: >> Can be fetched from github: >> https://github.com/adam900710/linux/tree/refactor_find_free_extent > > Can you please rebase it again, on top of current misc-4.20? Ie. the 2nd > pull request.

btrfs partition is broken, cannot restore anything

2018-11-01 Thread Attila Vangel
Hi, Somehow my btrfs partition got broken. I use Arch, so my kernel is quite new (4.18.x). I don't remember exactly the sequence of events. At some point it was accessible in read-only, but unfortunately I did not take backup immediately. dmesg log from that time: [ 62.602388] BTRFS warning

Re: [PATCH 8/8] btrfs: Remove extent_io_ops::split_extent_hook callback

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:53PM +0200, Nikolay Borisov wrote: > This is the counterpart to merge_extent_hook, similarly, it's used only > for data/freespace inodes so let's remove it, rename it and call it > directly where necessary. No functional changes. > > Signed-off-by: Nikolay Borisov >

Re: [PATCH 7/8] btrfs: Remove extent_io_ops::merge_extent_hook callback

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:52PM +0200, Nikolay Borisov wrote: > This callback is used only for data and free space inodes. Such inodes > are guaranteed to have their extent_io_tree::private_data set to the > inode struct. Exploit this fact to directly call the function. Also > give it a more

Re: [PATCH 6/8] btrfs: Remove extent_io_ops::clear_bit_hook callback

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:51PM +0200, Nikolay Borisov wrote: > This is the counterpart to ex-set_bit_hook (now btrfs_set_delalloc_extent), > similar to what was done before remove clear_bit_hook and rename the > function. No functional changes. > > Signed-off-by: Nikolay Borisov

Re: [PATCH 5/8] btrfs: Remove extent_io_ops::set_bit_hook extent_io callback

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:50PM +0200, Nikolay Borisov wrote: > This callback is used to properly account delalloc extents for > data inodes (ordinary file inodes and freespace v1 inodes). Those can > be easily identified since they have their extent_io trees > ->private_data member point to

Re: [PATCH 4/8] btrfs: Remove extent_io_ops::check_extent_io_range callback

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:49PM +0200, Nikolay Borisov wrote: > This callback was only used in debug builds by btrfs_leak_debug_check. > A better approach is to move its implementation in > btrfs_leak_debug_check and ensure the latter is only executed for > extent tree which have ->private_data

Re: [PATCH 3/8] btrfs: Remove extent_io_ops::writepage_end_io_hook

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:48PM +0200, Nikolay Borisov wrote: > This callback is ony ever called for data page writeout so > there is no need to actually abstract it via extent_io_ops. Lets just > export it, remove the definition of the callback and call it directly > in the functions that

Re: [PATCH 2/8] btrfs: Remove extent_io_ops::writepage_start_hook

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:47PM +0200, Nikolay Borisov wrote: > This hook is called only from __extent_writepage_io which is already > called only from the data page writeout path. So there is no need to > make an indirect call via extent_io_ops. This patch just removes the > callback

Re: [PATCH 1/8] btrfs: Remove extent_io_ops::fill_delalloc

2018-11-01 Thread Josef Bacik
On Thu, Nov 01, 2018 at 02:09:46PM +0200, Nikolay Borisov wrote: > This callback is called only from writepage_delalloc which in turn > is guaranteed to be called from the data page writeout path. In the end > there is no reason to have the call to this function to be indrected > via the

Re: [PATCH v4 0/4] btrfs: Refactor find_free_extent()

2018-11-01 Thread David Sterba
On Wed, Oct 17, 2018 at 02:56:02PM +0800, Qu Wenruo wrote: > Can be fetched from github: > https://github.com/adam900710/linux/tree/refactor_find_free_extent Can you please rebase it again, on top of current misc-4.20? Ie. the 2nd pull request. There were some fixes to the space infos, a new

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 02:49:03PM +0800, Ethan Lien wrote: > Snapshot is expected to be fast. But if there are writers steadily > create 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 > flusher as we do

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Chris Mason
On 1 Nov 2018, at 12:00, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:29:48PM +0100, David Sterba wrote: >>> >>> How is that? kthread_stop() frees the task struct, so >>> wake_up_process() >>> would be a use-after-free. >> >> That was an assumption for the demonstration purposes, the

Re: [PATCH] Btrfs: fix missing data checksums after a ranged fsync (msync)

2018-11-01 Thread David Sterba
On Mon, Oct 29, 2018 at 09:42:06AM +, fdman...@kernel.org wrote: > From: Filipe Manana > > Recently we got a massive simplification for fsync, where for the fast > path we no longer log new extents while their respective ordered extents > are still running. > > However that simplification

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 06:50:03PM +0200, Nikolay Borisov wrote: > > > On 1.11.18 г. 18:44 ч., David Sterba wrote: > > On Thu, Nov 01, 2018 at 09:00:56AM -0700, Omar Sandoval wrote: > >>> That was an assumption for the demonstration purposes, the wording was > >>> confusing sorry. > >> > >> Oh,

Re: [PATCH RFC RESEND] btrfs: harden agaist duplicate fsid

2018-11-01 Thread David Sterba
On Mon, Oct 15, 2018 at 10:45:17AM +0800, Anand Jain wrote: > (Thanks for the comments on requiring to warn_on if we fail the device > change.) > (This fixes an ugly bug, I appreciate if you have any further comments). > > Its not that impossible to imagine that a device OR a btrfs image is >

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 18:44 ч., David Sterba wrote: > On Thu, Nov 01, 2018 at 09:00:56AM -0700, Omar Sandoval wrote: >>> That was an assumption for the demonstration purposes, the wording was >>> confusing sorry. >> >> Oh, well in that case, that's exactly what kthread_park() is ;) Stop the >> thread

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 09:00:56AM -0700, Omar Sandoval wrote: > > That was an assumption for the demonstration purposes, the wording was > > confusing sorry. > > Oh, well in that case, that's exactly what kthread_park() is ;) Stop the > thread and make wake_up a noop, and then we don't need to

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 04:29:48PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 08:24:25AM -0700, Omar Sandoval wrote: > > On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > > > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > > > On Thu, Nov 01, 2018 at

Re: [PATCH v2] btrfs: add zstd compression level support

2018-11-01 Thread Nick Terrell
> On Nov 1, 2018, at 5:57 AM, Timofey Titovets wrote: > > ср, 31 окт. 2018 г. в 21:12, Nick Terrell : >> >> From: Jennifer Liu >> >> Adds zstd compression level support to btrfs. Zstd requires >> different amounts of memory for each level, so the design had >> to be modified to allow

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 08:24:25AM -0700, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > > On 1 Nov 2018, at 6:15, David

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 08:23:17AM -0700, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700,

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 08:24:25AM -0700, Omar Sandoval wrote: > On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > > On 1 Nov 2018, at 6:15, David

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 04:22:29PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700,

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Omar Sandoval
On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > > >> From: Omar Sandoval > > >> > > >> There's a

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 04:08:32PM +0100, David Sterba wrote: > On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > > >> From: Omar Sandoval > > >> > > >> There's a

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 16:35 ч., Nikolay Borisov wrote: > > > On 31.10.18 г. 19:06 ч., Omar Sandoval wrote: >> From: Omar Sandoval >> >> There's a race between close_ctree() and cleaner_kthread(). >> close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it >> sees it set, but this is

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Thu, Nov 01, 2018 at 01:31:18PM +, Chris Mason wrote: > On 1 Nov 2018, at 6:15, David Sterba wrote: > > > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > >> From: Omar Sandoval > >> > >> There's a race between close_ctree() and cleaner_kthread(). > >> close_ctree() sets

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Nikolay Borisov
On 31.10.18 г. 19:06 ч., Omar Sandoval wrote: > From: Omar Sandoval > > There's a race between close_ctree() and cleaner_kthread(). > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > sees it set, but this is racy; the cleaner might have already checked > the bit and

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread Chris Mason
On 1 Nov 2018, at 6:15, David Sterba wrote: > On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: >> From: Omar Sandoval >> >> There's a race between close_ctree() and cleaner_kthread(). >> close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it >> sees it set, but this

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread Chris Mason
On 1 Nov 2018, at 6:21, ethanlien wrote: > Nikolay Borisov 於 2018-11-01 18:01 寫到: >> On 1.11.18 г. 11:56 ч., ethanlien wrote: >>> Nikolay Borisov 於 2018-11-01 16:59 寫到: On 1.11.18 г. 8:49 ч., Ethan Lien wrote: > Snapshot is expected to be fast. But if there are writers steadily >

[PATCH 2/8] btrfs: Remove extent_io_ops::writepage_start_hook

2018-11-01 Thread Nikolay Borisov
This hook is called only from __extent_writepage_io which is already called only from the data page writeout path. So there is no need to make an indirect call via extent_io_ops. This patch just removes the callback definition, exports the callback function and calls it directly at the only call

[PATCH 3/8] btrfs: Remove extent_io_ops::writepage_end_io_hook

2018-11-01 Thread Nikolay Borisov
This callback is ony ever called for data page writeout so there is no need to actually abstract it via extent_io_ops. Lets just export it, remove the definition of the callback and call it directly in the functions that invoke the callback. Also rename the function to

[PATCH 5/8] btrfs: Remove extent_io_ops::set_bit_hook extent_io callback

2018-11-01 Thread Nikolay Borisov
This callback is used to properly account delalloc extents for data inodes (ordinary file inodes and freespace v1 inodes). Those can be easily identified since they have their extent_io trees ->private_data member point to the inode. Let's exploit this fact to remove the needless indirection

[PATCH 7/8] btrfs: Remove extent_io_ops::merge_extent_hook callback

2018-11-01 Thread Nikolay Borisov
This callback is used only for data and free space inodes. Such inodes are guaranteed to have their extent_io_tree::private_data set to the inode struct. Exploit this fact to directly call the function. Also give it a more descriptive name. No functional changes. Signed-off-by: Nikolay Borisov

[PATCH 8/8] btrfs: Remove extent_io_ops::split_extent_hook callback

2018-11-01 Thread Nikolay Borisov
This is the counterpart to merge_extent_hook, similarly, it's used only for data/freespace inodes so let's remove it, rename it and call it directly where necessary. No functional changes. Signed-off-by: Nikolay Borisov --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/extent_io.c | 10 ++

[PATCH 1/8] btrfs: Remove extent_io_ops::fill_delalloc

2018-11-01 Thread Nikolay Borisov
This callback is called only from writepage_delalloc which in turn is guaranteed to be called from the data page writeout path. In the end there is no reason to have the call to this function to be indrected via the extent_io_ops structure. This patch removes the callback definition, exports the

[PATCH 6/8] btrfs: Remove extent_io_ops::clear_bit_hook callback

2018-11-01 Thread Nikolay Borisov
This is the counterpart to ex-set_bit_hook (now btrfs_set_delalloc_extent), similar to what was done before remove clear_bit_hook and rename the function. No functional changes. Signed-off-by: Nikolay Borisov --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/extent_io.c | 12

[PATCH 4/8] btrfs: Remove extent_io_ops::check_extent_io_range callback

2018-11-01 Thread Nikolay Borisov
This callback was only used in debug builds by btrfs_leak_debug_check. A better approach is to move its implementation in btrfs_leak_debug_check and ensure the latter is only executed for extent tree which have ->private_data set i.e. relate to a data node and not the btree one. No functional

[PATCH 0/8] Removal of optional hooks from struct extent_io_ops

2018-11-01 Thread Nikolay Borisov
extent_io_ops has a set of 8 optional hooks which are set only for data and freespace inodes. The majority of them actually deal with delallocs in one way or another. Inspecting the code it transpired that there is actually no need to have them as function pointers in a structure. Data/freespace

BTRFS RAID5 disk failed while balancing

2018-11-01 Thread Oliver R.
If you clicked on the link to this topic: Thank you! I have the following setup: 6x 500GB HDD-Drives 1x 32GB NVME-SSD (Intel Optane) I used bcache to setup up the SSD as caching device and all other six drives are backing devices. After all that was in place, I formatted the six HHDs with

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 8:49 ч., Ethan Lien wrote: > Snapshot is expected to be fast. But if there are writers steadily > create 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 > flusher as we do in the generic

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread ethanlien
Nikolay Borisov 於 2018-11-01 18:01 寫到: On 1.11.18 г. 11:56 ч., ethanlien wrote: Nikolay Borisov 於 2018-11-01 16:59 寫到: On 1.11.18 г. 8:49 ч., Ethan Lien wrote: Snapshot is expected to be fast. But if there are writers steadily create dirty pages in our subvolume, the snapshot may take a very

Re: [PATCH v2] Btrfs: fix missing delayed iputs on unmount

2018-11-01 Thread David Sterba
On Wed, Oct 31, 2018 at 10:06:08AM -0700, Omar Sandoval wrote: > From: Omar Sandoval > > There's a race between close_ctree() and cleaner_kthread(). > close_ctree() sets btrfs_fs_closing(), and the cleaner stops when it > sees it set, but this is racy; the cleaner might have already checked >

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 11:56 ч., ethanlien wrote: > Nikolay Borisov 於 2018-11-01 16:59 寫到: >> On 1.11.18 г. 8:49 ч., Ethan Lien wrote: >>> Snapshot is expected to be fast. But if there are writers steadily >>> create dirty pages in our subvolume, the snapshot may take a very long >>> time to complete.

Re: [PATCH v2] btrfs: add zstd compression level support

2018-11-01 Thread Timofey Titovets
ср, 31 окт. 2018 г. в 21:12, Nick Terrell : > > From: Jennifer Liu > > Adds zstd compression level support to btrfs. Zstd requires > different amounts of memory for each level, so the design had > to be modified to allow set_level() to allocate memory. We > preallocate one workspace of the

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread ethanlien
Nikolay Borisov 於 2018-11-01 16:59 寫到: On 1.11.18 г. 8:49 ч., Ethan Lien wrote: Snapshot is expected to be fast. But if there are writers steadily create 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

Re: [PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread Nikolay Borisov
On 1.11.18 г. 8:49 ч., Ethan Lien wrote: > Snapshot is expected to be fast. But if there are writers steadily > create 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 > flusher as we do in the generic

[Spam]Quick Response

2018-11-01 Thread Annable Katherine Grosvenor
Good day, My name is Annable Katherine Grosvenor, I'm 57yrs old, a widow, no kids, from the United Kingdom, I'm very sorry to bother you with this message but it is very important for me that I send out this message because I am very sick and at the point of death, I'm diagnosed with Ovarian

[PATCH] btrfs: use tagged writepage to mitigate livelock of snapshot

2018-11-01 Thread Ethan Lien
Snapshot is expected to be fast. But if there are writers steadily create 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 flusher as we do in the generic write_cache_pages(), so we can ommit pages dirtied