29f9b2b7d6c79bd9064f35adb52037e7430cad62
[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.2 2004/12/29 02:40:03 dillon Exp $
35  */
36
37 /*
38  * General constants
39  */
40
41 #define JIDMAX          32      /* id string buf[] size (incls \0) */
42
43 /*
44  * Data structures for the journaling API
45  */
46
47 #define MOUNTCTL_INSTALL_VFS_JOURNAL    1
48 #define MOUNTCTL_REMOVE_VFS_JOURNAL     2
49 #define MOUNTCTL_RESYNC_VFS_JOURNAL     3
50 #define MOUNTCTL_JOURNAL_VFS_STATUS     4
51
52 #define MOUNTCTL_INSTALL_BLK_JOURNAL    8
53 #define MOUNTCTL_REMOVE_BLK_JOURNAL     9
54 #define MOUNTCTL_RESYNC_BLK_JOURNAL     10
55 #define MOUNTCTL_JOURNAL_BLK_STATUS     11
56
57 struct mountctl_install_journal {
58         char    id[JIDMAX];
59         int     flags;          /* journaling flags */
60         int     unused01;
61         int64_t membufsize;     /* backing store */
62         int64_t swapbufsize;    /* backing store */
63         int64_t transid;        /* starting with specified transaction id */
64         int64_t unused02;
65         int     stallwarn;      /* stall warning (seconds) */
66         int     stallerror;     /* stall error (seconds) */
67         int     unused03;
68         int     unused04;
69 };
70
71 #define MC_JOURNAL_REVERSABLE           0x00000001      /* reversable log */
72 #define MC_JOURNAL_BINARY               0x00000002      /* use binary format */
73 #define MC_JOURNAL_ACTIVE               0x00000004      /* journal is active */
74 #define MC_JOURNAL_STREAM_TWO_WAY       0x00000008      /* trans id ack */
75 #define MC_JOURNAL_STOP_REQ             0x00000010      /* stop request pend */
76 #define MC_JOURNAL_STOP_IMM             0x00000020      /* do not flush */
77 #define MC_JOURNAL_WWAIT                0x00000040      /* write stall */
78 #define MC_JOURNAL_MBSIZE_PROVIDED      0x00000200      /* data space */
79 #define MC_JOURNAL_SWSIZE_PROVIDED      0x00000400      /* data space */
80 #define MC_JOURNAL_TRANSID_PROVIDED     0x00000800      /* restart transid */
81 #define MC_JOURNAL_STALLWARN_PROVIDED   0x00001000      /* restart transid */
82 #define MC_JOURNAL_STALLERROR_PROVIDED  0x00002000      /* restart transid */
83
84 struct mountctl_remove_journal {
85         char    id[JIDMAX];
86         int     flags;
87 };
88
89 #define MC_JOURNAL_REMOVE_TRASH         0x00000001      /* data -> trash */
90 #define MC_JOURNAL_REMOVE_ASSYNC        0x00000002      /* asynchronous op */
91
92 struct mountctl_journal_status {
93         char    id[JIDMAX];
94         int     flags;
95         int64_t membufsize;
96         int64_t membufused;
97         int64_t membufqueued;
98         int64_t swapbufsize;
99         int64_t swapbufused;
100         int64_t swapbufqueued;
101         int64_t transidstart;
102         int64_t transidcurrent;
103         int64_t transidqueued;
104         int64_t transidacked;
105         int64_t bytessent;
106         int64_t bytesacked;
107         struct timeval lastack;
108 };
109
110 #define MC_JOURNAL_STATUS_NEXT          0x80000000      /* find next id */
111
112 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
113
114 /*
115  * Support structures for the generic journaling structure
116  */
117 struct journal_memfifo {
118         int     size;           /* size (power of two) */
119         int     mask;           /* index mask (size - 1) */
120         int     rindex;         /* stream reader index */
121         int     xindex;         /* last acked / reader restart */
122         int     windex;         /* stream writer index */
123         char    *membase;       /* memory buffer representing the FIFO */
124 };
125
126 /*
127  * Generic journaling structure attached to a mount point.
128  */
129 struct journal {
130         TAILQ_ENTRY(journal) jentry;
131         struct file     *fp;
132         char    id[JIDMAX];
133         int     flags;          /* journaling flags */
134         int64_t transid;
135         struct journal_memfifo fifo;
136         struct thread   thread;
137 };
138
139 #endif