Re: [PATCH] btrfs: fix invalid memory access with journal_info

2018-05-09 Thread robbieko
Omar Sandoval 於 2018-05-10 12:53 寫到: On Wed, May 09, 2018 at 06:35:25PM +0800, robbieko wrote: From: Robbie Ko When send process requires memory allocation, shrinker may be triggered due to insufficient memory. Then evict_inode gets called when inode is freed, and

Re: [PATCH] btrfs: fix invalid memory access with journal_info

2018-05-09 Thread Omar Sandoval
On Wed, May 09, 2018 at 06:35:25PM +0800, robbieko wrote: > From: Robbie Ko > > When send process requires memory allocation, shrinker may be triggered > due to insufficient memory. > Then evict_inode gets called when inode is freed, and this function > may need to start

[PATCH 3/3] btrfs-progs: print-tree: Enhance btrfs_print_tree() check to avoid out-of-boundary memory access

2018-05-09 Thread Qu Wenruo
For btrfs_print_tree(), if nr_items is corrupted, it can easily go beyond extent buffer boundary. Add extra nr_item check, and only print as many valid slots as possible. Signed-off-by: Qu Wenruo --- changelog: v2: Use better loop condition suggested by Su. --- print-tree.c |

[PATCH v2] btrfs: return original error code when failing from option parsing

2018-05-09 Thread Chengguang Xu
It's no good to overwrite -ENOMEM using -EINVAL when failing from mount option parsing, so just return original error code. Signed-off-by: Chengguang Xu Reviewed-by: David Sterba Reviewed-by: Qu Wenruo --- v1->v2: - Remove bracket for single

Re: [PATCH 1/2] btrfs-progs: check: Make btrfs check return error for qgroup mismatch

2018-05-09 Thread Qu Wenruo
On 2018年05月09日 01:45, David Sterba wrote: > On Mon, Apr 30, 2018 at 02:16:59PM +0800, Qu Wenruo wrote: >> Current btrfs-check will check qgroup consistency, but even when it >> finds something wrong, the return value is still 0. >> >> Fix it by allowing report_qgroups() to return int to indicate

Re: [PATCH] btrfs: return original error code when failing from option parsing

2018-05-09 Thread Qu Wenruo
On 2018年05月10日 08:34, Qu Wenruo wrote: > > > On 2018年05月09日 21:08, Chengguang Xu wrote: >> It's no good to overwrite -ENOMEM using -EINVAL when failing >> from mount option parsing, so just return original error code. >> >> Signed-off-by: Chengguang Xu > > Reviewed-by: Qu

Re: [PATCH] btrfs: return original error code when failing from option parsing

2018-05-09 Thread Qu Wenruo
On 2018年05月09日 21:08, Chengguang Xu wrote: > It's no good to overwrite -ENOMEM using -EINVAL when failing > from mount option parsing, so just return original error code. > > Signed-off-by: Chengguang Xu Reviewed-by: Qu Wenruo Thanks, Qu > --- >

Re: [PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread David Sterba
On Wed, May 09, 2018 at 11:01:21AM -0500, Eric Sandeen wrote: > Move the btrfs label ioctls up to the vfs for general use. > > This retains 256 chars as the maximum size through the interface, which > is the btrfs limit and AFAIK exceeds any other filesystem's maximum > label size. > >

Re: [PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread Eric Sandeen
On 5/9/18 12:35 PM, Randy Dunlap wrote: > On 05/09/2018 09:01 AM, Eric Sandeen wrote: >> Move the btrfs label ioctls up to the vfs for general use. >> >> This retains 256 chars as the maximum size through the interface, which >> is the btrfs limit and AFAIK exceeds any other filesystem's maximum

Re: [PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread Randy Dunlap
On 05/09/2018 09:01 AM, Eric Sandeen wrote: > Move the btrfs label ioctls up to the vfs for general use. > > This retains 256 chars as the maximum size through the interface, which > is the btrfs limit and AFAIK exceeds any other filesystem's maximum > label size. > > Signed-off-by: Eric Sandeen

Re: [PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread Darrick J. Wong
On Wed, May 09, 2018 at 11:15:46AM -0600, Andreas Dilger wrote: > On May 9, 2018, at 10:10 AM, Darrick J. Wong wrote: > > > > On Wed, May 09, 2018 at 11:01:21AM -0500, Eric Sandeen wrote: > >> Move the btrfs label ioctls up to the vfs for general use. > >> > >> This

Re: [PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread Andreas Dilger
On May 9, 2018, at 10:10 AM, Darrick J. Wong wrote: > > On Wed, May 09, 2018 at 11:01:21AM -0500, Eric Sandeen wrote: >> Move the btrfs label ioctls up to the vfs for general use. >> >> This retains 256 chars as the maximum size through the interface, which >> is the

Re: [PATCH] test online label ioctl

2018-05-09 Thread Eric Sandeen
On 5/9/18 10:49 AM, Eryu Guan wrote: > On Mon, Apr 30, 2018 at 04:43:18PM -0500, Eric Sandeen wrote: >> This tests the online label ioctl that btrfs has, which has been >> recently proposed for XFS. >> >> To run, it requires an updated xfs_io with the label command and a >> filesystem that

Re: [PATCH v2 1/2] Btrfs: fiemap: pass correct bytenr when fm_extent_count is zero

2018-05-09 Thread Nikolay Borisov
On 7.05.2018 11:42, robbieko wrote: > From: Robbie Ko > > [BUG] > fm_mapped_extents is not correct when fm_extent_count is 0 > Like: ># mount /dev/vdb5 /mnt/btrfs ># dd if=/dev/zero bs=16K count=4 oflag=dsync of=/mnt/btrfs/file ># xfs_io -c "fiemap -v"

Re: [PATCH 2/2] man2: New page documenting filesystem get/set label ioctls

2018-05-09 Thread Darrick J. Wong
On Wed, May 09, 2018 at 11:04:03AM -0500, Eric Sandeen wrote: > This documents the proposed new vfs-level ioctls which can > get or set a mounted filesytem's label. > > Signed-off-by: Eric Sandeen > --- > > btrfs folks, please verify that this accurately describes your >

Re: [PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread Darrick J. Wong
On Wed, May 09, 2018 at 11:01:21AM -0500, Eric Sandeen wrote: > Move the btrfs label ioctls up to the vfs for general use. > > This retains 256 chars as the maximum size through the interface, which > is the btrfs limit and AFAIK exceeds any other filesystem's maximum > label size. > >

[PATCH 2/2] man2: New page documenting filesystem get/set label ioctls

2018-05-09 Thread Eric Sandeen
This documents the proposed new vfs-level ioctls which can get or set a mounted filesytem's label. Signed-off-by: Eric Sandeen --- btrfs folks, please verify that this accurately describes your current behavior, thanks. diff --git a/man2/ioctl_fslabel.2

[PATCH 1/2] fs: hoist BTRFS_IOC_[SG]ET_FSLABEL to vfs

2018-05-09 Thread Eric Sandeen
Move the btrfs label ioctls up to the vfs for general use. This retains 256 chars as the maximum size through the interface, which is the btrfs limit and AFAIK exceeds any other filesystem's maximum label size. Signed-off-by: Eric Sandeen --- Let the bikeshedding on the

[PATCH 0/2] hoist btrfs' label set/get ioctls to vfs, and document

2018-05-09 Thread Eric Sandeen
I'm planning to add online label set/get support to xfs, and to do so I plan to re-use the existing btrfs ioctls, BTRFS_IOC_[SG]ET_FSLABEL We're still working out minor details on the xfs side, but I'd like to start the conversation regarding the new more generic interface ASAP, so here goes -

Re: [PATCH] test online label ioctl

2018-05-09 Thread Eryu Guan
On Mon, Apr 30, 2018 at 04:43:18PM -0500, Eric Sandeen wrote: > This tests the online label ioctl that btrfs has, which has been > recently proposed for XFS. > > To run, it requires an updated xfs_io with the label command and a > filesystem that supports it > > A slight change here to

[PATCH] Btrfs: fix duplicate extents after fsync of file with prealloc extents

2018-05-09 Thread fdmanana
From: Filipe Manana In commit 471d557afed1 ("Btrfs: fix loss of prealloc extents past i_size after fsync log replay"), on fsync, we started to always log all prealloc extents beyond an inode's i_size in order to avoid losing them after a power failure. However under some

Re: [PATCH] btrfs: return original error code when failing from option parsing

2018-05-09 Thread David Sterba
On Wed, May 09, 2018 at 09:08:23PM +0800, Chengguang Xu wrote: > It's no good to overwrite -ENOMEM using -EINVAL when failing > from mount option parsing, so just return original error code. > > Signed-off-by: Chengguang Xu Reviewed-by: David Sterba -- To

[PATCH v2 4/8] btrfs: rename btrfs_flags_to_ioctl to reflect which flags it touches

2018-05-09 Thread David Sterba
Converts btrfs_inode::flags to the FS_*_FL flags. Signed-off-by: David Sterba --- fs/btrfs/ioctl.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 0b84f9e68f86..40eeb99310d5 100644 --- a/fs/btrfs/ioctl.c

[PATCH v2 3/8] btrfs: rename check_flags to reflect which flags it touches

2018-05-09 Thread David Sterba
The FS_*_FL flags cannot be easily identified by a prefix but we still need to recognize them so the 'fsflags' should be closer to the naming scheme but again the 'fs' part sounds like it's a filesystem flag. I don't have a better idea for now. Signed-off-by: David Sterba ---

[PATCH v2 8/8] btrfs: unify naming of flags variables for SETFLAGS and XFLAGS

2018-05-09 Thread David Sterba
* The simple 'flags' refer to the btrfs inode * ... that's in 'binode * the FS_*_FL variables are 'fsflags' * the old copies of the variable are prefixed by 'old_' * Struct inode flags contain 'i_flags'. Signed-off-by: David Sterba --- fs/btrfs/ioctl.c | 106

[PATCH v2 6/8] btrfs: add FS_IOC_FSGETXATTR ioctl

2018-05-09 Thread David Sterba
The new ioctl is an extension to the FS_IOC_GETFLAGS and adds new flags and is extensible. This patch allows to return the xflags portion of the fsxattr structure, other items have no meaning for btrfs or can be added later. The original patch was written by Chandan Jay Sharma but was incomplete

[PATCH v2 5/8] btrfs: add helpers for FS_XFLAG_* conversion

2018-05-09 Thread David Sterba
Preparatory work for the FS_IOC_FSGETXATTR ioctl, basic conversions and checking helpers. Signed-off-by: David Sterba --- fs/btrfs/ioctl.c | 32 1 file changed, 32 insertions(+) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index

[PATCH v2 7/8] btrfs: add FS_IOC_FSSETXATTR ioctl

2018-05-09 Thread David Sterba
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 extended attributes, incidentally also abbreviated as XATTRs. This patch allows to set the xflags portion of the

[PATCH v2 1/8] btrfs: rename btrfs_update_iflags to reflect which flags it touches

2018-05-09 Thread David Sterba
The btrfs inode flag flavour is now simply called 'inode flags' and the vfs inode are i_flags. Also rename the internal variable to something less confusing than 'ip'. Signed-off-by: David Sterba --- fs/btrfs/ctree.h | 2 +- fs/btrfs/inode.c | 4 ++-- fs/btrfs/ioctl.c | 4 ++--

[PATCH v2 0/8] Add ioctl to support extended inode flags

2018-05-09 Thread David Sterba
Changes for v2: - dropped renaming of variable from patch "btrfs: rename btrfs_flags_to_ioctl to reflect which flags it touches" - fixed the error handling in "btrfs: add FS_IOC_FSSETXATTR ioctl" - new patch to unify naming of some local variables I'm about to add this patchset to the main

[PATCH v2 2/8] btrfs: rename btrfs_mask_flags to reflect which flags it touches

2018-05-09 Thread David Sterba
The FS_*_FL flags cannot be easily identified by a variable name prefix but we still need to recognize them so the 'fsflags' should be closer to the naming scheme but again the 'fs' part sounds like it's a filesystem flag. I don't have a better idea for now. Signed-off-by: David Sterba

Re: [PATCH] btrfs: qgroup: Finish rescan when hit the last leaf of extent tree

2018-05-09 Thread Qu Wenruo
On 2018年05月09日 21:00, David Sterba wrote: > On Fri, May 04, 2018 at 01:56:59PM +0800, Qu Wenruo wrote: >> Under the following case, qgroup rescan can double account cowed tree >> blocks: >> >> In this case, extent tree only has one tree block. >> >> - >> | transid=5 last committed=4 >> |

[PATCH] btrfs: return original error code when failing from option parsing

2018-05-09 Thread Chengguang Xu
It's no good to overwrite -ENOMEM using -EINVAL when failing from mount option parsing, so just return original error code. Signed-off-by: Chengguang Xu --- fs/btrfs/super.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index

Re: [PATCH] btrfs: qgroup: Search commit root for rescan to avoid missing extent

2018-05-09 Thread David Sterba
On Thu, May 03, 2018 at 03:20:52PM +0800, Qu Wenruo wrote: > When doing qgroup rescan using the following script (modified from > btrfs/017 test case), we can sometimes hit qgroup corruption. > > -- > umount $dev &> /dev/null > umount $mnt &> /dev/null > > mkfs.btrfs -f -n 64k $dev > mount

Re: [PATCH] btrfs: qgroup: Finish rescan when hit the last leaf of extent tree

2018-05-09 Thread David Sterba
On Fri, May 04, 2018 at 01:56:59PM +0800, Qu Wenruo wrote: > Under the following case, qgroup rescan can double account cowed tree > blocks: > > In this case, extent tree only has one tree block. > > - > | transid=5 last committed=4 > | btrfs_qgroup_rescan_worker() > | |-

Re: [PATCH v2] btrfs-progs: tests: test mkfs.btrfs fails on small backing size thin provision device

2018-05-09 Thread David Sterba
On Thu, Apr 12, 2018 at 09:10:28AM +0800, Su Yue wrote: > This tests is most similar to xfstests generic/405. > It calls device mapper to create a thin provision device with small > backing size and big virtual size. mkfs.btrfs should fail on such > devices. > > This test should pass after commit

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

2018-05-09 Thread David Sterba
On Tue, Apr 24, 2018 at 01:52:31PM +0800, Su Yue wrote: > There is no delayed ref in btrfs-progs, so remove related comments. > > Signed-off-by: Su Yue 1-3 applied. Please send cover letter for patch series with more than 1 patch. -- To unsubscribe from this list: send

Re: [PATCH 3/3] btrfs-progs: print-tree: Enhance btrfs_print_tree() check to avoid out-of-boundary memory access

2018-05-09 Thread David Sterba
On Mon, Apr 30, 2018 at 11:51:19AM +0800, Qu Wenruo wrote: > >>   btrfs_print_leaf(eb); > >>   return; > >>   } > >> +    /* We are crossing eb boundary, this node must be corrupted */ > >> +    if (nr > BTRFS_NODEPTRS_PER_EXTENT_BUFFER(eb)) > >> +    warning( > >> +   

Re: [PATCH 1/3] btrfs-progs: Remove fs_info parameter from btrfs_leaf_free_space()

2018-05-09 Thread David Sterba
On Mon, Apr 30, 2018 at 11:15:43AM +0800, Qu Wenruo wrote: > For btrfs_leaf_free_space(), to get leaf data size, we have two way to > get it: > > 1) leaf->fs_info->nodesize > 2) leaf->len > > Anyway, we could get rid of @fs_info parameter for > btrfs_leaf_free_space(). > And here we choose

Re: [PATCH 1/3] btrfs-progs: convert: fix support for e2fsprogs < 1.42

2018-05-09 Thread David Sterba
On Mon, Apr 30, 2018 at 10:37:06AM -0400, je...@suse.com wrote: > From: Jeff Mahoney > > Commit 324d4c1857a (btrfs-progs: convert: Add larger device support) > introduced new dependencies on the 64-bit API provided by e2fsprogs. > That API was introduced in v1.42 (along with

Re: [PATCH v2 0/3] btrfs-progs: Some fix for fi usage

2018-05-09 Thread David Sterba
On Thu, Mar 29, 2018 at 05:21:29PM +0900, Misono Tomohiro wrote: > v1->v2 > These were sent several months ago, just rebased to current devel branch. > > Patch 1 and 2 aims to fix the "fi du" to include the information of "fi df" > even when running without root privilege. > > Patch 3 is an

Re: [PATCH 00/10] Simplify function interfaces

2018-05-09 Thread David Sterba
On Wed, May 02, 2018 at 08:50:54AM +0300, Nikolay Borisov wrote: > On 27.03.2018 10:19, Nikolay Borisov wrote: > > A bunch of functions in lowmem mode take an 'ext_ref' parameter only to > > pass it > > down the call chain where it eventually is consumed. Turns out the functions > > which

Re: [PATCH 1/2] btrfs-progs: Fix DIR_ITEM checking in lowmem

2018-05-09 Thread David Sterba
On Wed, May 02, 2018 at 08:50:38AM +0300, Nikolay Borisov wrote: > > correctly. > > > > Fixes: 564901eac7a4 ("btrfs-progs: check: introduce print_dir_item_err()") > > Signed-off-by: Nikolay Borisov > > --- > > Ping Applied, thanks. -- To unsubscribe from this list: send the

[PATCH] btrfs: fix invalid memory access with journal_info

2018-05-09 Thread robbieko
From: Robbie Ko When send process requires memory allocation, shrinker may be triggered due to insufficient memory. Then evict_inode gets called when inode is freed, and this function may need to start transaction. However, the journal_info is already points to

Re: [PATCH v2 0/2] btrfs :incremental send, improve rmdir performance

2018-05-09 Thread David Sterba
On Tue, May 08, 2018 at 06:11:36PM +0800, robbieko wrote: > From: Robbie Ko > > The following patch is to improve the btrfs send, the speed of large > directory deletion. > > 1. Optimization, avoid unnecessary allocations. > > 2. Increase the speed of can_rmdir. > >

Re: [PATCH] btrfs: incremental send, fix BUG when parent commit_root changed

2018-05-09 Thread robbieko
Hi Filipe Manana, Ok. I will add all this information, in detail, to the changelog, and than send a patch V2 later. Thanks. Robbie Ko Filipe Manana 於 2018-05-09 16:29 寫到: On Wed, May 9, 2018 at 2:10 AM, robbieko wrote: Filipe Manana 於 2018-05-08 19:12 寫到: On Tue,

Re: [PATCH] btrfs: incremental send, fix BUG when parent commit_root changed

2018-05-09 Thread Filipe Manana
On Wed, May 9, 2018 at 2:10 AM, robbieko wrote: > Filipe Manana 於 2018-05-08 19:12 寫到: >> >> On Tue, May 8, 2018 at 11:30 AM, robbieko wrote: >>> >>> Hi Filipe Manana, >>> >>> Although the snapshot is readonly, when the snapshot is created, >>> in

Re: [RFC][PATCH 0/76] vfs: 'views' for filesystems with more than one root

2018-05-09 Thread Dave Chinner
On Tue, May 08, 2018 at 10:06:44PM -0400, Jeff Mahoney wrote: > On 5/8/18 7:38 PM, Dave Chinner wrote: > > On Tue, May 08, 2018 at 11:03:20AM -0700, Mark Fasheh wrote: > >> Hi, > >> > >> The VFS's super_block covers a variety of filesystem functionality. In > >> particular we have a single