Re: [PATCH 1/3] btrfs: simplify counting number of eb pages

2018-04-23 Thread Nikolay Borisov
On 24.04.2018 02:03, David Sterba wrote: > The eb length is nodesize, as initialized in __alloc_extent_buffer. > Regardless of start, we should always get the same number of pages, so > use that fact. > > Signed-off-by: David Sterba > --- > fs/btrfs/extent_io.h | 3 +-- > 1

[PATCH 3/3] btrfs-progs: do not merge tree block refs have different root_id

2018-04-23 Thread Su Yue
For an extent item which contains many tree block backrefs, like = In 020-extent-ref-cases/keyed_block_ref.img item 10 key (29470720 METADATA_ITEM 0) itemoff 3450 itemsize 222 refs 23 gen 10 flags TREE_BLOCK

[PATCH 1/3] btrfs-progs: remove comments about delayed ref in backref.c

2018-04-23 Thread Su Yue
There is no delayed ref in btrfs-progs, so remove related comments. Signed-off-by: Su Yue --- backref.c | 19 +++ 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/backref.c b/backref.c index 27309e07a1e9..c144dbf060f2 100644 --- a/backref.c

[PATCH 2/3] btrfs-progs: remove useless branch in __merge_refs

2018-04-23 Thread Su Yue
After call of ref_for_same_block, ref1->parent must equals to ref2->parent, the block of exchange is never reached. So remove the block of exchange. Signed-off-by: Su Yue --- backref.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/backref.c b/backref.c index

[PATCH v2] btrfs: print-tree: Add locking status output for debug build

2018-04-23 Thread Qu Wenruo
It's pretty handy if we can get debug output for locking status of an extent buffer, specially for race related debugging. So add the following output for btrfs_print_tree() and btrfs_print_leaf(): - refs - write_locks (as w:%d) - read_locks (as r:%d) - blocking_writers (as bw:%d) -

[PATCH v2 3/4] btrfs: Add csum type check for btrfs_check_super_valid()

2018-04-23 Thread Qu Wenruo
Just like incompat flags check, although we have already done super csum type check before calling btrfs_check_super_valid(), we can still add such check for later write time check. Signed-off-by: Qu Wenruo --- fs/btrfs/disk-io.c | 9 + 1 file changed, 9 insertions(+)

[PATCH v2 2/4] btrfs: Add incompat flags check for btrfs_check_super_valid()

2018-04-23 Thread Qu Wenruo
Although we have already checked incompat flags manually before really mounting it, we could still enhance btrfs_check_super_valid() to check incompat flags for later write time super block validation check. This patch adds such incompat flags check for btrfs_check_super_valid(), currently it

[PATCH v2 0/4] btrfs: Add write time super block validation

2018-04-23 Thread Qu Wenruo
This patchset can be fetched from github: https://github.com/adam900710/linux/tree/write_time_sb_check We have 2 reports about corrupted btrfs super block, which has some garbage in its super block, but otherwise it's completely fine and its csum even matches. This means we develop memory

[PATCH v2 1/4] btrfs: Rename btrfs_check_super_valid() to btrfs_validate_super()

2018-04-23 Thread Qu Wenruo
Makes the function name a little shorter and easier to read. Signed-off-by: Qu Wenruo --- fs/btrfs/disk-io.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 60caa68c3618..23b5c90cdbb2 100644 ---

[PATCH v2 4/4] btrfs: Do super block verification before writing it to disk

2018-04-23 Thread Qu Wenruo
There are already 2 reports about strangely corrupted super blocks, where csum still matches but extra garbage gets slipped into super block. The corruption would looks like: -- superblock: bytenr=65536, device=/dev/sdc1 - csum_type

Re: [PATCH] btrfs-progs: treewide: Replace strerror(errno) with %m.

2018-04-23 Thread Su Yue
On 01/24/2018 03:42 AM, David Sterba wrote: On Sun, Jan 07, 2018 at 01:54:21PM -0800, Rosen Penev wrote: As btrfs is specific to Linux, %m can be used instead of strerror(errno) in format strings. This has some size reduction benefits for embedded systems. Makes sense. glibc, musl, and

4.14.35: possible circular locking dependency detected

2018-04-23 Thread Petr Janecek
Hi, after scrub start, scrub cancel, umount, mount of a two disk raid1 (data + metadata): [12999.229791] == [12999.236029] WARNING: possible circular locking dependency detected [12999.242261] 4.14.35 #36 Not tainted [12999.245806]

[PATCH 3/3] btrfs: switch types to int when counting eb pages

2018-04-23 Thread David Sterba
The loops iterating eb pages use unsigned long, that's an overkill as we know that there are at most 16 pages (64k / 4k), and 4 by default (with nodesize 16k). Signed-off-by: David Sterba --- fs/btrfs/extent_io.c | 44 ++--

[PATCH 0/3] Simplify counting of extent buffer pages

2018-04-23 Thread David Sterba
Some low-hanging cleanup fruit. The argument bloat-o-meter shows some improvements: extent_io.c:cache_state_if_flags.part.27 -8 (8 -> 0) extent_io.c:cache_state.part.28-8 (8 -> 0) extent_io.c:check_buffer_tree_ref.part.31 -24 (24 -> 0)

[PATCH 2/3] btrfs: pass only eb to num_extent_pages

2018-04-23 Thread David Sterba
Almost all callers pass the start and len as 2 arguments but this is not necessary, all the information is provided by the eb. By reordering the calls to num_extent_pages, we don't need the local variables with start/len. Signed-off-by: David Sterba --- fs/btrfs/extent_io.c |

[PATCH 1/3] btrfs: simplify counting number of eb pages

2018-04-23 Thread David Sterba
The eb length is nodesize, as initialized in __alloc_extent_buffer. Regardless of start, we should always get the same number of pages, so use that fact. Signed-off-by: David Sterba --- fs/btrfs/extent_io.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git

Re: [PATCH] btrfs: push relocation recovery into a helper thread

2018-04-23 Thread David Sterba
On Tue, Apr 17, 2018 at 02:45:33PM -0400, Jeff Mahoney wrote: > On a file system with many snapshots and qgroups enabled, an interrupted > balance can end up taking a long time to mount due to recovering the > relocations during mount. It does this in the task performing the mount, > which can't

Re: [RFC] Add support for BTRFS raid5/6 to GRUB

2018-04-23 Thread Goffredo Baroncelli
On 04/23/2018 01:50 PM, Daniel Kiper wrote: > On Tue, Apr 17, 2018 at 09:57:40PM +0200, Goffredo Baroncelli wrote: >> Hi All, >> >> Below you can find a patch to add support for accessing files from >> grub in a RAID5/6 btrfs filesystem. This is a RFC because it is >> missing the support for

Re: libbrtfsutil questions

2018-04-23 Thread Austin S. Hemmelgarn
On 2018-04-23 14:25, waxhead wrote: Howdy! I am pondering writing a little C program that use libmicrohttpd and libbtrfsutil to display some very basic (overview) details about BTRFS. I was hoping to display the same information that'btrfs fi sh /mnt' and 'btrfs fi us -T /mnt' do, but

libbrtfsutil questions

2018-04-23 Thread waxhead
Howdy! I am pondering writing a little C program that use libmicrohttpd and libbtrfsutil to display some very basic (overview) details about BTRFS. I was hoping to display the same information that'btrfs fi sh /mnt' and 'btrfs fi us -T /mnt' do, but somewhat combined. Since I recently just

Re: status page

2018-04-23 Thread David Sterba
On Thu, Apr 19, 2018 at 06:24:29PM +0200, Gandalf Corvotempesta wrote: > Hi to all, > as kernel 4.16 is out and 4.17 in in RC, would be possible to update > BTRFS status page > https://btrfs.wiki.kernel.org/index.php/Status to reflect 4.16 stability ? > > That page is still based on kernel 4.15

Re: [PATCH] btrfs: Fix wrong first_key parameter in replace_path

2018-04-23 Thread David Sterba
On Mon, Apr 23, 2018 at 05:20:06PM +0300, Nikolay Borisov wrote: > On 23.04.2018 17:16, David Sterba wrote: > > On Mon, Apr 23, 2018 at 05:32:04PM +0800, Qu Wenruo wrote: > >> Commit 581c1760415c ("btrfs: Validate child tree block's level and first > >> key") introduced new @first_key parameter

Re: [PATCH] btrfs: Fix wrong first_key parameter in replace_path

2018-04-23 Thread Nikolay Borisov
On 23.04.2018 17:16, David Sterba wrote: > On Mon, Apr 23, 2018 at 05:32:04PM +0800, Qu Wenruo wrote: >> Commit 581c1760415c ("btrfs: Validate child tree block's level and first >> key") introduced new @first_key parameter for read_tree_block(), however >> caller in replace_path() is parasing

Re: [PATCH] btrfs: Fix wrong first_key parameter in replace_path

2018-04-23 Thread David Sterba
On Mon, Apr 23, 2018 at 05:32:04PM +0800, Qu Wenruo wrote: > Commit 581c1760415c ("btrfs: Validate child tree block's level and first > key") introduced new @first_key parameter for read_tree_block(), however > caller in replace_path() is parasing wrong key to read_tree_block(). > > It should use

Re: [PATCH 7/7] btrfs: add FS_IOC_FSSETXATTR ioctl

2018-04-23 Thread David Sterba
On Mon, Apr 23, 2018 at 11:42:42AM +0900, Misono Tomohiro wrote: > On 2018/04/21 2:02, David Sterba wrote: > > The new ioctl is an extension to the FS_IOC_SETFLAGS and adds new > > flags and is extensible. Don't get fooled by the XATTR in the name, it > > does not have anything in common with the

Re: [PATCH 4/7] btrfs: rename btrfs_flags_to_ioctl to reflect which flags it touches

2018-04-23 Thread David Sterba
On Mon, Apr 23, 2018 at 11:37:08AM +0900, Misono Tomohiro wrote: > On 2018/04/21 2:02, David Sterba wrote: > > Converts btrfs_inode::flags to the FS_*_FL flags. > > > > Signed-off-by: David Sterba > > --- > > fs/btrfs/ioctl.c | 9 + > > 1 file changed, 5 insertions(+),

Re: [RFC] Add support for BTRFS raid5/6 to GRUB

2018-04-23 Thread Daniel Kiper
On Tue, Apr 17, 2018 at 09:57:40PM +0200, Goffredo Baroncelli wrote: > Hi All, > > Below you can find a patch to add support for accessing files from > grub in a RAID5/6 btrfs filesystem. This is a RFC because it is > missing the support for recovery (i.e. if some devices are missed). In > the

[PATCH] btrfs: Fix wrong first_key parameter in replace_path

2018-04-23 Thread Qu Wenruo
Commit 581c1760415c ("btrfs: Validate child tree block's level and first key") introduced new @first_key parameter for read_tree_block(), however caller in replace_path() is parasing wrong key to read_tree_block(). It should use parameter @first_key other than @key. Normally it won't expose

Re: [PATCH 0/5] Remove delay_iput parameter when running delalloc work

2018-04-23 Thread Nikolay Borisov
On 23.04.2018 12:27, Qu Wenruo wrote: > > > On 2018年04月23日 15:54, Nikolay Borisov wrote: >> While trying to make sense of the lifecycle of delayed iputs it became >> apparent >> that the delay_iput parameter of btrfs_start_delalloc_roots/ >> btrfs_start_delalloc_inodes is always set to 0.

Re: [PATCH 0/5] Remove delay_iput parameter when running delalloc work

2018-04-23 Thread Qu Wenruo
On 2018年04月23日 15:54, Nikolay Borisov wrote: > While trying to make sense of the lifecycle of delayed iputs it became > apparent > that the delay_iput parameter of btrfs_start_delalloc_roots/ > btrfs_start_delalloc_inodes is always set to 0. (Patch 1 contains historical > information of why

Re: 4.17-rc1 FS went read-only during balance

2018-04-23 Thread Dmitrii Tcvetkov
> > TL;DR It seems as regression in 4.17, but I managed to find a > > workaround to make filesystem rw mountable again. > > > > Kernel built from tag v4.17-rc1 > > btrfs-progs 4.16 > > > > Tonight two my machines (PC (ECC RAM) and laptop(non-ECC RAM)) were > > doing

Re: 4.17-rc1 FS went read-only during balance

2018-04-23 Thread Qu Wenruo
On 2018年04月23日 16:04, Dmitrii Tcvetkov wrote: > TL;DR It seems as regression in 4.17, but I managed to find a > workaround to make filesystem rw mountable again. > > Kernel built from tag v4.17-rc1 > btrfs-progs 4.16 > > Tonight two my machines (PC (ECC RAM) and

[PATCH 3/5] btrfs: Remove delay_iput parameter from __start_delalloc_inodes

2018-04-23 Thread Nikolay Borisov
It's always set to 0 so remove it Signed-off-by: Nikolay Borisov --- fs/btrfs/inode.c | 14 +- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 855237737acb..42a2590559df 100644 --- a/fs/btrfs/inode.c +++

[PATCH 1/5] btrfs: Remove delayed_iput parameter of btrfs_start_delalloc_roots

2018-04-23 Thread Nikolay Borisov
This parameter was introduced alongside the function in eb73c1b7cea7 ("Btrfs: introduce per-subvolume delalloc inode list") to avoid deadlocks since this function was used in the transaction commit path. However, commit 8d875f95da43 ("btrfs: disable strict file flushes for renames and truncates")

[PATCH 0/5] Remove delay_iput parameter when running delalloc work

2018-04-23 Thread Nikolay Borisov
While trying to make sense of the lifecycle of delayed iputs it became apparent that the delay_iput parameter of btrfs_start_delalloc_roots/ btrfs_start_delalloc_inodes is always set to 0. (Patch 1 contains historical information of why this parameter was needed and when it became obsolete). Now

[PATCH 4/5] btrfs: Remove delayed_iput member from btrfs_delalloc_work

2018-04-23 Thread Nikolay Borisov
When allocating a delalloc work we are always setting the delayed_iput to 0. So remove the delay_iput member of btrfs_delalloc_work, as a result also remove it as a parameter from btrfs_alloc_delalloc_work since it's not used anymore. Signed-off-by: Nikolay Borisov ---

[PATCH 2/5] btrfs: Remove delayed_iput parameter from btrfs_start_delalloc_inodes

2018-04-23 Thread Nikolay Borisov
It's always set to 0, so just remove it and collapse the constant value to the only function we are passing it. Signed-off-by: Nikolay Borisov --- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 4 ++-- fs/btrfs/ioctl.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)

[PATCH 5/5] btrfs: Unexport btrfs_alloc_delalloc_work

2018-04-23 Thread Nikolay Borisov
It's used only in inode.c so makes no sense to have it exported. Signed-off-by: Nikolay Borisov --- fs/btrfs/ctree.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 91f51a80334f..e5c24d86fdfa 100644 --- a/fs/btrfs/ctree.h +++

Re: 4.17-rc1 FS went read-only during balance

2018-04-23 Thread Qu Wenruo
On 2018年04月23日 13:08, Dmitrii Tcvetkov wrote: > On Mon, 23 Apr 2018 09:23:53 +0800 > Qu Wenruo wrote: > >> On 2018年04月21日 22:55, Dmitrii Tcvetkov wrote: >>> TL;DR It seems as regression in 4.17, but I managed to find a >>> workaround to make filesystem rw mountable