Re: off-by-one uncompressed invalid ram_bytes corruptions

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 13:23, Steve Leung wrote: > Hi list, > > I've got 3-device raid1 btrfs filesystem that's throwing up some > "corrupt leaf" errors in dmesg.  This is a uniquified list I've > observed lately: > >   BTRFS critical (device sda1): corrupt leaf: root=1 block=4970196795392 > slot=307

Re: [PATCH 4/6] Btrfs: remove unused check of skip_locking

2018-05-17 Thread Nikolay Borisov
On 18.05.2018 05:55, Liu Bo wrote: > On Wed, May 16, 2018 at 3:03 PM, Nikolay Borisov wrote: >> >> >> On 15.05.2018 20:52, Liu Bo wrote: >>> The check is superfluous since all of callers who set search_for_commit >>> also have skip_locking set. >> >> This is false. For

Re: [PATCH v2 6/6] Btrfs: remove always true check in unlock_up

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 11:00, Liu Bo wrote: > As unlock_up() is written as > > for () { >if (!path->locks[i]) >break; >... >if (... && path->locks[i]) { >} > } > > Apparently, @path->locks[i] is always true at this 'if'. > > Signed-off-by: Liu Bo

off-by-one uncompressed invalid ram_bytes corruptions

2018-05-17 Thread Steve Leung
Hi list, I've got 3-device raid1 btrfs filesystem that's throwing up some "corrupt leaf" errors in dmesg. This is a uniquified list I've observed lately: BTRFS critical (device sda1): corrupt leaf: root=1 block=4970196795392 slot=307 ino=206231 file_offset=0, invalid ram_bytes for

Re: [PATCH v2 4/6] Btrfs: remove unused check of skip_locking

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 11:00, Liu Bo wrote: > The check is superfluous since all of callers who set search_for_commit > also have skip_locking set. > > Signed-off-by: Liu Bo Reviewed-by: Qu Wenruo Although more obvious comment about search_commit_root and

Re: [PATCH v2 2/6] Btrfs: use more straightforward extent_buffer_uptodate

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 11:00, Liu Bo wrote: > If parent_transid "0" is passed to btrfs_buffer_uptodate(), > btrfs_buffer_uptodate() is equivalent to extent_buffer_uptodate(), but > extent_buffer_uptodate() is preferred since we don't have to look into > verify_parent_transid(). > > Signed-off-by: Liu

Re: [PATCH v2 3/6] Btrfs: move get root of btrfs_search_slot to a helper

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 11:00, Liu Bo wrote: > It's good to have a helper instead of having all get-root details > open-coded. > > The new helper locks (if necessary) and sets root node of the path. > > Also invert the checks to make the code flow easier to read. > > There is no functional change in

RE: [PATCH v6 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-17 Thread Gu, Jinxiang
> -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Tomohiro Misono > Sent: Friday, May 18, 2018 10:55 AM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH v6 2/3] btrfs: Add unprivileged ioctl which returns >

Re: [PATCH v2 1/6] Btrfs: remove superfluous free_extent_buffer

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 11:00, Liu Bo wrote: > read_block_for_search() can be simplified as, > > tmp = find_extent_buffer(); > if (tmp) >return; > > free_extent_buffer(); > read_tree_block(); > > Apparently, @tmp must be NULL at this point, free_extent_buffer() is not > needed.> > Signed-off-by:

Re: [PATCH v2] Btrfs: add parent_transid parameter to veirfy_level_key

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 13:02, Nikolay Borisov wrote: > > > On 18.05.2018 05:59, Liu Bo wrote: >> As verify_level_key() is checked after verify_parent_transid(), i.e. >> >> if (verify_parent_transid()) >>ret = -EIO; >> else if (verify_level_key()) >>ret = -EUCLEAN; >> >> if parent_transid is 0,

RE: [PATCH v6 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Gu, Jinxiang
> -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Tomohiro Misono > Sent: Friday, May 18, 2018 10:55 AM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH v6 1/3] btrfs: Add unprivileged ioctl which returns

Re: [PATCH v2] Btrfs: add parent_transid parameter to veirfy_level_key

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 10:59, Liu Bo wrote: > As verify_level_key() is checked after verify_parent_transid(), i.e. > > if (verify_parent_transid()) >ret = -EIO; > else if (verify_level_key()) >ret = -EUCLEAN; > > if parent_transid is 0, verify_parent_transid() skips verifying > parent_transid

Re: [PATCH v2] Btrfs: add parent_transid parameter to veirfy_level_key

2018-05-17 Thread Nikolay Borisov
On 18.05.2018 05:59, Liu Bo wrote: > As verify_level_key() is checked after verify_parent_transid(), i.e. > > if (verify_parent_transid()) >ret = -EIO; > else if (verify_level_key()) >ret = -EUCLEAN; > > if parent_transid is 0, verify_parent_transid() skips verifying > parent_transid

Re: [PATCH 05/18] btrfs-progs: qgroups: add pathname to show output

2018-05-17 Thread Misono Tomohiro
On 2018/05/17 6:38, je...@suse.com wrote: > From: Jeff Mahoney > > The btrfs qgroup show command currently only exports qgroup IDs, > forcing the user to resolve which subvolume each corresponds to. > > This patch adds pathname resolution to qgroup show so that when > the -P

Re: [PATCH V4] test online label ioctl

2018-05-17 Thread Dave Chinner
On Thu, May 17, 2018 at 10:28:26AM -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 v2 4/6] Btrfs: remove unused check of skip_locking

2018-05-17 Thread Liu Bo
The check is superfluous since all of callers who set search_for_commit also have skip_locking set. Signed-off-by: Liu Bo --- fs/btrfs/ctree.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index d12fc0474e21..8d3b09038f37

[PATCH v2 2/6] Btrfs: use more straightforward extent_buffer_uptodate

2018-05-17 Thread Liu Bo
If parent_transid "0" is passed to btrfs_buffer_uptodate(), btrfs_buffer_uptodate() is equivalent to extent_buffer_uptodate(), but extent_buffer_uptodate() is preferred since we don't have to look into verify_parent_transid(). Signed-off-by: Liu Bo --- fs/btrfs/ctree.c

[PATCH v2 1/6] Btrfs: remove superfluous free_extent_buffer

2018-05-17 Thread Liu Bo
read_block_for_search() can be simplified as, tmp = find_extent_buffer(); if (tmp) return; free_extent_buffer(); read_tree_block(); Apparently, @tmp must be NULL at this point, free_extent_buffer() is not needed. Signed-off-by: Liu Bo --- fs/btrfs/ctree.c | 1 -

[PATCH v2 3/6] Btrfs: move get root of btrfs_search_slot to a helper

2018-05-17 Thread Liu Bo
It's good to have a helper instead of having all get-root details open-coded. The new helper locks (if necessary) and sets root node of the path. Also invert the checks to make the code flow easier to read. There is no functional change in this commit. Signed-off-by: Liu Bo

[PATCH v2 5/6] Btrfs: grab write lock directly if write_lock_level is the max level

2018-05-17 Thread Liu Bo
Typically, when acquiring root node's lock, btrfs tries its best to get read lock and trade for write lock if @write_lock_level implies to do so. In case of (cow && (p->keep_locks || p->lowest_level)), write_lock_level is set to BTRFS_MAX_LEVEL, which means we need to acquire root node's write

[PATCH v2 6/6] Btrfs: remove always true check in unlock_up

2018-05-17 Thread Liu Bo
As unlock_up() is written as for () { if (!path->locks[i]) break; ... if (... && path->locks[i]) { } } Apparently, @path->locks[i] is always true at this 'if'. Signed-off-by: Liu Bo --- fs/btrfs/ctree.c | 2 +- 1 file changed, 1 insertion(+), 1

[PATCH v2 0/6] btrfs_search_slot cleanups

2018-05-17 Thread Liu Bo
Here are a collection of patches I did for btrfs_search_slot(). v2: more explicit commit log for each patch. Liu Bo (6): Btrfs: remove superfluous free_extent_buffer Btrfs: use more straightforward extent_buffer_uptodate Btrfs: move get root of btrfs_search_slot to a helper Btrfs: remove

[PATCH v2] Btrfs: add parent_transid parameter to veirfy_level_key

2018-05-17 Thread Liu Bo
As verify_level_key() is checked after verify_parent_transid(), i.e. if (verify_parent_transid()) ret = -EIO; else if (verify_level_key()) ret = -EUCLEAN; if parent_transid is 0, verify_parent_transid() skips verifying parent_transid and considers eb as valid, and if verify_level_key()

Re: [PATCH v6 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Misono Tomohiro
On 2018/05/18 11:54, Tomohiro Misono wrote: > Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns > the information of subvolume containing this inode. > (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) > > Signed-off-by: Tomohiro Misono

Re: [PATCH 4/6] Btrfs: remove unused check of skip_locking

2018-05-17 Thread Liu Bo
On Wed, May 16, 2018 at 3:03 PM, Nikolay Borisov wrote: > > > On 15.05.2018 20:52, Liu Bo wrote: >> The check is superfluous since all of callers who set search_for_commit >> also have skip_locking set. > > This is false. For example btrfs_qgroup_rescan_worker sets >

[PATCH v6 3/3] btrfs: Add unprivileged version of ino_lookup ioctl

2018-05-17 Thread Tomohiro Misono
Add unprivileged version of ino_lookup ioctl BTRFS_IOC_INO_LOOKUP_USER to allow normal users to call "btrfs subvolume list/show" etc. in combination with BTRFS_IOC_GET_SUBVOL_INFO/BTRFS_IOC_GET_SUBVOL_ROOTREF. This can be used like BTRFS_IOC_INO_LOOKUP but the argument is different. This is

[PATCH v6 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Tomohiro Misono
Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume containing this inode. (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) Signed-off-by: Tomohiro Misono --- v5 -> v6 - Use brfs_read_fs_root_no_name()

[PATCH v6 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-17 Thread Tomohiro Misono
changelog: v5 -> v6 - Update 1st patch by using btrfs_fs_root_no_name() - Return -EUCLEAN when btrfs_next_leaf/next_item() should not fail - Add Reviewed-by tag v4 -> v5 - Update error handling of 1st/2nd patch. See each log for details - Fix misspelling v3 -> v4 - call

[PATCH v6 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-17 Thread Tomohiro Misono
Add unprivileged ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF which returns ROOT_REF information of the subvolume containing this inode except the subvolume name (this is because to prevent potential name leak). The subvolume name will be gained by user version of ino_lookup ioctl

Re: [PATCH 2/6] Btrfs: use more straightforward extent_buffer_uptodate

2018-05-17 Thread Liu Bo
On Wed, May 16, 2018 at 2:43 PM, Nikolay Borisov wrote: > > > On 15.05.2018 20:52, Liu Bo wrote: >> In read_block_for_search(), it's straightforward to use >> extent_buffer_uptodate() instead since 0 is passed as parent transid to > > "instead of the more heavyweight

Re: [PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Misono Tomohiro
On 2018/05/18 10:10, Qu Wenruo wrote: > > > On 2018年05月18日 09:00, Misono Tomohiro wrote: >> On 2018/05/17 15:39, Qu Wenruo wrote: >>> >>> >>> On 2018年05月16日 13:49, Tomohiro Misono wrote: Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns the information of subvolume

Re: [PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Qu Wenruo
On 2018年05月18日 09:00, Misono Tomohiro wrote: > On 2018/05/17 15:39, Qu Wenruo wrote: >> >> >> On 2018年05月16日 13:49, Tomohiro Misono wrote: >>> Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns >>> the information of subvolume containing this inode. >>> (i.e. returns the

Re: [PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Misono Tomohiro
On 2018/05/17 15:39, Qu Wenruo wrote: > > > On 2018年05月16日 13:49, Tomohiro Misono wrote: >> Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns >> the information of subvolume containing this inode. >> (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) >> >>

Re: [PATCH 2/2] vfs: dedupe should return EPERM if permission is not granted

2018-05-17 Thread Mark Fasheh
On Thu, May 17, 2018 at 01:15:51AM -0400, Zygo Blaxell wrote: > On Sun, May 13, 2018 at 11:26:39AM -0700, Darrick J. Wong wrote: > > On Sun, May 13, 2018 at 06:21:52PM +, Mark Fasheh wrote: > > > On Fri, May 11, 2018 at 05:06:34PM -0700, Darrick J. Wong wrote: > > > > On Fri, May 11, 2018 at

Re: [PATCH 1/2] vfs: allow dedupe of user owned read-only files

2018-05-17 Thread Mark Fasheh
On Sun, May 13, 2018 at 10:50:25PM +0200, Adam Borowski wrote: > On Sun, May 13, 2018 at 06:16:53PM +, Mark Fasheh wrote: > > On Sat, May 12, 2018 at 04:49:20AM +0200, Adam Borowski wrote: > > > On Fri, May 11, 2018 at 12:26:50PM -0700, Mark Fasheh wrote: > > > > The permission check in

Re: [PATCH v4 03/12] Btrfs: don't BUG_ON() in btrfs_truncate_inode_items()

2018-05-17 Thread David Sterba
On Fri, May 11, 2018 at 01:13:31PM -0700, Omar Sandoval wrote: > From: Omar Sandoval > > btrfs_free_extent() can fail because of ENOMEM. There's no reason to > panic here, we can just abort the transaction. > > Fixes: f4b9aa8d3b87 ("btrfs_truncate") > Reviewed-by: Nikolay

Re: [PATCH] btrfs: Remove stale comment about select_delayed_ref

2018-05-17 Thread David Sterba
On Thu, May 17, 2018 at 02:16:29PM +0300, Nikolay Borisov wrote: > select_delayed_ref really just gets the next delayed ref which has to > be processed - either an add ref or drop ref. We never go back for > anything. So the comment is actually bogus, just remove it. > > Signed-off-by: Nikolay

Re: [PATCH v3 2/2] btrfs: sysfs: Add entry which shows rmdir(2) can work for subvolume

2018-05-17 Thread David Sterba
On Thu, May 17, 2018 at 02:24:51PM +0900, Misono Tomohiro wrote: > Deletion of a subvolume by rmdir(2) has become allowed by the > 'commit cd2decf640b1 ("btrfs: Allow rmdir(2) to delete an empty > subvolume")'. > > It is a kind of new feature and this commits add a sysfs entry >

Re: [PATCH v2] btrfs: use kvzalloc for EXTENT_SAME temporary data

2018-05-17 Thread Nikolay Borisov
On 17.05.2018 18:41, David Sterba wrote: > The dedupe range is 16 MiB, with 4 KiB pages and 8 byte pointers, the > arrays can be 32KiB large. To avoid allocation failures due to > fragmented memory, use the allocation with fallback to vmalloc. > > The arrays are allocated and freed only inside

[PATCH v2] btrfs: use kvzalloc for EXTENT_SAME temporary data

2018-05-17 Thread David Sterba
The dedupe range is 16 MiB, with 4 KiB pages and 8 byte pointers, the arrays can be 32KiB large. To avoid allocation failures due to fragmented memory, use the allocation with fallback to vmalloc. The arrays are allocated and freed only inside btrfs_extent_same and reused for all the ranges.

Re: [PATCH v2 0/3] btrfs: add read mirror policy

2018-05-17 Thread Austin S. Hemmelgarn
On 2018-05-17 10:46, Jeff Mahoney wrote: On 5/16/18 6:35 PM, David Sterba wrote: On Wed, May 16, 2018 at 06:03:56PM +0800, Anand Jain wrote: Not yet ready for the integration. As I need to introduce -o no_read_mirror_policy instead of -o read_mirror_policy=- Mount option is mostly likely not

[PATCH V4] test online label ioctl

2018-05-17 Thread Eric Sandeen
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 _require_xfs_io_command as well, so that tests which simply fail with "Inappropriate

Re: [PATCH v2 0/3] btrfs: add read mirror policy

2018-05-17 Thread Jeff Mahoney
On 5/17/18 8:25 AM, Austin S. Hemmelgarn wrote: > On 2018-05-16 22:32, Anand Jain wrote: >> >> >> On 05/17/2018 06:35 AM, David Sterba wrote: >>> On Wed, May 16, 2018 at 06:03:56PM +0800, Anand Jain wrote: Not yet ready for the integration. As I need to introduce -o no_read_mirror_policy

Re: [PATCH v2 0/3] btrfs: add read mirror policy

2018-05-17 Thread Jeff Mahoney
On 5/16/18 6:35 PM, David Sterba wrote: > On Wed, May 16, 2018 at 06:03:56PM +0800, Anand Jain wrote: >> Not yet ready for the integration. As I need to introduce >> -o no_read_mirror_policy instead of -o read_mirror_policy=- > > Mount option is mostly likely not the right interface for setting

[PATCH] btrfs: fix describe_relocation string pointer

2018-05-17 Thread Anand Jain
Looks like the original idea was to print the hex of the flags which is not coded with their flag name. So use the current buf pointer bp instead of buf. Signed-off-by: Anand Jain --- fs/btrfs/relocation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

btrfs hang on rsync in linux 4.16.8

2018-05-17 Thread E V
running an rsync -av --del as the only process hiting my btrfs backup filesystem. rsync is now stuck and so is all other access to the filesystem. Looking at ps it seems the btrfs-cleaner is running, so maybe that deadlocked with Stack for the rsync: [<0>]

Re: [PATCH v2 0/3] btrfs: add read mirror policy

2018-05-17 Thread Austin S. Hemmelgarn
On 2018-05-16 22:32, Anand Jain wrote: On 05/17/2018 06:35 AM, David Sterba wrote: On Wed, May 16, 2018 at 06:03:56PM +0800, Anand Jain wrote: Not yet ready for the integration. As I need to introduce -o no_read_mirror_policy instead of -o read_mirror_policy=- Mount option is mostly likely

Re: [PATCH v2 3/3] btrfs: balance: add kernel log for end or paused

2018-05-17 Thread David Sterba
On Wed, May 16, 2018 at 10:51:28AM +0800, Anand Jain wrote: > Add a kernel log when the balance ends, either for cancel or completed > or if it is paused. Missing S-O-B. > --- > v1->v2: Moved from 2/3 to 3/3 > > fs/btrfs/volumes.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git

Re: [PATCH v2 1/3] btrfs: balance: prefix kernel logs

2018-05-17 Thread David Sterba
On Wed, May 16, 2018 at 10:51:26AM +0800, Anand Jain wrote: > Kernel logs are very important for the forensic investigations of the > issues in general make it easy to use it. This patch adds 'balance:' > prefix so that it can be easily searched. > > Signed-off-by: Anand Jain

Re: [PATCH v2 2/3] btrfs: balance: add args info during start and resume

2018-05-17 Thread David Sterba
On Wed, May 16, 2018 at 10:51:27AM +0800, Anand Jain wrote: > Balance args info is an important information to be reviewed for the > system audit. So this patch adds it to the kernel log. > > Example: > > -> btrfs bal start -dprofiles='raid1|single',convert=raid5 >

[PATCH] btrfs: Remove stale comment about select_delayed_ref

2018-05-17 Thread Nikolay Borisov
select_delayed_ref really just gets the next delayed ref which has to be processed - either an add ref or drop ref. We never go back for anything. So the comment is actually bogus, just remove it. Signed-off-by: Nikolay Borisov --- fs/btrfs/extent-tree.c | 4 1 file

btrfs device replace can cause silent or noisy corruption on compressed NOCOW/NODATASUM

2018-05-17 Thread james harvey
Looks like Qu may have taken care of corrupted compressed data with NODATASUM from causing causing random kernel memory corruption. As long as the compressed data was valid and could be uncompressed, there were no problems, even on data marked NOCOW/NODATASUM. If the data being sent to be

Re: [PATCH v5 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-17 Thread Qu Wenruo
On 2018年05月17日 16:25, Misono Tomohiro wrote: > On 2018/05/17 15:56, Qu Wenruo wrote: >> >> >> On 2018年05月16日 13:49, Tomohiro Misono wrote: >>> [based on current misc-next] >>> >>> changelog: >>> v4 -> v5 >>> - Update error handling of 1st/2nd patch. See each log for details >>> - Fix

Re: [PATCH 3/4] btrfs: lzo: Add header length check to avoid slab out of bounds access

2018-05-17 Thread Qu Wenruo
On 2018年05月17日 16:19, Qu Wenruo wrote: > > > On 2018年05月17日 16:14, Nikolay Borisov wrote: >> >> >> On 17.05.2018 09:27, Qu Wenruo wrote: >>> James Harvey reported that some corrupted compressed extent data can >>> lead to various kernel memory corruption. >>> >>> Such corrupted extent data

Re: [PATCH v5 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-17 Thread Misono Tomohiro
On 2018/05/17 15:56, Qu Wenruo wrote: > > > On 2018年05月16日 13:49, Tomohiro Misono wrote: >> [based on current misc-next] >> >> changelog: >> v4 -> v5 >> - Update error handling of 1st/2nd patch. See each log for details >> - Fix misspelling >> v3 -> v4 >> - call btrfs_next_leaf() after

Re: [PATCH 3/4] btrfs: lzo: Add header length check to avoid slab out of bounds access

2018-05-17 Thread Qu Wenruo
On 2018年05月17日 16:14, Nikolay Borisov wrote: > > > On 17.05.2018 09:27, Qu Wenruo wrote: >> James Harvey reported that some corrupted compressed extent data can >> lead to various kernel memory corruption. >> >> Such corrupted extent data belongs to inode with NODATASUM flags, thus >> data

Re: [PATCH 3/4] btrfs: lzo: Add header length check to avoid slab out of bounds access

2018-05-17 Thread Nikolay Borisov
On 17.05.2018 09:27, Qu Wenruo wrote: > James Harvey reported that some corrupted compressed extent data can > lead to various kernel memory corruption. > > Such corrupted extent data belongs to inode with NODATASUM flags, thus > data csum won't help us detecting such bug. > > If lucky enough,

Re: [PATCH 2/4] btrfs: lzo: Add comment about the how btrfs records its lzo compressed data

2018-05-17 Thread Qu Wenruo
On 2018年05月17日 15:48, Nikolay Borisov wrote: > > > On 17.05.2018 09:27, Qu Wenruo wrote: >> Signed-off-by: Qu Wenruo > > Overall it looks good and useful just a couple of nits below. >> --- >> fs/btrfs/lzo.c | 23 +++ >> 1 file changed, 23 insertions(+) >>

Re: [PATCH 2/4] btrfs: lzo: Add comment about the how btrfs records its lzo compressed data

2018-05-17 Thread Nikolay Borisov
On 17.05.2018 09:27, Qu Wenruo wrote: > Signed-off-by: Qu Wenruo Overall it looks good and useful just a couple of nits below. > --- > fs/btrfs/lzo.c | 23 +++ > 1 file changed, 23 insertions(+) > > diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c > index

Re: [PATCH 1/4] btrfs: compression: Add linux/sizes.h for compression.h

2018-05-17 Thread Nikolay Borisov
On 17.05.2018 09:27, Qu Wenruo wrote: > Since compression.h is using SZ_* macros, and if some user only includes > compression.h without linux/sizes.h, it will cause compile error. > > One example is lzo.c, if it uses BTRFS_MAX_COMPRESSED, it would cause > compile error. > > Fix it by adding

Re: [PATCH v2] btrfs: fix BUG trying to resume balance without resume flag

2018-05-17 Thread Anand Jain
On 05/16/2018 10:35 PM, David Sterba wrote: On Mon, Apr 30, 2018 at 05:48:45PM +0800, Anand Jain wrote: We set the BTRFS_BALANCE_RESUME flag in the btrfs_recover_balance(), which is not called during the remount. So when resuming from the paused balance we hit BUG. kernel: kernel BUG at

[PATCH v3] btrfs: fix BUG trying to resume balance without resume flag

2018-05-17 Thread Anand Jain
We set the BTRFS_BALANCE_RESUME flag in the btrfs_recover_balance() only, which isn't called during the remount. So when resuming from the paused balance we hit the BUG. kernel: kernel BUG at fs/btrfs/volumes.c:3890! :: kernel: balance_kthread+0x51/0x60 [btrfs] kernel: kthread+0x111/0x130

[PATCH v2] btrfs: Skip some btrfs_cross_ref_exist() check in nocow path

2018-05-17 Thread Ethan Lien
In nocow path, we check if the extent is snapshotted in btrfs_cross_ref_exist(). We can do the similar check earlier and avoid unnecessary search into extent tree. A fio test on a Intel D-1531, 16GB RAM, SSD RAID-5 machine as follows: [global] group_reporting time_based thread=1 ioengine=libaio

Re: [PATCH v5 0/3] btrfs: Add three new unprivileged ioctls to allow normal users to call "sub list/show" etc.

2018-05-17 Thread Qu Wenruo
On 2018年05月16日 13:49, Tomohiro Misono wrote: > [based on current misc-next] > > changelog: > v4 -> v5 > - Update error handling of 1st/2nd patch. See each log for details > - Fix misspelling > v3 -> v4 > - call btrfs_next_leaf() after btrfs_search_slot() when the slot > position

Re: [PATCH v5 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-17 Thread Qu Wenruo
On 2018年05月16日 13:49, Tomohiro Misono wrote: > Add unprivileged ioctl BTRFS_IOC_GET_SUBVOL_ROOTREF which > returns ROOT_REF information of the subvolume containing this inode > except the subvolume name (this is because to prevent potential name > leak). The subvolume name will be gained by user

Re: [PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Qu Wenruo
On 2018年05月16日 13:49, Tomohiro Misono wrote: > Add new unprivileged ioctl BTRFS_IOC_GET_SUBVOL_INFO which returns > the information of subvolume containing this inode. > (i.e. returns the information in ROOT_ITEM and ROOT_BACKREF.) > > Signed-off-by: Tomohiro Misono

RE: [PATCH v5 2/3] btrfs: Add unprivileged ioctl which returns subvolume's ROOT_REF

2018-05-17 Thread Gu, Jinxiang
Hi, > -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Tomohiro Misono > Sent: Wednesday, May 16, 2018 1:50 PM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH v5 2/3] btrfs: Add unprivileged ioctl which returns >

[PATCH 3/4] btrfs: lzo: Add header length check to avoid slab out of bounds access

2018-05-17 Thread Qu Wenruo
James Harvey reported that some corrupted compressed extent data can lead to various kernel memory corruption. Such corrupted extent data belongs to inode with NODATASUM flags, thus data csum won't help us detecting such bug. If lucky enough, kasan could catch it like:

[PATCH 4/4] btrfs: lzo: Hardern inline lzo compressed extent decompression

2018-05-17 Thread Qu Wenruo
Unlike regular lzo compressed extent, inline extent doesn't have Header and only has one Segment. And further more, inlined extent always has csum in its leaf header, it's less possible to have corrupted data. Anyway, still add extra segment header length check. Signed-off-by: Qu Wenruo

[PATCH 2/4] btrfs: lzo: Add comment about the how btrfs records its lzo compressed data

2018-05-17 Thread Qu Wenruo
Signed-off-by: Qu Wenruo --- fs/btrfs/lzo.c | 23 +++ 1 file changed, 23 insertions(+) diff --git a/fs/btrfs/lzo.c b/fs/btrfs/lzo.c index 0667ea07f766..3d2ae4c08876 100644 --- a/fs/btrfs/lzo.c +++ b/fs/btrfs/lzo.c @@ -17,6 +17,29 @@ #define LZO_LEN4

[PATCH 0/4] btrfs: lzo: Harden decompression callers to avoid

2018-05-17 Thread Qu Wenruo
James Harvey reported pretty strange kernel misbehavior where after reading certain btrfs compressed data, kernel crash with unrelated calltrace. (https://bugzilla.kernel.org/show_bug.cgi?id=199707 and https://www.spinics.net/lists/linux-btrfs/msg77971.html) Thanks for his comprehensive debug

[PATCH 1/4] btrfs: compression: Add linux/sizes.h for compression.h

2018-05-17 Thread Qu Wenruo
Since compression.h is using SZ_* macros, and if some user only includes compression.h without linux/sizes.h, it will cause compile error. One example is lzo.c, if it uses BTRFS_MAX_COMPRESSED, it would cause compile error. Fix it by adding linux/sizes.h in compression.h Signed-off-by: Qu

RE: [PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns subvolume information

2018-05-17 Thread Gu, Jinxiang
> -Original Message- > From: linux-btrfs-ow...@vger.kernel.org > [mailto:linux-btrfs-ow...@vger.kernel.org] On Behalf Of Tomohiro Misono > Sent: Wednesday, May 16, 2018 1:50 PM > To: linux-btrfs@vger.kernel.org > Subject: [PATCH v5 1/3] btrfs: Add unprivileged ioctl which returns