[PATCH] btrfs-progs: restore: fix off-by-one len check

2015-10-08 Thread Vincent Stehlé
Fix a check of len versus PATH_MAX in function copy_symlink(), to account for the terminating null byte. Resolves-Coverity-CID: 1296749 Signed-off-by: Vincent Stehlé --- cmds-restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

Re: [PATCH] btrfs: test unmount during quota rescan

2015-10-08 Thread Filipe Manana
On Wed, Oct 7, 2015 at 4:08 PM, Justin Maggard wrote: > This test case tests if we are able to unmount a filesystem while > a quota rescan is running. Up to now (4.3-rc4) this would result > in a kernel NULL pointer dereference. Please mention here the title of the patch

Re: BTRFS RAID1 behavior after one drive temporal disconection

2015-10-08 Thread Pavel Pisa
Hello everybody, On Monday 05 of October 2015 22:26:46 Pavel Pisa wrote: > Hello everybody, ... > BTRFS has recognized appearance of its partition (even that hanged > from sdb5 to sde5 when disk "hotplugged" again). > But it seems that RAID1 components are not in sync and BTRFS > continues to

Re: Using BtrFS and backup tools for keeping two systems in sync

2015-10-08 Thread Hugo Mills
On Thu, Oct 08, 2015 at 08:05:09AM +0530, Shriramana Sharma wrote: > Hello. I see there are some backup tools taking advantage of BtrFS's > incremental send/receive feature: > https://btrfs.wiki.kernel.org/index.php/Incremental_Backup. [BTW Ames > Cornish's ButterSink

Re: [PATCH v2] btrfs: qgroup: exit the rescan worker during umount

2015-10-08 Thread Filipe Manana
On Thu, Sep 3, 2015 at 2:05 AM, Justin Maggard wrote: > v2: Fix stupid error while making formatting changes... > > I was hitting a consistent NULL pointer dereference during shutdown that > showed the trace running through end_workqueue_bio(). I traced it back to > the

[PATCH] btrfs: cleanup iterating over prop_handlers array

2015-10-08 Thread Byongho Lee
This patch eliminates the last item of prop_handlers array which is used to check end of array and instead uses ARRAY_SIZE macro. Though this is a very tiny optimization, using ARRAY_SIZE macro is a good practice to iterate array. Signed-off-by: Byongho Lee ---

Re: BTRFS RAID1 behavior after one drive temporal disconection

2015-10-08 Thread Austin S Hemmelgarn
On 2015-10-08 04:28, Pavel Pisa wrote: Hello everybody, On Monday 05 of October 2015 22:26:46 Pavel Pisa wrote: Hello everybody, ... BTRFS has recognized appearance of its partition (even that hanged from sdb5 to sde5 when disk "hotplugged" again). But it seems that RAID1 components are not

[PATCH v4 1/3] btrfs: Fix lost-data-profile caused by auto removing bg

2015-10-08 Thread Zhao Lei
Reproduce: (In integration-4.3 branch) TEST_DEV=(/dev/vdg /dev/vdh) TEST_DIR=/mnt/tmp umount "$TEST_DEV" >/dev/null mkfs.btrfs -f -d raid1 "${TEST_DEV[@]}" mount -o nospace_cache "$TEST_DEV" "$TEST_DIR" umount "$TEST_DEV" mount -o nospace_cache "$TEST_DEV" "$TEST_DIR" btrfs filesystem

[PATCH v4 2/3] btrfs: Fix lost-data-profile caused by balance bg

2015-10-08 Thread Zhao Lei
Reproduce: (In integration-4.3 branch) TEST_DEV=(/dev/vdg /dev/vdh) TEST_DIR=/mnt/tmp umount "$TEST_DEV" >/dev/null mkfs.btrfs -f -d raid1 "${TEST_DEV[@]}" mount -o nospace_cache "$TEST_DEV" "$TEST_DIR" btrfs balance start -dusage=0 $TEST_DIR btrfs filesystem usage $TEST_DIR dd

[PATCH v4 3/3] btrfs: Use fs_info directly in btrfs_delete_unused_bgs

2015-10-08 Thread Zhao Lei
No need to use root->fs_info in btrfs_delete_unused_bgs(), use fs_info directly instead. Signed-off-by: Zhao Lei --- fs/btrfs/extent-tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index

Re: Using BtrFS and backup tools for keeping two systems in sync

2015-10-08 Thread Austin S Hemmelgarn
On 2015-10-07 22:35, Shriramana Sharma wrote: Hello. I see there are some backup tools taking advantage of BtrFS's incremental send/receive feature: https://btrfs.wiki.kernel.org/index.php/Incremental_Backup. [BTW Ames Cornish's ButterSink (https://github.com/AmesCornish/buttersink) seems to be

Re: [PATCH 03/12] generic/80[0-2]: support xfs in addition to btrfs

2015-10-08 Thread Ari Sundholm
On Wed, 2015-10-07 at 05:13 +, Darrick J. Wong wrote: > Modify the reflink tests to support xfs. > > Signed-off-by: Darrick J. Wong > --- > common/rc | 37 + > tests/generic/800 |2 +- > tests/generic/801 |2 +- >

Re: [PATCH] btrfs: cleanup iterating over prop_handlers array

2015-10-08 Thread David Sterba
On Thu, Oct 08, 2015 at 08:49:34PM +0900, Byongho Lee wrote: > This patch eliminates the last item of prop_handlers array which is used > to check end of array and instead uses ARRAY_SIZE macro. > Though this is a very tiny optimization, using ARRAY_SIZE macro is a > good practice to iterate

Re: [PATCH] btrfs-progs: restore: fix off-by-one len check

2015-10-08 Thread David Sterba
On Thu, Oct 08, 2015 at 10:47:09AM +0200, Vincent Stehlé wrote: > Fix a check of len versus PATH_MAX in function copy_symlink(), to > account for the terminating null byte. > > Resolves-Coverity-CID: 1296749 > Signed-off-by: Vincent Stehlé Applied, thanks. -- To

[PATCH] Btrfs-progs: Do not force mixed block group creation unless '-M' option is specified

2015-10-08 Thread Chandan Rajendra
When creating small Btrfs filesystem instances (i.e. filesystem size <= 1GiB), mkfs.btrfs fails if both sectorsize and nodesize are specified on the command line and sectorsize != nodesize, since mixed block groups involves both data and metadata blocks sharing the same block group. This is an

Re: BTRFS RAID1 behavior after one drive temporal disconection

2015-10-08 Thread Pavel Pisa
Hello Austin, thanks for reply. On Thursday 08 of October 2015 13:47:33 Austin S Hemmelgarn wrote: > On 2015-10-08 04:28, Pavel Pisa wrote: > > Hello everybody, ... > > It seems that SATA controller is not able to activate link which > > has not been connected at BIOS POST time. This means that

Re: BTRFS RAID1 behavior after one drive temporal disconection

2015-10-08 Thread Pavel Pisa
Hello Hugo, On Thursday 08 of October 2015 23:13:52 Hugo Mills wrote: > On Thu, Oct 08, 2015 at 07:47:33AM -0400, Austin S Hemmelgarn wrote: > > On 2015-10-08 04:28, Pavel Pisa wrote: > > >I go to use "btrfs replace" because there has not been any reply to my > > > inplace correction question.

Re: BTRFS RAID1 behavior after one drive temporal disconection

2015-10-08 Thread Hugo Mills
On Fri, Oct 09, 2015 at 12:16:43AM +0200, Pavel Pisa wrote: > Hello Hugo, > > On Thursday 08 of October 2015 23:13:52 Hugo Mills wrote: > > On Thu, Oct 08, 2015 at 07:47:33AM -0400, Austin S Hemmelgarn wrote: > > > On 2015-10-08 04:28, Pavel Pisa wrote: > > > >I go to use "btrfs replace" because

Re: [PATCH] btrfs: test unmount during quota rescan

2015-10-08 Thread Dave Chinner
On Thu, Oct 08, 2015 at 10:39:48AM +0100, Filipe Manana wrote: > On Wed, Oct 7, 2015 at 4:08 PM, Justin Maggard wrote: > > This test case tests if we are able to unmount a filesystem while > > a quota rescan is running. Up to now (4.3-rc4) this would result > > in a kernel

Re: BTRFS RAID1 behavior after one drive temporal disconection

2015-10-08 Thread Hugo Mills
On Thu, Oct 08, 2015 at 07:47:33AM -0400, Austin S Hemmelgarn wrote: > On 2015-10-08 04:28, Pavel Pisa wrote: > >I go to use "btrfs replace" because there has not been any reply to my > >inplace correction > >question. But I expect that clarification if possible/how to resync RAID1 > >after one

Re: Using BtrFS and backup tools for keeping two systems in sync

2015-10-08 Thread Duncan
Hugo Mills posted on Thu, 08 Oct 2015 06:37:45 + as excerpted: > On Thu, Oct 08, 2015 at 08:05:09AM +0530, Shriramana Sharma wrote: >> Hello. I see there are some backup tools taking advantage of BtrFS's >> incremental send/receive feature: >>

[PATCH v2 21/23] btrfs: fallocate: Add support to accurate qgroup reserve

2015-10-08 Thread Qu Wenruo
Now fallocate will do accurate qgroup reserve space check, unlike old method, which will always reserve the whole length of the range. With this patch, fallocate will: 1) Iterate the desired range and mark in data rsv map Only range which is going to be allocated will be recorded in data

[PATCH v2 23/23] btrfs: qgroup: Avoid calling btrfs_free_reserved_data_space in clear_bit_hook

2015-10-08 Thread Qu Wenruo
In clear_bit_hook, qgroup reserved data is already handled quite well, either released by finish_ordered_io or invalidatepage. So calling btrfs_qgroup_free_data() here is completely meaningless, and since btrfs_qgroup_free_data() may sleep to allocate memory, it will cause lockdep warning. This

[PATCH v2 22/23] btrfs: Avoid truncate tailing page if fallocate range doesn't exceed inode size

2015-10-08 Thread Qu Wenruo
Current code will always truncate tailing page if its alloc_start is smaller than inode size. This behavior will cause a lot of unneeded COW page size extent. This patch will avoid such problem. Signed-off-by: Qu Wenruo --- v2: Newly introduced --- fs/btrfs/file.c |

[PATCH v2 20/23] btrfs: qgroup: Add new trace point for qgroup data reserve

2015-10-08 Thread Qu Wenruo
Now each qgroup reserve for data will has its ftrace event for better debugging. Signed-off-by: Qu Wenruo --- v2: Newly introduced --- fs/btrfs/qgroup.c| 15 +- fs/btrfs/qgroup.h| 8 +++ include/trace/events/btrfs.h | 113

[PATCH] btrfs: fix waitqueue_active without memory barrier in btrfs

2015-10-08 Thread Kosuke Tatsukawa
btrfs_bio_counter_sub() seems to be missing a memory barrier which might cause the waker to not notice the waiter and miss sending a wake_up as in the following figure. btrfs_bio_counter_sub btrfs_rm_dev_replace_blocked

[PATCH v2 19/23] btrfs: Add handler for invalidate page

2015-10-08 Thread Qu Wenruo
For btrfs_invalidatepage() and its variant evict_inode_truncate_page(), there will be pages don't reach disk. In that case, their reserved space won't be release nor freed by finish_ordered_io() nor delayed_ref handler. So we must free their qgroup reserved space, or we will leaking reserved

[PATCH v2 14/23] btrfs: extent-tree: Switch to new check_data_free_space and free_reserved_data_space

2015-10-08 Thread Qu Wenruo
Use new reserve/free for buffered write and inode cache. For buffered write case, as nodatacow write won't increase quota account, so unlike old behavior which does reserve before check nocow, now we check nocow first and then only reserve data if we can't do nocow write. Signed-off-by: Qu

[PATCH v2 15/23] btrfs: extent-tree: Add new version of btrfs_delalloc_reserve/release_space

2015-10-08 Thread Qu Wenruo
Add new version of btrfs_delalloc_reserve_space() and btrfs_delalloc_release_space() functions, which supports accurate qgroup reserve. Signed-off-by: Qu Wenruo --- v2: Add new function btrfs_delalloc_release_space() to handle error case. --- fs/btrfs/ctree.h |

[PATCH v2 10/23] btrfs: delayed_ref: release and free qgroup reserved at proper timing

2015-10-08 Thread Qu Wenruo
Qgroup reserved space needs to be released from inode dirty map and get freed at different timing: 1) Release when the metadata is written into tree After corresponding metadata is written into tree, any newer write will be COWed(don't include NOCOW case yet). So we must release its range from

[PATCH v2 16/23] btrfs: extent-tree: Switch to new delalloc space reserve and release

2015-10-08 Thread Qu Wenruo
Use new __btrfs_delalloc_reserve_space() and __btrfs_delalloc_release_space() to reserve and release space for delalloc. Signed-off-by: Qu Wenruo --- v2: Also use __btrfs_delalloc_release_space() function. --- fs/btrfs/file.c | 5 +++-- fs/btrfs/inode-map.c | 6

[PATCH v2 01/23] btrfs: qgroup: New function declaration for new reserve implement

2015-10-08 Thread Qu Wenruo
Add new structures and functions for new qgroup reserve implement dirty phase. Which will focus on avoiding over-reserve as in that case, which means for already reserved dirty space range, we won't reserve space again. This patch adds the needed structure declaration and comments.

[PATCH v2 18/23] btrfs: qgroup: Add handler for NOCOW and inline

2015-10-08 Thread Qu Wenruo
For NOCOW and inline case, there will be no delayed_ref created for them, so we should free their reserved data space at proper time(finish_ordered_io for NOCOW and cow_file_inline for inline). Signed-off-by: Qu Wenruo --- fs/btrfs/extent-tree.c | 7 ++-

[PATCH v2 08/23] btrfs: qgroup: Introduce function to release/free reserved data range

2015-10-08 Thread Qu Wenruo
Introduce functions btrfs_qgroup_release/free_data() to release/free reserved data range. Release means, just remove the data range from data rsv map, but doesn't free the reserved space. This is for normal buffered write case, when data is written into disc and its metadata is added into tree,

[PATCH v2 09/23] btrfs: delayed_ref: Add new function to record reserved space into delayed ref

2015-10-08 Thread Qu Wenruo
Add new function btrfs_add_delayed_qgroup_reserve() function to record how much space is reserved for that extent. As btrfs only accounts qgroup at run_delayed_refs() time, so newly allocated extent should keep the reserved space until then. So add needed function with related members to do it.

[PATCH v2 06/23] btrfs: qgroup: Introduce btrfs_qgroup_reserve_data function

2015-10-08 Thread Qu Wenruo
This new function will do all the hard work to reserve precious space for a write. The overall work flow will be the following. File A already has some dirty pages: 0 4K 8K 12K 16K |///| |///| And then, someone want to write some data into range [4K, 16K).

[PATCH v2 07/23] btrfs: qgroup: Introduce function to release reserved range

2015-10-08 Thread Qu Wenruo
Introduce new function release_data_range() to release reserved ranges. It will iterate through all existing ranges and remove/shrink them. Note this function will not free reserved space, as the range can be released in the following conditions: 1) The dirty range gets written to disk. In

[PATCH v2 02/23] btrfs: qgroup: Implement data_rsv_map init/free functions

2015-10-08 Thread Qu Wenruo
New functions btrfs_qgroup_init/free_data_rsv_map() to init/free data reserve map. Data reserve map is used to mark which range already holds reserved space, to avoid current reserved space leak. Signed-off-by: Qu Wenruo --- v2: Add reserved space leaking check at

[PATCH v2 00/23] Rework btrfs qgroup reserved space framework

2015-10-08 Thread Qu Wenruo
In previous rework of qgroup, we succeeded in fixing qgroup accounting part, making the rfer/excl numbers accurate. But that's just part of qgroup work, another part of qgroup still has quite a lot problem, that's qgroup reserve space part which will lead to EQUOT even we are far from the limit.

[PATCH v2 17/23] btrfs: qgroup: Cleanup old inaccurate facilities

2015-10-08 Thread Qu Wenruo
Cleanup the old facilities which use old btrfs_qgroup_reserve() function call, replace them with the newer version, and remove the "__" prefix in them. Also, make btrfs_qgroup_reserve/free() functions private, as they are now only used inside qgroup codes. Now, the whole btrfs qgroup is swithed

[PATCH v2 05/23] btrfs: qgroup: Introduce function to reserve data range per inode

2015-10-08 Thread Qu Wenruo
Introduce new function reserve_data_range(). This function will find non-overlap range and to insert it into reserve map using previously introduced functions. This provides the basis for later per inode reserve map implement. Signed-off-by: Qu Wenruo --- v2: Add

[PATCH v2 03/23] btrfs: qgroup: Introduce new function to search most left reserve range

2015-10-08 Thread Qu Wenruo
Introduce the new function to search the most left reserve range in a reserve map. It provides the basis for later reserve map implement. Signed-off-by: Qu Wenruo --- fs/btrfs/qgroup.c | 36 1 file changed, 36 insertions(+) diff

[PATCH v2 04/23] btrfs: qgroup: Introduce function to insert non-overlap reserve range

2015-10-08 Thread Qu Wenruo
New function insert_data_ranges() will insert non-overlap reserve ranges into reserve map. It provides the basis for later qgroup reserve map implement. Signed-off-by: Qu Wenruo --- v2: Fix comment typo --- fs/btrfs/qgroup.c | 124

[PATCH v2 11/23] btrfs: qgroup: Introduce new functions to reserve/free metadata

2015-10-08 Thread Qu Wenruo
Introduce new functions btrfs_qgroup_reserve/free_meta() to reserve/free metadata reserved space. Signed-off-by: Qu Wenruo --- fs/btrfs/ctree.h | 3 +++ fs/btrfs/disk-io.c | 1 + fs/btrfs/qgroup.c | 40 fs/btrfs/qgroup.h |

[PATCH v2 13/23] btrfs: extent-tree: Add new version of btrfs_check_data_free_space and btrfs_free_reserved_data_space.

2015-10-08 Thread Qu Wenruo
Add new functions __btrfs_check_data_free_space() and __btrfs_free_reserved_data_space() to work with new accurate qgroup reserved space framework. The new function will replace old btrfs_check_data_free_space() and btrfs_free_reserved_data_space() respectively, but until all the change is done,

[PATCH v2 12/23] btrfs: qgroup: Use new metadata reservation.

2015-10-08 Thread Qu Wenruo
As we have the new metadata reservation functions, use them to replace the old btrfs_qgroup_reserve() call for metadata. Signed-off-by: Qu Wenruo --- fs/btrfs/extent-tree.c | 14 ++ fs/btrfs/transaction.c | 34 ++

Re: [PATCH v2 00/23] Rework btrfs qgroup reserved space framework

2015-10-08 Thread Qu Wenruo
Josef Bacik wrote on 2015/10/08 21:36 -0700: On 10/08/2015 07:11 PM, Qu Wenruo wrote: In previous rework of qgroup, we succeeded in fixing qgroup accounting part, making the rfer/excl numbers accurate. But that's just part of qgroup work, another part of qgroup still has quite a lot problem,

Re: [PATCH v2 00/23] Rework btrfs qgroup reserved space framework

2015-10-08 Thread Josef Bacik
On 10/08/2015 07:11 PM, Qu Wenruo wrote: In previous rework of qgroup, we succeeded in fixing qgroup accounting part, making the rfer/excl numbers accurate. But that's just part of qgroup work, another part of qgroup still has quite a lot problem, that's qgroup reserve space part which will

Re: [PATCH] btrfs: fix waitqueue_active without memory barrier in btrfs

2015-10-08 Thread Kosuke Tatsukawa
Josef Bacik wrote: > On 10/08/2015 05:35 PM, Kosuke Tatsukawa wrote: >> btrfs_bio_counter_sub() seems to be missing a memory barrier which might >> cause the waker to not notice the waiter and miss sending a wake_up as >> in the following figure. >> >> btrfs_bio_counter_sub