btrfs-progs: print error when zeroing device fails in device_zero_blocks()

Use the template to be verbose about device zeroing failure, this can be
called repeatedly.

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2024-03-16 18:55:37 +01:00
parent 060f7d6c81
commit 054b314fbe

View File

@ -112,8 +112,11 @@ int device_zero_blocks(int fd, off_t start, size_t len, bool direct)
return -ENOMEM;
memset(buf, 0, len);
written = btrfs_pwrite(fd, buf, len, start, direct);
if (written != len)
if (written != len) {
error_msg(ERROR_MSG_WRITE, "zeroing range from %llu: %m",
(unsigned long long)start);
ret = -EIO;
}
free(buf);
return ret;
}