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.10 2005/08/24 20:28:33 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 #define MOUNTCTL_RESTART_VFS_JOURNAL 5 54 55 #define MOUNTCTL_INSTALL_BLK_JOURNAL 8 56 #define MOUNTCTL_REMOVE_BLK_JOURNAL 9 57 #define MOUNTCTL_RESYNC_BLK_JOURNAL 10 58 #define MOUNTCTL_STATUS_BLK_JOURNAL 11 59 60 struct mountctl_install_journal { 61 char id[JIDMAX]; 62 int flags; /* journaling flags */ 63 int unused01; 64 int64_t membufsize; /* backing store */ 65 int64_t swapbufsize; /* backing store */ 66 int64_t transid; /* starting with specified transaction id */ 67 int64_t unused02; 68 int stallwarn; /* stall warning (seconds) */ 69 int stallerror; /* stall error (seconds) */ 70 int unused03; 71 int unused04; 72 }; 73 74 #define MC_JOURNAL_UNUSED0001 0x00000001 75 #define MC_JOURNAL_STOP_REQ 0x00000002 /* stop request pend */ 76 #define MC_JOURNAL_STOP_IMM 0x00000004 /* STOP+trash fifo */ 77 #define MC_JOURNAL_WACTIVE 0x00000008 /* wthread running */ 78 #define MC_JOURNAL_RACTIVE 0x00000010 /* rthread running */ 79 #define MC_JOURNAL_WWAIT 0x00000040 /* write stall */ 80 #define MC_JOURNAL_WANT_AUDIT 0x00010000 /* audit trail */ 81 #define MC_JOURNAL_WANT_REVERSABLE 0x00020000 /* reversable stream */ 82 #define MC_JOURNAL_WANT_FULLDUPLEX 0x00040000 /* has ack stream */ 83 84 struct mountctl_restart_journal { 85 char id[JIDMAX]; 86 int flags; 87 int unused01; 88 }; 89 90 struct mountctl_remove_journal { 91 char id[JIDMAX]; 92 int flags; 93 }; 94 95 #define MC_JOURNAL_REMOVE_TRASH 0x00000001 /* data -> trash */ 96 #define MC_JOURNAL_REMOVE_ASSYNC 0x00000002 /* asynchronous op */ 97 98 struct mountctl_status_journal { 99 char id[JIDMAX]; 100 int index; 101 }; 102 103 #define MC_JOURNAL_INDEX_ALL -2 104 #define MC_JOURNAL_INDEX_ID -1 105 106 struct mountctl_journal_ret_status { 107 int recsize; 108 char id[JIDMAX]; 109 int index; 110 int flags; 111 int64_t membufsize; 112 int64_t membufused; 113 int64_t membufunacked; 114 int64_t swapbufsize; 115 int64_t swapbufused; 116 int64_t swapbufunacked; 117 int64_t transidstart; 118 int64_t transidcurrent; 119 int64_t transidunacked; 120 int64_t transidacked; 121 int64_t bytessent; 122 int64_t bytesacked; 123 int64_t fifostalls; 124 int64_t reserved[4]; 125 struct timeval lastack; 126 }; 127 128 #define MC_JOURNAL_STATUS_MORETOCOME 0x00000001 129 130 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) 131 132 /* 133 * Support structures for the generic journaling structure 134 */ 135 struct journal_memfifo { 136 int size; /* size (power of two) */ 137 int mask; /* index mask (size - 1) */ 138 int rindex; /* stream reader index (track fd writes) */ 139 int xindex; /* last acked / reader restart */ 140 int windex; /* stream writer index */ 141 char *membase; /* memory buffer representing the FIFO */ 142 }; 143 144 /* 145 * Generic journaling structure attached to a mount point. 146 */ 147 struct journal { 148 TAILQ_ENTRY(journal) jentry; 149 struct file *fp; 150 char id[JIDMAX]; 151 int flags; /* journaling flags */ 152 int64_t transid; 153 int64_t total_acked; 154 int64_t fifostalls; 155 struct journal_memfifo fifo; 156 struct thread wthread; 157 struct thread rthread; 158 }; 159 160 161 /* 162 * The jrecord structure is used to build a journaling transaction. Since 163 * a single journaling transaction might encompass very large buffers it 164 * is possible for multiple transactions to be written out to the FIFO 165 * in parallel and in peacemeal. 166 */ 167 struct jrecord { 168 struct journal *jo; 169 char *stream_ptr; 170 int stream_residual; 171 int stream_reserved; 172 struct journal_rawrecbeg *rawp; 173 struct journal_subrecord *parent; 174 struct journal_subrecord *last; 175 int16_t streamid; 176 int pushcount; 177 int pushptrgood; 178 int residual; 179 int residual_align; 180 181 /* 182 * These fields are not used by the jrecord routines. They may 183 * be used by higher level routines to manage multiple jrecords. 184 * See the jreclist_*() functions. 185 */ 186 TAILQ_ENTRY(jrecord) user_entry; 187 void *user_save; 188 }; 189 190 TAILQ_HEAD(jrecord_list, jrecord); 191 192 #endif 193 #endif 194