]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: use uint32_t when calling ioctl(BLKGETNRZONES)
authorKefu Chai <k.chai@proxmox.com>
Mon, 11 May 2026 05:07:25 +0000 (13:07 +0800)
committerKefu Chai <k.chai@proxmox.com>
Tue, 12 May 2026 03:03:03 +0000 (11:03 +0800)
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>
src/crimson/os/seastore/segment_manager.cc

index 899abf61c828e84a81e2c353683c3fbf4e5d9d4b..1252cc3859733c295f6d976d7cf41fd652061883 100644 (file)
@@ -38,8 +38,8 @@ SegmentManager::get_segment_manager(
        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");