diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index 152e5fa3b..8544040f5 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -7,6 +7,7 @@ use std::io::{Error, Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, RawFd}; use io_uring::{IoUring, opcode, types}; +use libc::{FALLOC_FL_KEEP_SIZE, FALLOC_FL_PUNCH_HOLE, FALLOC_FL_ZERO_RANGE}; use log::warn; use vmm_sys_util::eventfd::EventFd; @@ -268,8 +269,6 @@ impl AsyncIo for RawFileAsync { fn punch_hole(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> { let (submitter, mut sq, _) = self.io_uring.split(); - const FALLOC_FL_PUNCH_HOLE: i32 = 0x02; - const FALLOC_FL_KEEP_SIZE: i32 = 0x01; let mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; // SAFETY: The file descriptor is known to be valid. @@ -295,8 +294,6 @@ impl AsyncIo for RawFileAsync { fn write_zeroes(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> { let (submitter, mut sq, _) = self.io_uring.split(); - const FALLOC_FL_ZERO_RANGE: i32 = 0x10; - const FALLOC_FL_KEEP_SIZE: i32 = 0x01; let mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE; // SAFETY: The file descriptor is known to be valid. diff --git a/block/src/raw_async_aio.rs b/block/src/raw_async_aio.rs index 7f66ce411..f59e463b4 100644 --- a/block/src/raw_async_aio.rs +++ b/block/src/raw_async_aio.rs @@ -10,6 +10,7 @@ use std::fs::File; use std::io::{Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, RawFd}; +use libc::{FALLOC_FL_KEEP_SIZE, FALLOC_FL_PUNCH_HOLE, FALLOC_FL_ZERO_RANGE}; use log::warn; use vmm_sys_util::aio; use vmm_sys_util::eventfd::EventFd; @@ -189,8 +190,6 @@ impl AsyncIo for RawFileAsyncAio { // Linux AIO has no IOCB command for fallocate, so perform the operation // synchronously and signal completion via the completion list, matching // the pattern used by the sync backend (RawFileSync). - const FALLOC_FL_PUNCH_HOLE: i32 = 0x02; - const FALLOC_FL_KEEP_SIZE: i32 = 0x01; let mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; // SAFETY: FFI call with valid arguments @@ -216,8 +215,6 @@ impl AsyncIo for RawFileAsyncAio { // Linux AIO has no IOCB command for fallocate, so perform the operation // synchronously and signal completion via the completion list, matching // the pattern used by the sync backend (RawFileSync). - const FALLOC_FL_ZERO_RANGE: i32 = 0x10; - const FALLOC_FL_KEEP_SIZE: i32 = 0x01; let mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE; // SAFETY: FFI call with valid arguments diff --git a/block/src/raw_sync.rs b/block/src/raw_sync.rs index 0e60a48a7..b9f89dde0 100644 --- a/block/src/raw_sync.rs +++ b/block/src/raw_sync.rs @@ -7,6 +7,7 @@ use std::fs::File; use std::io::{Seek, SeekFrom}; use std::os::unix::io::{AsRawFd, RawFd}; +use libc::{FALLOC_FL_KEEP_SIZE, FALLOC_FL_PUNCH_HOLE, FALLOC_FL_ZERO_RANGE}; use log::warn; use vmm_sys_util::eventfd::EventFd; @@ -161,8 +162,6 @@ impl AsyncIo for RawFileSync { } fn punch_hole(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> { - const FALLOC_FL_PUNCH_HOLE: i32 = 0x02; - const FALLOC_FL_KEEP_SIZE: i32 = 0x01; let mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE; // SAFETY: FFI call with valid arguments @@ -185,8 +184,6 @@ impl AsyncIo for RawFileSync { } fn write_zeroes(&mut self, offset: u64, length: u64, user_data: u64) -> AsyncIoResult<()> { - const FALLOC_FL_ZERO_RANGE: i32 = 0x10; - const FALLOC_FL_KEEP_SIZE: i32 = 0x01; let mode = FALLOC_FL_ZERO_RANGE | FALLOC_FL_KEEP_SIZE; // SAFETY: FFI call with valid arguments