From: Kefu Chai Date: Mon, 11 May 2026 05:07:25 +0000 (+0800) Subject: crimson: use uint32_t when calling ioctl(BLKGETNRZONES) X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f8cde1e00fbf6d7b7815ec79a7340bd09fa54331;p=ceph.git crimson: use uint32_t when calling ioctl(BLKGETNRZONES) 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 --- diff --git a/src/crimson/os/seastore/segment_manager.cc b/src/crimson/os/seastore/segment_manager.cc index 899abf61c828..1252cc385973 100644 --- a/src/crimson/os/seastore/segment_manager.cc +++ b/src/crimson/os/seastore/segment_manager.cc @@ -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(device + "/block");