Re: IO errors when building RAID1.... ?

2018-08-31 Thread Duncan
Chris Murphy posted on Fri, 31 Aug 2018 13:02:16 -0600 as excerpted: > If you want you can post the output from 'sudo smartctl -x /dev/sda' > which will contain more information... but this is in some sense > superfluous. The problem is very clearly a bad drive, the drive > explicitly report to

Re: [PATCH 30/35] btrfs: cleanup pending bgs on transaction abort

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:42:20PM -0400, Josef Bacik wrote: > We may abort the transaction during a commit and not have a chance to > run the pending bgs stuff, which will leave block groups on our list and > cause us accounting issues and leaked memory. Fix this by running the > pending bgs

Re: [PATCH 29/35] btrfs: just delete pending bgs if we are aborted

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:42:19PM -0400, Josef Bacik wrote: > We still need to do all of the accounting cleanup for pending block > groups if we abort. So set the ret to trans->aborted so if we aborted > the cleanup happens and everybody is happy. Reviewed-by: Omar Sandoval Reusing the loop

Re: [PATCH 21/35] btrfs: only run delayed refs if we're committing

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:42:11PM -0400, Josef Bacik wrote: > I noticed in a giant dbench run that we spent a lot of time on lock > contention while running transaction commit. This is because dbench > results in a lot of fsync()'s that do a btrfs_transaction_commit(), and > they all run the

Re: [PATCH 23/35] btrfs: assert on non-empty delayed iputs

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:42:13PM -0400, Josef Bacik wrote: > I ran into an issue where there was some reference being held on an > inode that I couldn't track. This assert wasn't triggered, but it at > least rules out we're doing something stupid. Reviewed-by: Omar Sandoval > Signed-off-by:

Re: [PATCH 09/35] btrfs: protect space cache inode alloc with nofs

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:41:59PM -0400, Josef Bacik wrote: > If we're allocating a new space cache inode it's likely going to be > under a transaction handle, so we need to use memalloc_nofs_save() in > order to avoid deadlocks, and more importantly lockdep messages that > make xfstests fail.

Re: [PATCH 08/35] btrfs: release metadata before running delayed refs

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:41:58PM -0400, Josef Bacik wrote: > We want to release the unused reservation we have since it refills the > delayed refs reserve, which will make everything go smoother when > running the delayed refs if we're short on our reservation. Reviewed-by: Omar Sandoval >

Re: [PATCH 22/35] btrfs: make sure we create all new bgs

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:42:12PM -0400, Josef Bacik wrote: > We can actually allocate new chunks while we're creating our bg's, so > instead of doing list_for_each_safe, just do while (!list_empty()) so we > make sure to catch any new bg's that get added to the list. Reviewed-by: Omar Sandoval

Re: [PATCH 06/35] btrfs: check if free bgs for commit

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:41:56PM -0400, Josef Bacik wrote: > may_commit_transaction will skip committing the transaction if we don't > have enough pinned space or if we're trying to find space for a SYSTEM > chunk. However if we have pending free block groups in this transaction > we still want

Re: [PATCH 03/35] btrfs: use cleanup_extent_op in check_ref_cleanup

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:41:53PM -0400, Josef Bacik wrote: > From: Josef Bacik > > Unify the extent_op handling as well, just add a flag so we don't > actually run the extent op from check_ref_cleanup and instead return a > value so that we can skip cleaning up the ref head. > >

Re: [PATCH 02/35] btrfs: add cleanup_ref_head_accounting helper

2018-08-31 Thread Omar Sandoval
On Thu, Aug 30, 2018 at 01:41:52PM -0400, Josef Bacik wrote: > From: Josef Bacik > > We were missing some quota cleanups in check_ref_cleanup, so break the > ref head accounting cleanup into a helper and call that from both > check_ref_cleanup and cleanup_ref_head. This will hopefully ensure

[PATCH v5 3/6] vfs: update swap_{,de}activate documentation

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval The documentation for these functions is wrong in several ways: - swap_activate() is called with the inode locked - swap_activate() takes a swap_info_struct * and a sector_t * - swap_activate() can also return a positive number of extents it added itself -

[PATCH v5 0/6] Btrfs: implement swap file support

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval Hi, This series implements swap file support for Btrfs. Changes since v4 [1]: - Added a kernel doc for btrfs_get_chunk_map() - Got rid of "Btrfs: push EXCL_OP set into btrfs_rm_device()" - Made activate error messages more clear and consistent - Changed clear vs unlock

[PATCH v5 4/6] Btrfs: prevent ioctls from interfering with a swap file

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval When a swap file is active, we must make sure that the extents of the file are not moved and that they don't become shared. That means that the following are not safe: - chattr +c (enable compression) - reflink - dedupe - snapshot - defrag - balance - device

[PATCH v5 6/6] Btrfs: support swap files

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval Implement the swap file a_ops on Btrfs. Activation needs to make sure that the file can be used as a swap file, which currently means it must be fully allocated as nocow with no compression on one device. It also sets up the swap extents directly with add_swap_extent(), so

[PATCH v5 2/6] mm: export add_swap_extent()

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval Btrfs will need this for swap file support. Signed-off-by: Omar Sandoval --- mm/swapfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index d3f95833d12e..51cb30de17bc 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2365,6 +2365,7

[PATCH v5 1/6] mm: split SWP_FILE into SWP_ACTIVATED and SWP_FS

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval The SWP_FILE flag serves two purposes: to make swap_{read,write}page() go through the filesystem, and to make swapoff() call ->swap_deactivate(). For Btrfs, we want the latter but not the former, so split this flag into two. This makes us always call ->swap_deactivate() if

[PATCH v5 5/6] Btrfs: rename get_chunk_map() and make it non-static

2018-08-31 Thread Omar Sandoval
From: Omar Sandoval The Btrfs swap code is going to need it, so give it a btrfs_ prefix and make it non-static. Signed-off-by: Omar Sandoval --- fs/btrfs/volumes.c | 22 +++--- fs/btrfs/volumes.h | 9 + 2 files changed, 20 insertions(+), 11 deletions(-) diff --git

Re: IO errors when building RAID1.... ?

2018-08-31 Thread Chris Murphy
If you want you can post the output from 'sudo smartctl -x /dev/sda' which will contain more information... but this is in some sense superfluous. The problem is very clearly a bad drive, the drive explicitly report to libata a write error, and included the sector LBA affected, and only the drive

Re: IO errors when building RAID1.... ?

2018-08-31 Thread Chris Murphy
On Fri, Aug 31, 2018 at 10:35 AM, Pierre Couderc wrote: > > Aug 31 17:34:55 server su[559]: Successful su for root by nous > Aug 31 17:34:55 server su[559]: + /dev/pts/1 nous:root > Aug 31 17:34:55 server su[559]: pam_unix(su:session): session opened for > user root by nous(uid=1000) > Aug 31

bug: btrfs-progs scrub -R flag doesn't show per device stats

2018-08-31 Thread Chris Murphy
btrfs-progs v4.17.1 man btrfs-scrub: -R print raw statistics per-device instead of a summary However, on a two device Btrfs volume, -R does not show per device statistics. See screenshot: https://drive.google.com/open?id=1xmt_NHGlNJPc8I0F4_OZxgGe9b3quCnD

Re: How to erase a RAID1 (+++)?

2018-08-31 Thread Duncan
Alberto Bursi posted on Fri, 31 Aug 2018 14:54:46 + as excerpted: > I just keep around a USB drive with a full Linux system on it, to act as > "recovery". If the btrfs raid fails I boot into that and I can do > maintenance with a full graphical interface and internet access so I can > google

IO errors when building RAID1.... ?

2018-08-31 Thread Pierre Couderc
When trying to build a RAID1 on main fs. After  normal debian stretch install : root@server:/home/nous# btrfs device add /dev/sdb1 / root@server:/home/nous# btrfs fi show Label: none  uuid: ef0b9dad-c0eb-4a3b-9b41-e5e249363abc     Total devices 2 FS bytes used 824.60MiB     devid    1

Re: How to erase a RAID1 (+++)?

2018-08-31 Thread Pierre Couderc
On 08/31/2018 04:54 PM, Alberto Bursi wrote: On 8/31/2018 8:53 AM, Pierre Couderc wrote: OK, I have understood the message... I was planning that as you said "semi-routinely", and I understand btrfs is not soon enough ready, and I am very very far to be a specialist as you are. So, I shall

Re: How to erase a RAID1 (+++)?

2018-08-31 Thread Alberto Bursi
On 8/31/2018 8:53 AM, Pierre Couderc wrote: > > OK, I have understood the message... I was planning that as you said > "semi-routinely", and I understand btrfs is not soon enough ready, and > I am very very far to be a specialist as you are. > So, I shall mount my RAID1 very standard, and I 

Re: [PATCH 01/35] btrfs: add btrfs_delete_ref_head helper

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:57:45AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:41, Josef Bacik wrote: > > From: Josef Bacik > > > > We do this dance in cleanup_ref_head and check_ref_cleanup, unify it > > into a helper and cleanup the calling functions. > > > > Signed-off-by: Josef

Re: [PATCH 15/35] btrfs: run delayed iputs before committing

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:55:22AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:42, Josef Bacik wrote: > > We want to have a complete picture of any delayed inode updates before > > we make the decision to commit or not, so make sure we run delayed iputs > > before making the decision to

Re: [PATCH 07/35] btrfs: dump block_rsv whe dumping space info

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:53:54AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:41, Josef Bacik wrote: > > For enospc_debug having the block rsvs is super helpful to see if we've > > done something wrong. > > > > Signed-off-by: Josef Bacik > > --- > > fs/btrfs/extent-tree.c | 15

Re: [PATCH 04/35] btrfs: only track ref_heads in delayed_ref_updates

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:52:55AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:41, Josef Bacik wrote: > > From: Josef Bacik > > > > We use this number to figure out how many delayed refs to run, but > > __btrfs_run_delayed_refs really only checks every time we need a new > > delayed

Re: [PATCH 30/35] btrfs: cleanup pending bgs on transaction abort

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:48:58AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:42, Josef Bacik wrote: > > We may abort the transaction during a commit and not have a chance to > > run the pending bgs stuff, which will leave block groups on our list and > > cause us accounting issues and

Re: [PATCH 29/35] btrfs: just delete pending bgs if we are aborted

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:46:36AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:42, Josef Bacik wrote: > > We still need to do all of the accounting cleanup for pending block > > groups if we abort. So set the ret to trans->aborted so if we aborted > > the cleanup happens and everybody

Re: [PATCH 27/35] btrfs: handle delayed ref head accounting cleanup in abort

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:42:13AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:42, Josef Bacik wrote: > > We weren't doing any of the accounting cleanup when we aborted > > transactions. Fix this by making cleanup_ref_head_accounting global and > > calling it from the abort code, this

Re: [PATCH 22/35] btrfs: make sure we create all new bgs

2018-08-31 Thread Josef Bacik
On Fri, Aug 31, 2018 at 10:31:49AM +0300, Nikolay Borisov wrote: > > > On 30.08.2018 20:42, Josef Bacik wrote: > > We can actually allocate new chunks while we're creating our bg's, so > > instead of doing list_for_each_safe, just do while (!list_empty()) so we > > make sure to catch any new

Re: [PATCH 01/35] btrfs: add btrfs_delete_ref_head helper

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:41, Josef Bacik wrote: > From: Josef Bacik > > We do this dance in cleanup_ref_head and check_ref_cleanup, unify it > into a helper and cleanup the calling functions. > > Signed-off-by: Josef Bacik > --- > fs/btrfs/delayed-ref.c | 14 ++ >

Re: [PATCH 15/35] btrfs: run delayed iputs before committing

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We want to have a complete picture of any delayed inode updates before > we make the decision to commit or not, so make sure we run delayed iputs > before making the decision to commit or not. Again, there was request for more detail which is not

Re: [PATCH 07/35] btrfs: dump block_rsv whe dumping space info

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:41, Josef Bacik wrote: > For enospc_debug having the block rsvs is super helpful to see if we've > done something wrong. > > Signed-off-by: Josef Bacik > --- > fs/btrfs/extent-tree.c | 15 +++ > 1 file changed, 15 insertions(+) > > diff --git

Re: [PATCH 04/35] btrfs: only track ref_heads in delayed_ref_updates

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:41, Josef Bacik wrote: > From: Josef Bacik > > We use this number to figure out how many delayed refs to run, but > __btrfs_run_delayed_refs really only checks every time we need a new > delayed ref head, so we always run at least one ref head completely no > matter what the

Re: [PATCH 30/35] btrfs: cleanup pending bgs on transaction abort

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We may abort the transaction during a commit and not have a chance to > run the pending bgs stuff, which will leave block groups on our list and > cause us accounting issues and leaked memory. Fix this by running the > pending bgs when we cleanup a

Re: [PATCH 29/35] btrfs: just delete pending bgs if we are aborted

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We still need to do all of the accounting cleanup for pending block > groups if we abort. So set the ret to trans->aborted so if we aborted > the cleanup happens and everybody is happy. > > Signed-off-by: Josef Bacik > --- > fs/btrfs/extent-tree.c |

Re: [PATCH 28/35] btrfs: call btrfs_create_pending_block_groups unconditionally

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > The first thing we do is loop through the list, this > > if (!list_empty()) > btrfs_create_pending_block_groups(); > > thing is just wasted space. > > Signed-off-by: Josef Bacik Makes sense, although it would have been ideal if this patch

Re: [PATCH 27/35] btrfs: handle delayed ref head accounting cleanup in abort

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We weren't doing any of the accounting cleanup when we aborted > transactions. Fix this by making cleanup_ref_head_accounting global and > calling it from the abort code, this fixes the issue where our > accounting was all wrong after the fs aborts. >

Re: [PATCH 26/35] btrfs: make btrfs_destroy_delayed_refs use btrfs_delete_ref_head

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > Instead of open coding this stuff use the helper instead. > > Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov > --- > fs/btrfs/disk-io.c | 7 +-- > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/fs/btrfs/disk-io.c

Re: [PATCH 25/35] btrfs: make btrfs_destroy_delayed_refs use btrfs_delayed_ref_lock

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We have this open coded in btrfs_destroy_delayed_refs, use the helper > instead. > > Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov > --- > fs/btrfs/disk-io.c | 11 ++- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff

Re: [PATCH 24/35] btrfs: pass delayed_refs_root to btrfs_delayed_ref_lock

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We don't need the trans except to get the delayed_refs_root, so just > pass the delayed_refs_root into btrfs_delayed_ref_lock and call it a > day. > > Signed-off-by: Josef Bacik Reviewed-by: Nikolay Borisov > --- > fs/btrfs/delayed-ref.c | 5 +

Re: [PATCH 22/35] btrfs: make sure we create all new bgs

2018-08-31 Thread Nikolay Borisov
On 30.08.2018 20:42, Josef Bacik wrote: > We can actually allocate new chunks while we're creating our bg's, so > instead of doing list_for_each_safe, just do while (!list_empty()) so we > make sure to catch any new bg's that get added to the list. HOw can this occur, please elaborate and put

Re: How to erase a RAID1 (+++)?

2018-08-31 Thread Pierre Couderc
On 08/31/2018 04:29 AM, Duncan wrote: Chris Murphy posted on Thu, 30 Aug 2018 11:08:28 -0600 as excerpted: My purpose is a simple RAID1 main fs, with bootable flag on the 2 disks in prder to start in degraded mode Good luck with this. The Btrfs archives are full of various limitations

Re: How to erase a RAID1 (+++)?

2018-08-31 Thread Pierre Couderc
On 08/30/2018 07:08 PM, Chris Murphy wrote: On Thu, Aug 30, 2018 at 3:13 AM, Pierre Couderc wrote: Trying to install a RAID1 on a debian stretch, I made some mistake and got this, after installing on disk1 and trying to add second disk : root@server:~# fdisk -l Disk /dev/sda: 1.8 TiB,