#include #include #include #include #include #include #ifndef PRJQUOTA #define PRJQUOTA 2 #endif /* * Speculative preallocation trimming. */ #define XFS_EOFBLOCKS_VERSION 1 struct xfs_eofblocks { __s32 eof_version; __u32 eof_flags; __u32 eof_q_id; __u32 eof_q_type; __u32 eof_min_file_size; unsigned char pad[12]; }; /* eof_flags values */ #define XFS_EOF_FLAGS_SYNC 0x01 /* sync/wait mode scan */ #define XFS_EOF_FLAGS_QUOTA 0x02 /* filter by quota id */ #define XFS_EOF_FLAGS_MINFILESIZE 0x04 /* filter by min file size */ #define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_eofblocks) int main(int argc, char *argv[]) { int ret, fd; struct xfs_eofblocks eofb; fd = open(argv[1], O_RDONLY); if (fd < 0) { perror("open"); return -1; } memset(&eofb, 0, sizeof(struct xfs_eofblocks)); eofb.eof_version = XFS_EOFBLOCKS_VERSION; eofb.eof_flags |= XFS_EOF_FLAGS_SYNC; //eofb.eof_flags |= XFS_EOF_FLAGS_QUOTA; //eofb.eof_q_id = 42; //eofb.eof_q_type = PRJQUOTA; eofb.eof_flags |= XFS_EOF_FLAGS_MINFILESIZE; eofb.eof_min_file_size = 1024 * 1024 * 101; ret = xfsctl(NULL, fd, XFS_IOC_FREE_EOFBLOCKS, &eofb); if (ret < 0) perror("xfsctl"); if (close(fd) < 0) perror("close"); return 0; }