[PATCH v12.2 13/15] btrfs: improve inode's outstanding_extents computation

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang This issue was revealed by modifying BTRFS_MAX_EXTENT_SIZE(128MB) to 64KB, When modifying BTRFS_MAX_EXTENT_SIZE(128MB) to 64KB, fsstress test often gets these warnings from btrfs_destroy_inode(): WARN_ON(BTRFS_I(inode)->outstanding_extents); WARN_ON(BTRFS_I(in

[PATCH v12.2 05/15] btrfs: dedupe: Introduce function to remove hash from in-memory tree

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Introduce static function inmem_del() to remove hash from in-memory dedupe tree. And implement btrfs_dedupe_del() and btrfs_dedup_disable() interfaces. Also for btrfs_dedupe_disable(), add new functions to wait existing writer and block incoming writers to eliminate all poss

[PATCH v12.2 03/15] btrfs: dedupe: Introduce function to initialize dedupe info

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Add generic function to initialize dedupe info. Signed-off-by: Qu Wenruo Signed-off-by: Wang Xiaoguang Reviewed-by: Josef Bacik --- fs/btrfs/Makefile | 2 +- fs/btrfs/dedupe.c | 185 + fs/btrfs/dedupe.h

[PATCH v12.2 04/15] btrfs: dedupe: Introduce function to add hash into in-memory tree

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Introduce static function inmem_add() to add hash into in-memory tree. And now we can implement the btrfs_dedupe_add() interface. Signed-off-by: Qu Wenruo Signed-off-by: Wang Xiaoguang Reviewed-by: Josef Bacik --- fs/btrfs/dedupe.c | 151 +

[PATCH v12.2 08/15] btrfs: dedupe: Implement btrfs_dedupe_calc_hash interface

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Unlike in-memory or on-disk dedupe method, only SHA256 hash method is supported yet, so implement btrfs_dedupe_calc_hash() interface using SHA256. Signed-off-by: Qu Wenruo Signed-off-by: Wang Xiaoguang Reviewed-by: Josef Bacik --- fs/btrfs/dedupe.c | 46 +

[PATCH v12.2 02/15] btrfs: dedupe: Introduce dedupe framework and its header

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Introduce the header for btrfs in-band(write time) de-duplication framework and needed header. The new de-duplication framework is going to support 2 different dedupe methods and 1 dedupe hash. Signed-off-by: Qu Wenruo Signed-off-by: Wang Xiaoguang --- fs/btrfs/ctree.h

[PATCH v12.2 11/15] btrfs: dedupe: Add ioctl for inband dedupelication

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Add ioctl interface for inband dedupelication, which includes: 1) enable 2) disable 3) status And a pseudo RO compat flag, to imply that btrfs now supports inband dedup. However we don't add any ondisk format change, it's just a pseudo RO compat flag. All these ioctl interf

[PATCH v12.2 09/15] btrfs: ordered-extent: Add support for dedupe

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Add ordered-extent support for dedupe. Note, current ordered-extent support only supports non-compressed source extent. Support for compressed source extent will be added later. Signed-off-by: Qu Wenruo Signed-off-by: Wang Xiaoguang Reviewed-by: Josef Bacik --- fs/btrfs

[PATCH v12.2 07/15] btrfs: dedupe: Introduce function to search for an existing hash

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang Introduce static function inmem_search() to handle the job for in-memory hash tree. The trick is, we must ensure the delayed ref head is not being run at the time we search the for the hash. With inmem_search(), we can implement the btrfs_dedupe_search() interface. Signed-

[PATCH v12.2 01/15] btrfs: expand btrfs_set_extent_delalloc() and its friends to support in-band dedupe and subpage size patchset

2016-07-19 Thread Qu Wenruo
Extract btrfs_set_extent_delalloc() and extent_clear_unlock_delalloc() parameters for both in-band dedupe and subpage sector size patchset. This should reduce conflict of both patchset and the effort to rebase them. Cc: Chandan Rajendra Cc: David Sterba Signed-off-by: Qu Wenruo --- fs/btrfs/c

[PATCH v12.2 15/15] btrfs: dedupe: Introduce new reconfigure ioctl

2016-07-19 Thread Qu Wenruo
Introduce new reconfigure ioctl, and new FORCE flag for in-band dedupe ioctls. Now dedupe enable and reconfigure ioctl are stateful. | Current state | Ioctl| Next state | | Disabled | enable

[PATCH v12.2 14/15] btrfs: dedupe: fix false ENOSPC

2016-07-19 Thread Qu Wenruo
From: Wang Xiaoguang When testing in-band dedupe, sometimes we got ENOSPC error, though fs still has much free space. After some debuging work, we found that it's btrfs_delalloc_reserve_metadata() which sometimes tries to reserve plenty of metadata space, even for very small data range. In btrfs

[PATCH v12.2 10/15] btrfs: dedupe: Inband in-memory only de-duplication implement

2016-07-19 Thread Qu Wenruo
Core implement for inband de-duplication. It reuse the async_cow_start() facility to do the calculate dedupe hash. And use dedupe hash to do inband de-duplication at extent level. The work flow is as below: 1) Run delalloc range for an inode 2) Calculate hash for the delalloc range at the unit of

[PATCH v12.2 00/15] Btrfs In-band De-duplication

2016-07-19 Thread Qu Wenruo
This patchset can be fetched from github: https://github.com/adam900710/linux.git wang_dedupe_20160719 This version is just another small update, rebased to David's for-next-20160715 branch. (Which already includes the first rebase patch for cow_file_range) Added a small non-functional patch to c

[PATCH v12.2 12/15] btrfs: relocation: Enhance error handling to avoid BUG_ON

2016-07-19 Thread Qu Wenruo
Since the introduce of btrfs dedupe tree, it's possible that balance can race with dedupe disabling. When this happens, dedupe_enabled will make btrfs_get_fs_root() return PTR_ERR(-ENOENT). But due to a bug in error handling branch, when this happens backref_cache->nr_nodes is increased but the no

[PATCH v12.2 06/15] btrfs: delayed-ref: Add support for increasing data ref under spinlock

2016-07-19 Thread Qu Wenruo
For in-band dedupe, btrfs needs to increase data ref with delayed_ref locked, so add a new function btrfs_add_delayed_data_ref_lock() to increase extent ref with delayed_refs already locked. Signed-off-by: Qu Wenruo Reviewed-by: Josef Bacik --- fs/btrfs/delayed-ref.c | 30 ++

Re: A lot warnings in dmesg while running thunderbird

2016-07-19 Thread Chris Mason
On Mon, Jul 11, 2016 at 11:28:01AM +0530, Chandan Rajendra wrote: Hi Chris, I am able to reproduce the issue with the 'short-write' program. But before the call trace associated with btrfs_destroy_inode(), I see the following call trace ... [ cut here ] WARNING: CPU: 2 P

Re: [PATCH 0/3] Btrfs: fix free space tree bitmaps+tests on big-endian systems

2016-07-19 Thread Chandan Rajendra
On Monday, July 18, 2016 03:31:04 PM Omar Sandoval wrote: > On Mon, Jul 18, 2016 at 02:43:26PM -0400, Chris Mason wrote: > > > > > > On 07/17/2016 08:19 AM, Chandan Rajendra wrote: > > > On Friday, July 15, 2016 12:15:15 PM Omar Sandoval wrote: > > > > On Fri, Jul 15, 2016 at 12:34:10PM +0530, Ch

Re: [PATCH 0/3] Btrfs: fix free space tree bitmaps+tests on big-endian systems

2016-07-19 Thread Chris Mason
On 07/19/2016 12:06 PM, Chandan Rajendra wrote: On Monday, July 18, 2016 03:31:04 PM Omar Sandoval wrote: Yeah, this should definitely not work. It's possible that things are just silently failing and getting corrupted if the module isn't built with CONFIG_BTRFS_ASSERT, but btrfsck v4.6.1 + my p

[PATCH] Btrfs: fix memory leak of reloc_root

2016-07-19 Thread Liu Bo
When some critical errors occur and FS would be flipped into RO, if we have an on-going balance, we can end up with a memory leak of root->reloc_root since btrfs_drop_snapshots() bails out without freeing reloc_root at the very early start. However, we're not able to free reloc_root in btrfs_drop_

Re: A lot warnings in dmesg while running thunderbird

2016-07-19 Thread Gabriel C
On 19.07.2016 13:05, Chris Mason wrote: > On Mon, Jul 11, 2016 at 11:28:01AM +0530, Chandan Rajendra wrote: >> Hi Chris, >> >> I am able to reproduce the issue with the 'short-write' program. But before >> the call trace associated with btrfs_destroy_inode(), I see the following >> call >> trace

ENOSPC / no space on very large devices

2016-07-19 Thread Stefan Priebe - Profihost AG
Hi list, while i didn't had the problem for some month i'm now getting ENOSPC on a regular basis on one host. It would be great if someone can help me debugging this. Some basic informations: # touch /vmbackup/abc touch: cannot touch `/vmbackup/abc': No space left on device # df -h /vmbackup/ F

[PATCH 1/4] btrfs: use correct offset for reloc_inode in prealloc_file_extent_cluster()

2016-07-19 Thread Wang Xiaoguang
In prealloc_file_extent_cluster(), btrfs_check_data_free_space() uses wrong file offset for reloc_inode, it uses cluster->start and cluster->end, which indeed are extent's bytenr. The correct value should be cluster->[start|end] minus block group's start bytenr. start bytenr cluster->start |

[PATCH 2/4] btrfs: divide btrfs_update_reserved_bytes() into two functions

2016-07-19 Thread Wang Xiaoguang
This patch divides btrfs_update_reserved_bytes() into btrfs_add_reserved_bytes() and btrfs_free_reserved_bytes(), and next patch will extend btrfs_add_reserved_bytes()to fix some false ENOSPC error, please see later patch for detailed info. Signed-off-by: Wang Xiaoguang --- fs/btrfs/extent-tree.

[PATCH 3/4] btrfs: introduce new EXTENT_CLEAR_DATA_RESV flag

2016-07-19 Thread Wang Xiaoguang
In next patch, btrfs_clear_bit_hook() will not call btrfs_free_reserved_data_space_noquota() to update btrfs_space_info's bytes_may_use unless it has EXTENT_DO_ACCOUNTING or EXTENT_CLEAR_DATA_RESV, as for the reason, please see the next patch for detailed info. As we know, usually EXTENT_DO_ACCOUN

[PATCH 0/4] update bytes_may_use timely to avoid false ENOSPC issue

2016-07-19 Thread Wang Xiaoguang
Currently in btrfs, for data space reservation, it does not update bytes_may_use in btrfs_update_reserved_bytes() and the decrease operation will be delayed to be done in extent_clear_unlock_delalloc(), for fallocate(2), decrease operation is even delayed to be done in end of btrfs_fallocate(), whi

[PATCH 4/4] btrfs: update btrfs_space_info's bytes_may_use timely

2016-07-19 Thread Wang Xiaoguang
This patch can fix some false ENOSPC errors, below test script can reproduce one false ENOSPC error: #!/bin/bash dd if=/dev/zero of=fs.img bs=$((1024*1024)) count=128 dev=$(losetup --show -f fs.img) mkfs.btrfs -f -M $dev mkdir /tmp/mntpoint mount $dev

Re: ENOSPC / no space on very large devices

2016-07-19 Thread Wang Xiaoguang
hello, On 07/20/2016 01:31 PM, Stefan Priebe - Profihost AG wrote: Hi list, while i didn't had the problem for some month i'm now getting ENOSPC on a regular basis on one host. It would be great if someone can help me debugging this. Some basic informations: # touch /vmbackup/abc touch: canno