Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * ocfs2_ioctl.h
0004  *
0005  * Defines OCFS2 ioctls.
0006  *
0007  * Copyright (C) 2010 Oracle.  All rights reserved.
0008  */
0009 
0010 #ifndef OCFS2_IOCTL_H
0011 #define OCFS2_IOCTL_H
0012 
0013 /*
0014  * Space reservation / allocation / free ioctls and argument structure
0015  * are designed to be compatible with XFS.
0016  *
0017  * ALLOCSP* and FREESP* are not and will never be supported, but are
0018  * included here for completeness.
0019  */
0020 struct ocfs2_space_resv {
0021     __s16       l_type;
0022     __s16       l_whence;
0023     __s64       l_start;
0024     __s64       l_len;      /* len == 0 means until end of file */
0025     __s32       l_sysid;
0026     __u32       l_pid;
0027     __s32       l_pad[4];   /* reserve area             */
0028 };
0029 
0030 #define OCFS2_IOC_ALLOCSP       _IOW ('X', 10, struct ocfs2_space_resv)
0031 #define OCFS2_IOC_FREESP        _IOW ('X', 11, struct ocfs2_space_resv)
0032 #define OCFS2_IOC_RESVSP        _IOW ('X', 40, struct ocfs2_space_resv)
0033 #define OCFS2_IOC_UNRESVSP  _IOW ('X', 41, struct ocfs2_space_resv)
0034 #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
0035 #define OCFS2_IOC_FREESP64  _IOW ('X', 37, struct ocfs2_space_resv)
0036 #define OCFS2_IOC_RESVSP64  _IOW ('X', 42, struct ocfs2_space_resv)
0037 #define OCFS2_IOC_UNRESVSP64    _IOW ('X', 43, struct ocfs2_space_resv)
0038 
0039 /* Used to pass group descriptor data when online resize is done */
0040 struct ocfs2_new_group_input {
0041     __u64 group;        /* Group descriptor's blkno. */
0042     __u32 clusters;     /* Total number of clusters in this group */
0043     __u32 frees;        /* Total free clusters in this group */
0044     __u16 chain;        /* Chain for this group */
0045     __u16 reserved1;
0046     __u32 reserved2;
0047 };
0048 
0049 #define OCFS2_IOC_GROUP_EXTEND  _IOW('o', 1, int)
0050 #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
0051 #define OCFS2_IOC_GROUP_ADD64   _IOW('o', 3,struct ocfs2_new_group_input)
0052 
0053 /* Used to pass 2 file names to reflink. */
0054 struct reflink_arguments {
0055     __u64 old_path;
0056     __u64 new_path;
0057     __u64 preserve;
0058 };
0059 #define OCFS2_IOC_REFLINK   _IOW('o', 4, struct reflink_arguments)
0060 
0061 /* Following definitions dedicated for ocfs2_info_request ioctls. */
0062 #define OCFS2_INFO_MAX_REQUEST      (50)
0063 #define OCFS2_TEXT_UUID_LEN     (OCFS2_VOL_UUID_LEN * 2)
0064 
0065 /* Magic number of all requests */
0066 #define OCFS2_INFO_MAGIC        (0x4F32494E)
0067 
0068 /*
0069  * Always try to separate info request into small pieces to
0070  * guarantee the backward&forward compatibility.
0071  */
0072 struct ocfs2_info {
0073     __u64 oi_requests;  /* Array of __u64 pointers to requests */
0074     __u32 oi_count;     /* Number of requests in info_requests */
0075     __u32 oi_pad;
0076 };
0077 
0078 struct ocfs2_info_request {
0079 /*00*/  __u32 ir_magic; /* Magic number */
0080     __u32 ir_code;  /* Info request code */
0081     __u32 ir_size;  /* Size of request */
0082     __u32 ir_flags; /* Request flags */
0083 /*10*/          /* Request specific fields */
0084 };
0085 
0086 struct ocfs2_info_clustersize {
0087     struct ocfs2_info_request ic_req;
0088     __u32 ic_clustersize;
0089     __u32 ic_pad;
0090 };
0091 
0092 struct ocfs2_info_blocksize {
0093     struct ocfs2_info_request ib_req;
0094     __u32 ib_blocksize;
0095     __u32 ib_pad;
0096 };
0097 
0098 struct ocfs2_info_maxslots {
0099     struct ocfs2_info_request im_req;
0100     __u32 im_max_slots;
0101     __u32 im_pad;
0102 };
0103 
0104 struct ocfs2_info_label {
0105     struct ocfs2_info_request il_req;
0106     __u8    il_label[OCFS2_MAX_VOL_LABEL_LEN];
0107 } __attribute__ ((packed));
0108 
0109 struct ocfs2_info_uuid {
0110     struct ocfs2_info_request iu_req;
0111     __u8    iu_uuid_str[OCFS2_TEXT_UUID_LEN + 1];
0112 } __attribute__ ((packed));
0113 
0114 struct ocfs2_info_fs_features {
0115     struct ocfs2_info_request if_req;
0116     __u32 if_compat_features;
0117     __u32 if_incompat_features;
0118     __u32 if_ro_compat_features;
0119     __u32 if_pad;
0120 };
0121 
0122 struct ocfs2_info_journal_size {
0123     struct ocfs2_info_request ij_req;
0124     __u64 ij_journal_size;
0125 };
0126 
0127 struct ocfs2_info_freeinode {
0128     struct ocfs2_info_request ifi_req;
0129     struct ocfs2_info_local_freeinode {
0130         __u64 lfi_total;
0131         __u64 lfi_free;
0132     } ifi_stat[OCFS2_MAX_SLOTS];
0133     __u32 ifi_slotnum; /* out */
0134     __u32 ifi_pad;
0135 };
0136 
0137 #define OCFS2_INFO_MAX_HIST     (32)
0138 
0139 struct ocfs2_info_freefrag {
0140     struct ocfs2_info_request iff_req;
0141     struct ocfs2_info_freefrag_stats { /* (out) */
0142         struct ocfs2_info_free_chunk_list {
0143             __u32 fc_chunks[OCFS2_INFO_MAX_HIST];
0144             __u32 fc_clusters[OCFS2_INFO_MAX_HIST];
0145         } ffs_fc_hist;
0146         __u32 ffs_clusters;
0147         __u32 ffs_free_clusters;
0148         __u32 ffs_free_chunks;
0149         __u32 ffs_free_chunks_real;
0150         __u32 ffs_min; /* Minimum free chunksize in clusters */
0151         __u32 ffs_max;
0152         __u32 ffs_avg;
0153         __u32 ffs_pad;
0154     } iff_ffs;
0155     __u32 iff_chunksize; /* chunksize in clusters(in) */
0156     __u32 iff_pad;
0157 };
0158 
0159 /* Codes for ocfs2_info_request */
0160 enum ocfs2_info_type {
0161     OCFS2_INFO_CLUSTERSIZE = 1,
0162     OCFS2_INFO_BLOCKSIZE,
0163     OCFS2_INFO_MAXSLOTS,
0164     OCFS2_INFO_LABEL,
0165     OCFS2_INFO_UUID,
0166     OCFS2_INFO_FS_FEATURES,
0167     OCFS2_INFO_JOURNAL_SIZE,
0168     OCFS2_INFO_FREEINODE,
0169     OCFS2_INFO_FREEFRAG,
0170     OCFS2_INFO_NUM_TYPES
0171 };
0172 
0173 /* Flags for struct ocfs2_info_request */
0174 /* Filled by the caller */
0175 #define OCFS2_INFO_FL_NON_COHERENT  (0x00000001)    /* Cluster coherency not
0176                                required. This is a hint.
0177                                It is up to ocfs2 whether
0178                                the request can be fulfilled
0179                                without locking. */
0180 /* Filled by ocfs2 */
0181 #define OCFS2_INFO_FL_FILLED        (0x40000000)    /* Filesystem understood
0182                                this request and
0183                                filled in the answer */
0184 
0185 #define OCFS2_INFO_FL_ERROR     (0x80000000)    /* Error happened during
0186                                request handling. */
0187 
0188 #define OCFS2_IOC_INFO      _IOR('o', 5, struct ocfs2_info)
0189 
0190 struct ocfs2_move_extents {
0191 /* All values are in bytes */
0192     /* in */
0193     __u64 me_start;     /* Virtual start in the file to move */
0194     __u64 me_len;       /* Length of the extents to be moved */
0195     __u64 me_goal;      /* Physical offset of the goal,
0196                    it's in block unit */
0197     __u64 me_threshold; /* Maximum distance from goal or threshold
0198                    for auto defragmentation */
0199     __u64 me_flags;     /* Flags for the operation:
0200                  * - auto defragmentation.
0201                  * - refcount,xattr cases.
0202                  */
0203     /* out */
0204     __u64 me_moved_len; /* Moved/defraged length */
0205     __u64 me_new_offset;    /* Resulting physical location */
0206     __u32 me_reserved[2];   /* Reserved for futhure */
0207 };
0208 
0209 #define OCFS2_MOVE_EXT_FL_AUTO_DEFRAG   (0x00000001)    /* Kernel manages to
0210                                claim new clusters
0211                                as the goal place
0212                                for extents moving */
0213 #define OCFS2_MOVE_EXT_FL_PART_DEFRAG   (0x00000002)    /* Allow partial extent
0214                                moving, is to make
0215                                movement less likely
0216                                to fail, may make fs
0217                                even more fragmented */
0218 #define OCFS2_MOVE_EXT_FL_COMPLETE  (0x00000004)    /* Move or defragmenation
0219                                completely gets done.
0220                              */
0221 
0222 #define OCFS2_IOC_MOVE_EXT  _IOW('o', 6, struct ocfs2_move_extents)
0223 
0224 #endif /* OCFS2_IOCTL_H */