summaryrefslogtreecommitdiff
path: root/utils.c
diff options
context:
space:
mode:
authorQu Wenruo <quwenruo@cn.fujitsu.com>2017-01-24 11:03:05 +0800
committerDavid Sterba <dsterba@suse.com>2017-03-08 13:00:45 +0100
commita2203246ae483d09114329d5d1f898efb23d6168 (patch)
tree40cea3c2a1293e7f23559c5183cf92c22312321b /utils.c
parent95f515f2d12fb1c1b5a01e03d9f709570b762eeb (diff)
btrfs-progs: Introduce kernel sizes to cleanup large intermediate number
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 <quwenruo@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r--utils.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/utils.c b/utils.c
index 1adcc84e..b4f667e5 100644
--- a/utils.c
+++ b/utils.c
@@ -134,7 +134,7 @@ static int discard_blocks(int fd, u64 start, u64 len)
{
while (len > 0) {
/* 1G granularity */
- u64 chunk_size = min_t(u64, len, 1*1024*1024*1024);
+ u64 chunk_size = min_t(u64, len, SZ_1G);
int ret;
ret = discard_range(fd, start, chunk_size);
@@ -542,7 +542,7 @@ static int insert_temp_chunk_item(int fd, struct extent_buffer *buf,
chunk = btrfs_item_ptr(buf, *slot, struct btrfs_chunk);
btrfs_set_chunk_length(buf, chunk, len);
btrfs_set_chunk_owner(buf, chunk, BTRFS_EXTENT_TREE_OBJECTID);
- btrfs_set_chunk_stripe_len(buf, chunk, 64 * 1024);
+ btrfs_set_chunk_stripe_len(buf, chunk, BTRFS_STRIPE_LEN);
btrfs_set_chunk_type(buf, chunk, type);
btrfs_set_chunk_io_align(buf, chunk, cfg->sectorsize);
btrfs_set_chunk_io_width(buf, chunk, cfg->sectorsize);
@@ -1335,7 +1335,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
chunk = btrfs_item_ptr(buf, nritems, struct btrfs_chunk);
btrfs_set_chunk_length(buf, chunk, BTRFS_MKFS_SYSTEM_GROUP_SIZE);
btrfs_set_chunk_owner(buf, chunk, BTRFS_EXTENT_TREE_OBJECTID);
- btrfs_set_chunk_stripe_len(buf, chunk, 64 * 1024);
+ btrfs_set_chunk_stripe_len(buf, chunk, BTRFS_STRIPE_LEN);
btrfs_set_chunk_type(buf, chunk, BTRFS_BLOCK_GROUP_SYSTEM);
btrfs_set_chunk_io_align(buf, chunk, cfg->sectorsize);
btrfs_set_chunk_io_width(buf, chunk, cfg->sectorsize);
@@ -1684,7 +1684,7 @@ static int zero_blocks(int fd, off_t start, size_t len)
return ret;
}
-#define ZERO_DEV_BYTES (2 * 1024 * 1024)
+#define ZERO_DEV_BYTES SZ_2M
/* don't write outside the device by clamping the region to the device size */
static int zero_dev_clamped(int fd, off_t start, ssize_t len, u64 dev_size)