* [PATCH 1/2] btrfs-progs: Use already defined BTRFS_BLOCK_GROUP_PROFILE_MASK @ 2017-07-27 8:16 Nikolay Borisov 2017-07-27 8:17 ` [PATCH 2/2] btrfs-progs: Use named constants for common sizes Nikolay Borisov 0 siblings, 1 reply; 5+ messages in thread From: Nikolay Borisov @ 2017-07-27 8:16 UTC (permalink / raw) To: linux-btrfs; +Cc: Nikolay Borisov Instead of opencoding it. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- volumes.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/volumes.c b/volumes.c index b350e259dded..e60dc0e0dd93 100644 --- a/volumes.c +++ b/volumes.c @@ -869,10 +869,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, return -ENOSPC; } - if (type & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | - BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 | - BTRFS_BLOCK_GROUP_RAID10 | - BTRFS_BLOCK_GROUP_DUP)) { + if (type & BTRFS_BLOCK_GROUP_PROFILE_MASK) { if (type & BTRFS_BLOCK_GROUP_SYSTEM) { calc_size = SZ_8M; max_chunk_size = calc_size * 2; -- 2.7.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] btrfs-progs: Use named constants for common sizes 2017-07-27 8:16 [PATCH 1/2] btrfs-progs: Use already defined BTRFS_BLOCK_GROUP_PROFILE_MASK Nikolay Borisov @ 2017-07-27 8:17 ` Nikolay Borisov 2017-07-27 21:02 ` Duncan 2017-08-22 14:31 ` David Sterba 0 siblings, 2 replies; 5+ messages in thread From: Nikolay Borisov @ 2017-07-27 8:17 UTC (permalink / raw) To: linux-btrfs; +Cc: Nikolay Borisov There multiple places where we use well-known sizes - 1,8,16,32 megabytes. We also have them defined as constants in the sizes.h header. So let's use them. No functional changes. Signed-off-by: Nikolay Borisov <nborisov@suse.com> --- convert/main.c | 8 ++++---- mkfs/common.c | 2 +- mkfs/main.c | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/convert/main.c b/convert/main.c index c56382e915fd..49ab829b5641 100644 --- a/convert/main.c +++ b/convert/main.c @@ -630,7 +630,7 @@ static int calculate_available_space(struct btrfs_convert_context *cctx) * Twice the minimal chunk size, to allow later wipe_reserved_ranges() * works without need to consider overlap */ - u64 min_stripe_size = 2 * 16 * 1024 * 1024; + u64 min_stripe_size = SZ_32M; int ret; /* Calculate data_chunks */ @@ -795,7 +795,7 @@ static int create_image(struct btrfs_root *root, * Start from 1M, as 0~1M is reserved, and create_image_file_range() * can't handle bytenr 0(will consider it as a hole) */ - cur = 1024 * 1024; + cur = SZ_1M; while (cur < size) { u64 len = size - cur; @@ -1010,7 +1010,7 @@ static int make_convert_data_block_groups(struct btrfs_trans_handle *trans, * And for single chunk, don't create chunk larger than 1G. */ max_chunk_size = cfg->num_bytes / 10; - max_chunk_size = min((u64)(1024 * 1024 * 1024), max_chunk_size); + max_chunk_size = min((u64)(SZ_1G), max_chunk_size); max_chunk_size = round_down(max_chunk_size, extent_root->sectorsize); for (cache = first_cache_extent(data_chunks); cache; @@ -1586,7 +1586,7 @@ next: * | RSV 1 | | Old | | RSV 2 | | Old | | RSV 3 | * | 0~1M | | Fs | | SB2 + 64K | | Fs | | SB3 + 64K | * - * On the other hande, the converted fs image in btrfs is a completely + * On the other hande, the converted fs image in btrfs is a completely * valid old fs. * * |<-----------------Converted fs image in btrfs-------------------->| diff --git a/mkfs/common.c b/mkfs/common.c index 1e8f26ea4dda..5fbd38c1230b 100644 --- a/mkfs/common.c +++ b/mkfs/common.c @@ -95,7 +95,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg) cfg->blocks[0] = BTRFS_SUPER_INFO_OFFSET; for (i = 1; i < 7; i++) { - cfg->blocks[i] = BTRFS_SUPER_INFO_OFFSET + 1024 * 1024 + + cfg->blocks[i] = BTRFS_SUPER_INFO_OFFSET + SZ_1M + cfg->nodesize * i; } diff --git a/mkfs/main.c b/mkfs/main.c index 61f746b30e7c..b89f7d1af903 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -716,7 +716,7 @@ again: * keep our extent size at 1MB max, this makes it easier to work inside * the tiny block groups created during mkfs */ - cur_bytes = min(total_bytes, 1024ULL * 1024); + cur_bytes = min(total_bytes, (u64)SZ_1M); ret = btrfs_reserve_extent(trans, root, cur_bytes, 0, 0, (u64)-1, &key, 1); if (ret) @@ -988,7 +988,7 @@ static int create_chunks(struct btrfs_trans_handle *trans, u64 chunk_size; u64 meta_type = BTRFS_BLOCK_GROUP_METADATA; u64 data_type = BTRFS_BLOCK_GROUP_DATA; - u64 minimum_data_chunk_size = 8 * 1024 * 1024; + u64 minimum_data_chunk_size = SZ_8M; u64 i; int ret; @@ -1092,9 +1092,9 @@ static u64 size_sourcedir(const char *dir_name, u64 sectorsize, u64 dir_size = 0; u64 total_size = 0; int ret; - u64 default_chunk_size = 8 * 1024 * 1024; /* 8MB */ - u64 allocated_meta_size = 8 * 1024 * 1024; /* 8MB */ - u64 allocated_total_size = 20 * 1024 * 1024; /* 20MB */ + u64 default_chunk_size = SZ_8M; + u64 allocated_meta_size = SZ_8M; + u64 allocated_total_size = 20 * SZ_1M; /* 20MB */ u64 num_of_meta_chunks = 0; u64 num_of_data_chunks = 0; u64 num_of_allocated_meta_chunks = -- 2.7.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] btrfs-progs: Use named constants for common sizes 2017-07-27 8:17 ` [PATCH 2/2] btrfs-progs: Use named constants for common sizes Nikolay Borisov @ 2017-07-27 21:02 ` Duncan 2017-08-22 14:31 ` David Sterba 2017-08-22 14:31 ` David Sterba 1 sibling, 1 reply; 5+ messages in thread From: Duncan @ 2017-07-27 21:02 UTC (permalink / raw) To: linux-btrfs Nikolay Borisov posted on Thu, 27 Jul 2017 11:17:00 +0300 as excerpted: > diff --git a/convert/main.c b/convert/main.c > index c56382e915fd..49ab829b5641 100644 > --- a/convert/main.c > +++ b/convert/main.c > @@ -1586,7 +1586,7 @@ next: > * | RSV 1 | | Old | | RSV 2 | | Old | | RSV 3 | > * | 0~1M | | Fs | | SB2 + 64K | | Fs | | SB3 + 64K | > * > - * On the other hande, the converted fs image in btrfs is a completely > + * On the other hande, the converted fs image in btrfs is a completely > * valid old fs. > * > * |<-----------------Converted fs image in btrfs-------------------->| If you're going to kill the line-terminating space, you might as well do the spell-correct in the same line: s/hande/hand/ (Or avoid the noise of doing either. I'm not sure which the devs prefer.) -- Duncan - List replies preferred. No HTML msgs. "Every nonfree program has a lord, a master -- and if you use the program, he is your master." Richard Stallman ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] btrfs-progs: Use named constants for common sizes 2017-07-27 21:02 ` Duncan @ 2017-08-22 14:31 ` David Sterba 0 siblings, 0 replies; 5+ messages in thread From: David Sterba @ 2017-08-22 14:31 UTC (permalink / raw) To: Duncan; +Cc: linux-btrfs On Thu, Jul 27, 2017 at 09:02:12PM +0000, Duncan wrote: > Nikolay Borisov posted on Thu, 27 Jul 2017 11:17:00 +0300 as excerpted: > > > diff --git a/convert/main.c b/convert/main.c > > index c56382e915fd..49ab829b5641 100644 > > --- a/convert/main.c > > +++ b/convert/main.c > > > @@ -1586,7 +1586,7 @@ next: > > * | RSV 1 | | Old | | RSV 2 | | Old | | RSV 3 | > > * | 0~1M | | Fs | | SB2 + 64K | | Fs | | SB3 + 64K | > > * > > - * On the other hande, the converted fs image in btrfs is a completely > > + * On the other hande, the converted fs image in btrfs is a completely > > * valid old fs. > > * > > * |<-----------------Converted fs image in btrfs-------------------->| > > If you're going to kill the line-terminating space, you might as well > do the spell-correct in the same line: > > s/hande/hand/ Fixed. ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 2/2] btrfs-progs: Use named constants for common sizes 2017-07-27 8:17 ` [PATCH 2/2] btrfs-progs: Use named constants for common sizes Nikolay Borisov 2017-07-27 21:02 ` Duncan @ 2017-08-22 14:31 ` David Sterba 1 sibling, 0 replies; 5+ messages in thread From: David Sterba @ 2017-08-22 14:31 UTC (permalink / raw) To: Nikolay Borisov; +Cc: linux-btrfs On Thu, Jul 27, 2017 at 11:17:00AM +0300, Nikolay Borisov wrote: > There multiple places where we use well-known sizes - 1,8,16,32 megabytes. We > also have them defined as constants in the sizes.h header. So let's use them. > No functional changes. Both applied, thanks. ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-08-22 14:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2017-07-27 8:16 [PATCH 1/2] btrfs-progs: Use already defined BTRFS_BLOCK_GROUP_PROFILE_MASK Nikolay Borisov 2017-07-27 8:17 ` [PATCH 2/2] btrfs-progs: Use named constants for common sizes Nikolay Borisov 2017-07-27 21:02 ` Duncan 2017-08-22 14:31 ` David Sterba 2017-08-22 14:31 ` David Sterba
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).