On Fri, Jun 12, 2020 at 09:00:58AM +0900, Daeho Jeong wrote: > For the incremental way of erasing, we might as well support the > (offset, length) option in a unit of 4KiB. > > So, you might use this ioctl like the below. Does it work for you? > struct f2fs_sec_trim { > u64 startblk; > u64 blklen; > u32 flags; > }; > > sectrim.startblk = 0; > sectrim.blklen = 256; // 1MiB > sectrim.flags = F2FS_TRIM_FILE_DISCARD | F2FS_TRIM_FILE_ZEROOUT; > ret = ioctl(fd, F2FS_SEC_TRIM_FILE, §rim);
Most filesystem ioctls and syscalls take offsets and lengths in bytes, especially newer ones. This way implementations of these APIs can support other alignments later. The implementation can still require alignment for now, i.e. return -EINVAL if !IS_ALIGNED(arg.pos | arg.len, sb->s_blocksize). Also, flags should be a u64, especially since it wouldn't actually increase the size of the struct (due to padding). - Eric