[PATCH v7 07/22] mm: don't TestClearPageError in __filemap_fdatawait_range

2017-06-16 Thread Jeff Layton
The -EIO returned here can end up overriding whatever error is marked in the address space, and be returned at fsync time, even when there is a more appropriate error stored in the mapping. Read errors are also sometimes tracked on a per-page level using PG_error. Suppose we have a read error on a

[PATCH v7 06/22] mm: clear AS_EIO/AS_ENOSPC when writeback initiation fails

2017-06-16 Thread Jeff Layton
filemap_write_and_wait{_range} will return an error if writeback initiation fails, but won't clear errors in the address_space. This is particularly problematic on DAX, as it's effectively synchronous. Ensure that we clear the AS_EIO/AS_ENOSPC flags when filemap_fdatawrite returns an error. Signed

[PATCH v7 11/22] fs: new infrastructure for writeback error handling and reporting

2017-06-16 Thread Jeff Layton
Most filesystems currently use mapping_set_error and filemap_check_errors for setting and reporting/clearing writeback errors at the mapping level. filemap_check_errors is indirectly called from most of the filemap_fdatawait_* functions and from filemap_write_and_wait*. These functions are called f

[PATCH v7 13/22] mm: set both AS_EIO/AS_ENOSPC and errseq_t in mapping_set_error

2017-06-16 Thread Jeff Layton
When a writeback error occurs, we want later callers to be able to pick up that fact when they go to wait on that writeback to complete. Traditionally, we've used AS_EIO/AS_ENOSPC flags to track that, but that's problematic since only one "checker" will be informed when an error occurs. In later p

[PATCH v7 22/22] btrfs: minimal conversion to errseq_t writeback error reporting on fsync

2017-06-16 Thread Jeff Layton
Just check and advance the errseq_t in the file before returning. Internal callers of filemap_* functions are left as-is. Signed-off-by: Jeff Layton --- fs/btrfs/file.c | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 0f102a1b851f

[xfstests PATCH v5 5/5] btrfs: make a btrfs version of writeback error reporting test

2017-06-16 Thread Jeff Layton
For btrfs, we can test how it reports data writeback errors on fsync by implementing a suggestion from Chris Mason: Build a filesystem with 2 devices that stripes the data across both devices, but mirrors metadata across both. Then, make one of the devices fail and test what it does. Cc: Chris Ma

[xfstests PATCH v5 4/5] generic: test writeback error handling on dmerror devices

2017-06-16 Thread Jeff Layton
Ensure that we get an error back on all fds when a block device is open by multiple writers and writeback fails. Signed-off-by: Jeff Layton --- tests/generic/998 | 63 +++ tests/generic/998.out | 2 ++ tests/generic/group | 1 + 3 files cha

[PATCH v7 14/22] Documentation: flesh out the section in vfs.txt on storing and reporting writeback errors

2017-06-16 Thread Jeff Layton
Let's try to make this extra clear for fs authors. Cc: Jan Kara Signed-off-by: Jeff Layton --- Documentation/filesystems/vfs.txt | 43 --- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesy

[PATCH v7 16/22] block: convert to errseq_t based writeback error tracking

2017-06-16 Thread Jeff Layton
This is a very minimal conversion to errseq_t based error tracking for raw block device access. Only real change that is strictly required is that we must unconditionally call filemap_report_wb_err in blkdev_fsync. That ensures that the file's errseq_t is always advanced to the latest value in the

[PATCH v7 19/22] ext4: add more robust reporting of metadata writeback errors

2017-06-16 Thread Jeff Layton
ext4 uses the blockdev mapping for tracking metadata stored in the pagecache. Sample its wb_err when opening a file and store that in the f_md_wb_err field. Change ext4_sync_file to check for data errors first, and then check the blockdev mapping for metadata errors afterward. Note that because m

[PATCH v7 12/22] mm: tracepoints for writeback error events

2017-06-16 Thread Jeff Layton
To enable that, make __errseq_set return the value that it was set to when we exit the loop. Take heed that that value is not suitable as a later "since" value, as it will not have been marked seen. Signed-off-by: Jeff Layton --- include/linux/errseq.h | 2 +- include/linux/fs.h

[xfstests PATCH v5 2/5] ext3: allow it to put journal on a separate device when doing scratch_mkfs

2017-06-16 Thread Jeff Layton
Signed-off-by: Jeff Layton --- common/rc | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/common/rc b/common/rc index 57001b47a8b7..43e160e91360 100644 --- a/common/rc +++ b/common/rc @@ -840,7 +840,16 @@ _scratch_mkfs() mkfs_cmd="$MKFS_BTRFS_PROG"

[xfstests PATCH v5 0/5] new tests for writeback error reporting behavior

2017-06-16 Thread Jeff Layton
The main changes in this set from the last are: - add a btrfs/999.out file - use _supported_fs to whitelist fs' on which the tests should run - fix the ext3/4 mount option handling when creating journal device - ensure that dmerror is installed on make install These tests are intended to test the

[xfstests PATCH v5 3/5] generic: add a writeback error handling test

2017-06-16 Thread Jeff Layton
I'm working on a set of kernel patches to change how writeback errors are handled and reported in the kernel. Instead of reporting a writeback error to only the first fsync caller on the file, it has the the kernel report them once on every file description that was open at the time of the error.

[PATCH v7 20/22] ext2: convert to errseq_t based writeback error tracking

2017-06-16 Thread Jeff Layton
Set the flag to indicate that we want new-style data writeback error handling. This means that we need to override the open routines for files and directories so that we can sample the bdev wb_err at open. Signed-off-by: Jeff Layton --- fs/ext2/dir.c | 8 fs/ext2/file.c | 26

[PATCH v7 15/22] dax: set errors in mapping when writeback fails

2017-06-16 Thread Jeff Layton
Jan Kara's description for this patch is much better than mine, so I'm quoting it verbatim here: DAX currently doesn't set errors in the mapping when cache flushing fails in dax_writeback_mapping_range(). Since this function can get called only from fsync(2) or sync(2), this is actually as good as

[PATCH v7 21/22] xfs: minimal conversion to errseq_t writeback error reporting

2017-06-16 Thread Jeff Layton
Just check and advance the data errseq_t in struct file before before returning from fsync on normal files. Internal filemap_* callers are left as-is. Signed-off-by: Jeff Layton --- fs/xfs/xfs_file.c | 15 +++ 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/xfs/xfs_

[PATCH v7 18/22] fs: add f_md_wb_err field to struct file for tracking metadata errors

2017-06-16 Thread Jeff Layton
Some filesystems keep a different mapping for metadata writeback. Add a second errseq_t to struct file for tracking metadata writeback errors. Also add a new function for checking a mapping of the caller's choosing vs. the f_md_wb_err value. Signed-off-by: Jeff Layton --- include/linux/fs.h

[xfstests PATCH v5 1/5] ext4: allow ext4 to use $SCRATCH_LOGDEV

2017-06-16 Thread Jeff Layton
The writeback error handling test requires that you put the journal on a separate device. This allows us to use dmerror to simulate data writeback failure, without affecting the journal. xfs already has infrastructure for this (a'la $SCRATCH_LOGDEV), so wire up the ext4 code so that it can do the

[PATCH v7 17/22] ext4: use errseq_t based error handling for reporting data writeback errors

2017-06-16 Thread Jeff Layton
Add a call to filemap_report_wb_err at the end of ext4_sync_file. This will ensure that we check and advance the errseq_t in the file, which allows us to track and report errors on all open fds when they occur. Note that metadata writeback errors are not yet reported on all fds at this point. That

[PATCH v7 10/22] lib: add errseq_t type and infrastructure for handling it

2017-06-16 Thread Jeff Layton
An errseq_t is a way of recording errors in one place, and allowing any number of "subscribers" to tell whether an error has been set again since a previous time. It's implemented as an unsigned 32-bit value that is managed with atomic operations. The low order bits are designated to hold an error

[PATCH v7 08/22] mm: clean up error handling in write_one_page

2017-06-16 Thread Jeff Layton
Don't try to check PageError since that's potentially racy and not necessarily going to be set after writepage errors out. Instead, check the mapping for an error after writepage returns. Signed-off-by: Jeff Layton Reviewed-by: Jan Kara --- mm/page-writeback.c | 15 +++ 1 file chan

[PATCH v7 09/22] fs: always sync metadata in __generic_file_fsync

2017-06-16 Thread Jeff Layton
If there were previously both metadata and data writeback errors when fsync is called, then it will currently take two calls to fsync() to clear them on some filesystems. The problem is in __generic_file_fsync, which won't try to write back the metadata if the data flush fails. Fix this by always

[PATCH v7 05/22] jbd2: don't clear and reset errors after waiting on writeback

2017-06-16 Thread Jeff Layton
Resetting this flag is almost certainly racy, and will be problematic with some coming changes. Make filemap_fdatawait_keep_errors return int, but not clear the flag(s). Have jbd2 call it instead of filemap_fdatawait and don't attempt to re-set the error flag if it fails. Signed-off-by: Jeff Layt

[PATCH v7 04/22] buffer: set errors in mapping at the time that the error occurs

2017-06-16 Thread Jeff Layton
I noticed on xfs that I could still sometimes get back an error on fsync on a fd that was opened after the error condition had been cleared. The problem is that the buffer code sets the write_io_error flag and then later checks that flag to set the error in the mapping. That flag perisists for qui

[PATCH v7 03/22] fs: check for writeback errors after syncing out buffers in generic_file_fsync

2017-06-16 Thread Jeff Layton
ext2 currently does a test+clear of the AS_EIO flag, which is is problematic for some coming changes. What we really need to do instead is call filemap_check_errors in __generic_file_fsync after syncing out the buffers. That will be sufficient for this case, and help other callers detect these err

[PATCH v7 00/22] fs: enhanced writeback error reporting with errseq_t (pile #1)

2017-06-16 Thread Jeff Layton
v7: === This is the seventh posting of the patchset to revamp the way writeback errors are tracked and reported. The main difference from the v6 posting is the removal of the FS_WB_ERRSEQ flag. That requires a few other incremental patches in the writeback code to ensure that both error tracking m

[PATCH v7 02/22] buffer: use mapping_set_error instead of setting the flag

2017-06-16 Thread Jeff Layton
Signed-off-by: Jeff Layton Reviewed-by: Jan Kara Reviewed-by: Matthew Wilcox Reviewed-by: Christoph Hellwig --- fs/buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/buffer.c b/fs/buffer.c index 44172d11efae..7b4f4bfde91e 100644 --- a/fs/buffer.c +++ b/fs/buffer.c

[PATCH v7 01/22] fs: remove call_fsync helper function

2017-06-16 Thread Jeff Layton
Requested-by: Christoph Hellwig Signed-off-by: Jeff Layton --- fs/sync.c | 2 +- include/linux/fs.h | 6 -- ipc/shm.c | 2 +- 3 files changed, 2 insertions(+), 8 deletions(-) diff --git a/fs/sync.c b/fs/sync.c index 11ba023434b1..2a54c1f22035 100644 --- a/fs/sync.c +++ b/f

Re: No such file or directory error

2017-06-16 Thread Cerem Cem ASLAN
Sorry for above post, the error is just because of passing the parent and current snapshots from different physical disks. 2017-06-16 9:29 GMT+03:00 Cerem Cem ASLAN : > Hello everybody, > > I'm facing with a "No such file or directory" issue which only occurs > if I use a `btrfs send -p myparent

[PATCH 1/3 v2] btrfs: preallocate device flush bio

2017-06-16 Thread David Sterba
For devices that support flushing, we allocate a bio, submit, wait for it and then free it. The bio allocation does not fail so ENOMEM is not a problem but we still may unnecessarily stress the allocation subsystem. Instead, we can allocate the bio at the same time we allocate the device and reuse

[PATCH 3/3 v2] btrfs: move dev stats accounting out of wait_dev_flush

2017-06-16 Thread David Sterba
We should really just wait in wait_dev_flush and let the caller decide what to do with the error value. Signed-off-by: David Sterba --- fs/btrfs/disk-io.c | 11 +++ 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 85f931c5e63c..5

[PATCH 2/3 v2] btrfs: account as waiting for IO, while waiting fot the flush bio completion

2017-06-16 Thread David Sterba
Similar to what submit_bio_wait does, we should account for IO while waiting for a bio completion. This has marginal visible effects, flush bio is short-lived. Reviewed-by: Anand Jain Signed-off-by: David Sterba --- fs/btrfs/disk-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff

[PATCH 0/3 v2] Preallocate flush bio

2017-06-16 Thread David Sterba
This patchset follows the updates in the write_dev_flush function. The flush bio can be preallocated at the device creation time, so we avoid repeated alloc/free. v2: - merge 'flush_bio_sent' from 4 to 1 and dropped patch 4 - dropped sysfs tunable (patch 5) - fix typo in patch 1 changelog David S

Re: [PATCH 4/5] btrfs: add fs flag to force device flushing

2017-06-16 Thread David Sterba
On Fri, Jun 16, 2017 at 06:27:20AM +0800, Anand Jain wrote: > > > > > >> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c > >> index 59a732a13370..659a3b4645d2 100644 > >> --- a/fs/btrfs/disk-io.c > >> +++ b/fs/btrfs/disk-io.c > >> @@ -3494,7 +3494,8 @@ static void write_dev_flush(struct bt

Re: [PATCH 1/5] btrfs: preallocate device flush bio

2017-06-16 Thread David Sterba
On Fri, Jun 16, 2017 at 05:53:12AM +0800, Anand Jain wrote: > On 06/16/2017 12:49 AM, David Sterba wrote: > > For devices that support flushing, we allocate a bio, submit, wait for > > it and then free it. The bio allocation does not fail so ENOMEM is not a > > problem but we still may unnecessaril

Re: [PATCH v3] btrfs: fiemap: Cache and merge fiemap extent before submit it to user

2017-06-16 Thread David Sterba
On Fri, Apr 07, 2017 at 10:43:15AM +0800, Qu Wenruo wrote: > fs/btrfs/extent_io.c | 124 > ++- > 1 file changed, 122 insertions(+), 2 deletions(-) I see a lot of warnings from btrfs/094 [13458.628334] BTRFS warning (device sdb6): unhandled fiemap

[PATCH v2 2/2] btrfs: Round down values which are written for total_bytes_size

2017-06-16 Thread Nikolay Borisov
We got an internal report about a file system not wanting to mount following 99e3ecfcb9f4 ("Btrfs: add more validation checks for superblock"). BTRFS error (device sdb1): super_total_bytes 1000203816960 mismatch with fs_devices total_rw_bytes 1000203820544 Substracting the numbers we get a differ

[PATCH v2 0/2] Ensure size values are rounded down

2017-06-16 Thread Nikolay Borisov
Hello, Here is a small series which fixes an issue that got reported internally to Suse and which affects devices whose size is not multiple of sectorsize. More information can be found in the changelog for patch 2 The first patch in the series re-implements the btrfs_device_total_bytes getter/

[PATCH v2 1/2] btrfs: Manually implement device_total_bytes getter/setter

2017-06-16 Thread Nikolay Borisov
The device->total_bytes member needs to always be rounded down to sectorsize so that it corresponds to the value of super->total_bytes. However, there are multiple places where the setter is fed a value which is not rounded which can cause a fs to be unmountable due to the check introduced in 99e3e

Re: Disk usage is more than double the snapshots exclusive data

2017-06-16 Thread Timofey Titovets
2017-06-15 12:44 GMT+03:00 Vianney Stroebel : > On a backup drive for a home computer, disk usage as shown by 'btrfs fi > show' is more than double the snapshots exclusive data as shown by "btrfs > qgroup show" (574 GB vs 265 GB). > > I've done a lot of research online and I couldn't find any answe

Re: [kbuild-all] [PATCH] btrfs: Use btrfs_space_info_used instead of opencoding it

2017-06-16 Thread Ye Xiaolong
On 06/15, Nikolay Borisov wrote: > > >On 15.06.2017 04:17, kbuild test robot wrote: >> Hi Nikolay, >> >> [auto build test ERROR on v4.9-rc8] >> [cannot apply to btrfs/next kdave/for-next next-20170614] >> [if your patch is applied to the wrong git tree, please drop us a note to >> help improve th