12910a90cSMatthew Dillon /* 2c007fe63SMatthew Dillon * Copyright (c) 2011-2020 The DragonFly Project. All rights reserved. 32910a90cSMatthew Dillon * 42910a90cSMatthew Dillon * This code is derived from software contributed to The DragonFly Project 52910a90cSMatthew Dillon * by Matthew Dillon <dillon@dragonflybsd.org> 62910a90cSMatthew Dillon * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org> 72910a90cSMatthew Dillon * 82910a90cSMatthew Dillon * Redistribution and use in source and binary forms, with or without 92910a90cSMatthew Dillon * modification, are permitted provided that the following conditions 102910a90cSMatthew Dillon * are met: 112910a90cSMatthew Dillon * 122910a90cSMatthew Dillon * 1. Redistributions of source code must retain the above copyright 132910a90cSMatthew Dillon * notice, this list of conditions and the following disclaimer. 142910a90cSMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright 152910a90cSMatthew Dillon * notice, this list of conditions and the following disclaimer in 162910a90cSMatthew Dillon * the documentation and/or other materials provided with the 172910a90cSMatthew Dillon * distribution. 182910a90cSMatthew Dillon * 3. Neither the name of The DragonFly Project nor the names of its 192910a90cSMatthew Dillon * contributors may be used to endorse or promote products derived 202910a90cSMatthew Dillon * from this software without specific, prior written permission. 212910a90cSMatthew Dillon * 222910a90cSMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 232910a90cSMatthew Dillon * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 242910a90cSMatthew Dillon * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 252910a90cSMatthew Dillon * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 262910a90cSMatthew Dillon * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 272910a90cSMatthew Dillon * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, 282910a90cSMatthew Dillon * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 292910a90cSMatthew Dillon * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 302910a90cSMatthew Dillon * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 312910a90cSMatthew Dillon * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 322910a90cSMatthew Dillon * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 332910a90cSMatthew Dillon * SUCH DAMAGE. 342910a90cSMatthew Dillon */ 35210a0869SSascha Wildner 36210a0869SSascha Wildner #ifndef _VFS_HAMMER2_IOCTL_H_ 37210a0869SSascha Wildner #define _VFS_HAMMER2_IOCTL_H_ 382910a90cSMatthew Dillon 39a8607002STomohiro Kusumi #include <sys/param.h> 40a8607002STomohiro Kusumi #include <sys/syslimits.h> 41a8607002STomohiro Kusumi 422910a90cSMatthew Dillon #ifndef _SYS_IOCCOM_H_ 432910a90cSMatthew Dillon #include <sys/ioccom.h> 442910a90cSMatthew Dillon #endif 452910a90cSMatthew Dillon #ifndef _VFS_HAMMER2_DISK_H_ 462910a90cSMatthew Dillon #include "hammer2_disk.h" 472910a90cSMatthew Dillon #endif 482910a90cSMatthew Dillon #ifndef _VFS_HAMMER2_MOUNT_H_ 492910a90cSMatthew Dillon #include "hammer2_mount.h" 502910a90cSMatthew Dillon #endif 512910a90cSMatthew Dillon 522910a90cSMatthew Dillon /* 532910a90cSMatthew Dillon * get_version 542910a90cSMatthew Dillon */ 552910a90cSMatthew Dillon struct hammer2_ioc_version { 562910a90cSMatthew Dillon int version; 572910a90cSMatthew Dillon char reserved[256 - 4]; 582910a90cSMatthew Dillon }; 592910a90cSMatthew Dillon 602910a90cSMatthew Dillon typedef struct hammer2_ioc_version hammer2_ioc_version_t; 612910a90cSMatthew Dillon 621a34728cSMatthew Dillon struct hammer2_ioc_recluster { 631a34728cSMatthew Dillon int fd; 641a34728cSMatthew Dillon char reserved[256 - 4]; 651a34728cSMatthew Dillon }; 661a34728cSMatthew Dillon 671a34728cSMatthew Dillon typedef struct hammer2_ioc_recluster hammer2_ioc_recluster_t; 681a34728cSMatthew Dillon 692910a90cSMatthew Dillon /* 702910a90cSMatthew Dillon * Ioctls to manage the volume->copyinfo[] array and to associate or 712910a90cSMatthew Dillon * disassociate sockets 722910a90cSMatthew Dillon */ 732910a90cSMatthew Dillon struct hammer2_ioc_remote { 742910a90cSMatthew Dillon int copyid; 752910a90cSMatthew Dillon int nextid; /* for iteration (get only) */ 762910a90cSMatthew Dillon int fd; /* socket descriptor if applicable */ 772910a90cSMatthew Dillon int reserved03; 782910a90cSMatthew Dillon int reserved04[8]; 791f179146SMatthew Dillon hammer2_volconf_t copy1; /* copy spec */ 801f179146SMatthew Dillon hammer2_volconf_t copy2; /* copy spec (rename ops only) */ 812910a90cSMatthew Dillon }; 822910a90cSMatthew Dillon 832910a90cSMatthew Dillon typedef struct hammer2_ioc_remote hammer2_ioc_remote_t; 842910a90cSMatthew Dillon 85ae183399SMatthew Dillon /* 86ae183399SMatthew Dillon * Ioctls to manage PFSs 87ae183399SMatthew Dillon * 888c280d5dSMatthew Dillon * PFSs can be clustered by matching their pfs_clid, and the PFSs making up 89ae183399SMatthew Dillon * a cluster can be uniquely identified by combining the vol_id with 908c280d5dSMatthew Dillon * the pfs_clid. 91ae183399SMatthew Dillon */ 92ae183399SMatthew Dillon struct hammer2_ioc_pfs { 93ae183399SMatthew Dillon hammer2_key_t name_key; /* super-root directory scan */ 94ae183399SMatthew Dillon hammer2_key_t name_next; /* (GET only) */ 95ae183399SMatthew Dillon uint8_t pfs_type; /* e.g. MASTER, SLAVE, ... */ 9622211834SMatthew Dillon uint8_t pfs_subtype; /* e.g. SNAPSHOT */ 97ae183399SMatthew Dillon uint8_t reserved0012; 98ae183399SMatthew Dillon uint8_t reserved0013; 990d66a712SMatthew Dillon uint32_t pfs_flags; 100ae183399SMatthew Dillon uint64_t reserved0018; 101ae183399SMatthew Dillon uuid_t pfs_fsid; /* identifies PFS instance */ 1028c280d5dSMatthew Dillon uuid_t pfs_clid; /* identifies PFS cluster */ 103913bc49bSTomohiro Kusumi char name[NAME_MAX+1]; /* PFS label */ 104ae183399SMatthew Dillon }; 1052910a90cSMatthew Dillon 106ae183399SMatthew Dillon typedef struct hammer2_ioc_pfs hammer2_ioc_pfs_t; 1072910a90cSMatthew Dillon 1083e8408dbSMatthew Dillon #define HAMMER2_PFSFLAGS_NOSYNC 0x00000001 1093e8408dbSMatthew Dillon 110344d4f82SMatthew Dillon /* 111344d4f82SMatthew Dillon * Ioctls to manage inodes 112344d4f82SMatthew Dillon */ 113344d4f82SMatthew Dillon struct hammer2_ioc_inode { 114344d4f82SMatthew Dillon uint32_t flags; 11544a0e418STomohiro Kusumi void *unused; 11629cbd7e5SMatthew Dillon hammer2_key_t data_count; 11729cbd7e5SMatthew Dillon hammer2_key_t inode_count; 118344d4f82SMatthew Dillon hammer2_inode_data_t ip_data; 119344d4f82SMatthew Dillon }; 120344d4f82SMatthew Dillon 121344d4f82SMatthew Dillon typedef struct hammer2_ioc_inode hammer2_ioc_inode_t; 122344d4f82SMatthew Dillon 123344d4f82SMatthew Dillon #define HAMMER2IOC_INODE_FLAG_IQUOTA 0x00000001 124344d4f82SMatthew Dillon #define HAMMER2IOC_INODE_FLAG_DQUOTA 0x00000002 125344d4f82SMatthew Dillon #define HAMMER2IOC_INODE_FLAG_COPIES 0x00000004 126b7add675SMatthew Dillon #define HAMMER2IOC_INODE_FLAG_CHECK 0x00000008 127b7add675SMatthew Dillon #define HAMMER2IOC_INODE_FLAG_COMP 0x00000010 128344d4f82SMatthew Dillon 129344d4f82SMatthew Dillon /* 1303148f677SMatthew Dillon * Ioctl for bulkfree scan 1313148f677SMatthew Dillon */ 1323148f677SMatthew Dillon struct hammer2_ioc_bulkfree { 1333148f677SMatthew Dillon hammer2_off_t sbase; /* starting storage offset */ 1343148f677SMatthew Dillon hammer2_off_t sstop; /* (set on return) */ 1353148f677SMatthew Dillon size_t size; /* swapable kernel memory to use */ 1363148f677SMatthew Dillon hammer2_off_t count_allocated; /* alloc fixups this run */ 1373148f677SMatthew Dillon hammer2_off_t count_freed; /* bytes freed this run */ 1383148f677SMatthew Dillon hammer2_off_t total_fragmented; /* merged result */ 1393148f677SMatthew Dillon hammer2_off_t total_allocated; /* merged result */ 1403148f677SMatthew Dillon hammer2_off_t total_scanned; /* bytes of storage */ 1413148f677SMatthew Dillon }; 1423148f677SMatthew Dillon 1433148f677SMatthew Dillon typedef struct hammer2_ioc_bulkfree hammer2_ioc_bulkfree_t; 1443148f677SMatthew Dillon 1453148f677SMatthew Dillon /* 146f6aebb44SMatthew Dillon * Unconditionally delete a hammer2 directory entry or inode number 147f6aebb44SMatthew Dillon */ 148f6aebb44SMatthew Dillon struct hammer2_ioc_destroy { 149f6aebb44SMatthew Dillon enum { HAMMER2_DELETE_NOP, 150f6aebb44SMatthew Dillon HAMMER2_DELETE_FILE, 151f6aebb44SMatthew Dillon HAMMER2_DELETE_INUM } cmd; 152f6aebb44SMatthew Dillon char path[HAMMER2_INODE_MAXNAME]; 153f6aebb44SMatthew Dillon hammer2_key_t inum; 154f6aebb44SMatthew Dillon }; 155f6aebb44SMatthew Dillon 156f6aebb44SMatthew Dillon typedef struct hammer2_ioc_destroy hammer2_ioc_destroy_t; 157f6aebb44SMatthew Dillon 158f6aebb44SMatthew Dillon /* 159c007fe63SMatthew Dillon * Grow the filesystem. If size is set to 0 H2 will auto-size to the 160c007fe63SMatthew Dillon * partition it is in. The caller can resize the partition, then issue 161c007fe63SMatthew Dillon * the ioctl. 162c007fe63SMatthew Dillon */ 163c007fe63SMatthew Dillon struct hammer2_ioc_growfs { 164c007fe63SMatthew Dillon hammer2_off_t size; 165c007fe63SMatthew Dillon int modified; 166c007fe63SMatthew Dillon int unused01; 167c007fe63SMatthew Dillon int unusedary[14]; 168c007fe63SMatthew Dillon }; 169c007fe63SMatthew Dillon 170c007fe63SMatthew Dillon typedef struct hammer2_ioc_growfs hammer2_ioc_growfs_t; 171c007fe63SMatthew Dillon 172c007fe63SMatthew Dillon /* 173*0b738157STomohiro Kusumi * Ioctls to manage volumes 174*0b738157STomohiro Kusumi */ 175*0b738157STomohiro Kusumi struct hammer2_ioc_volume { 176*0b738157STomohiro Kusumi char path[MAXPATHLEN]; 177*0b738157STomohiro Kusumi int id; 178*0b738157STomohiro Kusumi hammer2_off_t offset; 179*0b738157STomohiro Kusumi hammer2_off_t size; 180*0b738157STomohiro Kusumi }; 181*0b738157STomohiro Kusumi 182*0b738157STomohiro Kusumi typedef struct hammer2_ioc_volume hammer2_ioc_volume_t; 183*0b738157STomohiro Kusumi 184*0b738157STomohiro Kusumi struct hammer2_ioc_volume_list { 185*0b738157STomohiro Kusumi hammer2_ioc_volume_t *volumes; 186*0b738157STomohiro Kusumi int nvolumes; 187*0b738157STomohiro Kusumi int version; 188*0b738157STomohiro Kusumi char pfs_name[HAMMER2_INODE_MAXNAME]; 189*0b738157STomohiro Kusumi }; 190*0b738157STomohiro Kusumi 191*0b738157STomohiro Kusumi typedef struct hammer2_ioc_volume_list hammer2_ioc_volume_list_t; 192*0b738157STomohiro Kusumi 193*0b738157STomohiro Kusumi /* 194344d4f82SMatthew Dillon * Ioctl list 195344d4f82SMatthew Dillon */ 196344d4f82SMatthew Dillon 197ae183399SMatthew Dillon #define HAMMER2IOC_VERSION_GET _IOWR('h', 64, struct hammer2_ioc_version) 1981a34728cSMatthew Dillon #define HAMMER2IOC_RECLUSTER _IOWR('h', 65, struct hammer2_ioc_recluster) 199ae183399SMatthew Dillon 2001a34728cSMatthew Dillon #define HAMMER2IOC_REMOTE_SCAN _IOWR('h', 68, struct hammer2_ioc_remote) 201ae183399SMatthew Dillon #define HAMMER2IOC_REMOTE_ADD _IOWR('h', 69, struct hammer2_ioc_remote) 202ae183399SMatthew Dillon #define HAMMER2IOC_REMOTE_DEL _IOWR('h', 70, struct hammer2_ioc_remote) 203ae183399SMatthew Dillon #define HAMMER2IOC_REMOTE_REP _IOWR('h', 71, struct hammer2_ioc_remote) 204ae183399SMatthew Dillon 205ae183399SMatthew Dillon #define HAMMER2IOC_SOCKET_GET _IOWR('h', 76, struct hammer2_ioc_remote) 206ae183399SMatthew Dillon #define HAMMER2IOC_SOCKET_SET _IOWR('h', 77, struct hammer2_ioc_remote) 207ae183399SMatthew Dillon 208ae183399SMatthew Dillon #define HAMMER2IOC_PFS_GET _IOWR('h', 80, struct hammer2_ioc_pfs) 209ae183399SMatthew Dillon #define HAMMER2IOC_PFS_CREATE _IOWR('h', 81, struct hammer2_ioc_pfs) 210ae183399SMatthew Dillon #define HAMMER2IOC_PFS_DELETE _IOWR('h', 82, struct hammer2_ioc_pfs) 211458ecb1bSMatthew Dillon #define HAMMER2IOC_PFS_LOOKUP _IOWR('h', 83, struct hammer2_ioc_pfs) 212a864c5d9SMatthew Dillon #define HAMMER2IOC_PFS_SNAPSHOT _IOWR('h', 84, struct hammer2_ioc_pfs) 2132910a90cSMatthew Dillon 214344d4f82SMatthew Dillon #define HAMMER2IOC_INODE_GET _IOWR('h', 86, struct hammer2_ioc_inode) 215344d4f82SMatthew Dillon #define HAMMER2IOC_INODE_SET _IOWR('h', 87, struct hammer2_ioc_inode) 216344d4f82SMatthew Dillon 217acbbd0efSMatthew Dillon /* 218acbbd0efSMatthew Dillon * 88, 89, 90 - old copmression ioctls, now reserved 219acbbd0efSMatthew Dillon * 220acbbd0efSMatthew Dillon * 94 - note that this deletes a directory entry or inode number 221acbbd0efSMatthew Dillon * unconditionally. 222acbbd0efSMatthew Dillon */ 22303188ed8SMatthew Dillon #define HAMMER2IOC_DEBUG_DUMP _IOWR('h', 91, int) 2243148f677SMatthew Dillon #define HAMMER2IOC_BULKFREE_SCAN _IOWR('h', 92, struct hammer2_ioc_bulkfree) 2259dca9515SMatthew Dillon #define HAMMER2IOC_BULKFREE_ASYNC _IOWR('h', 93, struct hammer2_ioc_bulkfree) 226f6aebb44SMatthew Dillon #define HAMMER2IOC_DESTROY _IOWR('h', 94, struct hammer2_ioc_destroy) 227acbbd0efSMatthew Dillon #define HAMMER2IOC_EMERG_MODE _IOWR('h', 95, int) 228c007fe63SMatthew Dillon #define HAMMER2IOC_GROWFS _IOWR('h', 96, struct hammer2_ioc_growfs) 229*0b738157STomohiro Kusumi #define HAMMER2IOC_VOLUME_LIST _IOWR('h', 97, struct hammer2_ioc_volume_list) 230f6aebb44SMatthew Dillon 231210a0869SSascha Wildner #endif /* !_VFS_HAMMER2_IOCTL_H_ */ 232