[PATCH] tools/lib/traceevent, perf tools: Handle %pU format correctly

2019-10-15 Thread Qu Wenruo
[BUG] For btrfs related events, there is a field for fsid, but perf never parse it correctly. # perf trace -e btrfS:qgroup_meta_convert xfs_io -f -c "pwrite 0 4k" \ /mnt/btrfs/file1 0.000 xfs_io/77915 btrfs:qgroup_meta_reserve:(nil)U: refroot=5(FS_TREE) type=0x0 diff=2

Re: bad tree block start, want #### have 0

2019-10-15 Thread Qu Wenruo
On 2019/10/16 上午3:03, DrYak wrote: > Hello > > I'm having trouble on a BTRFS file system that I use on a Raspberry Pi. > I can still mount and access (nearly all) my data. > > The trouble origin itself is probably hardware (flacky USB3-to-mSATA > adapter and/or power stability), not necessarily

Re: kernel 5.2 read time tree block corruption

2019-10-15 Thread Qu Wenruo
On 2019/10/16 上午1:55, José Luis wrote: > I also noticed the craziness of the previous dump. I cannot remember > the kernel running by this date but I use to install the latest stable > kernel on the Manjaro repositories (I'm an early adopter :P). > According the Manjaro forum release news they ro

Re: [PATCH 24/34] btrfs: Use CONFIG_PREEMPTION

2019-10-15 Thread David Sterba
On Tue, Oct 15, 2019 at 09:18:11PM +0200, Sebastian Andrzej Siewior wrote: > From: Thomas Gleixner > > CONFIG_PREEMPTION is selected by CONFIG_PREEMPT and by CONFIG_PREEMPT_RT. > Both PREEMPT and PREEMPT_RT require the same functionality which today > depends on CONFIG_PREEMPT. > > Switch the bt

Re: [PATCH 03/19] btrfs: keep track of which extents have been discarded

2019-10-15 Thread Dennis Zhou
On Tue, Oct 15, 2019 at 02:17:55PM +0200, David Sterba wrote: > On Mon, Oct 07, 2019 at 04:17:34PM -0400, Dennis Zhou wrote: > > @@ -2165,6 +2173,7 @@ static bool try_merge_free_space(struct > > btrfs_free_space_ctl *ctl, > > bool merged = false; > > u64 offset = info->offset; > > u64

Re: [PATCH 05/19] btrfs: add the beginning of async discard, discard workqueue

2019-10-15 Thread Dennis Zhou
On Tue, Oct 15, 2019 at 02:49:19PM +0200, David Sterba wrote: > On Mon, Oct 07, 2019 at 04:17:36PM -0400, Dennis Zhou wrote: > > --- a/fs/btrfs/block-group.h > > +++ b/fs/btrfs/block-group.h > > @@ -115,7 +115,11 @@ struct btrfs_block_group_cache { > > /* For read-only block groups */ > > s

[PATCH 24/34] btrfs: Use CONFIG_PREEMPTION

2019-10-15 Thread Sebastian Andrzej Siewior
From: Thomas Gleixner CONFIG_PREEMPTION is selected by CONFIG_PREEMPT and by CONFIG_PREEMPT_RT. Both PREEMPT and PREEMPT_RT require the same functionality which today depends on CONFIG_PREEMPT. Switch the btrfs_device_set_…() macro over to use CONFIG_PREEMPTION. Cc: Chris Mason Cc: Josef Bacik

bad tree block start, want #### have 0

2019-10-15 Thread DrYak
Hello I'm having trouble on a BTRFS file system that I use on a Raspberry Pi. I can still mount and access (nearly all) my data. The trouble origin itself is probably hardware (flacky USB3-to-mSATA adapter and/or power stability), not necessarily a bug in BTRFS. As I've said I can retreive nearl

[RFC PATCH v2 1/5] fs: add O_ENCODED open flag

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval The upcoming RWF_ENCODED operation introduces some security concerns: 1. Compressed writes will pass arbitrary data to decompression algorithms in the kernel. 2. Compressed reads can leak truncated/hole punched data. Therefore, we need to require privilege for RWF_ENCODED

[RFC PATCH v2 0/5] fs: interface for directly reading/writing compressed data

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval Hello, This series adds an API for reading compressed data on a filesystem without decompressing it as well as support for writing compressed data directly to the filesystem. It is based on my previous series which added a Btrfs-specific ioctl [1], but it is now an extension

[RFC PATCH v2 5/5] btrfs: implement RWF_ENCODED writes

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval The implementation resembles direct I/O: we have to flush any ordered extents, invalidate the page cache, and do the io tree/delalloc/extent map/ordered extent dance. From there, we can reuse the compression code with a minor modification to distinguish the write from writebac

[RFC PATCH v2 4/5] btrfs: implement RWF_ENCODED reads

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval There are 4 main cases: 1. Inline extents: we copy the data straight out of the extent buffer. 2. Hole/preallocated extents: we indicate the size of the extent starting from the read position; we don't need to copy zeroes. 3. Regular, uncompressed extents: we read the sect

[PATCH man-pages] Document encoded I/O

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval This adds a new page, rwf_encoded(7), providing an overview of encoded I/O and updates fcntl(2), open(2), and preadv2(2)/pwritev2(2) to reference it. Signed-off-by: Omar Sandoval --- man2/fcntl.2 | 10 +- man2/open.2| 13 ++ man2/readv.2 | 46 +++

[RFC PATCH v2 3/5] btrfs: generalize btrfs_lookup_bio_sums_dio()

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval This isn't actually dio-specific; it just looks up the csums starting at the given offset instead of using the page index. Rename it to btrfs_lookup_bio_sums_at_offset() and add the dst parameter. We might even want to expose __btrfs_lookup_bio_sums() as the public API instead

[RFC PATCH v2 2/5] fs: add RWF_ENCODED for reading/writing compressed data

2019-10-15 Thread Omar Sandoval
From: Omar Sandoval Btrfs supports transparent compression: data written by the user can be compressed when written to disk and decompressed when read back. However, we'd like to add an interface to write pre-compressed data directly to the filesystem, and the matching interface to read compresse

Re: [PATCH 08/19] btrfs: track discardable extents for asnyc discard

2019-10-15 Thread Dennis Zhou
On Tue, Oct 15, 2019 at 03:12:17PM +0200, David Sterba wrote: > On Mon, Oct 07, 2019 at 04:17:39PM -0400, Dennis Zhou wrote: > > The number of discardable extents will serve as the rate limiting metric > > for how often we should discard. This keeps track of discardable extents > > in the free spac

Re: [PATCH 01/19] bitmap: genericize percpu bitmap region iterators

2019-10-15 Thread Dennis Zhou
On Tue, Oct 15, 2019 at 02:11:02PM +0200, David Sterba wrote: > On Mon, Oct 07, 2019 at 06:24:19PM -0400, Dennis Zhou wrote: > > > > + * Bitmap region iterators. Iterates over the bitmap between [@start, > > > > @end). > > > > > > Gonna be that guy here, should be '[@start, @end]' > > > > I dis

potential data race on `delayed_rsv->full`

2019-10-15 Thread Meng Xu
Hi Btrfs maintainers, I am reporting a potential data race around the `delayed_rsv->full` field. [thread 1] mount a btrfs image, a kernel thread of uuid_rescan will be created btrfs_uuid_rescan_kthread btrfs_end_transaction __btrfs_end_transaction btrfs_trans_release_metadata

Re: [PATCH 1/2] btrfs: check page->mapping when loading free space cache

2019-10-15 Thread David Sterba
On Tue, Sep 24, 2019 at 04:50:43PM -0400, Josef Bacik wrote: > While testing 5.2 we ran into the following panic > > [52238.017028] BUG: kernel NULL pointer dereference, address: 0001 > [52238.105608] RIP: 0010:drop_buffers+0x3d/0x150 > [52238.304051] Call Trace: > [52238.308958] try_

Re: kernel 5.2 read time tree block corruption

2019-10-15 Thread José Luis
I also noticed the craziness of the previous dump. I cannot remember the kernel running by this date but I use to install the latest stable kernel on the Manjaro repositories (I'm an early adopter :P). According the Manjaro forum release news they roll up version 4.19 by these days so probably I wa

[PATCH 2/2] btrfs-progs: tests: Test backup root retention logic

2019-10-15 Thread Nikolay Borisov
This tests ensures that the kernel correctly persists backup roots in case the filesystem has been mounted from a backup root. Signed-off-by: Nikolay Borisov --- .../misc-tests/038-backup-root-corruption/test.sh | 50 ++ 1 file changed, 50 insertions(+) create mode 100755 t

[PATCH 0/2] Support patches for btrfs backup root rework

2019-10-15 Thread Nikolay Borisov
Here are two patches which I cooked up while working on the kernel side of backup root retention code. The first one fixes '-m -f generation' options to btrfs-corrupt-block, allowing me to simulate backup root corruption. The second patch is a test case which sanity checks the implementation.

[PATCH 1/2] btrfs-progs: corrupt-block: Refactor tree block corruption code

2019-10-15 Thread Nikolay Borisov
As progs' transaction/CoW logic evolved over the years the metadata block corruption code failed to do so. It's currently impossible to corrupt the generation because the CoW logic will not only set it to the value of the currently running transaction (__btrfs_cow_block) but the current code will A

[PATCH 4/8] btrfs: Factor out tree roots initialization during mount

2019-10-15 Thread Nikolay Borisov
The code responsible for reading and initilizing tree roots is scattered in open_ctree among 2 labels, emulating a loop. This is rather confusing to reason about. Instead, factor the code in a new function, init_tree_roots which implements the same logical flow. There are a couple of notable diffe

[PATCH 5/8] btrfs: Don't use objectid_mutex during mount

2019-10-15 Thread Nikolay Borisov
Since the filesystem is not well formed and no trees are loaded it's pointless holding the objectid_mutex. Just remove its usage. --- fs/btrfs/disk-io.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index a82e3acca765..418619dfb7

[PATCH 6/8] btrfs: Remove unused next_root_backup function

2019-10-15 Thread Nikolay Borisov
This function is no longer used so just remove it --- fs/btrfs/disk-io.c | 50 -- 1 file changed, 50 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 418619dfb76c..bcb21a35d30c 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-i

[PATCH 3/8] btrfs: Add read_backup_root

2019-10-15 Thread Nikolay Borisov
This function will replace next_root_backup with a much saner/cleaner interface. --- fs/btrfs/disk-io.c | 44 1 file changed, 44 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index d51f76abde45..9ed3b40aa10d 100644 --- a/fs/btrfs/d

[PATCH 8/8] btrfs: Streamline btrfs_fs_info::backup_root_index semantics

2019-10-15 Thread Nikolay Borisov
The backup_root_index member stores the index at which the backup root should be saved upon next transaction commit. However, there is a small deviation from this behavior in the form of a check in backup_super_roots which checks if current root generation equals to the generation of the previous

[PATCH 7/8] btrfs: Rename find_oldest_super_backup to init_backup_root_slot

2019-10-15 Thread Nikolay Borisov
The old name name was an awful misnomer because it didn't really find the oldest super backup per se but rather its slot. For example if we have: slot0: gen - 2 slot1: gen - 1 slot2: gen slot3: empty init_backup_root_slot will return slot3 and not slot0. The new name is more appropriate since th

[PATCH 0/8] tree reading cleanups in mount

2019-10-15 Thread Nikolay Borisov
Hello, Here is the second version of the tree reading code which gets executed during mount. This goes a bit further than the previous posting in that it not only introduces a new function but also refactors the code which decides which backup root to use. Overall I think the semantics are now

[PATCH 2/8] btrfs: Remove newest_gen argument from find_oldest_super_backup

2019-10-15 Thread Nikolay Borisov
It's no longer needed following cleanups around find_newest_backup_root --- fs/btrfs/disk-io.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 8b1f6385023d..d51f76abde45 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c

[PATCH 1/8] btrfs: Cleanup and simplify find_newest_super_backup

2019-10-15 Thread Nikolay Borisov
Backup roots are always written in a circular manner. By definition we can only ever have 1 backup root whose generation equals to that of the superblock. Hence, the 'if' in the for loop will trigger at most once. This is sufficient to return the newest backup root. Furthermore thew newest_gen par

Re: [PATCH 15/19] btrfs: load block_groups into discard_list on mount

2019-10-15 Thread Dennis Zhou
On Tue, Oct 15, 2019 at 01:38:25AM +0200, David Sterba wrote: > On Mon, Oct 14, 2019 at 04:17:46PM -0400, Dennis Zhou wrote: > > On Thu, Oct 10, 2019 at 01:11:38PM -0400, Josef Bacik wrote: > > > On Mon, Oct 07, 2019 at 04:17:46PM -0400, Dennis Zhou wrote: > > > > Async discard doesn't remember the

Re: [RFC PATCH 00/19] btrfs: async discard support

2019-10-15 Thread Dennis Zhou
On Tue, Oct 15, 2019 at 02:08:31PM +0200, David Sterba wrote: > Hi, > > thanks for working on this. The plain -odiscard hasn't been recommended > to users for a long time, even with the SATA 3.1 drives that allow > queueing the requests. > > The overall approach to async discard sounds good, the

Re: [PATCH] btrfs: qgroup: Always free PREALLOC META reserve in btrfs_delalloc_release_extents()

2019-10-15 Thread David Sterba
On Mon, Oct 14, 2019 at 02:34:51PM +0800, Qu Wenruo wrote: > [Background] > Btrfs qgroup uses two types of reserved space for METADATA space, > PERTRANS and PREALLOC. > > PERTRANS is metadata space reserved for each transaction started by > btrfs_start_transaction(). > While PREALLOC is for delall

Re: kernel 5.2 read time tree block corruption

2019-10-15 Thread Qu Wenruo
On 2019/10/15 下午11:03, José Luis wrote: > Thanks for fast response Qu. > > I booted into a pendrive live system for the test cause I'm using the > involving fylesystem with kernel 4.19. This time when I mount >> [manjaro@manjaro ~]$ sudo mount /dev/sdb2 /mnt >> mount: /mnt: no se puede leer el s

Re: [PATCH 08/19] btrfs: track discardable extents for asnyc discard

2019-10-15 Thread David Sterba
On Mon, Oct 07, 2019 at 04:17:39PM -0400, Dennis Zhou wrote: > The number of discardable extents will serve as the rate limiting metric > for how often we should discard. This keeps track of discardable extents > in the free space caches by maintaining deltas and propagating them to > the global co

Re: kernel 5.2 read time tree block corruption

2019-10-15 Thread José Luis
Thanks for fast response Qu. I booted into a pendrive live system for the test cause I'm using the involving fylesystem with kernel 4.19. This time when I mount >[manjaro@manjaro ~]$ sudo mount /dev/sdb2 /mnt >mount: /mnt: no se puede leer el superbloque en /dev/sdb2. and in the dmesg: [ +30,86647

Re: [PATCH 05/19] btrfs: add the beginning of async discard, discard workqueue

2019-10-15 Thread David Sterba
On Mon, Oct 07, 2019 at 04:17:36PM -0400, Dennis Zhou wrote: > --- a/fs/btrfs/block-group.h > +++ b/fs/btrfs/block-group.h > @@ -115,7 +115,11 @@ struct btrfs_block_group_cache { > /* For read-only block groups */ > struct list_head ro_list; > > + /* For discard operations */ >

Re: kernel 5.2 read time tree block corruption

2019-10-15 Thread Qu Wenruo
On 2019/10/15 下午8:24, Qu Wenruo wrote: > > > On 2019/10/15 下午6:15, José Luis wrote: >> Dear devs, >> >> I cannot use kernel >= 5.2, They cannot mount sdb2 nor sb3 both btrfs >> filesystems. I can work as intended on 4.19 which is an LTS version, >> previously using 5.1 but Manjaro removed it fr

Re: kernel 5.2 read time tree block corruption

2019-10-15 Thread Qu Wenruo
On 2019/10/15 下午6:15, José Luis wrote: > Dear devs, > > I cannot use kernel >= 5.2, They cannot mount sdb2 nor sb3 both btrfs > filesystems. I can work as intended on 4.19 which is an LTS version, > previously using 5.1 but Manjaro removed it from their repositories. > > More info: > · dmesg: >

Re: [PATCH 04/19] btrfs: keep track of cleanliness of the bitmap

2019-10-15 Thread David Sterba
On Mon, Oct 07, 2019 at 04:17:35PM -0400, Dennis Zhou wrote: > --- a/fs/btrfs/free-space-cache.h > +++ b/fs/btrfs/free-space-cache.h > @@ -7,6 +7,7 @@ > #define BTRFS_FREE_SPACE_CACHE_H > > #define BTRFS_FSC_TRIMMED(1UL << 0) > +#define BTRFS_FSC_TRIMMING_BITMAP(1UL << 1) > >

Re: [PATCH 03/19] btrfs: keep track of which extents have been discarded

2019-10-15 Thread David Sterba
On Mon, Oct 07, 2019 at 04:17:34PM -0400, Dennis Zhou wrote: > @@ -2165,6 +2173,7 @@ static bool try_merge_free_space(struct > btrfs_free_space_ctl *ctl, > bool merged = false; > u64 offset = info->offset; > u64 bytes = info->bytes; > + bool is_trimmed = btrfs_free_space_trim

[RFC PATCH 2/2] btrfs: rename btrfs_parse_device_options back to btrfs_parse_early_options

2019-10-15 Thread Johannes Thumshirn
As btrfs_parse_device_options() now doesn't only parse the -o device mount option but -o auth_key as well, it makes sense to rename it back to btrfs_parse_early_options(). This reverts commit fa59f27c8c35bbe00af8eff23de446a7f4b048b0. Signed-off-by: Johannes Thumshirn --- fs/btrfs/super.c | 11 +

[RFC PATCH 1/2] btrfs: add authentication support

2019-10-15 Thread Johannes Thumshirn
Add authentication support for a BTRFS file-system. This works, because in BTRFS every meta-data block as well as every data-block has a own checksum. For meta-data the checksum is in the meta-data node itself. For data blocks, the checksums are stored in the checksum tree. When replacing the che

Re: [PATCH 01/19] bitmap: genericize percpu bitmap region iterators

2019-10-15 Thread David Sterba
On Mon, Oct 07, 2019 at 06:24:19PM -0400, Dennis Zhou wrote: > > > + * Bitmap region iterators. Iterates over the bitmap between [@start, > > > @end). > > > > Gonna be that guy here, should be '[@start, @end]' > > I disagree here. I'm pretty happy with [@start, @end). If btrfs wants to > carry

Re: [RFC PATCH 00/19] btrfs: async discard support

2019-10-15 Thread David Sterba
Hi, thanks for working on this. The plain -odiscard hasn't been recommended to users for a long time, even with the SATA 3.1 drives that allow queueing the requests. The overall approach to async discard sounds good, the hard part is not shoot down the filesystem by trimming live data, and we had

kernel 5.2 read time tree block corruption

2019-10-15 Thread José Luis
Dear devs, I cannot use kernel >= 5.2, They cannot mount sdb2 nor sb3 both btrfs filesystems. I can work as intended on 4.19 which is an LTS version, previously using 5.1 but Manjaro removed it from their repositories. More info: · dmesg: > [oct15 13:47] BTRFS info (device sdb2): disk space cachi

Re: [PATCH] btrfs: qgroup: Always free PREALLOC META reserve in btrfs_delalloc_release_extents()

2019-10-15 Thread Filipe Manana
On Mon, Oct 14, 2019 at 7:36 AM Qu Wenruo wrote: > > [Background] > Btrfs qgroup uses two types of reserved space for METADATA space, > PERTRANS and PREALLOC. > > PERTRANS is metadata space reserved for each transaction started by > btrfs_start_transaction(). > While PREALLOC is for delalloc, wher

[PATCH] Btrfs: fix qgroup double free after failure to reserve metadata for delalloc

2019-10-15 Thread fdmanana
From: Filipe Manana If we fail to reserve metadata for delalloc operations we end up releasing the previously reserved qgroup amount twice, once explicitly under the 'out_qgroup' label by calling btrfs_qgroup_free_meta_prealloc() and once again, under label 'out_fail', by calling btrfs_inode_rsv_