From c7b5f884e0db6cc53e0907a55e956e888e25b989 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 29 Apr 2021 18:36:44 +0200 Subject: [PATCH] btrfs-progs: add prefix to zero_blocks This is a public helper for devices, add the prefix to make it clear. Signed-off-by: David Sterba --- common/device-utils.c | 7 +++++-- common/device-utils.h | 2 +- kernel-shared/zoned.c | 6 +++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common/device-utils.c b/common/device-utils.c index 50773873..09fa938d 100644 --- a/common/device-utils.c +++ b/common/device-utils.c @@ -68,7 +68,10 @@ int device_discard_blocks(int fd, u64 start, u64 len) return 0; } -int zero_blocks(int fd, off_t start, size_t len) +/* + * Write zeros to the given range [start, start + len) + */ +int device_zero_blocks(int fd, off_t start, size_t len) { char *buf = malloc(len); int ret = 0; @@ -104,7 +107,7 @@ static int zero_dev_clamped(int fd, struct btrfs_zoned_device_info *zinfo, if (zinfo && zinfo->model == ZONED_HOST_MANAGED) return zero_zone_blocks(fd, zinfo, start, end - start); - return zero_blocks(fd, start, end - start); + return device_zero_blocks(fd, start, end - start); } static int btrfs_wipe_existing_sb(int fd, struct btrfs_zoned_device_info *zinfo) diff --git a/common/device-utils.h b/common/device-utils.h index 1c11abed..f83ac560 100644 --- a/common/device-utils.h +++ b/common/device-utils.h @@ -26,7 +26,7 @@ #define PREP_DEVICE_ZONED (1U << 3) int device_discard_blocks(int fd, u64 start, u64 len); -int zero_blocks(int fd, off_t start, size_t len); +int device_zero_blocks(int fd, off_t start, size_t len); u64 get_partition_size(const char *dev); u64 disk_size(const char *path); u64 btrfs_device_size(int fd, struct stat *st); diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c index 778815c9..a08184ff 100644 --- a/kernel-shared/zoned.c +++ b/kernel-shared/zoned.c @@ -398,15 +398,15 @@ int zero_zone_blocks(int fd, struct btrfs_zoned_device_info *zinfo, off_t start, size_t count; int ret; - /* Make sure that zero_blocks does not write sequential zones */ + /* Make sure that device_zero_blocks does not write sequential zones */ while (len > 0) { - /* Limit zero_blocks to a single zone */ + /* Limit device_zero_blocks to a single zone */ count = min_t(size_t, len, zone_len); if (count > zone_len - (ofst & (zone_len - 1))) count = zone_len - (ofst & (zone_len - 1)); if (!zone_is_sequential(zinfo, ofst)) { - ret = zero_blocks(fd, ofst, count); + ret = device_zero_blocks(fd, ofst, count); if (ret != 0) return ret; }