Re: [PATCH 12/17] btrfs: add boilerplate code for directly including the crypto framework

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Add boilerplate code for directly including the crypto framework. > > This helps us flipping the switch for new algorithms. > > Signed-off-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov > --- > fs/btrfs/ctree.h | 11 +++ >

Re: [PATCH 02/17] btrfs: resurrect btrfs_crc32c()

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Commit 9678c54388b6 ("btrfs: Remove custom crc32c init code") removed the > btrfs_crc32c() function, because it was a duplicate of the crc32c() library > function we already have in the kernel. > > Resurrect it as a shim wrapper over crc32c()

Re: [PATCH 01/17] btrfs: use btrfs_csum_data() instead of directly calling crc32c

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > btrfsic_test_for_metadata() directly calls the crc32c() library function > for calculating the CRC32C checksum, but then uses btrfs_csum_final() to > invert the result. > > To ease further refactoring and development around checksumming in BT

Re: [PATCH 14/17] btrfs: directly call into crypto framework for checsumming

2019-05-10 Thread Chris Mason
On 10 May 2019, at 9:45, Chris Mason wrote: > On 10 May 2019, at 7:15, Johannes Thumshirn wrote: > >> Currently btrfs_csum_data() relied on the crc32c() wrapper around the >> crypto >> framework for calculating the CRCs. >> >> As we have our own crypto_shash structure in the fs_info now, we can

Re: [PATCH 14/17] btrfs: directly call into crypto framework for checsumming

2019-05-10 Thread Chris Mason
On 10 May 2019, at 7:15, Johannes Thumshirn wrote: > Currently btrfs_csum_data() relied on the crc32c() wrapper around the > crypto > framework for calculating the CRCs. > > As we have our own crypto_shash structure in the fs_info now, we can > directly call into the crypto framework without goin

Re: [PATCH 11/17] btrfs: Simplify btrfs_check_super_csum() and get rid of size assumptions

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Now that we have already checked for a valid checksum type before calling > btrfs_check_super_csum(), it can be simplified even further. > > While at it get rid of the implicit size assumption of the resulting > checksum as well. > > Signed-

Re: [PATCH 09/17] btrfs: add common checksum type validation

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Currently btrfs is only supporting CRC32C as checksumming algorithm. As > this is about to change provide a function to validate the checksum type in > the superblock against all possible algorithms. > > This makes adding new algorithms easie

Re: [PATCH 10/17] btrfs: check for supported superblock checksum type before checksum validation

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Check for supported superblock checksum type before doing the actual > checksum validation of the superblock read from disk. This is rather terse, how does it improve the code and what was the current status quo (e.g before this patch). > >

Re: [PATCH 08/17] btrfs: format checksums according to type for printing

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Add a small helper for btrfs_print_data_csum_error() which formats the > checksum according to it's type for pretty printing. > > Signed-off-by: Johannes Thumshirn Reviewed-by: Nikolay Borisov > --- > fs/btrfs/btrfs_inode.h | 28

Re: [PATCH 07/17] btrfs: use btrfs_crc32c{,_final}() in for free space cache

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > The CRC checksum in the free space cache is not dependant on the super > block's csum_type field but always a CRC32C. > > So use btrfs_crc32c() and btrfs_crc32c_final() instead of btrfs_csum_data() > and btrfs_csum_final() for computing these

Re: [PATCH 05/17] btrfs: don't assume ordered sums to be 4 bytes

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 16:25 ч., Nikolay Borisov wrote: > > > On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: >> BTRFS has the implicit assumption that a checksum in btrfs_orderd_sums is 4 >> bytes. While this is true for CRC32C, it is not for any other checksum. >> >> Change the data type to be a

Re: [PATCH 05/17] btrfs: don't assume ordered sums to be 4 bytes

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > BTRFS has the implicit assumption that a checksum in btrfs_orderd_sums is 4 > bytes. While this is true for CRC32C, it is not for any other checksum. > > Change the data type to be a byte array and adjust loop index calculation > accordingly.

Re: [PATCH 03/17] btrfs: use btrfs_crc32c() instead of btrfs_extref_hash()

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Like btrfs_crc32c() btrfs_extref_hash() is only a shim wrapper over the > crc32c() library function. So we can just use btrfs_crc32c() instead of > btrfs_extref_hash(). > > Signed-off-by: Johannes Thumshirn I agree with Chris' feedback on t

Re: [PATCH 04/17] btrfs: use btrfs_crc32c() instead of btrfs_name_hash()

2019-05-10 Thread Chris Mason
On 10 May 2019, at 7:15, Johannes Thumshirn wrote: > Like btrfs_crc32c() btrfs_name_hash() is only a shim wrapper over the > crc32c() library function. So we can just use btrfs_crc32c() instead > of > btrfs_name_hash(). Reading through the rest of the series, but I think using btrfs_name_hash()

Re: [PATCH 17/17] btrfs: add sha256 as another checksum algorithm

2019-05-10 Thread Nikolay Borisov
On 10.05.19 г. 14:15 ч., Johannes Thumshirn wrote: > Now that we everything in place, we can add SHA-256 as another checksum > algorithm. > > SHA-256 was taken as it was the cryptographically strongest algorithm that > can fit into the 32 Bytes we have left. > > Signed-off-by: Johannes Thumshi

Re: [PATCH v2 0/3] Ordered extent flushing refactor

2019-05-10 Thread David Sterba
On Tue, May 07, 2019 at 10:19:21AM +0300, Nikolay Borisov wrote: > Here is v2 of factoring out common code when flushing ordered extent. The main > change in this version is the switch from inode to btrfs_inode for function > interfaces as per David's feedback. > > Nikolay Borisov (3): > btrf

Re: [PATCH] btrfs: Return EAGAIN if we can't start no snpashot write in check_can_nocow

2019-05-10 Thread David Sterba
On Tue, May 07, 2019 at 10:23:46AM +0300, Nikolay Borisov wrote: > The first thing code does in check_can_nocow is trying to block > concurrent snapshots. If this fails (due to snpashot already being in > progress) the function returns ENOSPC which makes no sense. Instead > return EAGAIN. Despite t

Re: [PATCH v2] btrfs: Add comments on locking of several device-related fields

2019-05-10 Thread David Sterba
On Thu, May 09, 2019 at 06:11:11PM +0300, Nikolay Borisov wrote: > Signed-off-by: Nikolay Borisov Added to 5.3 queue, thanks.

[PATCH 04/17] btrfs: use btrfs_crc32c() instead of btrfs_name_hash()

2019-05-10 Thread Johannes Thumshirn
Like btrfs_crc32c() btrfs_name_hash() is only a shim wrapper over the crc32c() library function. So we can just use btrfs_crc32c() instead of btrfs_name_hash(). Signed-off-by: Johannes Thumshirn --- fs/btrfs/ctree.h| 5 - fs/btrfs/dir-item.c | 10 +- fs/btrfs/inode.c

[PATCH 16/17] btrfs: remove assumption about csum type form btrfs_print_data_csum_error()

2019-05-10 Thread Johannes Thumshirn
btrfs_print_data_csum_error() still assumed checksums to be 32 bit in size. Make it size agnostic. Signed-off-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 6 +++--- fs/btrfs/compression.c | 2 +- fs/btrfs/inode.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --gi

[PATCH 10/17] btrfs: check for supported superblock checksum type before checksum validation

2019-05-10 Thread Johannes Thumshirn
Check for supported superblock checksum type before doing the actual checksum validation of the superblock read from disk. Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 8 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ab13282d91

[PATCH 03/17] btrfs: use btrfs_crc32c() instead of btrfs_extref_hash()

2019-05-10 Thread Johannes Thumshirn
Like btrfs_crc32c() btrfs_extref_hash() is only a shim wrapper over the crc32c() library function. So we can just use btrfs_crc32c() instead of btrfs_extref_hash(). Signed-off-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 9 - fs/btrfs/inode-item.c | 6 +++--- fs/btrfs/tree-log.c

[PATCH 07/17] btrfs: use btrfs_crc32c{,_final}() in for free space cache

2019-05-10 Thread Johannes Thumshirn
The CRC checksum in the free space cache is not dependant on the super block's csum_type field but always a CRC32C. So use btrfs_crc32c() and btrfs_crc32c_final() instead of btrfs_csum_data() and btrfs_csum_final() for computing these checksums. Signed-off-by: Johannes Thumshirn --- fs/btrfs/fr

[PATCH 01/17] btrfs: use btrfs_csum_data() instead of directly calling crc32c

2019-05-10 Thread Johannes Thumshirn
btrfsic_test_for_metadata() directly calls the crc32c() library function for calculating the CRC32C checksum, but then uses btrfs_csum_final() to invert the result. To ease further refactoring and development around checksumming in BTRFS convert to calling btrfs_csum_data(), which is a wrapper aro

[PATCH 09/17] btrfs: add common checksum type validation

2019-05-10 Thread Johannes Thumshirn
Currently btrfs is only supporting CRC32C as checksumming algorithm. As this is about to change provide a function to validate the checksum type in the superblock against all possible algorithms. This makes adding new algorithms easier as there are fewer places to adjust when adding new algorithms

[PATCH 12/17] btrfs: add boilerplate code for directly including the crypto framework

2019-05-10 Thread Johannes Thumshirn
Add boilerplate code for directly including the crypto framework. This helps us flipping the switch for new algorithms. Signed-off-by: Johannes Thumshirn --- fs/btrfs/ctree.h | 11 +++ fs/btrfs/disk-io.c | 49 ++--- 2 files changed, 53 inser

[PATCH 17/17] btrfs: add sha256 as another checksum algorithm

2019-05-10 Thread Johannes Thumshirn
Now that we everything in place, we can add SHA-256 as another checksum algorithm. SHA-256 was taken as it was the cryptographically strongest algorithm that can fit into the 32 Bytes we have left. Signed-off-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 3 +++ fs/btrfs/ctree.h

[PATCH 13/17] btrfs: pass in an fs_info to btrfs_csum_{data,final}()

2019-05-10 Thread Johannes Thumshirn
Later patches will need the fs_info to get the checksum function in btrfs_csum_data() and btrfs_csum_final(). Signed-off-by: Johannes Thumshirn --- fs/btrfs/check-integrity.c | 4 ++-- fs/btrfs/compression.c | 4 ++-- fs/btrfs/disk-io.c | 18 ++ fs/btrfs/disk-io.h

[PATCH 11/17] btrfs: Simplify btrfs_check_super_csum() and get rid of size assumptions

2019-05-10 Thread Johannes Thumshirn
Now that we have already checked for a valid checksum type before calling btrfs_check_super_csum(), it can be simplified even further. While at it get rid of the implicit size assumption of the resulting checksum as well. Signed-off-by: Johannes Thumshirn --- fs/btrfs/disk-io.c | 37 +++

[PATCH 15/17] btrfs: remove assumption about csum type form btrfs_csum_{data,final}()

2019-05-10 Thread Johannes Thumshirn
btrfs_csum_data() and btrfs_csum_final() still have assumptions on the checksums' type and size. Remove it so we can plumb in more types. Signed-off-by: Johannes Thumshirn --- fs/btrfs/check-integrity.c | 6 ++--- fs/btrfs/compression.c | 13 ++- fs/btrfs/disk-io.c | 58

[PATCH 05/17] btrfs: don't assume ordered sums to be 4 bytes

2019-05-10 Thread Johannes Thumshirn
BTRFS has the implicit assumption that a checksum in btrfs_orderd_sums is 4 bytes. While this is true for CRC32C, it is not for any other checksum. Change the data type to be a byte array and adjust loop index calculation accordingly. Signed-off-by: Johannes Thumshirn --- fs/btrfs/compression.c

[PATCH 08/17] btrfs: format checksums according to type for printing

2019-05-10 Thread Johannes Thumshirn
Add a small helper for btrfs_print_data_csum_error() which formats the checksum according to it's type for pretty printing. Signed-off-by: Johannes Thumshirn --- fs/btrfs/btrfs_inode.h | 28 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/btrf

[PATCH 06/17] btrfs: dont assume compressed_bio sums to be 4 bytes

2019-05-10 Thread Johannes Thumshirn
BTRFS has the implicit assumption that a checksum in compressed_bio is 4 bytes. While this is true for CRC32C, it is not for any other checksum. Change the data type to be a byte array and adjust loop index calculation accordingly. Signed-off-by: Johannes Thumshirn --- fs/btrfs/compression.c |

[PATCH 14/17] btrfs: directly call into crypto framework for checsumming

2019-05-10 Thread Johannes Thumshirn
Currently btrfs_csum_data() relied on the crc32c() wrapper around the crypto framework for calculating the CRCs. As we have our own crypto_shash structure in the fs_info now, we can directly call into the crypto framework without going trough the wrapper. Signed-off-by: Johannes Thumshirn --- f

[PATCH 00/17] Add support for SHA-256 checksums

2019-05-10 Thread Johannes Thumshirn
This patchset add support for adding new checksum types in BTRFS. Currently BTRFS only supports CRC32C as data and metadata checksum, which is good if you only want to detect errors due to data corruption in hardware. But CRC32C isn't able cover other use-cases like de-duplication or cryptographi

[PATCH 02/17] btrfs: resurrect btrfs_crc32c()

2019-05-10 Thread Johannes Thumshirn
Commit 9678c54388b6 ("btrfs: Remove custom crc32c init code") removed the btrfs_crc32c() function, because it was a duplicate of the crc32c() library function we already have in the kernel. Resurrect it as a shim wrapper over crc32c() to make following transformations of the checksumming code in b