hang in btrfs_async_reclaim_metadata_space

2018-01-05 Thread Adam Borowski
Hi! I got a reproducible infinite hang, reliably triggered by the testsuite of "flatpak"; fails on at least 4.15-rc6, 4.9.75, and on another machine with Debian's 4.14.2-1. [580632.355107] INFO: task kworker/u8:2:11105 blocked for more than 120 seconds. [580632.355120] Not tainted 4.14.0-1-a

btrfs quota exceeded notifications through netlink sockets

2018-01-05 Thread Karsai, Gabor
I created a subvolume on a btrfs, set a limit and the quota is enforced - dumping too much data into the subvolume results in a 'quota exceeded' message (from dd, for example). But when I am trying to get netlink socket notifications, nothing arrives on the socket (I am using pyroute2 which is

[PATCH v2 00/10] bugfixes and regression tests of btrfs_get_extent

2018-01-05 Thread Liu Bo
Although commit e6c4efd87ab0 ("btrfs: Fix and enhance merge_extent_mapping() to insert best fitted extent map") fixed up the negetive em->len, it has introduced several regressions, several has been fixed by commit 32be3a1ac6d0 ("btrfs: Fix the wrong condition judgment about subset extent map")

[PATCH v2 04/10] Btrfs: move extent map specific code to extent_map.c

2018-01-05 Thread Liu Bo
These helpers are extent map specific, move them to extent_map.c. Signed-off-by: Liu Bo --- fs/btrfs/ctree.h | 2 - fs/btrfs/extent_map.c | 125 ++ fs/btrfs/extent_map.h | 2 + fs/btrfs/inode.c | 107 --

[PATCH v2 08/10] Btrfs: add WARN_ONCE to detect unexpected error from merge_extent_mapping

2018-01-05 Thread Liu Bo
This is a subtle case, so in order to understand the problem, it'd be good to know the content of existing and em when any error occurs. Signed-off-by: Liu Bo --- v2: Remove unnecessary KERN_INFO. fs/btrfs/extent_map.c | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/f

[PATCH v2 10/10] Btrfs: noinline merge_extent_mapping

2018-01-05 Thread Liu Bo
In order to debug subtle bugs around merge_extent_mapping(), perf probe can be used to check the arguments, but sometimes merge_extent_mapping() got inlined by compiler and couldn't be probed. This is adding noinline attribute to merge_extent_mapping(). Signed-off-by: Liu Bo --- fs/btrfs/extent

[PATCH v2 07/10] Btrfs: extent map selftest: dio write vs dio read

2018-01-05 Thread Liu Bo
This test case simulates the racy situation of dio write vs dio read, and see if btrfs_get_extent() would return -EEXIST. Signed-off-by: Liu Bo --- fs/btrfs/tests/extent-map-tests.c | 88 +++ 1 file changed, 88 insertions(+) diff --git a/fs/btrfs/tests/extent

[PATCH v2 06/10] Btrfs: extent map selftest: buffered write vs dio read

2018-01-05 Thread Liu Bo
This test case simulates the racy situation of buffered write vs dio read, and see if btrfs_get_extent() would return -EEXIST. Signed-off-by: Liu Bo --- fs/btrfs/tests/extent-map-tests.c | 73 +++ 1 file changed, 73 insertions(+) diff --git a/fs/btrfs/tests/e

[PATCH v2 05/10] Btrfs: add extent map selftests

2018-01-05 Thread Liu Bo
We've observed that btrfs_get_extent() and merge_extent_mapping() could return -EEXIST in several cases, and they are caused by some racy condition, e.g dio read vs dio write, which makes the problem very tricky to reproduce. This adds extent map selftests in order to simulate those racy situation

[PATCH v2 01/10] Btrfs: fix incorrect block_len in merge_extent_mapping

2018-01-05 Thread Liu Bo
%block_len could be checked on deciding if two em are mergeable. merge_extent_mapping() has only added the front pad if the front part of em gets truncated, but it's possible that the end part gets truncated. For both compressed extent and inline extent, em->block_len is not adjusted accordingly,

[PATCH v2 02/10] Btrfs: fix unexpected EEXIST from btrfs_get_extent

2018-01-05 Thread Liu Bo
This fixes a corner case that is caused by a race of dio write vs dio read/write. Here is how the race could happen. Suppose that no extent map has been loaded into memory yet. There is a file extent [0, 32K), two jobs are running concurrently against it, t1 is doing dio write to [8K, 32K) and t2

[PATCH v2 09/10] Btrfs: add tracepoint for em's EEXIST case

2018-01-05 Thread Liu Bo
This is adding a tracepoint 'btrfs_handle_em_exist' to help debug the subtle bugs around merge_extent_mapping. Signed-off-by: Liu Bo --- fs/btrfs/extent_map.c| 3 +++ include/trace/events/btrfs.h | 35 +++ 2 files changed, 38 insertions(+) diff --git a/f

[PATCH v2 03/10] Btrfs: add helper for em merge logic

2018-01-05 Thread Liu Bo
This is a prepare work for the following extent map selftest, which runs tests against em merge logic. Signed-off-by: Liu Bo --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/inode.c | 80 2 files changed, 48 insertions(+), 34 deletions(-) diff --gi

Btrfs progs release 4.14.1

2018-01-05 Thread David Sterba
Hi, btrfs-progs version 4.14.1 have been released. Changes: * dump-tree: print times of root items * check: fix several lowmem mode bugs * convert: fix rollback after balance * other * new and updated tests, enabled lowmem mode in CI * docs updates * fix travis CI build *

Re: [PATCH v3] Btrfs: avoid losing data raid profile when deleting a device

2018-01-05 Thread David Sterba
On Wed, Nov 15, 2017 at 04:28:11PM -0700, Liu Bo wrote: > We've avoided data losing raid profile when doing balance, but it > turns out that deleting a device could also result in the same > problem. > > Say we have 3 disks, and they're created with '-d raid1' profile. > > - We have chunk P (the

[GIT PULL] Btrfs fixes for 4.15-rc7

2018-01-05 Thread David Sterba
Hi, we have two more fixes for 4.15, aimed for stable. The leak fix is obvious, the second patch fixes a bug revealed by the refcount API, when it behaves differently than previous atomic_t and reports refs going from 0 to 1 in one case. No merge conflicts. Please pull, thanks. The following cha

Awaiting for your confirmation

2018-01-05 Thread Emma Aiden
09 We now need Invoice. http://www.petewalker.me/Invoices-attached/ This correspondence and any files transmitted with it are confidential and intended solely for the use of the intended recipient(s) to whom it is addressed. Emma Aiden

Re: [PATCH v4] Btrfs: add support for fallocate's zero range operation

2018-01-05 Thread David Sterba
On Sat, Nov 04, 2017 at 04:07:47AM +, fdman...@kernel.org wrote: > From: Filipe Manana > > This implements support the zero range operation of fallocate. For now > at least it's as simple as possible while reusing most of the existing > fallocate and hole punching infrastructure. > > Signed-

Re: [PATCH] btrfs: handle failure of add_pending_csums

2018-01-05 Thread David Sterba
On Tue, Dec 05, 2017 at 01:51:43PM +0200, Nikolay Borisov wrote: > add_pending_csums was added as part of the new data=ordered implementation in > e6dcd2dc9c48 ("Btrfs: New data=ordered implementation"). Even back then it > called the btrfs_csum_file_blocks which can fail but it never bothered > h

Re: [PATCH 0/3] Btrfs: loop retry on raid6 read failures

2018-01-05 Thread David Sterba
On Mon, Dec 04, 2017 at 03:40:34PM -0700, Liu Bo wrote: > Patch 1 is a simple cleanup. > Patch 2 fixes a bug in raid56 rbio merging code. > Patch 3 fixes a bug in raid6 reconstruction process which can end up > read failure when it can rebuild up good data. > > Liu Bo (3): > Btrfs: remove redund

Re: [PATCH] btrfs: add missing BTRFS_SUPER_FLAG define

2018-01-05 Thread David Sterba
On Fri, Jan 05, 2018 at 05:24:22PM +0800, Anand Jain wrote: > btrfs-progs uses additional two super flag bits. So just define > that so that we know its been used. > > Signed-off-by: Anand Jain > --- > The btrfs-progs commits (very old) introduced them, > > commit 7cc792872a133cabc3467e6ccaf5a2

Re: [PATCH 3/3] btrfs: misc cleanup btrfs_scan_one_device()

2018-01-05 Thread David Sterba
On Fri, Dec 15, 2017 at 03:40:16PM +0800, Anand Jain wrote: > Assign ret = -EINVAL where actually its required. > Remove { } around single line if else code. > > Signed-off-by: Anand Jain Added to next, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body

Re: [PATCH 2/3] btrfs: optimize move uuid_mutex closer to the critical section

2018-01-05 Thread David Sterba
On Fri, Dec 15, 2017 at 03:40:15PM +0800, Anand Jain wrote: > Move uuid_mutex closer to the exclusion section. Looks good, there's really something unrelated inside the critical section so this could potentially speed up scanning devices. Reviewed-by: David Sterba -- To unsubscribe from this lis

Re: [PATCH 1/3] btrfs: make code easy to read in btrfs_open_one_device()

2018-01-05 Thread David Sterba
On Fri, Dec 15, 2017 at 03:40:14PM +0800, Anand Jain wrote: > No functional change. First set the usual case, writeable then check > for any special config. > > Signed-off-by: Anand Jain > --- > fs/btrfs/volumes.c | 8 +++- > 1 file changed, 3 insertions(+), 5 deletions(-) > > diff --git a/

Filesystem corruption (v4.14) & btrfs-progs btrfs check --repair loop

2018-01-05 Thread Joerie de Gram
Hi, My filesytem appears to have become corrupted and btrfs check appears to get stuck in an infinite loop trying to repair it. The issue initially manifested itself as a BUG (RIP: btrfs_set_item_key_safe+0x132/0x190) on v4.14.8 - see attached dmesg.txt. I do not know whether this is the cause of

Re: [PATCH] Btrfs: replace raid56 stripe bubble sort with insert sort

2018-01-05 Thread Filipe Manana
On Wed, Jan 3, 2018 at 3:39 PM, Timofey Titovets wrote: > 2018-01-03 14:40 GMT+03:00 Filipe Manana : >> On Thu, Dec 28, 2017 at 3:28 PM, Timofey Titovets >> wrote: >>> Insert sort are generaly perform better then bubble sort, >>> by have less iterations on avarage. >>> That version also try plac

Re: [PATCH] btrfs: optimize code converge mutex unlock

2018-01-05 Thread David Sterba
On Wed, Dec 20, 2017 at 10:19:14AM +0200, Nikolay Borisov wrote: > > > On 20.12.2017 08:42, Anand Jain wrote: > > No functional change rearrange the mutex_unlock. > > > > Signed-off-by: Anand Jain > > Reviewed-by: Nikolay Borisov Added to for-next. -- To unsubscribe from this list: send the

Re: [PATCH] btrfs: rename btrfs_device::scrub_device to scrub_ctx

2018-01-05 Thread David Sterba
On Wed, Jan 03, 2018 at 04:08:30PM +0800, Anand Jain wrote: > btrfs_device::scrub_device is not a device which is being scrubbed, > but it holds the scrub context, so rename to reflect the same. No > functional changes here. > > Signed-off-by: Anand Jain Reviewed-by: David Sterba -- To unsubscr

Re: [PATCH 2/2] btrfS: collapse btrfs_handle_error() into __btrfs_handle_fs_error()

2018-01-05 Thread David Sterba
On Thu, Jan 04, 2018 at 02:11:21PM +0200, Nikolay Borisov wrote: > > > On 4.01.2018 12:01, Anand Jain wrote: > > There is no other consumer for btrfs_handle_error() other than > > __btrfs_handle_fs_error(), further this function quite small. > > Merge it into its parent. > > > > Signed-off-by:

Re: [PATCH 1/2 RESEND] Btrfs: make raid6 rebuild retry more

2018-01-05 Thread David Sterba
On Tue, Jan 02, 2018 at 01:36:41PM -0700, Liu Bo wrote: > There is a scenario that can end up with rebuild process failing to > return good content, i.e. > suppose that all disks can be read without problems and if the content > that was read out doesn't match its checksum, currently for raid6 > bt

Re: [PATCH] btrfs: Don't generate UUID for non-fs tree

2018-01-05 Thread David Sterba
On Thu, Jan 04, 2018 at 09:38:46AM +0800, Qu Wenruo wrote: > >> - uuid_le uuid; > >> + uuid_le uuid = { 0 }; > > > > I get a warning with gcc 4.8.5 > > > > fs/btrfs/disk-io.c:1236:2: warning: missing braces around initializer > > [-Wmissing-braces] > > > > but no warning with gcc 7.2.1 (built

[v6 05/16] btrfs-progs: scrub: Introduce functions to scrub mirror based tree block

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce new functions, check/recover_tree_mirror(), to check and recover mirror-based tree blocks (Single/DUP/RAID0/1/10). check_tree_mirror() can also be used on in-memory tree blocks using @data parameter. This is very handy for RAID5/6 case, either checking the data stripe t

[v6 07/16] btrfs-progs: scrub: Introduce function to scrub one mirror-based extent

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, scrub_one_extent(), as a wrapper to check one mirror-based extent. It will accept a btrfs_path parameter @path, which must point to a META/EXTENT_ITEM. And @start, @len, which must be a subset of META/EXTENT_ITEM. Signed-off-by: Qu Wenruo Signed-off-by

[v6 04/16] btrfs-progs: scrub: Introduce structures to support offline scrub for RAID56

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introuduce new local structures, scrub_full_stripe and scrub_stripe, for incoming offline RAID56 scrub support. For pure stripe/mirror based profiles, like raid0/1/10/dup/single, we will follow the original bytenr and mirror number based iteration, so they don't need any extra st

[v6 09/16] btrfs-progs: scrub: Introduce function to verify parities

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, verify_parities(), to check whether parities match with full stripe, whose data stripes match with their csum. Caller should fill the scrub_full_stripe structure properly before calling this function. Signed-off-by: Qu Wenruo Signed-off-by: Gu Jinxiang

[v6 14/16] btrfs-progs: scrub: Introduce function to check a whole block group

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, scrub_one_block_group(), to scrub a block group. For Single/DUP/RAID0/RAID1/RAID10, we use old mirror number based map_block, and check extent by extent. For parity based profile (RAID5/6), we use new map_block_v2() and check full stripe by full stripe.

[v6 10/16] btrfs-progs: extent-tree: Introduce function to check if there is any extent in given range.

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, btrfs_check_extent_exists(), to check if there is any extent in the range specified by user. The parameter can be a large range, and if any extent exists in the range, it will return >0 (in fact it will return 1). Or return 0 if no extent is found. Sign

[v6 08/16] btrfs-progs: scrub: Introduce function to scrub one data stripe

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, scrub_one_data_stripe(), to check all data and tree blocks inside the data stripe. This function will not try to recovery any error, but only check if any data/tree blocks has mismatch csum. If data missing csum, which is completely valid for case like no

[v6 03/16] btrfs-progs: csum: Introduce function to read out data csums

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function: btrfs_read_data_csums(), to read out csums for sectors in range. This is quite useful for read out data csum so we don't need to do it using open code. Signed-off-by: Qu Wenruo Signed-off-by: Su Yue Signed-off-by: Gu Jinxiang --- Makefile | 2

[v6 11/16] btrfs-progs: scrub: Introduce function to recover data parity

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce function, recover_from_parities(), to recover data stripes. It just wraps raid56_recov() with extra check functions to scrub_full_stripe structure. Signed-off-by: Qu Wenruo --- scrub.c | 51 +++ 1 file changed, 51 inser

[v6 16/16] btrfs-progs: add test for offline-scrub

2018-01-05 Thread Gu Jinxiang
Add a test for offline-scrub. The process of this test case: 1)create a filesystem with profile raid10 2)mount the filesystem, create a file in the mount point, and write some data to the file 3)get the logical address of the file's extent data 4)get the physical address of the logical address 5)ov

[v6 01/16] btrfs-progs: Introduce new btrfs_map_block function which returns more unified result.

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, __btrfs_map_block_v2(). Unlike old btrfs_map_block(), which needs different parameter to handle different RAID profile, this new function uses unified btrfs_map_block structure to handle all RAID profile in a more meaningful method: Return physical addr

[v6 15/16] btrfs-progs: scrub: Introduce offline scrub function

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Now, btrfs-progs has a kernel scrub equivalent. A new option, --offline is added to "btrfs scrub start". If --offline is given, btrfs scrub will just act like kernel scrub, to check every copy of extent and do a report on corrupted data and if it's recoverable. The advantage com

[v6 12/16] btrfs-progs: scrub: Introduce helper to write a full stripe

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce a internal helper, write_full_stripe() to calculate P/Q and write the whole full stripe. This is useful to recover RAID56 stripes. Signed-off-by: Qu Wenruo --- scrub.c | 44 1 file changed, 44 insertions(+) diff --git a/s

[v6 02/16] btrfs-progs: Allow __btrfs_map_block_v2 to remove unrelated stripes

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo For READ, caller normally hopes to get what they request, other than full stripe map. In this case, we should remove unrelated stripe map, just like the following case: 32K 96K |<-request range->| 0 64k 1

[v6 13/16] btrfs-progs: scrub: Introduce a function to scrub one full stripe

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce a new function, scrub_one_full_stripe(), to check a full stripe. It handles the full stripe scrub in the following steps: 0) Check if we need to check full stripe If full stripe contains no extent, why waste our CPU and IO? 1) Read out full stripe Then we know ho

[v6 06/16] btrfs-progs: scrub: Introduce functions to scrub mirror based data blocks

2018-01-05 Thread Gu Jinxiang
From: Qu Wenruo Introduce new function, check/recover_data_mirror(), to check and recover mirror based data blocks. Unlike tree block, data blocks must be recovered sector by sector, so we introduced corrupted_bitmap for check and recover. Signed-off-by: Qu Wenruo Signed-off-by: Su Yue Signed

[v6 00/16] Btrfs-progs offline scrub

2018-01-05 Thread Gu Jinxiang
For any one who wants to try it, it can be get from my repo: https://github.com/gujx2017/btrfs-progs/tree/offline-scrub/ In this v6, just rebase to v4.14 and a test for offline-scrub. Several reports on kernel scrub screwing up good data stripes are in ML for sometime. And since kernel scrub wo

Re: [PATCH 2/2] btrfs-progs: Make btrfs_alloc_chunk to handle block group creation

2018-01-05 Thread Su Yue
On 01/05/2018 04:12 PM, Qu Wenruo wrote: Before this patch, chunk allocation is split into 2 parts: 1) Chunk allocation Handled by btrfs_alloc_chunk(), which will insert chunk and device extent items. 2) Block group allocation Handled by btrfs_make_block_group(), which will insert

Re: [PATCH 1/2] btrfs-progs: Merge btrfs_alloc_data_chunk into btrfs_alloc_chunk

2018-01-05 Thread Qu Wenruo
On 2018年01月05日 17:36, Su Yue wrote: > > > On 01/05/2018 04:12 PM, Qu Wenruo wrote: >> We used to have two chunk allocators, btrfs_alloc_chunk() and >> btrfs_alloc_data_chunk(), the former is the more generic one, while the >> later is only used in mkfs and convert, to allocate SINGLE data chunk

Re: [PATCH 1/2] btrfs-progs: Merge btrfs_alloc_data_chunk into btrfs_alloc_chunk

2018-01-05 Thread Su Yue
On 01/05/2018 05:36 PM, Su Yue wrote: On 01/05/2018 04:12 PM, Qu Wenruo wrote: We used to have two chunk allocators, btrfs_alloc_chunk() and btrfs_alloc_data_chunk(), the former is the more generic one, while the later is only used in mkfs and convert, to allocate SINGLE data chunk. Althoug

Re: [PATCH 1/2] btrfs-progs: Merge btrfs_alloc_data_chunk into btrfs_alloc_chunk

2018-01-05 Thread Su Yue
On 01/05/2018 04:12 PM, Qu Wenruo wrote: We used to have two chunk allocators, btrfs_alloc_chunk() and btrfs_alloc_data_chunk(), the former is the more generic one, while the later is only used in mkfs and convert, to allocate SINGLE data chunk. Although btrfs_alloc_data_chunk() has some speci

[PATCH] btrfs: add missing BTRFS_SUPER_FLAG define

2018-01-05 Thread Anand Jain
btrfs-progs uses additional two super flag bits. So just define that so that we know its been used. Signed-off-by: Anand Jain --- The btrfs-progs commits (very old) introduced them, commit 7cc792872a133cabc3467e6ccaf5a2c8ea9e5218 btrfs-progs: Add CHANGING_FSID super flag commit 797a937e5d

[PATCH 2/2] btrfs-progs: Make btrfs_alloc_chunk to handle block group creation

2018-01-05 Thread Qu Wenruo
Before this patch, chunk allocation is split into 2 parts: 1) Chunk allocation Handled by btrfs_alloc_chunk(), which will insert chunk and device extent items. 2) Block group allocation Handled by btrfs_make_block_group(), which will insert block group item and update space info. How

[PATCH 1/2] btrfs-progs: Merge btrfs_alloc_data_chunk into btrfs_alloc_chunk

2018-01-05 Thread Qu Wenruo
We used to have two chunk allocators, btrfs_alloc_chunk() and btrfs_alloc_data_chunk(), the former is the more generic one, while the later is only used in mkfs and convert, to allocate SINGLE data chunk. Although btrfs_alloc_data_chunk() has some special hacks to cooperate with convert, it's quit

[PATCH 0/2] Preparation for later btrfs_alloc_chunk() rework, Part 2

2018-01-05 Thread Qu Wenruo
This patchset, along with its prerequisite (patchset named: "[PATCH 0/5] Cleanups for later btrfs_alloc_chunk() rework") can be fetched from github: https://github.com/adam900710/btrfs-progs/tree/chunk_alloc_enospc This patchset can still be treated as cleanup, but brings a much larger structure m