Journaling layer work. Generate output for path names, creds, and vattr,
[dragonfly.git] / sys / sys / mountctl.h
1 /*
2  * Copyright (c) 2004 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/sys/mountctl.h,v 1.6 2005/02/28 17:40:51 dillon Exp $
35  */
36
37 #ifndef _SYS_MOUNTCTL_H_
38 #define _SYS_MOUNTCTL_H_
39 /*
40  * General constants
41  */
42
43 #define JIDMAX          32      /* id string buf[] size (incls \0) */
44
45 /*
46  * Data structures for the journaling API
47  */
48
49 #define MOUNTCTL_INSTALL_VFS_JOURNAL    1
50 #define MOUNTCTL_REMOVE_VFS_JOURNAL     2
51 #define MOUNTCTL_RESYNC_VFS_JOURNAL     3
52 #define MOUNTCTL_STATUS_VFS_JOURNAL     4
53
54 #define MOUNTCTL_INSTALL_BLK_JOURNAL    8
55 #define MOUNTCTL_REMOVE_BLK_JOURNAL     9
56 #define MOUNTCTL_RESYNC_BLK_JOURNAL     10
57 #define MOUNTCTL_STATUS_BLK_JOURNAL     11
58
59 struct mountctl_install_journal {
60         char    id[JIDMAX];
61         int     flags;          /* journaling flags */
62         int     unused01;
63         int64_t membufsize;     /* backing store */
64         int64_t swapbufsize;    /* backing store */
65         int64_t transid;        /* starting with specified transaction id */
66         int64_t unused02;
67         int     stallwarn;      /* stall warning (seconds) */
68         int     stallerror;     /* stall error (seconds) */
69         int     unused03;
70         int     unused04;
71 };
72
73 #define MC_JOURNAL_ACTIVE               0x00000001      /* journal is active */
74 #define MC_JOURNAL_STOP_REQ             0x00000002      /* stop request pend */
75 #define MC_JOURNAL_STOP_IMM             0x00000004      /* STOP+trash fifo */
76 #define MC_JOURNAL_WWAIT                0x00000040      /* write stall */
77 #define MC_JOURNAL_WANT_AUDIT           0x00010000      /* audit trail */
78 #define MC_JOURNAL_WANT_REVERSABLE      0x00020000      /* reversable stream */
79
80 struct mountctl_remove_journal {
81         char    id[JIDMAX];
82         int     flags;
83 };
84
85 #define MC_JOURNAL_REMOVE_TRASH         0x00000001      /* data -> trash */
86 #define MC_JOURNAL_REMOVE_ASSYNC        0x00000002      /* asynchronous op */
87
88 struct mountctl_status_journal {
89         char    id[JIDMAX];
90         int     index;
91 };
92
93 #define MC_JOURNAL_INDEX_ALL            -2
94 #define MC_JOURNAL_INDEX_ID             -1
95
96 struct mountctl_journal_ret_status {
97         int     recsize;
98         char    id[JIDMAX];
99         int     index;
100         int     flags;
101         int64_t membufsize;
102         int64_t membufused;
103         int64_t membufiopend;
104         int64_t swapbufsize;
105         int64_t swapbufused;
106         int64_t swapbufiopend;
107         int64_t transidstart;
108         int64_t transidcurrent;
109         int64_t transidiopend;
110         int64_t transidacked;
111         int64_t bytessent;
112         int64_t bytesacked;
113         struct timeval lastack;
114 };
115
116 #define MC_JOURNAL_STATUS_MORETOCOME    0x00000001
117
118 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
119
120 /*
121  * Support structures for the generic journaling structure
122  */
123 struct journal_memfifo {
124         int     size;           /* size (power of two) */
125         int     mask;           /* index mask (size - 1) */
126         int     rindex;         /* stream reader index (track fd writes) */
127         int     xindex;         /* last acked / reader restart */
128         int     windex;         /* stream writer index */
129         char    *membase;       /* memory buffer representing the FIFO */
130 };
131
132 /*
133  * Generic journaling structure attached to a mount point.
134  */
135 struct journal {
136         TAILQ_ENTRY(journal) jentry;
137         struct file     *fp;
138         char            id[JIDMAX];
139         int             flags;          /* journaling flags */
140         int64_t         transid;
141         int64_t         total_acked;
142         struct journal_memfifo fifo;
143         struct thread   thread;
144 };
145
146 /*
147  * The jrecord structure is used to build a journaling transaction.  Since
148  * a single journaling transaction might encompass very large buffers it 
149  * is possible for multiple transactions to be written out to the FIFO
150  * in parallel and in peacemeal.
151  */
152 struct jrecord {
153         struct journal  *jo;
154         char            *stream_ptr;
155         int             stream_residual;
156         int             stream_reserved;
157         struct journal_rawrecbeg *rawp;
158         struct journal_subrecord *parent;
159         struct journal_subrecord *last;
160         int16_t         streamid;
161         int             pushcount;
162         int             pushptrgood;
163         int             residual;
164         int             residual_align;
165 };
166
167 #endif
168 #endif