* [PATCH] btrfs: Replace opencoded sizes with their symbolic constants
@ 2017-10-16 13:29 Nikolay Borisov
2017-10-16 13:41 ` David Sterba
0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2017-10-16 13:29 UTC (permalink / raw)
To: linux-btrfs; +Cc: dsterba, Nikolay Borisov
Currently btrfs' code uses a mix of opencoded sizes and defines from sizes.h.
Let's unifiy the code base to always use the symbolic constants. No functional
changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
fs/btrfs/ctree.h | 2 +-
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/file.c | 2 +-
fs/btrfs/raid56.c | 2 +-
fs/btrfs/super.c | 2 +-
fs/btrfs/tests/inode-tests.c | 2 +-
6 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e2afe524e25e..7bda8429e93f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -523,7 +523,7 @@ struct btrfs_caching_control {
};
/* Once caching_thread() finds this much free space, it will wake up waiters. */
-#define CACHING_CTL_WAKE_UP (1024 * 1024 * 2)
+#define CACHING_CTL_WAKE_UP SZ_2M
struct btrfs_io_ctl {
void *cur, *orig;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 69ce738c00d0..484cf8fc952c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2733,7 +2733,7 @@ int open_ctree(struct super_block *sb,
sb->s_bdi->congested_fn = btrfs_congested_fn;
sb->s_bdi->congested_data = fs_info;
sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
- sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
+ sb->s_bdi->ra_pages = VM_MAX_READAHEAD * SZ_1K / PAGE_SIZE;
sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
index d3c1725f03e4..7d338e497097 100644
--- a/fs/btrfs/file.c
+++ b/fs/btrfs/file.c
@@ -281,7 +281,7 @@ void btrfs_cleanup_defrag_inodes(struct btrfs_fs_info *fs_info)
spin_unlock(&fs_info->defrag_inodes_lock);
}
-#define BTRFS_DEFRAG_BATCH 1024
+#define BTRFS_DEFRAG_BATCH SZ_1K
static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
struct inode_defrag *defrag)
diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
index a7f79254ecca..553172271913 100644
--- a/fs/btrfs/raid56.c
+++ b/fs/btrfs/raid56.c
@@ -58,7 +58,7 @@
*/
#define RBIO_CACHE_READY_BIT 3
-#define RBIO_CACHE_SIZE 1024
+#define RBIO_CACHE_SIZE SZ_1K
enum btrfs_rbio_ops {
BTRFS_RBIO_WRITE,
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6b279d873440..72160cf5d934 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2126,7 +2126,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
* succeed even if the Avail is zero. But this is better than the other
* way around.
*/
- thresh = 4 * 1024 * 1024;
+ thresh = SZ_4M;
if (!mixed && total_free_meta - thresh < block_rsv->size)
buf->f_bavail = 0;
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
index 8c91d03cc82d..330815eb07b4 100644
--- a/fs/btrfs/tests/inode-tests.c
+++ b/fs/btrfs/tests/inode-tests.c
@@ -770,7 +770,7 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
offset = em->start + em->len;
free_extent_map(em);
- em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, 4096 * 1024, 0);
+ em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, SZ_4M, 0);
if (IS_ERR(em)) {
test_msg("Got an error when we shouldn't have\n");
goto out;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] btrfs: Replace opencoded sizes with their symbolic constants
2017-10-16 13:29 [PATCH] btrfs: Replace opencoded sizes with their symbolic constants Nikolay Borisov
@ 2017-10-16 13:41 ` David Sterba
2017-10-16 13:48 ` [PATCH v2] " Nikolay Borisov
0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2017-10-16 13:41 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: linux-btrfs, dsterba
On Mon, Oct 16, 2017 at 04:29:56PM +0300, Nikolay Borisov wrote:
> Currently btrfs' code uses a mix of opencoded sizes and defines from sizes.h.
> Let's unifiy the code base to always use the symbolic constants. No functional
> changes
>
> -#define BTRFS_DEFRAG_BATCH 1024
> +#define BTRFS_DEFRAG_BATCH SZ_1K
This is a number, not a size, so the SZ_ constant is misleading
> static int __btrfs_run_defrag_inode(struct btrfs_fs_info *fs_info,
> struct inode_defrag *defrag)
> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c
> index a7f79254ecca..553172271913 100644
> --- a/fs/btrfs/raid56.c
> +++ b/fs/btrfs/raid56.c
> @@ -58,7 +58,7 @@
> */
> #define RBIO_CACHE_READY_BIT 3
>
> -#define RBIO_CACHE_SIZE 1024
> +#define RBIO_CACHE_SIZE SZ_1K
Same here.
The rest is ok.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2] btrfs: Replace opencoded sizes with their symbolic constants
2017-10-16 13:41 ` David Sterba
@ 2017-10-16 13:48 ` Nikolay Borisov
2017-10-16 14:51 ` David Sterba
0 siblings, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2017-10-16 13:48 UTC (permalink / raw)
To: dsterba; +Cc: linux-btrfs, Nikolay Borisov
Currently btrfs' code uses a mix of opencoded sizes and defines from sizes.h.
Let's unifiy the code base to always use the symbolic constants. No functional
changes
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
Changes since v1:
* Don't modify values which represent counts rather than bytes
fs/btrfs/ctree.h | 2 +-
fs/btrfs/disk-io.c | 2 +-
fs/btrfs/super.c | 2 +-
fs/btrfs/tests/inode-tests.c | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index e2afe524e25e..7bda8429e93f 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -523,7 +523,7 @@ struct btrfs_caching_control {
};
/* Once caching_thread() finds this much free space, it will wake up waiters. */
-#define CACHING_CTL_WAKE_UP (1024 * 1024 * 2)
+#define CACHING_CTL_WAKE_UP SZ_2M
struct btrfs_io_ctl {
void *cur, *orig;
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 69ce738c00d0..484cf8fc952c 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -2733,7 +2733,7 @@ int open_ctree(struct super_block *sb,
sb->s_bdi->congested_fn = btrfs_congested_fn;
sb->s_bdi->congested_data = fs_info;
sb->s_bdi->capabilities |= BDI_CAP_CGROUP_WRITEBACK;
- sb->s_bdi->ra_pages = VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
+ sb->s_bdi->ra_pages = VM_MAX_READAHEAD * SZ_1K / PAGE_SIZE;
sb->s_bdi->ra_pages *= btrfs_super_num_devices(disk_super);
sb->s_bdi->ra_pages = max(sb->s_bdi->ra_pages, SZ_4M / PAGE_SIZE);
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index 6b279d873440..72160cf5d934 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -2126,7 +2126,7 @@ static int btrfs_statfs(struct dentry *dentry, struct kstatfs *buf)
* succeed even if the Avail is zero. But this is better than the other
* way around.
*/
- thresh = 4 * 1024 * 1024;
+ thresh = SZ_4M;
if (!mixed && total_free_meta - thresh < block_rsv->size)
buf->f_bavail = 0;
diff --git a/fs/btrfs/tests/inode-tests.c b/fs/btrfs/tests/inode-tests.c
index 8c91d03cc82d..330815eb07b4 100644
--- a/fs/btrfs/tests/inode-tests.c
+++ b/fs/btrfs/tests/inode-tests.c
@@ -770,7 +770,7 @@ static noinline int test_btrfs_get_extent(u32 sectorsize, u32 nodesize)
offset = em->start + em->len;
free_extent_map(em);
- em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, 4096 * 1024, 0);
+ em = btrfs_get_extent(BTRFS_I(inode), NULL, 0, offset, SZ_4M, 0);
if (IS_ERR(em)) {
test_msg("Got an error when we shouldn't have\n");
goto out;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] btrfs: Replace opencoded sizes with their symbolic constants
2017-10-16 13:48 ` [PATCH v2] " Nikolay Borisov
@ 2017-10-16 14:51 ` David Sterba
0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2017-10-16 14:51 UTC (permalink / raw)
To: Nikolay Borisov; +Cc: dsterba, linux-btrfs
On Mon, Oct 16, 2017 at 04:48:40PM +0300, Nikolay Borisov wrote:
> Currently btrfs' code uses a mix of opencoded sizes and defines from sizes.h.
> Let's unifiy the code base to always use the symbolic constants. No functional
> changes
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-16 14:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-16 13:29 [PATCH] btrfs: Replace opencoded sizes with their symbolic constants Nikolay Borisov
2017-10-16 13:41 ` David Sterba
2017-10-16 13:48 ` [PATCH v2] " Nikolay Borisov
2017-10-16 14:51 ` 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).