before this change, we pass a pointer to a `size_t` to
ioctl(BLKGETNRZONES), but in the Linux kernel,
include/uapi/linux/blkzoned.h:
```c
#define BLKGETNRZONES _IOR(0x12, 133, __u32)
```
this API reads 32 bits of data into the pointer. on 64-bit
architectures, size_t is 64 bits. fortunately, we initialize
nr_zones with 0, so the upper 32 bits remain zero. this works
on little-endian systems, but not on big-endian systems. it is
also semantically wrong. we should pass a pointer to a 32-bit
value when calling ioctl(BLKGETNRZONES).
in this change, we change the type of nr_zones from size_t to
uint32_t to match what the Linux kernel expects.
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
device + "/block",
seastar::open_flags::rw);
ceph_assert(file);
- size_t nr_zones = 0;
- [[maybe_unused]] auto ret = co_await file.ioctl(BLKGETNRZONES, (void *)&nr_zones);
+ uint32_t nr_zones = 0;
+ [[maybe_unused]] auto ret = co_await file.ioctl(BLKGETNRZONES, &nr_zones);
INFO("Found {} zones.", nr_zones);
if (nr_zones != 0) {
co_return std::make_unique<segment_manager::zbd::ZBDSegmentManager>(device + "/block");