Re: [PATCH 5/5] btrfs: Verify every chunk has corresponding block group at mount time

2018-07-04 Thread Nikolay Borisov
On 3.07.2018 12:10, Qu Wenruo wrote: > If a crafted btrfs has missing block group items, it could cause > unexpected behavior and breaks our expectation on 1:1 > chunk<->block group mapping. > > Although we added block group -> chunk mapping check, we still need > chunk -> block group mapping

[PATCH 2/2] btrfs: Reword dodgy comments

2018-07-04 Thread Nikolay Borisov
Commit eb14ab8ed24a ("Btrfs: fix page->private races") fixed a genuine race between extent buffer initialisation and btree_releaseage. Unfortunately as the code has evolved the comments weren't changed which made them slightly wrong and they weren't very clear in the fist place. Fix this by (hopefu

[PATCH 1/2] btrfs: Simplify page unlocking in alloc_extent_buffer

2018-07-04 Thread Nikolay Borisov
Current version of the page unlocking code was added in 727011e07cbd ("Btrfs: allow metadata blocks larger than the page size") but even in this commit that particular flag was never used per-se. In fact, btrfs only uses PageChecked for data pages to identify pages which have been dirtied but don't

RE: [PATCH 1/5] btrfs: tree-checker: Verify block_group_item

2018-07-04 Thread Gu, Jinxiang
> -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Qu Wenruo > Sent: Tuesday, July 03, 2018 5:10 PM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH 1/5] btrfs: tree-checker: Verify block_group_item > > A crafted i

RE: [PATCH 2/5] btrfs: tree-checker: Detect invalid empty essential tree

2018-07-04 Thread Gu, Jinxiang
> -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Qu Wenruo > Sent: Tuesday, July 03, 2018 5:10 PM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH 2/5] btrfs: tree-checker: Detect invalid empty essential tree > >

RE: [PATCH 3/5] btrfs: relocation: Only remove reloc rb_trees if reloc control has been initialized

2018-07-04 Thread Gu, Jinxiang
> -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Qu Wenruo > Sent: Tuesday, July 03, 2018 5:10 PM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH 3/5] btrfs: relocation: Only remove reloc rb_trees if reloc > con

Re: [PATCH 1/7] btrfs: restore uuid_mutex in btrfs_open_devices

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: Commit 542c5908abfe84f7b4c1 ("btrfs: replace uuid_mutex by device_list_mutex in btrfs_open_devices") switched to device_list_mutex as we need that for the device list traversal, but we also need uuid_mutex to protect access to fs_devices::opened to b

Re: [PATCH 2/7] btrfs: extend critical section when scanning a new device

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: The stale device list removal needs to be protected by device_list_mutex too as this could delete from the list and could race with another list modification and cause crash. The device needs to be fully initialized before it's added to the list so

Re: [PATCH v2 00/20] btrfs-progs: Rework of "subvolume list/show" and relax the root privileges of them

2018-07-04 Thread Misono Tomohiro
Gentle ping, as this is related to the new ioctls merged in 4.18-rc1. On 2018/06/18 17:40, Misono Tomohiro wrote: > Changelog > > v1 -> v2: > generally update whole patch set, especially: >- rebased to progs 4.17 >- Improve error handling >- Update man/help/commit message >-

Re: [PATCH v2] btrfs: Add chunk type check in read a chunk

2018-07-04 Thread Nikolay Borisov
On 3.07.2018 09:20, Gu Jinxiang wrote: > Reported in https://bugzilla.kernel.org/show_bug.cgi?id=199839, > which has a invalid chunk, not return error opportunlly. > > Add chunk type check in btrfs_check_chunk_valid, > to make error be returned in advance. > > Reported-by: Xu Wen > Signed-of

Re: [PATCH 3/7] btrfs: lift uuid_mutex to callers of btrfs_scan_one_device

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: Prepartory work to fix race between mount and device scan. The callers will have to manage the critical section, eg. mount wants to scan and then call btrfs_open_devices without the ioctl scan walking in and modifying the fs devices in the meantime.

Re: [PATCH 6/7] btrfs: reorder initialization before the mount locks uuid_mutex

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: In preparation to take a big lock, move resource initialization before the critical section. It's not obvious from the diff, the desired order is: - initialize mount security options - allocate temporary fs_info - allocate superblock buffers Signed

Re: [PATCH 5/7] btrfs: lift uuid_mutex to callers of btrfs_parse_early_options

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: Prepartory work to fix race between mount and device scan. btrfs_parse_early_options calls the device scan from mount and we'll need to let mount completely manage the critical section. Signed-off-by: David Sterba Reviewed-by: Anand Jain Thank

Re: [PATCH 4/7] btrfs: lift uuid_mutex to callers of btrfs_open_devices

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: Prepartory work to fix race between mount and device scan. The callers will have to manage the critical section, eg. mount wants to scan and then call btrfs_open_devices without the ioctl scan walking in and modifying the fs devices in the meantime

Re: [PATCH 7/7] btrfs: fix mount and ioctl device scan ioctl race

2018-07-04 Thread Anand Jain
On 06/21/2018 01:51 AM, David Sterba wrote: Technically this extends the critical section covered by uuid_mutex to: - parse early mount options -- here we can call device scan on paths that can be passed as 'device=/dev/...' - scan the device passed to mount - open the devices related to

RE: [PATCH v2] btrfs: Add chunk type check in read a chunk

2018-07-04 Thread Gu, Jinxiang
> -Original Message- > From: Nikolay Borisov [mailto:nbori...@suse.com] > Sent: Wednesday, July 04, 2018 4:15 PM > To: Gu, Jinxiang/顾 金香 ; linux-btrfs@vger.kernel.org > Cc: quwenruo.bt...@gmx.com; wen...@gatech.edu; xuwen.s...@gmail.com > Subject: Re: [PATCH v2] btrfs: Add chunk type chec

Re: [PATCH 5/5] btrfs: Verify every chunk has corresponding block group at mount time

2018-07-04 Thread Qu Wenruo
On 2018年07月04日 15:08, Nikolay Borisov wrote: > > > On 3.07.2018 12:10, Qu Wenruo wrote: >> If a crafted btrfs has missing block group items, it could cause >> unexpected behavior and breaks our expectation on 1:1 >> chunk<->block group mapping. >> >> Although we added block group -> chunk map

Re: [PATCH v2] btrfs: Add chunk type check in read a chunk

2018-07-04 Thread Qu Wenruo
On 2018年07月04日 16:39, Gu, Jinxiang wrote: > > >> -Original Message- >> From: Nikolay Borisov [mailto:nbori...@suse.com] >> Sent: Wednesday, July 04, 2018 4:15 PM >> To: Gu, Jinxiang/顾 金香 ; linux-btrfs@vger.kernel.org >> Cc: quwenruo.bt...@gmx.com; wen...@gatech.edu; xuwen.s...@gmail.co

[PATCH v3] btrfs: Add chunk type check in read a chunk

2018-07-04 Thread Gu Jinxiang
Reported in https://bugzilla.kernel.org/show_bug.cgi?id=199839, which has a invalid chunk, not return error opportunlly. Add chunk type check in btrfs_check_chunk_valid, to make error be returned in advance. Reported-by: Xu Wen Signed-off-by: Gu Jinxiang Reviewed-by: Qu Wenruo --- changelog: v

Re: [PATCH] btrfs-progs: check: add experimental flag for lowmem mode

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 01:42:37PM +0200, David Disseldorp wrote: > The experimental flag is already carried in the manpage, but was removed > from the btrfs check usage message as part of refactoring via > 87c1bd13c1fca430c3dbf0da62e9aa33bde609c8. Add it back. > > Signed-off-by: David Disseldorp

Re: [PATCH] btrfs-progs: Don't BUG_ON() if we failed to load one device or one chunk

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 09:40:40PM +0800, Qu Wenruo wrote: > Don't panic for btrfs_read_chunk_tree() if one device or chunk is > corrupted. > Caller can already handle it pretty well. > > Link: https://bugzilla.kernel.org/show_bug.cgi?id=199839 > Signed-off-by: Qu Wenruo Applied, thanks. In cas

Re: [PATCH] btrfs-progs: Don't BUG_ON() if we failed to load one device or one chunk

2018-07-04 Thread Qu Wenruo
On 2018年07月04日 19:58, David Sterba wrote: > On Tue, Jul 03, 2018 at 09:40:40PM +0800, Qu Wenruo wrote: >> Don't panic for btrfs_read_chunk_tree() if one device or chunk is >> corrupted. >> Caller can already handle it pretty well. >> >> Link: https://bugzilla.kernel.org/show_bug.cgi?id=199839 >>

Re: [PATCH] btrfs-progs: doc: Update man 5 btrfs for 4.18

2018-07-04 Thread David Sterba
On Wed, Jul 04, 2018 at 02:31:20PM +0900, Misono Tomohiro wrote: > Update the information to reflect the status of 4.18 > > Main Updates: > - Add explanation of improved compression heuristic algorithm > - Add explanation that norecovery == nologreplay > - Add explanation of nossd_spread mount opt

Re: [PATCH] btrfs-progs: Don't BUG_ON() if we failed to load one device or one chunk

2018-07-04 Thread David Sterba
On Wed, Jul 04, 2018 at 08:01:11PM +0800, Qu Wenruo wrote: > > > On 2018年07月04日 19:58, David Sterba wrote: > > On Tue, Jul 03, 2018 at 09:40:40PM +0800, Qu Wenruo wrote: > >> Don't panic for btrfs_read_chunk_tree() if one device or chunk is > >> corrupted. > >> Caller can already handle it pretty

Re: [PATCH v3] btrfs: Add chunk type check in read a chunk

2018-07-04 Thread Nikolay Borisov
On 4.07.2018 13:16, Gu Jinxiang wrote: > Reported in https://bugzilla.kernel.org/show_bug.cgi?id=199839, > which has a invalid chunk, not return error opportunlly. > > Add chunk type check in btrfs_check_chunk_valid, > to make error be returned in advance. > > Reported-by: Xu Wen > Signed-of

Re: [PATCH 0/5] Enhancement for block group/chunk verification

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 05:10:04PM +0800, Qu Wenruo wrote: > Can be fetched from github, which is based on v4.18-rc1 tag: > https://github.com/adam900710/linux/tree/tree_checker_enhance > > Reported by Xu Wen , some crafted btrfs image can > cause unexpected kernel behavior. > > All of them are r

Re: [PATCH v2] btrfs: Add chunk type check in read a chunk

2018-07-04 Thread David Sterba
On Wed, Jul 04, 2018 at 05:49:50PM +0800, Qu Wenruo wrote: > On 2018年07月04日 16:39, Gu, Jinxiang wrote: > >> -Original Message- > >> From: Nikolay Borisov [mailto:nbori...@suse.com] > >> Sent: Wednesday, July 04, 2018 4:15 PM > >> To: Gu, Jinxiang/顾 金香 ; linux-btrfs@vger.kernel.org > >> Cc:

Re: [PATCH 1/2] btrfs: declare fs_devices in btrfs_init_new_device()

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 01:14:50PM +0800, Anand Jain wrote: > There are many instances of the %fs_info->fs_devices pointer > de-reference, so declare a %fs_devices pointer instead. > > Signed-off-by: Anand Jain 1-2 added to misc-next, thanks. -- To unsubscribe from this list: send the line "unsu

Re: [PATCH] btrfs: qgroups: Move transaction managed inside btrfs_quota_enable

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 11:54:11AM +0300, Nikolay Borisov wrote: > > > On 2.07.2018 18:40, David Sterba wrote: > > On Mon, Jul 02, 2018 at 02:00:34PM +0300, Nikolay Borisov wrote: > >> Commit 5d23515be669 ("btrfs: Move qgroup rescan on quota enable to > >> btrfs_quota_enable") not only resulted

Re: [PATCH] Btrfs: make sure there is always room for generation number

2018-07-04 Thread David Sterba
On Mon, Jul 02, 2018 at 08:00:54PM -0400, Zhihui Zhang wrote: > io_ctl_set_generation() assumes that the generation number shares > the same page with inline CRCs. Let's make sure this is always true. Have you found this by code inspection or is it a fix for a bug that can be reproduced? -- To uns

Re: [PATCH] Btrfs: make sure there is always room for generation number

2018-07-04 Thread David Sterba
On Mon, Jul 02, 2018 at 08:00:54PM -0400, Zhihui Zhang wrote: > io_ctl_set_generation() assumes that the generation number shares > the same page with inline CRCs. Let's make sure this is always true. > > Signed-off-by: Zhihui Zhang Reviewed-by: David Sterba -- To unsubscribe from this list: se

Re: [PATCH] btrfs: fix a typo in comment of btrfs_balance

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 04:16:29PM +0800, Su Yue wrote: > The typo 'mutexe' should be 'mutex'. > > Signed-off-by: Su Yue > --- > fs/btrfs/volumes.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index e034ad9e23b4..d9d87deb1160

Re: [PATCH v2 1/2] btrfs: Check each block group has corresponding chunk at mount time

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 08:58:05PM +0200, Martin Steigerwald wrote: > Nikolay Borisov - 03.07.18, 11:08: > > On 3.07.2018 11:47, Qu Wenruo wrote: > > > On 2018年07月03日 16:33, Nikolay Borisov wrote: > > >> On 3.07.2018 11:08, Qu Wenruo wrote: > > >>> Reported in https://bugzilla.kernel.org/show_bug

Re: [PATCH v2 1/2] btrfs: Check each block group has corresponding chunk at mount time

2018-07-04 Thread David Sterba
On Tue, Jul 03, 2018 at 12:08:02PM +0300, Nikolay Borisov wrote: > >> Also for evry patch which fixes a specific issue from one of the > >> reported on bugzilla.kernel.org just use the Link: tag to point to the > >> original report on bugzilla that will make it easier to relate the > >> fixes to th

Re: [PATCH] btrfs: use correct compare function of dirty_metadata_bytes

2018-07-04 Thread David Sterba
On Mon, Jul 02, 2018 at 03:44:58PM +0800, Ethan Lien wrote: > We use customized, nodesize batch value to update dirty_metadata_bytes. > We should also use batch version of compare function or we will easily > goto fast path and get false result from percpu_counter_compare(). > > Signed-off-by: Eth

Re: [PATCH] btrfs: use correct compare function of dirty_metadata_bytes

2018-07-04 Thread David Sterba
On Mon, Jul 02, 2018 at 10:49:46AM +0300, Nikolay Borisov wrote: > On 2.07.2018 10:44, Ethan Lien wrote: > > We use customized, nodesize batch value to update dirty_metadata_bytes. > > We should also use batch version of compare function or we will easily > > goto fast path and get false result fr

Re: [PATCH] btrfs: use correct compare function of dirty_metadata_bytes

2018-07-04 Thread Nikolay Borisov
On 4.07.2018 19:55, David Sterba wrote: > On Mon, Jul 02, 2018 at 10:49:46AM +0300, Nikolay Borisov wrote: >> On 2.07.2018 10:44, Ethan Lien wrote: >>> We use customized, nodesize batch value to update dirty_metadata_bytes. >>> We should also use batch version of compare function or we will ea

A list of new findings when fuzzing Linux btrfs module

2018-07-04 Thread Xu, Wen
Hi BTRFS developers, Here are a list of new issues I found: 200403 BUG() triggered in btrfs_free_dev_extent() when un-mounting a btrfs image https://bugzilla.kernel.org/show_bug.cgi?id=200403 200405 Potential deadlock in btrfs_tree_lock() when perform writing to btrfs filesystem https://bugz

[PATCH 0/2] btrfs-progs: check: enhanced progress indicator

2018-07-04 Thread Stéphane Lesimple
This patch replaces the current ".oOo."-style progress indicator of btrfs check (-p), by a more helpful live indication of the check progress. I've been using it on a custom btrfs-progs version since 2015. Here's how the output looks like on a 22 Tb 5-disk RAID1 FS: # btrfs check -p /dev/mapper/l

[PATCH 2/2] btrfs-progs: check: enhanced progress indicator

2018-07-04 Thread Stéphane Lesimple
We reuse the task_position enum and task_ctx struct of the original progress indicator, adding more values and fields for our needs. Then add hooks in all steps of the check to properly record progress. Signed-off-by: Stéphane Lesimple --- check/main.c| 176 +

[PATCH 1/2] btrfs-progs: fix nanosecs in task_period_start

2018-07-04 Thread Stéphane Lesimple
This is a single-line fix on the preexisting task_period_start function. Signed-off-by: Stéphane Lesimple --- task-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task-utils.c b/task-utils.c index 12b0002..284cbb3 100644 --- a/task-utils.c +++ b/task-utils.c @@ -102,7

Re: [PATCH 0/5] Enhancement for block group/chunk verification

2018-07-04 Thread Qu Wenruo
On 2018年07月04日 21:36, David Sterba wrote: > On Tue, Jul 03, 2018 at 05:10:04PM +0800, Qu Wenruo wrote: >> Can be fetched from github, which is based on v4.18-rc1 tag: >> https://github.com/adam900710/linux/tree/tree_checker_enhance >> >> Reported by Xu Wen , some crafted btrfs image can >> cause

[PATCH] btrfs-progs: tests/fuzz: Use correct suffix for raw image

2018-07-04 Thread Qu Wenruo
* Please fold this patch into original commit in devel branch * It's raw image, so it should be ".raw.xz" not ".img.xz" Fixes: 19154c230314 ("btrfs-progs: tests: add fuzzed image that triggers crash in reloc setup on mount") Signed-off-by: Qu Wenruo --- ...mg.xz => bko-199833-reloc-recovery-cr