HAMMER 42E/Many: Cleanup.
[dragonfly.git] / sys / vfs / hammer / hammer_ioctl.h
1 /*
2  * Copyright (c) 2008 The DragonFly Project.  All rights reserved.
3  * 
4  * This code is derived from software contributed to The DragonFly Project
5  * by Matthew Dillon <dillon@backplane.com>
6  * 
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of The DragonFly Project nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific, prior written permission.
20  * 
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32  * SUCH DAMAGE.
33  * 
34  * $DragonFly: src/sys/vfs/hammer/hammer_ioctl.h,v 1.7 2008/05/12 05:13:11 dillon Exp $
35  */
36 /*
37  * HAMMER ioctl's.  This file can be #included from userland
38  */
39
40 #ifndef VFS_HAMMER_IOCTL_H_
41 #define VFS_HAMMER_IOCTL_H_
42
43 #include <sys/types.h>
44 #include <sys/ioccom.h>
45 #include "hammer_disk.h"
46
47 /*
48  * Common HAMMER ioctl header
49  *
50  * Global flags are stored in the upper 16 bits
51  */
52 struct hammer_ioc_head {
53         int32_t         flags;
54         int32_t         reserved01;
55         int32_t         reserved02[4];
56 };
57
58 #define HAMMER_IOC_HEAD_INTR    0x00010000
59 #define HAMMER_IOC_DO_BTREE     0x00020000      /* reblocker */
60 #define HAMMER_IOC_DO_RECS      0x00040000      /* reblocker */
61 #define HAMMER_IOC_DO_DATA      0x00080000      /* reblocker */
62
63 #define HAMMER_IOC_DO_FLAGS     (HAMMER_IOC_DO_BTREE | HAMMER_IOC_DO_RECS | \
64                                  HAMMER_IOC_DO_DATA)
65
66 /*
67  * HAMMERIOC_PRUNE
68  *
69  * beg/end TID ranges in the element array must be sorted in descending
70  * order, with the most recent (highest) range at elms[0].
71  */
72 struct hammer_ioc_prune_elm {
73         hammer_tid_t    beg_tid;        /* starting tid */
74         hammer_tid_t    end_tid;        /* ending tid (non inclusive) */
75         hammer_tid_t    mod_tid;        /* modulo */
76 };
77
78 #define HAMMER_MAX_PRUNE_ELMS   64
79
80 struct hammer_ioc_prune {
81         struct hammer_ioc_head head;
82         int             nelms;
83         int             reserved01;
84         int64_t         beg_obj_id;
85         int64_t         cur_obj_id;
86         int64_t         cur_key;
87         int64_t         end_obj_id;      /* (range-exclusive) */
88         int64_t         stat_scanrecords;/* number of records scanned */
89         int64_t         stat_rawrecords; /* number of raw records pruned */
90         int64_t         stat_dirrecords; /* number of dir records pruned */
91         int64_t         stat_bytes;      /* number of data bytes pruned */
92         int64_t         stat_realignments; /* number of raw records realigned */
93         hammer_tid_t    stat_oldest_tid; /* oldest create_tid encountered */
94         int64_t         reserved02[6];
95         struct hammer_ioc_prune_elm elms[HAMMER_MAX_PRUNE_ELMS];
96 };
97
98 #define HAMMER_IOC_PRUNE_ALL    0x0001
99
100
101 /*
102  * HAMMERIOC_GETHISTORY
103  *
104  * Retrieve an array of ordered transaction ids >= beg and < end indicating
105  * all changes made to the specified object's inode up to the
106  * maximum.
107  *
108  * If ATKEY is set the key field indicates a particular key within the
109  * inode to retrieve the history for.
110  *
111  * On return count is set to the number of elements returned, nxt_tid is
112  * set to the tid the caller should store in beg_tid to continue the
113  * iteration, and nxt_key is set to the nearest key boundary > key
114  * indicating the range key - nxt_key (nxt_key non-inclusive) the tid
115  * array represents.  Also obj_id is set to the object's inode number.
116  *
117  * nxt_key can be used to iterate the contents of a single file but should
118  * not be stored in key until all modifications at key have been retrieved.
119  * To work properly nxt_key should be initialized to HAMMER_MAX_KEY.
120  * Successive ioctl() calls will reduce nxt_key as appropriate so at the
121  * end of your iterating for 'key', key to nxt_key will represent the
122  * shortest range of keys that all returned TIDs apply to.
123  */
124
125 #define HAMMER_MAX_HISTORY_ELMS 64
126
127 struct hammer_ioc_history {
128         struct hammer_ioc_head head;
129         int64_t         obj_id;
130         hammer_tid_t    beg_tid;
131         hammer_tid_t    nxt_tid;
132         hammer_tid_t    end_tid;
133         int64_t         key;
134         int64_t         nxt_key;
135         int             count;
136         int             reserve01;
137         hammer_tid_t    tid_ary[HAMMER_MAX_HISTORY_ELMS];
138 };
139
140 #define HAMMER_IOC_HISTORY_ATKEY        0x0001
141 #define HAMMER_IOC_HISTORY_NEXT_TID     0x0002  /* iterate via nxt_tid */
142 #define HAMMER_IOC_HISTORY_NEXT_KEY     0x0004  /* iterate via nxt_key */
143 #define HAMMER_IOC_HISTORY_EOF          0x0008  /* no more keys */
144 #define HAMMER_IOC_HISTORY_UNSYNCED     0x0010  /* unsynced info in inode */
145
146 /*
147  * Reblock request
148  */
149 struct hammer_ioc_reblock {
150         struct hammer_ioc_head head;
151         int64_t         beg_obj_id;
152         int64_t         cur_obj_id;             /* Stopped at (interrupt) */
153         int64_t         end_obj_id;
154         int32_t         free_level;             /* 0 for maximum compaction */
155         int32_t         unused01;
156
157         int64_t         btree_count;            /* B-Tree nodes checked */
158         int64_t         record_count;           /* Records checked */
159         int64_t         data_count;             /* Data segments checked */
160         int64_t         data_byte_count;        /* Data bytes checked */
161
162         int64_t         btree_moves;            /* B-Tree nodes moved */
163         int64_t         record_moves;           /* Records moved */
164         int64_t         data_moves;             /* Data segments moved */
165         int64_t         data_byte_moves;        /* Data bytes moved */
166
167         int32_t         unused02;
168         int32_t         unused03;
169 };
170
171 #define HAMMERIOC_PRUNE         _IOWR('h',1,struct hammer_ioc_prune)
172 #define HAMMERIOC_GETHISTORY    _IOWR('h',2,struct hammer_ioc_history)
173 #define HAMMERIOC_REBLOCK       _IOWR('h',3,struct hammer_ioc_reblock)
174
175 #endif