Remove custom crc32c init code from btrfs
Subsystems (4)
cover Remove custom crc32c init code from btrfs
So here is a small 2 patch set which removes btrfs' manual initialisation of the lower level crc32c module. Explanation why is ok can be found in Patch 2/2.
Patch 1/2 just adds a function to the generic crc32c header which allows querying the actual crc32c implementaiton used (i.e. software or hw-accelerated) to retain current btrfs behavior. This is mainly used for debugging purposes and is independent.
Nikolay Borisov (2):
libcrc32c: Add crc32c_impl function
btrfs: Remove custom crc32c init code
fs/btrfs/Kconfig | 3 +-- fs/btrfs/Makefile | 2 +- fs/btrfs/check-integrity.c | 4 ++-- fs/btrfs/ctree.h | 16 ++++++++++++++ fs/btrfs/dir-item.c | 1 - fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 10 ++++----- fs/btrfs/hash.c | 54 ---------------------------------------------- fs/btrfs/hash.h | 43 ------------------------------------ fs/btrfs/inode-item.c | 1 - fs/btrfs/inode.c | 1 - fs/btrfs/props.c | 2 +- fs/btrfs/send.c | 4 ++-- fs/btrfs/super.c | 14 ++++-------- fs/btrfs/tree-log.c | 2 +- include/linux/crc32c.h | 1 + lib/libcrc32c.c | 6 ++++++ 17 files changed, 42 insertions(+), 126 deletions(-) delete mode 100644 fs/btrfs/hash.c delete mode 100644 fs/btrfs/hash.h
Signature · 1 line
2.7.4
PATCH 1/2 libcrc32c: Add crc32c_impl function
This function returns a string with the currently in-use implementation of the crc32c algorithm, i.e crc32c-generic (for unoptimised, generic implementation) or crc32c-intel for the sse optimised version. This will be used by btrfs.
--- include/linux/crc32c.h | 1 + lib/libcrc32c.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/linux/crc32c.h +1 -0
@@ -5,6 +5,7 @@#include <linux/types.h> extern u32 crc32c (u32 crc,const void *address,unsigned int length); +extern const char *crc32c_impl (void );/* This macro exists for backwards-compatibility. */ #define crc32c_le crc32c
lib/libcrc32c.c +6 -0
@@ -71,6 +71,12 @@ static void __exit libcrc32c_mod_fini(void)crypto_free_shash (tfm); } +const char *crc32c_impl (void ) +{ +return crypto_tfm_alg_driver_name (crypto_shash_tfm (tfm)); +} +EXPORT_SYMBOL (crc32c_impl); +module_init (libcrc32c_mod_init);module_exit (libcrc32c_mod_fini);
Signature · 1 line
2.7.4
PATCH 2/2 btrfs: Remove custom crc32c init code
In reply to Nikolay BorisovThe custom crc32 init code was introduced in14a958e678cd ("Btrfs: fix btrfs boot when compiled as built-in") to enable using btrfs as a built-in. However, later as pointed out by 60efa5eb2e88 ("Btrfs: use late_initcall instead of module_init") this wasn't enough and finally btrfs was switched to late_initcall which comes after the generic crc32c implementation is initiliased. The latter commit superseeded the former. Now that we don't have to maintain our own code let's just remove it and switch to using the generic implementation.
---
Despite touching a lot of files the patch is really simple. Here is the gist of the changes:
1. Select LIBCRC32C rather than the low-level modules.
2. s/btrfs_crc32c/crc32c/g
3. replace hash.h with linux/crc32c.h
4. Move the btrfs namehash funcs to ctree.h and change the tree accordingly.
I've tested this with btrfs being both a module and a built-in and xfstest doesn't complain.
fs/btrfs/Kconfig | 3 +-- fs/btrfs/Makefile | 2 +- fs/btrfs/check-integrity.c | 4 ++-- fs/btrfs/ctree.h | 16 ++++++++++++++ fs/btrfs/dir-item.c | 1 - fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 10 ++++----- fs/btrfs/hash.c | 54 ---------------------------------------------- fs/btrfs/hash.h | 43 ------------------------------------ fs/btrfs/inode-item.c | 1 - fs/btrfs/inode.c | 1 - fs/btrfs/props.c | 2 +- fs/btrfs/send.c | 4 ++-- fs/btrfs/super.c | 14 ++++-------- fs/btrfs/tree-log.c | 2 +- 15 files changed, 35 insertions(+), 126 deletions(-) delete mode 100644 fs/btrfs/hash.c delete mode 100644 fs/btrfs/hash.h
fs/btrfs/Kconfig +1 -2
@@ -1,7 +1,6 @@ config BTRFS_FS tristate "Btrfs filesystem support" - select CRYPTO - select CRYPTO_CRC32C + select LIBCRC32C select ZLIB_INFLATE select ZLIB_DEFLATE select LZO_COMPRESS
fs/btrfs/Makefile +1 -1
@@ -10,7 +10,7 @@ btrfs-y += super.o ctree.o extent-tree.o print-tree.o root-tree.o dir-item.o \ export.o tree-log.o free-space-cache.o zlib.o lzo.o zstd.o \ compression.o delayed-ref.o relocation.o delayed-inode.o scrub.o \ reada.o backref.o ulist.o qgroup.o send.o dev-replace.o raid56.o \ - uuid-tree.o props.o hash.o free-space-tree.o tree-checker.o + uuid-tree.o props.o free-space-tree.o tree-checker.o btrfs-$(CONFIG_BTRFS_FS_POSIX_ACL) += acl.o btrfs-$(CONFIG_BTRFS_FS_CHECK_INTEGRITY) += check-integrity.o
fs/btrfs/check-integrity.c +2 -2
@@ -96,9 +96,9 @@#include <linux/blkdev.h> #include <linux/mm.h> #include <linux/string.h> +#include <linux/crc32c.h> #include "ctree.h" #include "disk-io.h" -#include "hash.h" #include "transaction.h" #include "extent_io.h" #include "volumes.h"
@@ -1736,7 +1736,7 @@ static int btrfsic_test_for_metadata(struct btrfsic_state *state,size_t sublen = i ?PAGE_SIZE : (PAGE_SIZE -BTRFS_CSUM_SIZE ); - crc =btrfs_crc32c (crc, data, sublen); + crc =crc32c (crc, data, sublen); }btrfs_csum_final (crc, csum);if (memcmp (csum, h->csum, state->csum_size))
fs/btrfs/ctree.h +16 -0
@@ -40,6 +40,7 @@#include <linux/sizes.h> #include <linux/dynamic_debug.h> #include <linux/refcount.h> +#include <linux/crc32c.h> #include "extent_io.h" #include "extent_map.h" #include "async-thread.h"
@@ -98,6 +99,7 @@ static const int btrfs_csum_sizes[] = { 4 };#define BTRFS_MAX_EXTENT_SIZE SZ_128M +/* * Count how many BTRFS_MAX_EXTENT_SIZE cover the @size */
@@ -2555,6 +2557,20 @@ BTRFS_SETGET_STACK_FUNCS(stack_dev_replace_cursor_right, ((unsigned long )(BTRFS_LEAF_DATA_OFFSET + \ btrfs_item_offset_nr(leaf, slot))) +static inline u64 btrfs_name_hash (const char *name,int len) +{ +return crc32c ((u32 )~1 , name, len); +} + +/* +* Figure the key offset of an extended inode ref +*/ +static inline u64 btrfs_extref_hash (u64 parent_objectid,const char *name, +int len) +{ +return (u64 )crc32c (parent_objectid, name, len); +} +static inline bool btrfs_mixed_space_info (struct btrfs_space_info *space_info) { return ((space_info->flags & BTRFS_BLOCK_GROUP_METADATA) &&
fs/btrfs/dir-item.c +0 -1
@@ -18,7 +18,6 @@#include "ctree.h" #include "disk-io.h" -#include "hash.h" #include "transaction.h" /*
fs/btrfs/disk-io.c +2 -2
@@ -30,10 +30,10 @@#include <linux/ratelimit.h> #include <linux/uuid.h> #include <linux/semaphore.h> +#include <linux/crc32c.h> #include <asm/unaligned.h> #include "ctree.h" #include "disk-io.h" -#include "hash.h" #include "transaction.h" #include "btrfs_inode.h" #include "volumes.h"
@@ -268,7 +268,7 @@ static struct extent_map *btree_get_extent(struct btrfs_inode *inode,u32 btrfs_csum_data (const char *data,u32 seed,size_t len) { -return btrfs_crc32c (seed, data, len); +return crc32c (seed, data, len); }void btrfs_csum_final (u32 crc,u8 *result)
fs/btrfs/extent-tree.c +5 -5
@@ -27,7 +27,7 @@#include <linux/ratelimit.h> #include <linux/percpu_counter.h> #include <linux/lockdep.h> -#include "hash.h" +#include <linux/crc32c.h> #include "tree-log.h" #include "disk-io.h" #include "print-tree.h"
@@ -1203,11 +1203,11 @@ static u64 hash_extent_data_ref(u64 root_objectid, u64 owner, u64 offset)__le64 lenum; lenum =cpu_to_le64 (root_objectid); - high_crc =btrfs_crc32c (high_crc, &lenum,sizeof (lenum)); + high_crc =crc32c (high_crc, &lenum,sizeof (lenum)); lenum =cpu_to_le64 (owner); - low_crc =btrfs_crc32c (low_crc, &lenum,sizeof (lenum)); + low_crc =crc32c (low_crc, &lenum,sizeof (lenum)); lenum =cpu_to_le64 (offset); - low_crc =btrfs_crc32c (low_crc, &lenum,sizeof (lenum)); + low_crc =crc32c (low_crc, &lenum,sizeof (lenum));return ((u64 )high_crc <<31 ) ^ (u64 )low_crc; }
@@ -5950,7 +5950,7 @@ int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans,*/ u64 num_bytes =btrfs_calc_trans_metadata_size (fs_info,1 ); -trace_btrfs_space_reservation (fs_info,"orphan" ,btrfs_ino (inode), +trace_btrfs_space_reservation (fs_info,"orphan" ,btrfs_ino (inode), num_bytes,1 );return btrfs_block_rsv_migrate (src_rsv, dst_rsv, num_bytes,1 ); }
fs/btrfs/hash.c deleted +0 -54
54 lines not on this page · raw message
fs/btrfs/hash.h deleted +0 -43
43 lines not on this page · raw message
fs/btrfs/inode-item.c +0 -1
@@ -18,7 +18,6 @@#include "ctree.h" #include "disk-io.h" -#include "hash.h" #include "transaction.h" #include "print-tree.h"
fs/btrfs/inode.c +0 -1
@@ -57,7 +57,6 @@#include "free-space-cache.h" #include "inode-map.h" #include "backref.h" -#include "hash.h" #include "props.h" #include "qgroup.h" #include "dedupe.h"
fs/btrfs/props.c +1 -1
@@ -19,8 +19,8 @@#include <linux/hashtable.h> #include "props.h" #include "btrfs_inode.h" -#include "hash.h" #include "transaction.h" +#include "ctree.h" #include "xattr.h" #include "compression.h"
fs/btrfs/send.c +2 -2
@@ -27,10 +27,10 @@#include <linux/vmalloc.h> #include <linux/string.h> #include <linux/compat.h> +#include <linux/crc32c.h> #include "send.h" #include "backref.h" -#include "hash.h" #include "locking.h" #include "disk-io.h" #include "btrfs_inode.h"
@@ -695,7 +695,7 @@ static int send_cmd(struct send_ctx *sctx) hdr->len =cpu_to_le32 (sctx->send_size -sizeof (*hdr)); hdr->crc =0 ; - crc =btrfs_crc32c (0 , (unsigned char *)sctx->send_buf, sctx->send_size); + crc =crc32c (0 , (unsigned char *)sctx->send_buf, sctx->send_size); hdr->crc =cpu_to_le32 (crc); ret = write_buf(sctx->send_filp, sctx->send_buf, sctx->send_size,
fs/btrfs/super.c +4 -10
@@ -41,6 +41,7 @@#include <linux/slab.h> #include <linux/cleancache.h> #include <linux/ratelimit.h> +#include <linux/crc32c.h> #include <linux/btrfs.h> #include "delayed-inode.h" #include "ctree.h"
@@ -48,7 +49,6 @@#include "transaction.h" #include "btrfs_inode.h" #include "print-tree.h" -#include "hash.h" #include "props.h" #include "xattr.h" #include "volumes.h"
@@ -2350,22 +2350,18 @@ static void btrfs_print_mod_info(void)", ref-verify=on" #endif"\n" , - btrfs_crc32c_impl()); + crc32c_impl()); }static int __init init_btrfs_fs (void ) {int err; - err =btrfs_hash_init (); -if (err) -return err; -btrfs_props_init (); err =btrfs_init_sysfs ();if (err) - goto free_hash; +return err;btrfs_init_compress ();
@@ -2446,8 +2442,7 @@ static int __init init_btrfs_fs(void) free_compress:btrfs_exit_compress ();btrfs_exit_sysfs (); -free_hash: -btrfs_hash_exit (); +return err; }
@@ -2467,7 +2462,6 @@ static void __exit exit_btrfs_fs(void)btrfs_exit_sysfs ();btrfs_cleanup_fs_uuids ();btrfs_exit_compress (); -btrfs_hash_exit (); }late_initcall (init_btrfs_fs);
fs/btrfs/tree-log.c +1 -1
@@ -20,12 +20,12 @@#include <linux/slab.h> #include <linux/blkdev.h> #include <linux/list_sort.h> +#include "ctree.h" #include "tree-log.h" #include "disk-io.h" #include "locking.h" #include "print-tree.h" #include "backref.h" -#include "hash.h" #include "compression.h" #include "qgroup.h"
Signature · 1 line
2.7.4
2018-01-08 12:45 GMT+03:00 Nikolay Borisov <[email protected]>:
Quoted 33 lines
So here is a small 2 patch set which removes btrfs' manual initialisation of the lower level crc32c module. Explanation why is ok can be found in Patch 2/2.
Patch 1/2 just adds a function to the generic crc32c header which allows querying the actual crc32c implementaiton used (i.e. software or hw-accelerated) to retain current btrfs behavior. This is mainly used for debugging purposes and is independent.
Nikolay Borisov (2):
libcrc32c: Addcrc32c_implfunction
btrfs: Remove custom crc32c init codefs/btrfs/Kconfig | 3 +-- fs/btrfs/Makefile | 2 +- fs/btrfs/check-integrity.c | 4 ++-- fs/btrfs/ctree.h | 16 ++++++++++++++ fs/btrfs/dir-item.c | 1 - fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 10 ++++----- fs/btrfs/hash.c | 54 ---------------------------------------------- fs/btrfs/hash.h | 43 ------------------------------------ fs/btrfs/inode-item.c | 1 - fs/btrfs/inode.c | 1 - fs/btrfs/props.c | 2 +- fs/btrfs/send.c | 4 ++-- fs/btrfs/super.c | 14 ++++-------- fs/btrfs/tree-log.c | 2 +- include/linux/crc32c.h | 1 + lib/libcrc32c.c | 6 ++++++ 17 files changed, 42 insertions(+), 126 deletions(-) delete mode 100644 fs/btrfs/hash.c delete mode 100644 fs/btrfs/hash.h
Quoted 7 lines
--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
P.S.
May that are overkill to remove hash.c completely? i.e. if we have a "plan" to support another hash algo, we still need some abstractions for that.
Inband dedup don't touch hash.* so, no one else must be affected.
Thanks.
Signature · 2 lines
Have a nice day, Timofey.
Nikolay Borisov
NAKQuoted 42 lines · Timofey Titovets
2018-01-08 12:45 GMT+03:00 Nikolay Borisov <[email protected]>:
Quoted 33 lines
So here is a small 2 patch set which removes btrfs' manual initialisation of the lower level crc32c module. Explanation why is ok can be found in Patch 2/2.
Patch 1/2 just adds a function to the generic crc32c header which allows querying the actual crc32c implementaiton used (i.e. software or hw-accelerated) to retain current btrfs behavior. This is mainly used for debugging purposes and is independent.
Nikolay Borisov (2):
libcrc32c: Addcrc32c_implfunction
btrfs: Remove custom crc32c init codefs/btrfs/Kconfig | 3 +-- fs/btrfs/Makefile | 2 +- fs/btrfs/check-integrity.c | 4 ++-- fs/btrfs/ctree.h | 16 ++++++++++++++ fs/btrfs/dir-item.c | 1 - fs/btrfs/disk-io.c | 4 ++-- fs/btrfs/extent-tree.c | 10 ++++----- fs/btrfs/hash.c | 54 ---------------------------------------------- fs/btrfs/hash.h | 43 ------------------------------------ fs/btrfs/inode-item.c | 1 - fs/btrfs/inode.c | 1 - fs/btrfs/props.c | 2 +- fs/btrfs/send.c | 4 ++-- fs/btrfs/super.c | 14 ++++-------- fs/btrfs/tree-log.c | 2 +- include/linux/crc32c.h | 1 + lib/libcrc32c.c | 6 ++++++ 17 files changed, 42 insertions(+), 126 deletions(-) delete mode 100644 fs/btrfs/hash.c delete mode 100644 fs/btrfs/hash.hQuoted 7 lines
--
2.7.4--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines
Reviewed-by Timofey Titovets <[email protected]>
P.S.
May that are overkill to removehash.ccompletely? i.e. if we have a "plan" to support another hash algo, we still need some abstractions for that.
NAK.
Btrfs' code base has seen way too many instances of people dumping code "in anticipation of feature X", only to result in said feature never materializing. The end result is cruft being added. When/if someones decides to add a new checksum algo they will have to account for the existing crc32c and come up with appropriate abstraction. Until (if at all) that time comes - we don't need any of the hash.[ch] stuff.
Quoted 5 lines
Inband dedup don't touch hash.* so, no one else must be affected.
Thanks.
Re: [PATCH 2/2] btrfs: Remove custom crc32c init code
In reply to Nikolay BorisovQuoted 16 lines · Nikolay Borisov
The custom crc32 init code was introduced in
14a958e678cd("Btrfs: fix btrfs boot when compiled as built-in") to enable using btrfs as a built-in. However, later as pointed out by60efa5eb2e88("Btrfs: uselate_initcallinstead ofmodule_init") this wasn't enough and finally btrfs was switched tolate_initcallwhich comes after the generic crc32c implementation is initiliased. The latter commit superseeded the former. Now that we don't have to maintain our own code let's just remove it and switch to using the generic implementation.Signed-off-by Nikolay Borisov <[email protected]>---
Despite touching a lot of files the patch is really simple. Here is the gist of the changes:
Quoted 7 lines
1. Select LIBCRC32C rather than the low-level modules.
2. s/btrfs_crc32c/crc32c/g
3. replacehash.hwithlinux/crc32c.h
4. Move the btrfs namehash funcs toctree.hand change the tree accordingly.I've tested this with btrfs being both a module and a built-in and xfstest doesn't complain.
This text could be also part of the changelog, it's useful to understand how the change is done.
So this patches looks good to me and does seem to fix the longstanding problem of not automatically selectiong the crc32c module when btrfs is used. IIRC this has some workaround in dracut.
The modinfo confirms that now all the module dependencies are there:
before:
depends: zstd_compress,zstd_decompress,raid6_pq,xor,zlib_deflate
after:
depends: libcrc32c,zstd_compress,zstd_decompress,raid6_pq,xor,zlib_deflate
Re: [PATCH 1/2] libcrc32c: Add crc32c_impl function
In reply to Nikolay BorisovAdding [email protected] to CC
Link to the 2/2 patch https://patchwork.kernel.org/patch/10149203/
Quoted 28 lines · Nikolay Borisov
This function returns a string with the currently in-use implementation of the crc32c algorithm, i.e crc32c-generic (for unoptimised, generic implementation) or crc32c-intel for the sse optimised version. This will be used by btrfs.
Signed-off-by Nikolay Borisov <[email protected]>--- include/linux/crc32c.h | 1 + lib/libcrc32c.c | 6 ++++++ 2 files changed, 7 insertions(+)include/linux/crc32c.h +1
-0@@ -5,6 +5,7 @@#include <linux/types.h> extern u32 crc32c (u32 crc,const void *address,unsigned int length); +extern const char *crc32c_impl (void );/* This macro exists for backwards-compatibility. */ #define crc32c_le crc32clib/libcrc32c.c +0
-0
lib/libcrc32c.c static void __exit libcrc32c_mod_fini(void) · line 78
Quoted 8 lines
lib/libcrc32c.c +5
-0@@ -71,6 +71,12 @@ static void __exit libcrc32c_mod_fini(void)crypto_free_shash (tfm); } +const char *crc32c_impl (void ) +{ +return crypto_tfm_alg_driver_name (crypto_shash_tfm (tfm)); +} +EXPORT_SYMBOL (crc32c_impl);
Crypto maintainers, would it be still possible to squeeze this patch to 4.16? It's quite trivial, but as it is not in a code I maintain I'm not comfortable to add it to my tree (unless I get an ACK).
The linked patch depends on that change and would let us get rid of some custom crypto wrappers around crc32c.
Re: [PATCH 2/2] btrfs: Remove custom crc32c init code
In reply to Nikolay BorisovQuoted 10 lines · Nikolay Borisov
The custom crc32 init code was introduced in
14a958e678cd("Btrfs: fix btrfs boot when compiled as built-in") to enable using btrfs as a built-in. However, later as pointed out by60efa5eb2e88("Btrfs: uselate_initcallinstead ofmodule_init") this wasn't enough and finally btrfs was switched tolate_initcallwhich comes after the generic crc32c implementation is initiliased. The latter commit superseeded the former. Now that we don't have to maintain our own code let's just remove it and switch to using the generic implementation.
Quoted 2 lines
fs/btrfs/hash.c | 54 ---------------------------------------------- fs/btrfs/hash.h | 43 ------------------------------------
IIRC Adding -D to git format-patch will make it shorter and nicer. But please, double check that git am actually detects removals.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH 1/2] libcrc32c: Add crc32c_impl function
In reply to David SterbaQuoted 36 lines · David Sterba
Adding [email protected] to CC
Link to the 2/2 patch https://patchwork.kernel.org/patch/10149203/
Quoted 31 lines · Nikolay Borisov
This function returns a string with the currently in-use implementation of the crc32c algorithm, i.e crc32c-generic (for unoptimised, generic implementation) or crc32c-intel for the sse optimised version. This will be used by btrfs.
Signed-off-by Nikolay Borisov <[email protected]>--- include/linux/crc32c.h | 1 + lib/libcrc32c.c | 6 ++++++ 2 files changed, 7 insertions(+)include/linux/crc32c.h +1
-0@@ -5,6 +5,7 @@#include <linux/types.h> extern u32 crc32c (u32 crc,const void *address,unsigned int length); +extern const char *crc32c_impl (void );/* This macro exists for backwards-compatibility. */ #define crc32c_le crc32clib/libcrc32c.c +0
-0@@ -71,6 +71,12 @@ static void __exit libcrc32c_mod_fini(void)crypto_free_shash (tfm); }
Quoted 5 lines
lib/libcrc32c.c static void __exit libcrc32c_mod_fini(void) · line 78
Quoted 5 lines
lib/libcrc32c.c +5
-0+const char *crc32c_impl (void ) +{ +return crypto_tfm_alg_driver_name (crypto_shash_tfm (tfm)); +} +EXPORT_SYMBOL (crc32c_impl);
You could just use crypto_shash_driver_name.
Quoted 6 lines
Crypto maintainers, would it be still possible to squeeze this patch to 4.16? It's quite trivial, but as it is not in a code I maintain I'm not comfortable to add it to my tree (unless I get an ACK).
The linked patch depends on that change and would let us get rid of some custom crypto wrappers around crc32c.
I'm fine with the patch otherwise.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
Re: [PATCH 2/2] btrfs: Remove custom crc32c init code
In reply to Andy ShevchenkoQuoted 11 lines · Andy Shevchenko
Quoted 9 lines · Nikolay Borisov
The custom crc32 init code was introduced in
14a958e678cd("Btrfs: fix btrfs boot when compiled as built-in") to enable using btrfs as a built-in. However, later as pointed out by60efa5eb2e88("Btrfs: uselate_initcallinstead ofmodule_init") this wasn't enough and finally btrfs was switched tolate_initcallwhich comes after the generic crc32c implementation is initiliased. The latter commit superseeded the former. Now that we don't have to maintain our own code let's just remove it and switch to using the generic implementation.
Quoted 5 lines
Quoted 2 lines
fs/btrfs/hash.c | 54 ---------------------------------------------- fs/btrfs/hash.h | 43 ------------------------------------IIRC Adding -D to git format-patch will make it shorter and nicer. But please, double check that git am actually detects removals.
While the patch looks better, my 'git am' does not want to apply the deletion:
$ git am 0001-btrfs-Remove-custom-crc32c-init-code.patch Applying: btrfs: Remove custom crc32c init code error: removal patch leaves file contents error: fs/btrfs/hash.c: patch does not apply error: removal patch leaves file contents error: fs/btrfs/hash.h: patch does not apply Patch failed at 0001 btrfs: Remove custom crc32c init code The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
so the ordinary diff shall be preferred.
Quoted 11 lines · Nikolay Borisov
So here is a small 2 patch set which removes btrfs' manual initialisation of the lower level crc32c module. Explanation why is ok can be found in Patch 2/2.
Patch 1/2 just adds a function to the generic crc32c header which allows querying the actual crc32c implementaiton used (i.e. software or hw-accelerated) to retain current btrfs behavior. This is mainly used for debugging purposes and is independent.
Nikolay Borisov (2):
libcrc32c: Addcrc32c_implfunction
btrfs: Remove custom crc32c init code
As we got ack from Herbert, I'm going to add the patches to my for-next.