162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * ocfs2_ioctl.h 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * Defines OCFS2 ioctls. 662306a36Sopenharmony_ci * 762306a36Sopenharmony_ci * Copyright (C) 2010 Oracle. All rights reserved. 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef OCFS2_IOCTL_H 1162306a36Sopenharmony_ci#define OCFS2_IOCTL_H 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci/* 1462306a36Sopenharmony_ci * Space reservation / allocation / free ioctls and argument structure 1562306a36Sopenharmony_ci * are designed to be compatible with XFS. 1662306a36Sopenharmony_ci * 1762306a36Sopenharmony_ci * ALLOCSP* and FREESP* are not and will never be supported, but are 1862306a36Sopenharmony_ci * included here for completeness. 1962306a36Sopenharmony_ci */ 2062306a36Sopenharmony_cistruct ocfs2_space_resv { 2162306a36Sopenharmony_ci __s16 l_type; 2262306a36Sopenharmony_ci __s16 l_whence; 2362306a36Sopenharmony_ci __s64 l_start; 2462306a36Sopenharmony_ci __s64 l_len; /* len == 0 means until end of file */ 2562306a36Sopenharmony_ci __s32 l_sysid; 2662306a36Sopenharmony_ci __u32 l_pid; 2762306a36Sopenharmony_ci __s32 l_pad[4]; /* reserve area */ 2862306a36Sopenharmony_ci}; 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv) 3162306a36Sopenharmony_ci#define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv) 3262306a36Sopenharmony_ci#define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv) 3362306a36Sopenharmony_ci#define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv) 3462306a36Sopenharmony_ci#define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv) 3562306a36Sopenharmony_ci#define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv) 3662306a36Sopenharmony_ci#define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv) 3762306a36Sopenharmony_ci#define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* Used to pass group descriptor data when online resize is done */ 4062306a36Sopenharmony_cistruct ocfs2_new_group_input { 4162306a36Sopenharmony_ci __u64 group; /* Group descriptor's blkno. */ 4262306a36Sopenharmony_ci __u32 clusters; /* Total number of clusters in this group */ 4362306a36Sopenharmony_ci __u32 frees; /* Total free clusters in this group */ 4462306a36Sopenharmony_ci __u16 chain; /* Chain for this group */ 4562306a36Sopenharmony_ci __u16 reserved1; 4662306a36Sopenharmony_ci __u32 reserved2; 4762306a36Sopenharmony_ci}; 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci#define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int) 5062306a36Sopenharmony_ci#define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input) 5162306a36Sopenharmony_ci#define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input) 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_ci/* Used to pass 2 file names to reflink. */ 5462306a36Sopenharmony_cistruct reflink_arguments { 5562306a36Sopenharmony_ci __u64 old_path; 5662306a36Sopenharmony_ci __u64 new_path; 5762306a36Sopenharmony_ci __u64 preserve; 5862306a36Sopenharmony_ci}; 5962306a36Sopenharmony_ci#define OCFS2_IOC_REFLINK _IOW('o', 4, struct reflink_arguments) 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* Following definitions dedicated for ocfs2_info_request ioctls. */ 6262306a36Sopenharmony_ci#define OCFS2_INFO_MAX_REQUEST (50) 6362306a36Sopenharmony_ci#define OCFS2_TEXT_UUID_LEN (OCFS2_VOL_UUID_LEN * 2) 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci/* Magic number of all requests */ 6662306a36Sopenharmony_ci#define OCFS2_INFO_MAGIC (0x4F32494E) 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci/* 6962306a36Sopenharmony_ci * Always try to separate info request into small pieces to 7062306a36Sopenharmony_ci * guarantee the backward&forward compatibility. 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_cistruct ocfs2_info { 7362306a36Sopenharmony_ci __u64 oi_requests; /* Array of __u64 pointers to requests */ 7462306a36Sopenharmony_ci __u32 oi_count; /* Number of requests in info_requests */ 7562306a36Sopenharmony_ci __u32 oi_pad; 7662306a36Sopenharmony_ci}; 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_cistruct ocfs2_info_request { 7962306a36Sopenharmony_ci/*00*/ __u32 ir_magic; /* Magic number */ 8062306a36Sopenharmony_ci __u32 ir_code; /* Info request code */ 8162306a36Sopenharmony_ci __u32 ir_size; /* Size of request */ 8262306a36Sopenharmony_ci __u32 ir_flags; /* Request flags */ 8362306a36Sopenharmony_ci/*10*/ /* Request specific fields */ 8462306a36Sopenharmony_ci}; 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_cistruct ocfs2_info_clustersize { 8762306a36Sopenharmony_ci struct ocfs2_info_request ic_req; 8862306a36Sopenharmony_ci __u32 ic_clustersize; 8962306a36Sopenharmony_ci __u32 ic_pad; 9062306a36Sopenharmony_ci}; 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_cistruct ocfs2_info_blocksize { 9362306a36Sopenharmony_ci struct ocfs2_info_request ib_req; 9462306a36Sopenharmony_ci __u32 ib_blocksize; 9562306a36Sopenharmony_ci __u32 ib_pad; 9662306a36Sopenharmony_ci}; 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_cistruct ocfs2_info_maxslots { 9962306a36Sopenharmony_ci struct ocfs2_info_request im_req; 10062306a36Sopenharmony_ci __u32 im_max_slots; 10162306a36Sopenharmony_ci __u32 im_pad; 10262306a36Sopenharmony_ci}; 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cistruct ocfs2_info_label { 10562306a36Sopenharmony_ci struct ocfs2_info_request il_req; 10662306a36Sopenharmony_ci __u8 il_label[OCFS2_MAX_VOL_LABEL_LEN]; 10762306a36Sopenharmony_ci} __attribute__ ((packed)); 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cistruct ocfs2_info_uuid { 11062306a36Sopenharmony_ci struct ocfs2_info_request iu_req; 11162306a36Sopenharmony_ci __u8 iu_uuid_str[OCFS2_TEXT_UUID_LEN + 1]; 11262306a36Sopenharmony_ci} __attribute__ ((packed)); 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_cistruct ocfs2_info_fs_features { 11562306a36Sopenharmony_ci struct ocfs2_info_request if_req; 11662306a36Sopenharmony_ci __u32 if_compat_features; 11762306a36Sopenharmony_ci __u32 if_incompat_features; 11862306a36Sopenharmony_ci __u32 if_ro_compat_features; 11962306a36Sopenharmony_ci __u32 if_pad; 12062306a36Sopenharmony_ci}; 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_cistruct ocfs2_info_journal_size { 12362306a36Sopenharmony_ci struct ocfs2_info_request ij_req; 12462306a36Sopenharmony_ci __u64 ij_journal_size; 12562306a36Sopenharmony_ci}; 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_cistruct ocfs2_info_freeinode { 12862306a36Sopenharmony_ci struct ocfs2_info_request ifi_req; 12962306a36Sopenharmony_ci struct ocfs2_info_local_freeinode { 13062306a36Sopenharmony_ci __u64 lfi_total; 13162306a36Sopenharmony_ci __u64 lfi_free; 13262306a36Sopenharmony_ci } ifi_stat[OCFS2_MAX_SLOTS]; 13362306a36Sopenharmony_ci __u32 ifi_slotnum; /* out */ 13462306a36Sopenharmony_ci __u32 ifi_pad; 13562306a36Sopenharmony_ci}; 13662306a36Sopenharmony_ci 13762306a36Sopenharmony_ci#define OCFS2_INFO_MAX_HIST (32) 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_cistruct ocfs2_info_freefrag { 14062306a36Sopenharmony_ci struct ocfs2_info_request iff_req; 14162306a36Sopenharmony_ci struct ocfs2_info_freefrag_stats { /* (out) */ 14262306a36Sopenharmony_ci struct ocfs2_info_free_chunk_list { 14362306a36Sopenharmony_ci __u32 fc_chunks[OCFS2_INFO_MAX_HIST]; 14462306a36Sopenharmony_ci __u32 fc_clusters[OCFS2_INFO_MAX_HIST]; 14562306a36Sopenharmony_ci } ffs_fc_hist; 14662306a36Sopenharmony_ci __u32 ffs_clusters; 14762306a36Sopenharmony_ci __u32 ffs_free_clusters; 14862306a36Sopenharmony_ci __u32 ffs_free_chunks; 14962306a36Sopenharmony_ci __u32 ffs_free_chunks_real; 15062306a36Sopenharmony_ci __u32 ffs_min; /* Minimum free chunksize in clusters */ 15162306a36Sopenharmony_ci __u32 ffs_max; 15262306a36Sopenharmony_ci __u32 ffs_avg; 15362306a36Sopenharmony_ci __u32 ffs_pad; 15462306a36Sopenharmony_ci } iff_ffs; 15562306a36Sopenharmony_ci __u32 iff_chunksize; /* chunksize in clusters(in) */ 15662306a36Sopenharmony_ci __u32 iff_pad; 15762306a36Sopenharmony_ci}; 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ci/* Codes for ocfs2_info_request */ 16062306a36Sopenharmony_cienum ocfs2_info_type { 16162306a36Sopenharmony_ci OCFS2_INFO_CLUSTERSIZE = 1, 16262306a36Sopenharmony_ci OCFS2_INFO_BLOCKSIZE, 16362306a36Sopenharmony_ci OCFS2_INFO_MAXSLOTS, 16462306a36Sopenharmony_ci OCFS2_INFO_LABEL, 16562306a36Sopenharmony_ci OCFS2_INFO_UUID, 16662306a36Sopenharmony_ci OCFS2_INFO_FS_FEATURES, 16762306a36Sopenharmony_ci OCFS2_INFO_JOURNAL_SIZE, 16862306a36Sopenharmony_ci OCFS2_INFO_FREEINODE, 16962306a36Sopenharmony_ci OCFS2_INFO_FREEFRAG, 17062306a36Sopenharmony_ci OCFS2_INFO_NUM_TYPES 17162306a36Sopenharmony_ci}; 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci/* Flags for struct ocfs2_info_request */ 17462306a36Sopenharmony_ci/* Filled by the caller */ 17562306a36Sopenharmony_ci#define OCFS2_INFO_FL_NON_COHERENT (0x00000001) /* Cluster coherency not 17662306a36Sopenharmony_ci required. This is a hint. 17762306a36Sopenharmony_ci It is up to ocfs2 whether 17862306a36Sopenharmony_ci the request can be fulfilled 17962306a36Sopenharmony_ci without locking. */ 18062306a36Sopenharmony_ci/* Filled by ocfs2 */ 18162306a36Sopenharmony_ci#define OCFS2_INFO_FL_FILLED (0x40000000) /* Filesystem understood 18262306a36Sopenharmony_ci this request and 18362306a36Sopenharmony_ci filled in the answer */ 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci#define OCFS2_INFO_FL_ERROR (0x80000000) /* Error happened during 18662306a36Sopenharmony_ci request handling. */ 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ci#define OCFS2_IOC_INFO _IOR('o', 5, struct ocfs2_info) 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_cistruct ocfs2_move_extents { 19162306a36Sopenharmony_ci/* All values are in bytes */ 19262306a36Sopenharmony_ci /* in */ 19362306a36Sopenharmony_ci __u64 me_start; /* Virtual start in the file to move */ 19462306a36Sopenharmony_ci __u64 me_len; /* Length of the extents to be moved */ 19562306a36Sopenharmony_ci __u64 me_goal; /* Physical offset of the goal, 19662306a36Sopenharmony_ci it's in block unit */ 19762306a36Sopenharmony_ci __u64 me_threshold; /* Maximum distance from goal or threshold 19862306a36Sopenharmony_ci for auto defragmentation */ 19962306a36Sopenharmony_ci __u64 me_flags; /* Flags for the operation: 20062306a36Sopenharmony_ci * - auto defragmentation. 20162306a36Sopenharmony_ci * - refcount,xattr cases. 20262306a36Sopenharmony_ci */ 20362306a36Sopenharmony_ci /* out */ 20462306a36Sopenharmony_ci __u64 me_moved_len; /* Moved/defraged length */ 20562306a36Sopenharmony_ci __u64 me_new_offset; /* Resulting physical location */ 20662306a36Sopenharmony_ci __u32 me_reserved[2]; /* Reserved for futhure */ 20762306a36Sopenharmony_ci}; 20862306a36Sopenharmony_ci 20962306a36Sopenharmony_ci#define OCFS2_MOVE_EXT_FL_AUTO_DEFRAG (0x00000001) /* Kernel manages to 21062306a36Sopenharmony_ci claim new clusters 21162306a36Sopenharmony_ci as the goal place 21262306a36Sopenharmony_ci for extents moving */ 21362306a36Sopenharmony_ci#define OCFS2_MOVE_EXT_FL_PART_DEFRAG (0x00000002) /* Allow partial extent 21462306a36Sopenharmony_ci moving, is to make 21562306a36Sopenharmony_ci movement less likely 21662306a36Sopenharmony_ci to fail, may make fs 21762306a36Sopenharmony_ci even more fragmented */ 21862306a36Sopenharmony_ci#define OCFS2_MOVE_EXT_FL_COMPLETE (0x00000004) /* Move or defragmenation 21962306a36Sopenharmony_ci completely gets done. 22062306a36Sopenharmony_ci */ 22162306a36Sopenharmony_ci 22262306a36Sopenharmony_ci#define OCFS2_IOC_MOVE_EXT _IOW('o', 6, struct ocfs2_move_extents) 22362306a36Sopenharmony_ci 22462306a36Sopenharmony_ci#endif /* OCFS2_IOCTL_H */ 225