* [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set
@ 2019-08-07 8:21 Anand Jain
2019-08-07 8:21 ` [PATCH 2/2] btrfs: opencode to reset all devices stat Anand Jain
2019-08-07 14:18 ` [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Anand Jain @ 2019-08-07 8:21 UTC (permalink / raw)
To: linux-btrfs
btrfs_dev_stat_reset() is an overdo in terms of wrapping. So this patch
open codes btrfs_dev_stat_reset().
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/volumes.c | 6 +++---
fs/btrfs/volumes.h | 6 ------
2 files changed, 3 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ea9ff506681a..3eed7968fe16 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -7316,7 +7316,7 @@ static void __btrfs_reset_dev_stats(struct btrfs_device *dev)
int i;
for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
- btrfs_dev_stat_reset(dev, i);
+ btrfs_dev_stat_set(dev, i, 0);
}
int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
@@ -7366,7 +7366,7 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
btrfs_dev_stat_set(device, i,
btrfs_dev_stats_value(eb, ptr, i));
else
- btrfs_dev_stat_reset(device, i);
+ btrfs_dev_stat_set(device, i, 0);
}
device->dev_stats_valid = 1;
@@ -7549,7 +7549,7 @@ int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
stats->values[i] =
btrfs_dev_stat_read_and_reset(dev, i);
else
- btrfs_dev_stat_reset(dev, i);
+ btrfs_dev_stat_set(dev, i, 0);
}
} else {
for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h
index 081cb734a239..a7da1f3e3627 100644
--- a/fs/btrfs/volumes.h
+++ b/fs/btrfs/volumes.h
@@ -547,12 +547,6 @@ static inline void btrfs_dev_stat_set(struct btrfs_device *dev,
atomic_inc(&dev->dev_stats_ccnt);
}
-static inline void btrfs_dev_stat_reset(struct btrfs_device *dev,
- int index)
-{
- btrfs_dev_stat_set(dev, index, 0);
-}
-
/*
* Convert block group flags (BTRFS_BLOCK_GROUP_*) to btrfs_raid_types, which
* can be used as index to access btrfs_raid_array[].
--
2.21.0 (Apple Git-120)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] btrfs: opencode to reset all devices stat
2019-08-07 8:21 [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set Anand Jain
@ 2019-08-07 8:21 ` Anand Jain
2019-08-07 14:18 ` [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Anand Jain @ 2019-08-07 8:21 UTC (permalink / raw)
To: linux-btrfs
__btrfs_reset_dev_stats() is a small helper function to reset devices stat
values, and is used only once, instead just open code it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
fs/btrfs/volumes.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 3eed7968fe16..492342973c3c 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -191,7 +191,6 @@ out_overflow:;
static int init_first_rw_device(struct btrfs_trans_handle *trans);
static int btrfs_relocate_sys_chunks(struct btrfs_fs_info *fs_info);
-static void __btrfs_reset_dev_stats(struct btrfs_device *dev);
static void btrfs_dev_stat_print_on_error(struct btrfs_device *dev);
static void btrfs_dev_stat_print_on_load(struct btrfs_device *device);
static int __btrfs_map_block(struct btrfs_fs_info *fs_info,
@@ -7311,14 +7310,6 @@ void btrfs_init_devices_late(struct btrfs_fs_info *fs_info)
}
}
-static void __btrfs_reset_dev_stats(struct btrfs_device *dev)
-{
- int i;
-
- for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
- btrfs_dev_stat_set(dev, i, 0);
-}
-
int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
{
struct btrfs_key key;
@@ -7348,7 +7339,8 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info)
key.offset = device->devid;
ret = btrfs_search_slot(NULL, dev_root, &key, path, 0, 0);
if (ret) {
- __btrfs_reset_dev_stats(device);
+ for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
+ btrfs_dev_stat_set(device, i, 0);
device->dev_stats_valid = 1;
btrfs_release_path(path);
continue;
--
2.21.0 (Apple Git-120)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set
2019-08-07 8:21 [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set Anand Jain
2019-08-07 8:21 ` [PATCH 2/2] btrfs: opencode to reset all devices stat Anand Jain
@ 2019-08-07 14:18 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2019-08-07 14:18 UTC (permalink / raw)
To: Anand Jain; +Cc: linux-btrfs
On Wed, Aug 07, 2019 at 04:21:19PM +0800, Anand Jain wrote:
> btrfs_dev_stat_reset() is an overdo in terms of wrapping. So this patch
> open codes btrfs_dev_stat_reset().
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
for both patches.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-08-07 14:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07 8:21 [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set Anand Jain
2019-08-07 8:21 ` [PATCH 2/2] btrfs: opencode to reset all devices stat Anand Jain
2019-08-07 14:18 ` [PATCH 1/2] btrfs: reset device stat using btrfs_dev_stat_set 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).