hammer2 - refactor filesystem sync 3/N
[dragonfly.git] / sys / vfs / hammer2 / hammer2_ioctl.h
1 /*
2  * Copyright (c) 2011-2018 The DragonFly Project.  All rights reserved.
3  *
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@dragonflybsd.org>
6  * by Venkatesh Srinivas <vsrinivas@dragonflybsd.org>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in
16  *    the documentation and/or other materials provided with the
17  *    distribution.
18  * 3. Neither the name of The DragonFly Project nor the names of its
19  *    contributors may be used to endorse or promote products derived
20  *    from this software without specific, prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
26  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33  * SUCH DAMAGE.
34  */
35
36 #ifndef _VFS_HAMMER2_IOCTL_H_
37 #define _VFS_HAMMER2_IOCTL_H_
38
39 #ifndef _SYS_IOCCOM_H_
40 #include <sys/ioccom.h>
41 #endif
42 #ifndef _VFS_HAMMER2_DISK_H_
43 #include "hammer2_disk.h"
44 #endif
45 #ifndef _VFS_HAMMER2_MOUNT_H_
46 #include "hammer2_mount.h"
47 #endif
48
49 /*
50  * get_version
51  */
52 struct hammer2_ioc_version {
53         int                     version;
54         char                    reserved[256 - 4];
55 };
56
57 typedef struct hammer2_ioc_version hammer2_ioc_version_t;
58
59 struct hammer2_ioc_recluster {
60         int                     fd;
61         char                    reserved[256 - 4];
62 };
63
64 typedef struct hammer2_ioc_recluster hammer2_ioc_recluster_t;
65
66 /*
67  * Ioctls to manage the volume->copyinfo[] array and to associate or
68  * disassociate sockets
69  */
70 struct hammer2_ioc_remote {
71         int                     copyid;
72         int                     nextid; /* for iteration (get only) */
73         int                     fd;     /* socket descriptor if applicable */
74         int                     reserved03;
75         int                     reserved04[8];
76         hammer2_volconf_t       copy1;  /* copy spec */
77         hammer2_volconf_t       copy2;  /* copy spec (rename ops only) */
78 };
79
80 typedef struct hammer2_ioc_remote hammer2_ioc_remote_t;
81
82 /*
83  * Ioctls to manage PFSs
84  *
85  * PFSs can be clustered by matching their pfs_clid, and the PFSs making up
86  * a cluster can be uniquely identified by combining the vol_id with
87  * the pfs_clid.
88  */
89 struct hammer2_ioc_pfs {
90         hammer2_key_t           name_key;       /* super-root directory scan */
91         hammer2_key_t           name_next;      /* (GET only) */
92         uint8_t                 pfs_type;       /* e.g. MASTER, SLAVE, ... */
93         uint8_t                 pfs_subtype;    /* e.g. SNAPSHOT */
94         uint8_t                 reserved0012;
95         uint8_t                 reserved0013;
96         uint32_t                pfs_flags;
97         uint64_t                reserved0018;
98         uuid_t                  pfs_fsid;       /* identifies PFS instance */
99         uuid_t                  pfs_clid;       /* identifies PFS cluster */
100         char                    name[NAME_MAX+1]; /* device@name mtpt */
101 };
102
103 typedef struct hammer2_ioc_pfs hammer2_ioc_pfs_t;
104
105 #define HAMMER2_PFSFLAGS_NOSYNC         0x00000001
106
107 /*
108  * Ioctls to manage inodes
109  */
110 struct hammer2_ioc_inode {
111         uint32_t                flags;
112         void                    *kdata;
113         hammer2_key_t           data_count;
114         hammer2_key_t           inode_count;
115         hammer2_inode_data_t    ip_data;
116 };
117
118 typedef struct hammer2_ioc_inode hammer2_ioc_inode_t;
119
120 #define HAMMER2IOC_INODE_FLAG_IQUOTA    0x00000001
121 #define HAMMER2IOC_INODE_FLAG_DQUOTA    0x00000002
122 #define HAMMER2IOC_INODE_FLAG_COPIES    0x00000004
123 #define HAMMER2IOC_INODE_FLAG_CHECK     0x00000008
124 #define HAMMER2IOC_INODE_FLAG_COMP      0x00000010
125
126 /*
127  * Ioctl for bulkfree scan
128  */
129 struct hammer2_ioc_bulkfree {
130         hammer2_off_t           sbase;  /* starting storage offset */
131         hammer2_off_t           sstop;  /* (set on return) */
132         size_t                  size;   /* swapable kernel memory to use */
133         hammer2_off_t           count_allocated;  /* alloc fixups this run */
134         hammer2_off_t           count_freed;      /* bytes freed this run */
135         hammer2_off_t           total_fragmented; /* merged result */
136         hammer2_off_t           total_allocated;  /* merged result */
137         hammer2_off_t           total_scanned;    /* bytes of storage */
138 };
139
140 typedef struct hammer2_ioc_bulkfree hammer2_ioc_bulkfree_t;
141
142 /*
143  * Unconditionally delete a hammer2 directory entry or inode number
144  */
145 struct hammer2_ioc_destroy {
146         enum { HAMMER2_DELETE_NOP,
147                HAMMER2_DELETE_FILE,
148                HAMMER2_DELETE_INUM } cmd;
149         char                    path[HAMMER2_INODE_MAXNAME];
150         hammer2_key_t           inum;
151 };
152
153 typedef struct hammer2_ioc_destroy hammer2_ioc_destroy_t;
154
155 /*
156  * Ioctl list
157  */
158
159 #define HAMMER2IOC_VERSION_GET  _IOWR('h', 64, struct hammer2_ioc_version)
160 #define HAMMER2IOC_RECLUSTER    _IOWR('h', 65, struct hammer2_ioc_recluster)
161
162 #define HAMMER2IOC_REMOTE_SCAN  _IOWR('h', 68, struct hammer2_ioc_remote)
163 #define HAMMER2IOC_REMOTE_ADD   _IOWR('h', 69, struct hammer2_ioc_remote)
164 #define HAMMER2IOC_REMOTE_DEL   _IOWR('h', 70, struct hammer2_ioc_remote)
165 #define HAMMER2IOC_REMOTE_REP   _IOWR('h', 71, struct hammer2_ioc_remote)
166
167 #define HAMMER2IOC_SOCKET_GET   _IOWR('h', 76, struct hammer2_ioc_remote)
168 #define HAMMER2IOC_SOCKET_SET   _IOWR('h', 77, struct hammer2_ioc_remote)
169
170 #define HAMMER2IOC_PFS_GET      _IOWR('h', 80, struct hammer2_ioc_pfs)
171 #define HAMMER2IOC_PFS_CREATE   _IOWR('h', 81, struct hammer2_ioc_pfs)
172 #define HAMMER2IOC_PFS_DELETE   _IOWR('h', 82, struct hammer2_ioc_pfs)
173 #define HAMMER2IOC_PFS_LOOKUP   _IOWR('h', 83, struct hammer2_ioc_pfs)
174 #define HAMMER2IOC_PFS_SNAPSHOT _IOWR('h', 84, struct hammer2_ioc_pfs)
175
176 #define HAMMER2IOC_INODE_GET    _IOWR('h', 86, struct hammer2_ioc_inode)
177 #define HAMMER2IOC_INODE_SET    _IOWR('h', 87, struct hammer2_ioc_inode)
178
179 /*#define HAMMER2IOC_INODE_COMP_SET     _IOWR('h', 88, struct hammer2_ioc_inode) //set compression mode on inode
180 #define HAMMER2IOC_INODE_COMP_REC_SET   _IOWR('h', 89, struct hammer2_ioc_inode)
181 #define HAMMER2IOC_INODE_COMP_REC_SET2  _IOWR('h', 90, struct hammer2_ioc_inode)*/
182 #define HAMMER2IOC_DEBUG_DUMP   _IOWR('h', 91, int)
183 #define HAMMER2IOC_BULKFREE_SCAN _IOWR('h', 92, struct hammer2_ioc_bulkfree)
184 #define HAMMER2IOC_BULKFREE_ASYNC _IOWR('h', 93, struct hammer2_ioc_bulkfree)
185
186 /*
187  * Delete a directory entry or inode number unconditionally.
188  */
189 #define HAMMER2IOC_DESTROY      _IOWR('h', 94, struct hammer2_ioc_destroy)
190
191 #endif /* !_VFS_HAMMER2_IOCTL_H_ */