Skip to content

Commit c92b635

Browse files
committed
btrfs-progs: unify init sequence of standalone utilities
Each utility that starts from main() (and is considered commonly used) should init fastest checksum implementation and set up config. This was properly done only in btrfs.c, fix it in btrfs-image, btrfs-convert and btrfstune as all of them do a lot of checksum calculations. Other standalone utilities do not need to do that. - cpu_detect_flags(); - hash_init_accel(); - btrfs_config_init(); Signed-off-by: David Sterba <[email protected]>
1 parent ffe019e commit c92b635

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

convert/main.c

+2
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
#include "common/extent-tree-utils.h"
122122
#include "common/root-tree-utils.h"
123123
#include "common/clear-cache.h"
124+
#include "common/utils.h"
124125
#include "cmds/commands.h"
125126
#include "check/repair.h"
126127
#include "mkfs/common.h"
@@ -1913,6 +1914,7 @@ int BOX_MAIN(convert)(int argc, char *argv[])
19131914

19141915
cpu_detect_flags();
19151916
hash_init_accel();
1917+
btrfs_config_init();
19161918
btrfs_assert_feature_buf_size();
19171919

19181920
while(1) {

image/main.c

+1
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ int BOX_MAIN(image)(int argc, char *argv[])
8888

8989
cpu_detect_flags();
9090
hash_init_accel();
91+
btrfs_config_init();
9192

9293
while (1) {
9394
enum { GETOPT_VAL_VERSION = GETOPT_VAL_FIRST };

tune/main.c

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "kernel-shared/volumes.h"
3131
#include "kernel-shared/free-space-tree.h"
3232
#include "kernel-shared/zoned.h"
33+
#include "crypto/hash.h"
34+
#include "common/cpu-utils.h"
3335
#include "common/utils.h"
3436
#include "common/open-utils.h"
3537
#include "common/device-scan.h"
@@ -204,6 +206,8 @@ int BOX_MAIN(btrfstune)(int argc, char *argv[])
204206
int fd = -1;
205207
int oflags = O_RDWR;
206208

209+
cpu_detect_flags();
210+
hash_init_accel();
207211
btrfs_config_init();
208212

209213
while(1) {

0 commit comments

Comments
 (0)