Large numbers like (1024 * 1024 * 1024) may cost reader/reviewer to
waste one second to convert to 1G.
Introduce kernel include/linux/sizes.h to replace any intermediate
number larger than 4096 (not including 4096) to SZ_*.
Signed-off-by: Qu Wenruo
---
btrfs-map-logical.c | 2 +-
cmds-fi-usage.c | 2 +-
cmds-filesystem.c | 2 +-
cmds-inspect.c | 6 +++---
cmds-scrub.c| 2 +-
cmds-send.c | 2 +-
ctree.c | 7 ---
ctree.h | 6 --
disk-io.c | 2 +-
disk-io.h | 5 +++--
extent-tree.c | 15 +++
free-space-cache.c | 2 +-
kernel-lib/sizes.h | 47 +++
send.h | 2 +-
utils.c | 8
utils.h | 9 +
volumes.c | 20 ++--
volumes.h | 2 +-
18 files changed, 96 insertions(+), 45 deletions(-)
create mode 100644 kernel-lib/sizes.h
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index e49a735e..bcbf2d90 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -30,7 +30,7 @@
#include "list.h"
#include "utils.h"
-#define BUFFER_SIZE (64 * 1024)
+#define BUFFER_SIZE SZ_64K
/* we write the mirror info to stdout unless they are dumping the data
* to stdout
diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c
index 8764fef6..5d8496fe 100644
--- a/cmds-fi-usage.c
+++ b/cmds-fi-usage.c
@@ -301,7 +301,7 @@ static void get_raid56_used(int fd, struct chunk_info
*chunks, int chunkcount,
}
}
-#defineMIN_UNALOCATED_THRESH (16 * 1024 * 1024)
+#defineMIN_UNALOCATED_THRESH SZ_16M
static int print_filesystem_usage_overall(int fd, struct chunk_info *chunkinfo,
int chunkcount, struct device_info *devinfo, int devcount,
char *path, unsigned unit_mode)
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index c66709b3..f3949b3b 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -1044,7 +1044,7 @@ static int cmd_filesystem_defrag(int argc, char **argv)
* but it does not defragment very well. The 32M will likely lead to
* better results and is independent of the kernel default.
*/
- thresh = 32 * 1024 * 1024;
+ thresh = SZ_32M;
defrag_global_errors = 0;
defrag_global_verbose = 0;
diff --git a/cmds-inspect.c b/cmds-inspect.c
index 5e58a284..ac3da618 100644
--- a/cmds-inspect.c
+++ b/cmds-inspect.c
@@ -173,7 +173,7 @@ static int cmd_inspect_logical_resolve(int argc, char
**argv)
if (check_argc_exact(argc - optind, 2))
usage(cmd_inspect_logical_resolve_usage);
- size = min(size, (u64)64 * 1024);
+ size = min(size, (u64)SZ_64K);
inodes = malloc(size);
if (!inodes)
return 1;
@@ -486,7 +486,7 @@ static void adjust_dev_min_size(struct list_head *extents,
* chunk tree, so often this can lead to the need of allocating
* a new system chunk too, which has a maximum size of 32Mb.
*/
- *min_size += 32 * 1024 * 1024;
+ *min_size += SZ_32M;
}
}
@@ -500,7 +500,7 @@ static int print_min_dev_size(int fd, u64 devid)
* possibility of deprecating/removing it has been discussed, so we
* ignore it here.
*/
- u64 min_size = 1 * 1024 * 1024ull;
+ u64 min_size = SZ_1M;
struct btrfs_ioctl_search_args args;
struct btrfs_ioctl_search_key *sk =
u64 last_pos = (u64)-1;
diff --git a/cmds-scrub.c b/cmds-scrub.c
index 2cf7f308..292a5dfd 100644
--- a/cmds-scrub.c
+++ b/cmds-scrub.c
@@ -467,7 +467,7 @@ static struct scrub_file_record **scrub_read_file(int fd,
int report_errors)
{
int avail = 0;
int old_avail = 0;
- char l[16 * 1024];
+ char l[SZ_16K];
int state = 0;
int curr = -1;
int i = 0;
diff --git a/cmds-send.c b/cmds-send.c
index cec11e6b..6c0a3dc3 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -44,7 +44,7 @@
#include "send.h"
#include "send-utils.h"
-#define SEND_BUFFER_SIZE (64 * 1024)
+#define SEND_BUFFER_SIZE SZ_64K
/*
* Default is 1 for historical reasons, changing may break scripts that expect
diff --git a/ctree.c b/ctree.c
index d07ec7d9..e3d687fb 100644
--- a/ctree.c
+++ b/ctree.c
@@ -21,6 +21,7 @@
#include "print-tree.h"
#include "repair.h"
#include "internal.h"
+#include "sizes.h"
static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
*root, struct btrfs_path *path, int level);
@@ -368,7 +369,7 @@ int btrfs_cow_block(struct btrfs_trans_handle *trans,
return 0;
}
- search_start = buf->start & ~((u64)(1024 * 1024 * 1024) - 1);
+ search_start = buf->start & ~((u64)SZ_1G - 1);
ret = __btrfs_cow_block(trans, root, buf, parent,
parent_slot,