[PATCH v4 2/2] btrfs: Introduce new mount option to skip block group items scan

2019-09-05 Thread Qu Wenruo
[PROBLEM] There are some reports of corrupted fs which can't be mounted due to corrupted extent tree. However under such situation, it's more likely the fs/subvolume trees are still fine. For such case we normally go btrfs-restore and salvage as much as we can. However btrfs-restore can't list su

[PATCH v4 1/2] btrfs: Introduce "rescue=" mount option

2019-09-05 Thread Qu Wenruo
This patch introduces a new "rescue=" mount option group for all those mount options for data recovery. Different rescue sub options are seperated by ':'. E.g "ro,rescue=nologreplay:usebackuproot". (The original plan is to use ';', but ';' needs to be escaped/quoted, or it will be interpreted by b

[PATCH v4 0/2] btrfs: Introduce new rescue= mount options

2019-09-05 Thread Qu Wenruo
There are quite a lot btrfs extent tree corruption report in the mail list. Since btrfs will do mount time block group item search, one corrupted leaf containing block group item will prevent the whole fs to be mounted. This patchset will try to address the problem by introducing a new mount optio

Re: [PATCH 04/15] btrfs: Add a simple buffered iomap write

2019-09-05 Thread Christoph Hellwig
On Thu, Sep 05, 2019 at 03:42:10PM -0500, Goldwyn Rodrigues wrote: > > Thіs looks really strange. Can you explain me why you need the > > manual dirtying and SetPageUptodate, and an additional page refcount > > here? > > It was a part btrfs code which is carried forward. Yes, we don't need > the

[PATCH] btrfs-progs: drop unique uuid test for btrfstune -M

2019-09-05 Thread Anand Jain
It's common to copy/snapshot an OS image to run another instance of the OS. A duplicate fsid can't be mounted on the same system unless the fsid is changed by using btrfstune -m. However in some circumstances the image needs to go back to the original fsid /metadata_uuid. As of now btrfstune -M f

Re: [PATCH 01/15] iomap: Use a srcmap for a read-modify-write I/O

2019-09-05 Thread Darrick J. Wong
On Thu, Sep 05, 2019 at 10:06:36AM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues > > A preparation patch for copy-on-write (CoW). > The srcmap is used to identify where the read is to be performed > from. This is passed to iomap->begin() of the respective > filesystem, which is suppos

Re: [PATCH 11/15] iomap: use a function pointer for dio submits

2019-09-05 Thread Darrick J. Wong
On Thu, Sep 05, 2019 at 06:27:21PM +0200, Christoph Hellwig wrote: > > + if (dio->dops && dio->dops->submit_io) { > > + dio->dops->submit_io(bio, file_inode(dio->iocb->ki_filp), > > + pos); > > pos would still fit on the previously line as-is. > > > +

Re: Unmountable degraded BTRFS RAID6 filesystem

2019-09-05 Thread Chris Murphy
On Thu, Sep 5, 2019 at 2:44 PM Edmund Urbani wrote: > > I did not need the degraded option. And so far I see no HW I/O errors in > dmesg. I have encountered a few errors while copying files and found > these in the log: > > [ 3560.273634] btrfs_print_data_csum_error: 50 callbacks suppressed > [ 35

Re: Unmountable degraded BTRFS RAID6 filesystem

2019-09-05 Thread Edmund Urbani
On 05.09.2019 21:57, Chris Murphy wrote: On Thu, Sep 5, 2019 at 1:18 PM Edmund Urbani wrote: On 04.09.2019 07:36, Chris Murphy wrote: I have tried all the mount / restore options listed here: https://forums.unraid.net/topic/46802-faq-for-unraid-v6/page/2/?tab=comments#comment-543490 Good.

Re: [PATCH 04/15] btrfs: Add a simple buffered iomap write

2019-09-05 Thread Goldwyn Rodrigues
On 18:23 05/09, Christoph Hellwig wrote: > > Most of the code is "inspired" by > > fs/btrfs/file.c. To keep the size small, all removals are in > > following patches. > > Wouldn't it be better to massage the existing code into a form where you > can fairly easily switch over to iomap? That is sta

Re: [PATCH 02/15] iomap: Read page from srcmap if IOMAP_F_COW is set

2019-09-05 Thread Goldwyn Rodrigues
On 18:37 05/09, Christoph Hellwig wrote: > On Thu, Sep 05, 2019 at 10:06:37AM -0500, Goldwyn Rodrigues wrote: > > - else if (iomap->flags & IOMAP_F_BUFFER_HEAD) > > + } else if (iomap->flags & IOMAP_F_COW) { > > + if (WARN_ON_ONCE(iomap->flags & IOMAP_F_BUFFER_HEAD)) { > > +

Re: Unmountable degraded BTRFS RAID6 filesystem

2019-09-05 Thread Chris Murphy
On Thu, Sep 5, 2019 at 1:18 PM Edmund Urbani wrote: > > > On 04.09.2019 07:36, Chris Murphy wrote: > > > >>> > I have tried all the mount / restore options listed here: > https://forums.unraid.net/topic/46802-faq-for-unraid-v6/page/2/?tab=comments#comment-543490 > >>> Good. Stick with ro

Re: Unmountable degraded BTRFS RAID6 filesystem

2019-09-05 Thread Edmund Urbani
On 04.09.2019 07:36, Chris Murphy wrote: I have tried all the mount / restore options listed here: https://forums.unraid.net/topic/46802-faq-for-unraid-v6/page/2/?tab=comments#comment-543490 Good. Stick with ro attempts for now. Including if you want to try a newer kernel. If it succeeds t

Re: No files in snapshot

2019-09-05 Thread Oliver Freyermuth
Dear Thomas, Am 05.09.19 um 10:50 schrieb Thomas Schneider: > Hi, > > I would agree with Oliver's conclusion: > the relevant directories are all tmpfs mounts. this of course easily explains it and btrfs can't do anything about these when snapshotting. In case you want to debug the issue in mo

Re: [PATCH 02/15] iomap: Read page from srcmap if IOMAP_F_COW is set

2019-09-05 Thread Christoph Hellwig
On Thu, Sep 05, 2019 at 10:06:37AM -0500, Goldwyn Rodrigues wrote: > - else if (iomap->flags & IOMAP_F_BUFFER_HEAD) > + } else if (iomap->flags & IOMAP_F_COW) { > + if (WARN_ON_ONCE(iomap->flags & IOMAP_F_BUFFER_HEAD)) { > + status = -EIO; > +

Re: [PATCH 14/15] btrfs: update inode size during bio completion

2019-09-05 Thread Christoph Hellwig
On Thu, Sep 05, 2019 at 10:06:49AM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues > > Update the inode size for dio writes during bio completion. > This ties the success of the underlying block layer > whether to increase the size of the inode. Especially for > in aio cases. Doesn't t

Re: [PATCH 13/15] btrfs: Remove btrfs_dio_data and __btrfs_direct_write

2019-09-05 Thread Christoph Hellwig
On Thu, Sep 05, 2019 at 10:06:48AM -0500, Goldwyn Rodrigues wrote: > From: Goldwyn Rodrigues > > btrfs_dio_data is unnecessary since we are now storing all > informaiton in btrfs_iomap. > > Advantage: We don't abuse current->journal_info anymore :) I'd suggest just folding that into the patch r

Re: [PATCH 12/15] btrfs: Use iomap_dio_rw for performing direct I/O writes

2019-09-05 Thread Christoph Hellwig
Lots of lines > 80 chars, and various indentation errors, I'm not going to point them out invdividually. > ssize_t btrfs_dio_iomap_read(struct kiocb *iocb, struct iov_iter *to) > @@ -437,7 +536,58 @@ ssize_t btrfs_dio_iomap_read(struct kiocb *iocb, struct > iov_iter *to) > struct inode *i

Re: [PATCH 11/15] iomap: use a function pointer for dio submits

2019-09-05 Thread Christoph Hellwig
> + if (dio->dops && dio->dops->submit_io) { > + dio->dops->submit_io(bio, file_inode(dio->iocb->ki_filp), > + pos); pos would still fit on the previously line as-is. > + dio->submit.cookie = BLK_QC_T_NONE; But I think you should return the

Re: [PATCH 08/15] btrfs: basic direct read operation

2019-09-05 Thread Christoph Hellwig
> +static ssize_t btrfs_file_read_iter(struct kiocb *iocb, struct iov_iter *to) > +{ > + ssize_t ret = 0; > + if (iocb->ki_flags & IOCB_DIRECT) Missing empty line after the declaration. > +ssize_t btrfs_dio_iomap_read(struct kiocb *iocb, struct iov_iter *to) The iomap in the name doesn't

Re: [PATCH 04/15] btrfs: Add a simple buffered iomap write

2019-09-05 Thread Christoph Hellwig
> Most of the code is "inspired" by > fs/btrfs/file.c. To keep the size small, all removals are in > following patches. Wouldn't it be better to massage the existing code into a form where you can fairly easily switch over to iomap? That is start refactoring the code into helpers that are mostly

Re: [PATCH] btrfs/048: fix test failure when fs mounted with v2 space cache option

2019-09-05 Thread Nikolay Borisov
On 5.09.19 г. 18:37 ч., fdman...@kernel.org wrote: > From: Filipe Manana > > In order to check that the filesystem generation does not change after > failure to set a property, the test expects a specific generation number > of 7 in its golden output. That currently works except when using the

Re: [PATCH v3] fstests: btrfs: Check snapshot creation and deletion with dm-logwrites

2019-09-05 Thread Filipe Manana
On Mon, Aug 26, 2019 at 7:21 AM Qu Wenruo wrote: > > We have generic dm-logwrites with fsstress test case (generic/482), but > it doesn't cover fs specific operations like btrfs snapshot creation and > deletion. > > Furthermore, that test is not heavy enough to bump btrfs tree height by > its shor

[PATCH] btrfs/048: fix test failure when fs mounted with v2 space cache option

2019-09-05 Thread fdmanana
From: Filipe Manana In order to check that the filesystem generation does not change after failure to set a property, the test expects a specific generation number of 7 in its golden output. That currently works except when using the v2 space cache mount option (MOUNT_OPTIONS="-o space_cache=v2")

Re: [PATCH] btrfs: Relinquish CPUs in btrfs_compare_trees

2019-09-05 Thread David Sterba
On Wed, Sep 04, 2019 at 07:33:58PM +0300, Nikolay Borisov wrote: > When doing any form of incremental send the parent and the child trees > need to be compared via btrfs_compare_trees. This can result in long > loop chains without ever relinquishing the CPU. This causes softlockup > detector to tr

[PATCH 15/15] xfs: Use the new iomap infrastructure for CoW

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Set the IOMAP_F_COW flag and create the srcmap based on current extents to read from. Signed-off-by: Goldwyn Rodrigues --- fs/xfs/xfs_iomap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 8321733c16c3..13495d8a1ee2

[PATCH 14/15] btrfs: update inode size during bio completion

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Update the inode size for dio writes during bio completion. This ties the success of the underlying block layer whether to increase the size of the inode. Especially for in aio cases. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/inode.c | 6 +- 1 file changed, 5 in

[PATCH 13/15] btrfs: Remove btrfs_dio_data and __btrfs_direct_write

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues btrfs_dio_data is unnecessary since we are now storing all informaiton in btrfs_iomap. Advantage: We don't abuse current->journal_info anymore :) Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/file.c | 40 fs/btrfs/inode.c | 81 ++--

[PATCH 12/15] btrfs: Use iomap_dio_rw for performing direct I/O writes

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues btrfs_iomap_init() is a function to be used to btrfs_iomap structure which is used to pass information between iomap begin() and end(). All data reservations and allocations must be performed in this function. For reads, btrfs_iomap allocation is not required. We perform

[PATCH 11/15] iomap: use a function pointer for dio submits

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues This helps filesystems to perform tasks on the bio while submitting for I/O. This could be post-write operations such as data CRC or data replication for fs-handled RAID. Signed-off-by: Goldwyn Rodrigues --- fs/iomap/direct-io.c | 16 +++- include/linux/iom

[PATCH 08/15] btrfs: basic direct read operation

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Add btrfs_dio_iomap_ops for iomap.begin() function. In order to accomodate dio reads, add a new function btrfs_file_read_iter() which would call btrfs_dio_iomap_read() for DIO reads and fallback to generic_file_buffered_read otherwise. Changed parameter written in generic

[PATCH 10/15] btrfs: Rename __endio_write_update_ordered() to btrfs_update_ordered_extent()

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Since we will be using it in another part of the code, use a better name to declare it non-static Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/ctree.h | 7 +-- fs/btrfs/inode.c | 14 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/f

[PATCH 06/15] btrfs: remove buffered write code made unnecessary

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Better done in a separate patch to keep the main patch short(er) Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/file.c | 463 1 file changed, 463 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 0

[PATCH 09/15] btrfs: Carve out btrfs_get_extent_map_write() out of btrfs_get_blocks_write()

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues This makes btrfs_get_extent_map_write() independent of Direct I/O code. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/ctree.h | 2 ++ fs/btrfs/inode.c | 40 +++- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/fs/btr

[PATCH 01/15] iomap: Use a srcmap for a read-modify-write I/O

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues A preparation patch for copy-on-write (CoW). The srcmap is used to identify where the read is to be performed from. This is passed to iomap->begin() of the respective filesystem, which is supposed to put in the details for reading before performing the copy for CoW. Signe

[PATCH 03/15] btrfs: Eliminate PagePrivate for btrfs data pages

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues While most of the code works just eliminating page's private field and related code, there is a problem when we are cloning. The extent assumes the data is uptodate. Clear the EXTENT_UPTODATE flag for the extent so the next time the file is read, it is forced to be read fr

[PATCH 07/15] fs: Export generic_file_buffered_read()

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Export generic_file_buffered_read() to be used to supplement incomplete direct reads. While we are at it, correct the comments and variable names. Signed-off-by: Goldwyn Rodrigues --- include/linux/fs.h | 2 ++ mm/filemap.c | 13 +++-- 2 files changed, 9

[PATCH 02/15] iomap: Read page from srcmap if IOMAP_F_COW is set

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues In case of a IOMAP_F_COW, read a page from the srcmap before performing a write on the page. Signed-off-by: Goldwyn Rodrigues Reviewed-by: Darrick J. Wong --- fs/iomap/buffered-io.c | 30 +- include/linux/iomap.h | 3 +++ 2 files changed,

[PATCH 05/15] btrfs: Add CoW in iomap based writes

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues Set iomap->flags to IOMAP_F_COW and fill up the source map in case the I/O is not page aligned. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/iomap.c | 42 +- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/

[PATCH 04/15] btrfs: Add a simple buffered iomap write

2019-09-05 Thread Goldwyn Rodrigues
From: Goldwyn Rodrigues This one is a long patch. Most of the code is "inspired" by fs/btrfs/file.c. To keep the size small, all removals are in following patches. Signed-off-by: Goldwyn Rodrigues --- fs/btrfs/Kconfig | 1 + fs/btrfs/Makefile | 2 +- fs/btrfs/ctree.h | 1 + fs/btrfs/fi

[PATCH v4 0/15] CoW support for iomap

2019-09-05 Thread Goldwyn Rodrigues
Previously called btrfs iomap. This is an effort to use iomap for btrfs. This would keep most responsibility of page handling during writes in iomap code, hence code reduction. For CoW support, changes are needed in iomap code to make sure we perform a copy before the write. This is in line with t

Re: [PATCH v2] btrfs: Don't assign retval of btrfs_try_tree_write_lock/btrfs_tree_read_lock_atomic

2019-09-05 Thread David Sterba
On Wed, Sep 04, 2019 at 08:22:39PM +0300, Nikolay Borisov wrote: > Those function are simple boolean predicates there is no need to assign > their return values to interim variables. Use them directly as > predicates. No functional changes. > > Signed-off-by: Nikolay Borisov Added to misc-next,

Btrfs progs release 5.2.2

2019-09-05 Thread David Sterba
Hi, btrfs-progs version 5.2.2 have been released. This is a bugfix release. Changes: * check: * fix false report of wrong byte count for orphan inodes * option -E was not handled correctly * new check and repair for root item generation * balance: check for full-balance before bac

Re: Cloning / getting a full backup of a BTRFS filesystem

2019-09-05 Thread Qu Wenruo
On 2019/9/5 下午9:06, Anand Jain wrote: > > >> On 5 Sep 2019, at 1:55 AM, Chris Murphy wrote: >> >> On Wed, Sep 4, 2019 at 12:16 AM Swâmi Petaramesh >> wrote: >>> >>> Hi list, >>> >>> Is there an advised way to completely “clone” a complete BTRFS >>> filesystem, I mean to get an exact copy of a

Re: Cloning / getting a full backup of a BTRFS filesystem

2019-09-05 Thread Anand Jain
> On 5 Sep 2019, at 1:55 AM, Chris Murphy wrote: > > On Wed, Sep 4, 2019 at 12:16 AM Swâmi Petaramesh wrote: >> >> Hi list, >> >> Is there an advised way to completely “clone” a complete BTRFS >> filesystem, I mean to get an exact copy of a BTRFS filesystem including >> subvolumes (even rea

Re: [PATCH 2/2] btrfs: add ioctl for directly writing compressed data

2019-09-05 Thread Johannes Thumshirn
On 05/09/2019 14:16, Johannes Thumshirn wrote: > On 05/09/2019 04:10, Dave Chinner wrote: >> On Wed, Sep 04, 2019 at 12:13:26PM -0700, Omar Sandoval wrote: >>> From: Omar Sandoval >>> >>> This adds an API for writing compressed data directly to the filesystem. >>> The use case that I have in mind

Re: [PATCH 2/2] btrfs: add ioctl for directly writing compressed data

2019-09-05 Thread Johannes Thumshirn
On 05/09/2019 04:10, Dave Chinner wrote: > On Wed, Sep 04, 2019 at 12:13:26PM -0700, Omar Sandoval wrote: >> From: Omar Sandoval >> >> This adds an API for writing compressed data directly to the filesystem. >> The use case that I have in mind is send/receive: currently, when >> sending data from

Re: [PATCHSET v3 btrfs/for-next] btrfs: fix cgroup writeback support

2019-09-05 Thread David Sterba
On Fri, Jul 26, 2019 at 05:13:21PM +0200, David Sterba wrote: > On Wed, Jul 10, 2019 at 12:28:13PM -0700, Tejun Heo wrote: > > Hello, > > > > This patchset contains only the btrfs part of the following patchset. > > > > [1] [PATCHSET v2 btrfs/for-next] blkcg, btrfs: fix cgroup writeback > > su

Re: [PATCH 2/2] btrfs: add ioctl for directly writing compressed data

2019-09-05 Thread Nikolay Borisov
On 4.09.19 г. 22:13 ч., Omar Sandoval wrote: > From: Omar Sandoval > > This adds an API for writing compressed data directly to the filesystem. > The use case that I have in mind is send/receive: currently, when > sending data from one compressed filesystem to another, the sending side > decom

Re: No files in snapshot

2019-09-05 Thread Thomas Schneider
Hi, I would agree with Oliver's conclusion: the relevant directories are all tmpfs mounts. root@ld5505:~# mount | grep /var /dev/sdbq3 on /var/cache type btrfs (rw,noatime,compress=lzo,ssd,space_cache=v2,subvolid=260,subvol=/@cache) /dev/sdbq3 on /var/lib/vz/images type btrfs (rw,noatime,compr

Re: [PATCH] btrfs: Relinquish CPUs in btrfs_compare_trees

2019-09-05 Thread Johannes Thumshirn
Looks good, Reviewed-by: Johannes Thumshirn -- Johannes ThumshirnSUSE Labs Filesystems jthumsh...@suse.de+49 911 74053 689 SUSE Software Solutions Germany GmbH Maxfeldstr. 5 90409 Nürnberg Germany (HRB 247165, AG München) Key fingerprin

[PATCH v2 4/6] btrfs-progs: check/lowmem: Repair bad imode early

2019-09-05 Thread Qu Wenruo
For lowmem mode, if we hit a bad inode mode, normally it is reported when we checking the DIR_INDEX/DIR_ITEM of the parent inode. If we didn't repair at that timing, the error will be recorded even we fixed it later. So this patch will check for INODE_ITEM_MISMATCH error type, and if it's really

[PATCH v2 3/6] btrfs-progs: check/common: Make repair_imode_common() to handle inodes in subvolume trees

2019-09-05 Thread Qu Wenruo
Before this patch, repair_imode_common() can only handle two types of inodes: - Free space cache inodes - ROOT DIR inodes For inodes in subvolume trees, the core complexity is how to determine the correct imode, thus it was not implemented. However there are more reports of incorrect imode in sub

[PATCH v2 5/6] btrfs-progs: check/original: Fix inode mode in subvolume trees

2019-09-05 Thread Qu Wenruo
To make original mode to repair imode error in subvolume trees, this patch will do: - Remove the show-stopper checks for root->objectid. Now repair_imode_original() will accept inodes in subvolume trees. - Export detect_imode() for original mode Due to the call requirement, original mode must

[PATCH v2 6/6] btrfs-progs: tests/fsck: Add new images for inode mode repair functionality

2019-09-05 Thread Qu Wenruo
Add new test image for imode repair in subvolume trees. Also rename the existing test case 039-bad-free-space-cache-inode-mode to 039-bad-inode-mode, since now we can fix all bad imode. And add the beacon file for lowmem test. Signed-off-by: Qu Wenruo --- .../039-bad-inode-mode/.lowmem_repaira

[PATCH v2 2/6] btrfs-progs: check/common: Introduce a function to find imode using INODE_REF

2019-09-05 Thread Qu Wenruo
Introduce a function, find_file_type(), to find filetype using INODE_REF. This function will: - Search DIR_INDEX first DIR_INDEX is easier since there is only one item in it. - Valid the DIR_INDEX item If the DIR_INDEX is valid, use the filetype and call it a day. - Search DIR_ITEM then - V

[PATCH v2 1/6] btrfs-progs: check: Export btrfs_type_to_imode

2019-09-05 Thread Qu Wenruo
This function will be later used by common mode code, so export it. Signed-off-by: Qu Wenruo --- check/main.c| 15 --- check/mode-common.h | 15 +++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/check/main.c b/check/main.c index 2e16b4e6f05b..90

[PATCH v2 0/6] btrfs-progs: check: Repair invalid inode mode in

2019-09-05 Thread Qu Wenruo
Before this patch, btrfs check can only repair bad free space cache inode mode (as it was the first case detected by tree-checker and reported) But Murphy is always right, what may happen will finally happen, we have users reporting bad inode mode in subvolume trees. According to the creation time