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 <dsterba@suse.com>
This commit is contained in:
David Sterba 2021-04-29 18:36:44 +02:00
parent 2b5d4f2e6f
commit c7b5f884e0
3 changed files with 9 additions and 6 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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;
}