Re: [PULL] Btrfs for 4.7, part 2

2016-06-14 Thread Anand Jain


Chris,

  Sorry for the delay due to vacation.

more below..

On 05/29/2016 08:21 PM, Chris Mason wrote:

On Sat, May 28, 2016 at 01:14:13PM +0800, Anand Jain wrote:



On 05/27/2016 11:42 PM, Chris Mason wrote:

I'm getting errors from btrfs fi show -d, after the very last round of
device replaces.  A little extra debugging:

bytenr mismatch, want=4332716032, have=0
ERROR: cannot read chunk root
ERROR reading /dev/vdh
failed /dev/vdh

Which is cute because the very next command we run fscks /dev/vdh and
succeeds.


Checked the code paths both btrfs fi show -d and btrfs check,
both are calling flush during relative open_ctree in progs.

However the flush is called after we have read superblock. That
means the read_superblock during 'show' cli (only) will read superblock
without flush, and 'check' won't, because 011 calls 'check' after
'show'. But it still does not explain the above error, which is
during open_ctree not at read superblock. Remains strange case as
of now.


It's because we're just not done writing it out yet when btrfs fi show
is run.
I think replace is special here.



Also. I can't reproduce.



I'm in a relatively new test rig using kvm, which probably explains why
I haven't seen it before.  You can probably make it easier by adding
a sleep inside the actual __free_device() func.


So the page cache is stale and this isn't related to any of our
patches.


close_ctree() calls into btrfs_close_devices(), which calls
btrfs_close_one_device(), which uses:

call_rcu(>rcu, free_device);

close_ctree() also does an rcu_barrier() to make sure and wait for
free_device() to finish.

But, free_device() just puts the work into schedule_work(), so we don't
know for sure the blkdev_put is done when we exit.


Right, saw that before. Any idea why its like that ? Or if it
should be fixed?


It's just trying to limit the work that is done from call_rcu, and it
should
definitely be fixed.  It might cause EBUSY or other problems.  Probably
easiest to add a counter or completion object that gets changed by the
__free_device function.



yes indeed sleep made the problem to reproduce,

Also looks like this problem was identified by below
commit before, however the fix wasn't correct.
   
 commit bc178622d40d87e75abc131007342429c9b03351
 btrfs: use rcu_barrier() to wait for bdev puts at unmount

 ::
 Adding an rcu_barrier() to btrfs_close_devices() causes unmount
 to wait
 until all blkdev_put()s are done, and the device is truly free once
 unmount complet
   

 As free_devces() spinoff __free_device() to make the actual
 bdev put we need to wait on __free_device(). But rcu_barrier()
 just waits for free_device() to complete, so at the end of
 rcu_barrier() the blkdev_put()  may not be completed.


 Wrote a new fix as in the patches,
  [PATH 2/2] btrfs: wait for bdev put

 For review comments.


Thanks, -Anand


-chris

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7, part 2

2016-05-29 Thread Chris Mason

On Sat, May 28, 2016 at 01:14:13PM +0800, Anand Jain wrote:



On 05/27/2016 11:42 PM, Chris Mason wrote:

I'm getting errors from btrfs fi show -d, after the very last round of
device replaces.  A little extra debugging:

bytenr mismatch, want=4332716032, have=0
ERROR: cannot read chunk root
ERROR reading /dev/vdh
failed /dev/vdh

Which is cute because the very next command we run fscks /dev/vdh and
succeeds.


Checked the code paths both btrfs fi show -d and btrfs check,
both are calling flush during relative open_ctree in progs.

However the flush is called after we have read superblock. That
means the read_superblock during 'show' cli (only) will read superblock
without flush, and 'check' won't, because 011 calls 'check' after
'show'. But it still does not explain the above error, which is
during open_ctree not at read superblock. Remains strange case as
of now.


It's because we're just not done writing it out yet when btrfs fi show is run.
I think replace is special here.



Also. I can't reproduce.



I'm in a relatively new test rig using kvm, which probably explains why
I haven't seen it before.  You can probably make it easier by adding
a sleep inside the actual __free_device() func.


So the page cache is stale and this isn't related to any of our patches.


close_ctree() calls into btrfs_close_devices(), which calls
btrfs_close_one_device(), which uses:

call_rcu(>rcu, free_device);

close_ctree() also does an rcu_barrier() to make sure and wait for
free_device() to finish.

But, free_device() just puts the work into schedule_work(), so we don't
know for sure the blkdev_put is done when we exit.


Right, saw that before. Any idea why its like that ? Or if it
should be fixed?


It's just trying to limit the work that is done from call_rcu, and it should
definitely be fixed.  It might cause EBUSY or other problems.  Probably
easiest to add a counter or completion object that gets changed by the
__free_device function.

-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7, part 2

2016-05-27 Thread Anand Jain



On 05/27/2016 11:42 PM, Chris Mason wrote:

On Fri, May 27, 2016 at 10:35:27AM -0400, Chris Mason wrote:

On Fri, May 27, 2016 at 01:18:22PM +0200, David Sterba wrote:

On Thu, May 26, 2016 at 08:14:14PM -0400, Chris Mason wrote:

On Thu, May 26, 2016 at 11:27:06AM +0200, David Sterba wrote:

Hi,

please pull a few more patches that did not go to pull #1 for 4.7, minor
cleanups and fixes. Thanks.


Thanks Dave!  Trying to figure out why we're failing btrfs/011, but I
don't see how it could be related to this bunch.  I'll nail it down.


011 passes here, there are some unrelated soft-failures (mismatching
output with new progs). I'm now testing a branch without "btrfs: scrub:
Set bbio to NULL before calling btrfs_map_block", that seems to be the
only likely offender.


I'm getting errors from btrfs fi show -d, after the very last round of
device replaces.  A little extra debugging:

bytenr mismatch, want=4332716032, have=0
ERROR: cannot read chunk root
ERROR reading /dev/vdh
failed /dev/vdh

>>

Which is cute because the very next command we run fscks /dev/vdh and
succeeds.


Checked the code paths both btrfs fi show -d and btrfs check,
both are calling flush during relative open_ctree in progs.

However the flush is called after we have read superblock. That
means the read_superblock during 'show' cli (only) will read superblock
without flush, and 'check' won't, because 011 calls 'check' after
'show'. But it still does not explain the above error, which is
during open_ctree not at read superblock. Remains strange case as
of now.

Also. I can't reproduce.


So the page cache is stale and this isn't related to any of our patches.


close_ctree() calls into btrfs_close_devices(), which calls
btrfs_close_one_device(), which uses:

call_rcu(>rcu, free_device);

close_ctree() also does an rcu_barrier() to make sure and wait for
free_device() to finish.

But, free_device() just puts the work into schedule_work(), so we don't
know for sure the blkdev_put is done when we exit.


 Right, saw that before. Any idea why its like that ? Or if it
 should be fixed?


It's been this way for a while, so its not holding up my pull request to
Linus.  But I'll fix it up.


 Yes. Its been like that.

Thanks, Anand



-chris

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7, part 2

2016-05-27 Thread Chris Mason
On Fri, May 27, 2016 at 10:35:27AM -0400, Chris Mason wrote:
> On Fri, May 27, 2016 at 01:18:22PM +0200, David Sterba wrote:
> > On Thu, May 26, 2016 at 08:14:14PM -0400, Chris Mason wrote:
> > > On Thu, May 26, 2016 at 11:27:06AM +0200, David Sterba wrote:
> > > > Hi,
> > > > 
> > > > please pull a few more patches that did not go to pull #1 for 4.7, minor
> > > > cleanups and fixes. Thanks.
> > > 
> > > Thanks Dave!  Trying to figure out why we're failing btrfs/011, but I
> > > don't see how it could be related to this bunch.  I'll nail it down.
> > 
> > 011 passes here, there are some unrelated soft-failures (mismatching
> > output with new progs). I'm now testing a branch without "btrfs: scrub:
> > Set bbio to NULL before calling btrfs_map_block", that seems to be the
> > only likely offender.
> 
> I'm getting errors from btrfs fi show -d, after the very last round of
> device replaces.  A little extra debugging:
> 
> bytenr mismatch, want=4332716032, have=0
> ERROR: cannot read chunk root
> ERROR reading /dev/vdh
> failed /dev/vdh
> 
> Which is cute because the very next command we run fscks /dev/vdh and
> succeeds.
> 
> So the page cache is stale and this isn't related to any of our patches.

close_ctree() calls into btrfs_close_devices(), which calls
btrfs_close_one_device(), which uses:

call_rcu(>rcu, free_device);

close_ctree() also does an rcu_barrier() to make sure and wait for
free_device() to finish.

But, free_device() just puts the work into schedule_work(), so we don't
know for sure the blkdev_put is done when we exit.

It's been this way for a while, so its not holding up my pull request to
Linus.  But I'll fix it up.

-chris

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7, part 2

2016-05-27 Thread Chris Mason
On Fri, May 27, 2016 at 01:18:22PM +0200, David Sterba wrote:
> On Thu, May 26, 2016 at 08:14:14PM -0400, Chris Mason wrote:
> > On Thu, May 26, 2016 at 11:27:06AM +0200, David Sterba wrote:
> > > Hi,
> > > 
> > > please pull a few more patches that did not go to pull #1 for 4.7, minor
> > > cleanups and fixes. Thanks.
> > 
> > Thanks Dave!  Trying to figure out why we're failing btrfs/011, but I
> > don't see how it could be related to this bunch.  I'll nail it down.
> 
> 011 passes here, there are some unrelated soft-failures (mismatching
> output with new progs). I'm now testing a branch without "btrfs: scrub:
> Set bbio to NULL before calling btrfs_map_block", that seems to be the
> only likely offender.

I'm getting errors from btrfs fi show -d, after the very last round of
device replaces.  A little extra debugging:

bytenr mismatch, want=4332716032, have=0
ERROR: cannot read chunk root
ERROR reading /dev/vdh
failed /dev/vdh

Which is cute because the very next command we run fscks /dev/vdh and
succeeds.

So the page cache is stale and this isn't related to any of our patches.

-chris

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7, part 2

2016-05-27 Thread David Sterba
On Thu, May 26, 2016 at 08:14:14PM -0400, Chris Mason wrote:
> On Thu, May 26, 2016 at 11:27:06AM +0200, David Sterba wrote:
> > Hi,
> > 
> > please pull a few more patches that did not go to pull #1 for 4.7, minor
> > cleanups and fixes. Thanks.
> 
> Thanks Dave!  Trying to figure out why we're failing btrfs/011, but I
> don't see how it could be related to this bunch.  I'll nail it down.

011 passes here, there are some unrelated soft-failures (mismatching
output with new progs). I'm now testing a branch without "btrfs: scrub:
Set bbio to NULL before calling btrfs_map_block", that seems to be the
only likely offender.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7, part 2

2016-05-26 Thread Chris Mason
On Thu, May 26, 2016 at 11:27:06AM +0200, David Sterba wrote:
> Hi,
> 
> please pull a few more patches that did not go to pull #1 for 4.7, minor
> cleanups and fixes. Thanks.

Thanks Dave!  Trying to figure out why we're failing btrfs/011, but I
don't see how it could be related to this bunch.  I'll nail it down.

-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL] Btrfs for 4.7, part 2

2016-05-26 Thread David Sterba
Hi,

please pull a few more patches that did not go to pull #1 for 4.7, minor
cleanups and fixes. Thanks.


The following changes since commit c315ef8d9db7f1a0ebd023a395ebdfde1c68057e:

  Merge branch 'for-chris-4.7' of 
git://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux into for-linus-4.7 
(2016-05-17 14:43:19 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-chris

for you to fetch changes up to 4c6143dd497901e3537dc4324dc203dfda442009:

  Merge branch 'dev/comp-workspaces' into for-chris-4.7-20160525 (2016-05-25 
22:51:04 +0200)


David Sterba (17):
  btrfs: rename and document compression workspace members
  btrfs: preallocate compression workspaces
  btrfs: make find_workspace always succeed
  btrfs: make find_workspace warn if there are no workspaces
  btrfs: sink gfp parameter to set_extent_bits
  btrfs: sink gfp parameter to clear_extent_bits
  btrfs: sink gfp parameter to clear_record_extent_bits
  btrfs: sink gfp parameter to clear_extent_dirty
  btrfs: sink gfp parameter to set_extent_delalloc
  btrfs: sink gfp parameter to set_extent_defrag
  btrfs: sink gfp parameter to set_extent_new
  btrfs: sink gfp parameter to set_record_extent_bits
  btrfs: untangle gotos a bit in __set_extent_bit
  btrfs: untangle gotos a bit in __clear_extent_bit
  btrfs: untangle gotos a bit in convert_extent_bit
  btrfs: make state preallocation more speculative in __set_extent_bit
  btrfs: sink gfp parameter to convert_extent_bit

Liu Bo (2):
  Btrfs: free sys_array eb as soon as possible
  Btrfs: fix unexpected return value of fiemap

Nicholas D Steeves (1):
  btrfs: fix string and comment grammatical issues and typos

Zhao Lei (1):
  btrfs: scrub: Set bbio to NULL before calling btrfs_map_block

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PULL] Btrfs for 4.7

2016-05-16 Thread Chris Mason
On Mon, May 16, 2016 at 04:14:23PM +0200, David Sterba wrote:
> Hi,
> 
> please queue the following branch to 4.7.
> 
> New features or user-visible changes:
> * device delete by id, a v2 ioctl for device deletion (this was held back from
>   4.6 pull due to possibly related crashes that haven't appeared for a long
>   time)
> * DUP allowed on multiple-device filesystem (help in case we want to go to
>   SINGLE from RAID1/.. but do not want to lose all redundancy while 
> converting)
> * GETFLAGS/SETFLAGS/GETVERSION ioctls work on 32bit
> 
> Developer-visible changes:
> * definitions that are shared with userspace are moved to the uapi directory
> 
> Other:
> * assorted bugfixes and cleanups
> 
> The branch is merged from several topic branches, grouped by functionality
> or purpose. The patches have been in for-next, most of them for a few weeks at
> least, tested together with Filipe's branch.

Great, thanks Dave!  I've got things merged up and I'm running more
tests.

-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PULL] Btrfs for 4.7

2016-05-16 Thread David Sterba
Hi,

please queue the following branch to 4.7.

New features or user-visible changes:
* device delete by id, a v2 ioctl for device deletion (this was held back from
  4.6 pull due to possibly related crashes that haven't appeared for a long
  time)
* DUP allowed on multiple-device filesystem (help in case we want to go to
  SINGLE from RAID1/.. but do not want to lose all redundancy while converting)
* GETFLAGS/SETFLAGS/GETVERSION ioctls work on 32bit

Developer-visible changes:
* definitions that are shared with userspace are moved to the uapi directory

Other:
* assorted bugfixes and cleanups

The branch is merged from several topic branches, grouped by functionality
or purpose. The patches have been in for-next, most of them for a few weeks at
least, tested together with Filipe's branch.

Thanks.


The following changes since commit 02da2d72174c61988eb4456b53f405e3ebdebce4:

  Linux 4.6-rc5 (2016-04-24 16:17:05 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git for-chris-4.7

for you to fetch changes up to 680834ca0ad4e9827048d4bda1e38db69c3dd1e4:

  Merge branch 'foreign/jeffm/uapi' into for-chris-4.7-20160516 (2016-05-16 
15:46:29 +0200)


Adam Borowski (1):
  btrfs: fix int32 overflow in shrink_delalloc().

Anand Jain (20):
  btrfs: rename btrfs_std_error to btrfs_handle_fs_error
  btrfs: remove unused function btrfs_assert()
  btrfs: move error handling code together in ctree.h
  btrfs: remove save_error_info()
  btrfs: create a helper function to read the disk super
  btrfs: create helper function __check_raid_min_devices()
  btrfs: clean up and optimize __check_raid_min_device()
  btrfs: create helper btrfs_find_device_by_user_input()
  btrfs: make use of btrfs_find_device_by_user_input()
  btrfs: enhance btrfs_find_device_by_user_input() to check device path
  btrfs: make use of btrfs_scratch_superblocks() in btrfs_rm_device()
  btrfs: introduce device delete by devid
  btrfs: optimize check for stale device
  btrfs: use fs_info directly
  btrfs: refactor btrfs_dev_replace_start for reuse
  btrfs: pass the right error code to the btrfs_std_error
  btrfs: s_bdev is not null after missing replace
  btrfs: cleanup assigning next active device with a check
  btrfs: fix lock dep warning, move scratch dev out of device_list_mutex 
and uuid_mutex
  btrfs: fix lock dep warning move scratch super outside of chunk_mutex

Ashish Samant (1):
  btrfs: Fix BUG_ON condition in scrub_setup_recheck_block()

Austin S. Hemmelgarn (1):
  btrfs: allow balancing to dup with multi-device

Chandan Rajendra (1):
  Btrfs: __btrfs_buffered_write: Pass valid file offset when releasing 
delalloc space

Dan Carpenter (1):
  btrfs: send: silence an integer overflow warning

David Sterba (32):
  btrfs: rename __check_raid_min_devices
  btrfs: pass number of devices to btrfs_check_raid_min_devices
  btrfs: introduce raid-type to error-code table, for minimum device 
constraint
  btrfs: use existing device constraints table btrfs_raid_array
  btrfs: rename btrfs_find_device_by_user_input
  btrfs: rename flags for vol args v2
  btrfs: kill unused writepage_io_hook callback
  btrfs: ioctl: reorder exclusive op check in RM_DEV
  btrfs: send: use vmalloc only as fallback for send_buf
  btrfs: send: use vmalloc only as fallback for read_buf
  btrfs: send: use temporary variable to store allocation size
  btrfs: send: use vmalloc only as fallback for clone_roots
  btrfs: send: use vmalloc only as fallback for clone_sources_tmp
  btrfs: clone: use vmalloc only as fallback for nodesize bufer
  btrfs: use dynamic allocation for root item in create_subvol
  btrfs: reuse existing variable in scrub_stripe, reduce stack usage
  btrfs: add read-only check to sysfs handler of features
  btrfs: add check to sysfs handler of label
  btrfs: sysfs: protect reading label by lock
  btrfs: add write protection to SET_FEATURES ioctl
  btrfs: ioctl: reorder exclusive op check in RM_DEV
  btrfs: switch to common message helpers in open_ctree, adjust messages
  btrfs: GFP_NOFS does not GFP_HIGHMEM
  btrfs: rename and document compression workspace members
  btrfs: preallocate compression workspaces
  btrfs: make find_workspace always succeed
  btrfs: make find_workspace warn if there are no workspaces
  btrfs: build fixup for qgroup_account_snapshot
  Merge branch 'misc-4.7' into for-chris-4.7-20160516
  Merge branch 'cleanups-4.7' into for-chris-4.7-20160516
  Merge branch 'foreign/anand/dev-del-by-id-ext' into for-chris-4.7-20160516
  Merge branch 'foreign/jeffm/uapi' into for-chris-4.7-20160516

Geert Uytterhoeven (1):
  Btrfs: Refactor