Re: [PATCH] btrfs-progs: Remove unused parameter

2018-03-29 Thread Nikolay Borisov
On 30.03.2018 05:56, Gu Jinxiang wrote: > Parameter usagestr is not used, remove it. > > Signed-off-by: Gu Jinxiang Reviewed-by: Nikolay Borisov > --- > cmds-filesystem.c | 2 +- > help.c| 2 +- > help.h| 3 +-- > 3 files

[PATCH v2 2/5] btrfs-progs: extent_io: Init eb->lru to avoid NULL pointer dereference

2018-03-29 Thread Qu Wenruo
eb->lru is not initialized in __alloc_extent_buffer(), so in the following call chain, it could call NULL pointer dereference: btrfs_clone_extent_buffer() |- __alloc_extent_buffer() |- Now eb->lru is NULL (not initialized) free_extent_buffer_final() |- list_del_init(>lru) Thankfully, current

[PATCH v2 0/5] btrfs-progs: extent buffer related refactor and cleanup

2018-03-29 Thread Qu Wenruo
The patchset can be fetched from github: https://github.com/adam900710/btrfs-progs/tree/eb_cleanup Just like kernel cleanup and refactors, this patchset will embed btrfs_fs_info structure into extent_buffer. And fixes several possible NULL pointer dereference (although not utilized in

[PATCH v2 5/5] btrfs-progs: print-tree: Remove btrfs_root parameter

2018-03-29 Thread Qu Wenruo
Just like kernel cleanup made by David, btrfs_print_leaf() and btrfs_print_tree() doesn't need btrfs_root parameter at all. With previous patches as preparation, now we can remove the btrfs_root parameter. Signed-off-by: Qu Wenruo --- cmds-inspect-dump-tree.c | 31

[PATCH v2 4/5] btrfs-progs: Unify btrfs_leaf_free_psace() parameter with kernel

2018-03-29 Thread Qu Wenruo
Instead of struct btrfs_root, use struct btrfs_fs_info, since nodesize is now a per-fs setting, and with the need to pass a @root, caller don't need to wonder which root should be passed. Signed-off-by: Qu Wenruo --- btrfs-corrupt-block.c | 2 +- check/main.c | 2 +-

[PATCH v2 3/5] btrfs-progs: extent_io: Refactor alloc_extent_buffer() to follow kernel parameters

2018-03-29 Thread Qu Wenruo
Instead of using the internal struct extent_io_tree, use struct fs_info. This does not only unify the interface between kernel and btrfs-progs, but also makes later btrfs_print_tree() use less parameters. Signed-off-by: Qu Wenruo --- convert/source-reiserfs.c | 3 +-- disk-io.c

[PATCH v2 1/5] btrfs-progs: extent_io: Fix NULL pointer dereference in free_extent_buffer_final()

2018-03-29 Thread Qu Wenruo
In free_extent_buffer_final() we access eb->tree->cache_size in BUG_ON(). However eb->tree can be NULL if it's a cloned extent buffer. Currently the cloned extent buffer is only used in backref.c, paths_from_inode() function. Thankfully that function is not used yet (but could be pretty useful to

[PATCH 1/5] btrfs-progs: extent_io: Fix NULL pointer dereference in free_extent_buffer_final()

2018-03-29 Thread Qu Wenruo
In free_extent_buffer_final() we access eb->tree->cache_size in BUG_ON(). However eb->tree can be NULL if it's a cloned extent buffer. Currently the cloned extent buffer is only used in backref.c, paths_from_inode() function. Thankfully that function is not used yet (but could be pretty useful to

[PATCH 3/5] btrfs-progs: extent_io: Refactor alloc_extent_buffer() to follow kernel parameters

2018-03-29 Thread Qu Wenruo
Instead of using the internal struct extent_io_tree, use struct fs_info. This does not only unify the interface between kernel and btrfs-progs, but also makes later btrfs_print_tree() use less parameters. Signed-off-by: Qu Wenruo --- disk-io.c | 3 +-- extent_io.c | 14

[PATCH 4/5] btrfs-progs: Unify btrfs_leaf_free_psace() parameter with kernel

2018-03-29 Thread Qu Wenruo
Instead of struct btrfs_root, use struct btrfs_fs_info, since nodesize is now a per-fs setting, and with the need to pass a @root, caller don't need to wonder which root should be passed. Signed-off-by: Qu Wenruo --- btrfs-corrupt-block.c | 2 +- check/main.c | 2 +-

[PATCH 5/5] btrfs-progs: print-tree: Remove btrfs_root parameter

2018-03-29 Thread Qu Wenruo
Just like kernel cleanup made by David, btrfs_print_leaf() and btrfs_print_tree() doesn't need btrfs_root parameter at all. With previous patches as preparation, now we can remove the btrfs_root parameter. Signed-off-by: Qu Wenruo --- cmds-inspect-dump-tree.c | 31

[PATCH 2/5] btrfs-progs: extent_io: Init eb->lru to avoid NULL pointer dereference

2018-03-29 Thread Qu Wenruo
eb->lru is not initialized in __alloc_extent_buffer(), so in the following call chain, it could call NULL pointer dereference: btrfs_clone_extent_buffer() |- __alloc_extent_buffer() |- Now eb->lru is NULL (not initialized) free_extent_buffer_final() |- list_del_init(>lru) Thankfully, current

Re: [RFC PATCH v3 0/7] btrfs-progs: Allow normal user to call "subvolume list/show"

2018-03-29 Thread Misono Tomohiro
On 2018/03/30 2:35, Goffredo Baroncelli wrote: > Hi Misono, Hello, > > I tested you patch, and it seems to work. I verified that the output is > correct and the permission check is performed. However the output of "btrfs > sub list" in the "root" mode and the "user" mode are a bit different.

[PATCH] btrfs-progs: Remove unused parameter

2018-03-29 Thread Gu Jinxiang
Parameter usagestr is not used, remove it. Signed-off-by: Gu Jinxiang --- cmds-filesystem.c | 2 +- help.c| 2 +- help.h| 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/cmds-filesystem.c b/cmds-filesystem.c index

[PATCH 1/7] btrfs: cleanup btrfs_check_super_csum() for better code flow

2018-03-29 Thread Anand Jain
We check the %csum_type twice. Drop one. Check for the csum_type and then for the csum. Which also matches with the progs which have better logic. This is preparatory patch to get proper error code from btrfs_check_super_csum(). Signed-off-by: Anand Jain Reviewed-by:

[PATCH v2 4/7] btrfs: check if the fsid in the primary sb and copy sb are same

2018-03-29 Thread Anand Jain
During the btrfs dev scan make sure that other copies of superblock contain the same fsid as the primary SB. So that we bring to the user notice if the superblock has been overwritten. mkfs.btrfs -fq /dev/sdc mkfs.btrfs -fq /dev/sdb dd if=/dev/sdb of=/dev/sdc count=4K skip=64K seek=64K obs=1

[PATCH v4 0/7] Superblock read and verify cleanups

2018-03-29 Thread Anand Jain
v3->v4: Update changelog and signoff. Reintroduce explicit check for '-EUCLEAN' at Patch 2/8 and 5/8. v2->v3: Squash 4/8 btrfs: make btrfs_check_super_csum() non static to 6/8 btrfs: verify superblock checksum during scan As in the individual patch mentioned v1->v2: Various changes

[PATCH v4 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Anand Jain
Return the required -EINVAL and -EUCLEAN from the function btrfs_check_super_csum(). And more the error log into the parent function. Signed-off-by: Anand Jain Reviewed-by: Nikolay Borisov --- v2->v4: Check for -EUCLEAN in else if v1->v2: Fix commit

[PATCH v2 3/7] btrfs: cleanup btrfs_read_disk_super() to return std error

2018-03-29 Thread Anand Jain
The only caller btrfs_scan_one_device() sets -EINVAL for error from btrfs_read_disk_super(), so this patch returns -EINVAL from the latter function. A preparatory patch to add csum check in btrfs_read_disk_super(). Signed-off-by: Anand Jain Reviewed-by: Nikolay Borisov

Re: [PATCH v2 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Anand Jain
@@ -2570,9 +2568,14 @@ int open_ctree(struct super_block *sb, * We want to check superblock checksum, the type is stored inside. * Pass the whole disk block of size BTRFS_SUPER_INFO_SIZE (4k). */ - if (btrfs_check_super_csum(fs_info, bh->b_data)) { -

[PATCH v4 5/7] btrfs: verify superblock checksum during scan

2018-03-29 Thread Anand Jain
During the scan context, we aren't verifying the superblock- checksum when read. This patch fixes it by adding the checksum verification function btrfs_check_super_csum() in the function btrfs_read_disk_super(). And makes device scan to error fail if the primary superblock csum is wrong, whereas

[PATCH] btrfs-progs: wipe copies of the stale superblock beyond -b size

2018-03-29 Thread Anand Jain
During the mkfs.btrfs -b btrfs_prepare_device() zeros all the superblock bytenr locations only if the bytenr is below the blockcount. The problem with this is that if the BTRFS is recreated with a smaller size then we will leave the stale superblock in the disk which shall confuse the recovery.

[PATCH 7/7] btrfs: drop the redundant invalidate_bdev()

2018-03-29 Thread Anand Jain
During the mount context btrfs_open_devices() calls invalidate_bdev() for all the devices. So drop the invalidate_bdev() in open_ctree() which is only for the btrfs_fs_devices::latest_bdev. The call trace is as shown below. btrfs_mount_root() | |_btrfs_parse_early_options (-o device only) |

Re: Status of RAID5/6

2018-03-29 Thread Zygo Blaxell
On Wed, Mar 21, 2018 at 09:02:36PM +0100, Christoph Anton Mitterer wrote: > Hey. > > Some things would IMO be nice to get done/clarified (i.e. documented in > the Wiki and manpages) from users'/admin's POV: > > Some basic questions: I can answer some easy ones: > - compression+raid? There

Re: [PATCH] fstests: test btrfs fsync after hole punching with no-holes mode

2018-03-29 Thread Jayashree Mohan
Hi Filipe, I tried running the xfstest above on kernel 4.15.0 and I haven't been able to hit the bug. The xfstest passes clean for me. I compared the btrfs-debug-tree in my case with the one attached by Eryu, and I see I do not have any xattr as he does. However, for every run of the xfstest, the

Re: [RFC PATCH v3 0/7] btrfs-progs: Allow normal user to call "subvolume list/show"

2018-03-29 Thread Goffredo Baroncelli
Hi Misono, I tested you patch, and it seems to work. I verified that the output is correct and the permission check is performed. However the output of "btrfs sub list" in the "root" mode and the "user" mode are a bit different. As reported before, I find your output more consistent, and

Re: [PATCH] Btrfs: print error messages when failing to read trees

2018-03-29 Thread Liu Bo
On Wed, Mar 28, 2018 at 11:24 PM, Nikolay Borisov wrote: > > > On 29.03.2018 01:11, Liu Bo wrote: >> When mount fails to read trees like fs tree, checksum tree, extent >> tree, etc, there is not enough information about where went wrong. >> >> With this, messages like >> >>

Re: [PATCH] fstests: test btrfs fsync after hole punching with no-holes mode

2018-03-29 Thread Filipe Manana
On Wed, Mar 28, 2018 at 11:33 AM, Eryu Guan wrote: > On Wed, Mar 28, 2018 at 09:48:17AM +0100, Filipe Manana wrote: >> On Wed, Mar 28, 2018 at 3:17 AM, Eryu Guan wrote: >> > On Mon, Mar 26, 2018 at 11:59:21PM +0100, fdman...@kernel.org wrote: >> >> From:

Re: [PATCH v3 5/7] btrfs: verify superblock checksum during scan

2018-03-29 Thread Nikolay Borisov
On 29.03.2018 13:37, Anand Jain wrote: > During the scan context, we aren't verifying the superblock- > checksum when read. > This patch fixes it by adding the checksum verification function > btrfs_check_super_csum() in the function btrfs_read_disk_super(). > And makes device scan to error fail

Re: [PATCH v2 4/7] btrfs: check if the fsid in the primary sb and copy sb are same

2018-03-29 Thread Nikolay Borisov
On 29.03.2018 13:37, Anand Jain wrote: > During the btrfs dev scan make sure that other copies of superblock > contain the same fsid as the primary SB. So that we bring to the > user notice if the superblock has been overwritten. > > mkfs.btrfs -fq /dev/sdc > mkfs.btrfs -fq /dev/sdb > dd

Re: [PATCH v2 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Nikolay Borisov
On 29.03.2018 13:36, Anand Jain wrote: > Return the required -EINVAL and -EUCLEAN from the function > btrfs_check_super_csum(). And more the error log into the > parent function. > > Signed-off-by: Anand Jain > v1->v2: > Fix commit indent reported by checkpatch.pl >

[PATCH v3 5/7] btrfs: verify superblock checksum during scan

2018-03-29 Thread Anand Jain
During the scan context, we aren't verifying the superblock- checksum when read. This patch fixes it by adding the checksum verification function btrfs_check_super_csum() in the function btrfs_read_disk_super(). And makes device scan to error fail if the primary superblock csum is wrong, whereas

[PATCH v2 6/7] btrfs: verify checksum for all devices in mount context

2018-03-29 Thread Anand Jain
During mount context, we aren't verifying the superblock checksum for all the devices, instead, we verify it only for the struct btrfs_fs_device::latest_bdev. This patch fixes it by moving the checksum verification code from the function open_ctree() into the function btrfs_read_dev_one_super().

[PATCH v2 2/7] btrfs: return required error from btrfs_check_super_csum

2018-03-29 Thread Anand Jain
Return the required -EINVAL and -EUCLEAN from the function btrfs_check_super_csum(). And more the error log into the parent function. Signed-off-by: Anand Jain v1->v2: Fix commit indent reported by checkpatch.pl Fix pr_err split string --- fs/btrfs/disk-io.c | 25

[PATCH v2 4/7] btrfs: check if the fsid in the primary sb and copy sb are same

2018-03-29 Thread Anand Jain
During the btrfs dev scan make sure that other copies of superblock contain the same fsid as the primary SB. So that we bring to the user notice if the superblock has been overwritten. mkfs.btrfs -fq /dev/sdc mkfs.btrfs -fq /dev/sdb dd if=/dev/sdb of=/dev/sdc count=4K skip=64K seek=64K obs=1

[PATCH] btrfs-progs: wipe copies of the stale superblock beyond -b size

2018-03-29 Thread Anand Jain
During the mkfs.btrfs -b btrfs_prepare_device() zeros all the superblock bytenr locations only if the bytenr is below the blockcount. The problem with this is that if the BTRFS is recreated with a smaller size then we will leave the stale superblock in the disk which shall confuse the recovery.

[PATCH 7/7] btrfs: drop the redundant invalidate_bdev()

2018-03-29 Thread Anand Jain
During the mount context btrfs_open_devices() calls invalidate_bdev() for all the devices. So drop the invalidate_bdev() in open_ctree() which is only for the btrfs_fs_devices::latest_bdev. The call trace is as shown below. btrfs_mount_root() | |_btrfs_parse_early_options (-o device only) |

[PATCH 1/7] btrfs: cleanup btrfs_check_super_csum() for better code flow

2018-03-29 Thread Anand Jain
We check the %csum_type twice. Drop one. Check for the csum_type and then for the csum. Which also matches with the progs which have better logic. This is preparatory patch to get proper error code from btrfs_check_super_csum(). Signed-off-by: Anand Jain Reviewed-by:

[PATCH v3 0/9] Superblock read and verify cleanups

2018-03-29 Thread Anand Jain
v2->v3: Squash 4/8 btrfs: make btrfs_check_super_csum() non static to 6/8 btrfs: verify superblock checksum during scan As in the individual patch mentioned v1->v2: Various changes suggested by Nicokay. Thanks. For specific changes pls ref to the patch. Patch 1-4/8 are preparatory

[PATCH v2 3/7] btrfs: cleanup btrfs_read_disk_super() to return std error

2018-03-29 Thread Anand Jain
The only caller btrfs_scan_one_device() sets -EINVAL for error from btrfs_read_disk_super(), so this patch returns -EINVAL from the latter function. A preparatory patch to add csum check in btrfs_read_disk_super(). Signed-off-by: Anand Jain Reviewed-by: Nikolay Borisov

[PATCH typo-fixed] fstests: btrfs: 159 superblock corruption test case

2018-03-29 Thread Anand Jain
Verify if the superblock corruption is handled correctly. Signed-off-by: Anand Jain --- tests/btrfs/159 | 142 tests/btrfs/159.out | 35 + tests/btrfs/group | 1 + 3 files changed, 178 insertions(+)

Re: [PATCH v2 5/8] btrfs: check if the fsid in the primary sb and copy sb are same

2018-03-29 Thread Anand Jain
- btrfs_release_disk_super(page); -> error_bdev_put: You need a check whether page_primary is set here and release it, otherwise you are leaking it. This needs to handle both the primary sb read failure (where page_primary might not be set) as well as any FSID mismatch from loop.

Re: [PATCH v2 6/8] btrfs: verify superblock checksum during scan

2018-03-29 Thread Anand Jain
On 03/28/2018 03:21 PM, Nikolay Borisov wrote: On 28.03.2018 02:39, Anand Jain wrote: During the scan context, we aren't verifying the superblock- checksum when read. This patch fixes it by adding the checksum verification function btrfs_check_super_csum() in the function

[PATCH] fstests: btrfs: 159 superblock courruption test case

2018-03-29 Thread Anand Jain
Verify if the superblock corruption is handled correctly. Signed-off-by: Anand Jain --- tests/btrfs/159 | 142 tests/btrfs/159.out | 35 + tests/btrfs/group | 1 + 3 files changed, 178 insertions(+)

[PATCH] btrfs-progs: Do not add extra slash if given path end with it

2018-03-29 Thread Gu Jinxiang
When use a given path end with a slash like below, the output of path will have double slash. Do not add extra slash if there is already one in the given path. $ btrfs filesystem du ./test/ output: Total Exclusive Set shared Filename 0.00B 0.00B -

Re: [PATCH v2 1/3] btrfs-progs: fi usage: change warning message more appropriately

2018-03-29 Thread Nikolay Borisov
On 29.03.2018 11:22, Misono Tomohiro wrote: > "fi usage" shows the warning "RAID5/6 numbers will be incorrect" when > running without root privilege even if raid5/6 is not used. What > happens is it cannot get the per device profile usage info, so change > the message more appropriately. > >

[PATCH v2 2/3] btrfs-progs: fi usage: change to output more info without root privilege

2018-03-29 Thread Misono Tomohiro
Although per device usage cannot be shown without root privilege, per profile usage can be shown. To achieve this, we just basically need to remove the check of nullness of chunkinfo in print_filesystem_usage_by_chunk(), because other functions except print_unused() properly handles chunkinfo by

[PATCH 1/5] libbtrfsutil: don't return free space cache inodes from deleted_subvolumes()

2018-03-29 Thread Omar Sandoval
From: Omar Sandoval Deleted free space cache inodes also get an orphan item in the root tree, but we shouldn't report those as deleted subvolumes. Deleted subvolumes will still have the root item, so we can just do an extra tree search. Reported-by: Tomohiro Misono

[PATCH 2/5] libbtrfsutil: fix memory leak in deleted_subvolumes()

2018-03-29 Thread Omar Sandoval
From: Omar Sandoval If we fail to reallocate the ID array, we still need to free it. Signed-off-by: Omar Sandoval --- libbtrfsutil/subvolume.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libbtrfsutil/subvolume.c

[PATCH 4/5] libbtrfsutil: always build libbtrfsutil.so.$MAJOR

2018-03-29 Thread Omar Sandoval
From: Omar Sandoval Otherwise, make test-libbtrfsutil from a fresh checkout fails. Signed-off-by: Omar Sandoval --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 699f864d..fbd6677a 100644 --- a/Makefile

[PATCH 0/5] libbtrfsutil: misc fixes

2018-03-29 Thread Omar Sandoval
From: Omar Sandoval Hi, Dave, This is a handful of minor fixes for libbtrfsutil that would be good to get in before the release. Patch 1 fixes an issue reported by Tomohiro a few weeks back. Patch 2 fixes a memory leak I noticed while writing patch 1. Patch 3 makes us use the

[PATCH 5/5] libbtrfsutil: fix test assumptions about top-level subvolume

2018-03-29 Thread Omar Sandoval
From: Omar Sandoval Since "btrfs-progs: mkfs: add uuid and otime to ROOT_ITEM of, FS_TREE", the top-level subvolume has a non-zero UUID, ctime, and otime. Fix the subvolume_info() test to not check for zero. Signed-off-by: Omar Sandoval ---