[PATCH] btrfs: extent-tree: Fix a bug that btrfs is unable to add pinned bytes

2019-05-09 Thread Qu Wenruo
Commit ddf30cf03fb5 ("btrfs: extent-tree: Use btrfs_ref to refactor add_pinned_bytes()") refactored add_pinned_bytes(), but during that refactor, there are two callers which add the pinned bytes instead of subtracting. That refactor misses those two caller, causing incorrect pinned bytes calculati

Re: [PATCH v3] btrfs: Flush before reflinking any extent to prevent NOCOW write falling back to CoW without data reservation

2019-05-09 Thread Qu Wenruo
On 2019/5/9 下午10:49, David Sterba wrote: > On Wed, May 08, 2019 at 06:49:58PM +0800, Qu Wenruo wrote: >> [BUG] >> The following script can cause unexpected fsync failure: >> >> #!/bin/bash >> >> dev=/dev/test/test >> mnt=/mnt/btrfs >> >> mkfs.btrfs -f $dev -b 512M > /dev/null >> mount $

Hibernation into swap file

2019-05-09 Thread Maksim Fomin
‐‐‐ Original Message ‐‐‐ On Thursday, May 9, 2019 6:13 AM, Andrei Borzenkov wrote: > I think we need to allow at least some amount of trust to developers and > expect that this feature would not be released if it had such an obvious > problem. > > Of course bug happens and it surely needs

Re: [PATCH v2 3/3] btrfs: Always use a cached extent_state in btrfs_lock_and_flush_ordered_range

2019-05-09 Thread David Sterba
On Tue, May 07, 2019 at 10:19:24AM +0300, Nikolay Borisov wrote: > In case no cached_state argument is passed to > btrfs_lock_and_flush_ordered_range use one locally in the function. This > optimises the case when an ordered extent is found since the unlock > function will be able to unlock that st

[PATCH v2] btrfs: Add comments on locking of several device-related fields

2019-05-09 Thread Nikolay Borisov
Signed-off-by: Nikolay Borisov --- V2: * Document post_commit_list is protected by chunk_mutex in the "Device Locking" section. fs/btrfs/volumes.c | 4 +++- fs/btrfs/volumes.h | 11 --- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/volumes.c b/fs/btrfs/vo

Re: [PATCH v3] btrfs: Flush before reflinking any extent to prevent NOCOW write falling back to CoW without data reservation

2019-05-09 Thread David Sterba
On Wed, May 08, 2019 at 06:49:58PM +0800, Qu Wenruo wrote: > [BUG] > The following script can cause unexpected fsync failure: > > #!/bin/bash > > dev=/dev/test/test > mnt=/mnt/btrfs > > mkfs.btrfs -f $dev -b 512M > /dev/null > mount $dev $mnt -o nospace_cache > > # Prealloc one exte

Re: [PATCH] btrfs: Add comments on locking of several device-related fields

2019-05-09 Thread David Sterba
On Thu, May 09, 2019 at 05:12:16PM +0300, Nikolay Borisov wrote: > > > On 9.05.19 г. 16:55 ч., David Sterba wrote: > > On Tue, May 07, 2019 at 05:24:28PM +0300, Nikolay Borisov wrote: > >> Signed-off-by: Nikolay Borisov > >> --- > >> fs/btrfs/volumes.h | 11 --- > >> 1 file changed, 8 i

Re: [PATCH] btrfs: run delayed iput at unlink time

2019-05-09 Thread David Sterba
On Wed, May 08, 2019 at 10:15:16AM +0300, Nikolay Borisov wrote: > > + if (!list_empty(&inode->delayed_iput)) { > > + spin_lock(&fs_info->delayed_iput_lock); > > + if (!list_empty(&inode->delayed_iput)) { > > + list_del_init(&inode->delayed_iput); > > +

Re: [PATCH] btrfs: Add comments on locking of several device-related fields

2019-05-09 Thread Nikolay Borisov
On 9.05.19 г. 16:55 ч., David Sterba wrote: > On Tue, May 07, 2019 at 05:24:28PM +0300, Nikolay Borisov wrote: >> Signed-off-by: Nikolay Borisov >> --- >> fs/btrfs/volumes.h | 11 --- >> 1 file changed, 8 insertions(+), 3 deletions(-) >> >> diff --git a/fs/btrfs/volumes.h b/fs/btrfs/vo

Re: [PATCH] btrfs: Add comments on locking of several device-related fields

2019-05-09 Thread David Sterba
On Tue, May 07, 2019 at 05:24:28PM +0300, Nikolay Borisov wrote: > Signed-off-by: Nikolay Borisov > --- > fs/btrfs/volumes.h | 11 --- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h > index 3b97e8092ba7..514799362244 100644 > --

Re: [PATCH] btrfs: extent-io: Remove the incorrect comment on RO fs when btrfs_run_delalloc_range() fails

2019-05-09 Thread David Sterba
On Thu, May 09, 2019 at 03:31:50PM +0800, Qu Wenruo wrote: > At the context of btrfs_run_delalloc_range(), we haven't started/joined > a transaction, thus even something went wrong, we can't and won't abort > transaction, thus no way to make the fs RO. > > Signed-off-by: Qu Wenruo Added to 5.3 q

Re: [PATCH 2/2] btrfs: extent-tree: Add trace events for space info numbers update

2019-05-09 Thread David Sterba
On Mon, Apr 29, 2019 at 02:03:33PM +0800, Qu Wenruo wrote: > Add trace event for update_bytes_pinned() and update_bytes_may_use() to > detect underflow better. > > The output would be something like (only showing data part): > > ## Buffered write start, 16K total ## > 2255.954 xfs_io/860 btrf

Re: [PATCH] Btrfs: do not abort transaction at btrfs_update_root() after failure to COW path

2019-05-09 Thread David Sterba
On Mon, Apr 29, 2019 at 01:08:14PM +0100, fdman...@kernel.org wrote: > From: Filipe Manana > > Currently when we fail to COW a path at btrfs_update_root() we end up > always aborting the transaction. However all the current callers of > btrfs_update_root() are able to deal with errors returned fr

Re: [PATCH] btrfs: extent-io: Remove the incorrect comment on RO fs when btrfs_run_delalloc_range() fails

2019-05-09 Thread Nikolay Borisov
On 9.05.19 г. 10:31 ч., Qu Wenruo wrote: > At the context of btrfs_run_delalloc_range(), we haven't started/joined > a transaction, thus even something went wrong, we can't and won't abort > transaction, thus no way to make the fs RO. > > Signed-off-by: Qu Wenruo Reviewed-by: Nikolay Borisov

[PATCH] btrfs: extent-io: Remove the incorrect comment on RO fs when btrfs_run_delalloc_range() fails

2019-05-09 Thread Qu Wenruo
At the context of btrfs_run_delalloc_range(), we haven't started/joined a transaction, thus even something went wrong, we can't and won't abort transaction, thus no way to make the fs RO. Signed-off-by: Qu Wenruo --- fs/btrfs/extent_io.c | 1 - 1 file changed, 1 deletion(-) diff --git a/fs/btrf