1 #ifndef __INTERMEZZO_KML_H 2 #define __INTERMEZZO_KML_H 3 4 #include <linux/version.h> 5 #include <linux/intermezzo_psdev.h> 6 #include <linux/fs.h> 7 #include <linux/intermezzo_journal.h> 8 9 #define PRESTO_KML_MAJOR_VERSION 0x00010000 10 #define PRESTO_KML_MINOR_VERSION 0x00002001 11 #define PRESTO_OP_NOOP 0 12 #define PRESTO_OP_CREATE 1 13 #define PRESTO_OP_MKDIR 2 14 #define PRESTO_OP_UNLINK 3 15 #define PRESTO_OP_RMDIR 4 16 #define PRESTO_OP_CLOSE 5 17 #define PRESTO_OP_SYMLINK 6 18 #define PRESTO_OP_RENAME 7 19 #define PRESTO_OP_SETATTR 8 20 #define PRESTO_OP_LINK 9 21 #define PRESTO_OP_OPEN 10 22 #define PRESTO_OP_MKNOD 11 23 #define PRESTO_OP_WRITE 12 24 #define PRESTO_OP_RELEASE 13 25 #define PRESTO_OP_TRUNC 14 26 #define PRESTO_OP_SETEXTATTR 15 27 #define PRESTO_OP_DELEXTATTR 16 28 29 #define PRESTO_LML_DONE 1 /* flag to get first write to do LML */ 30 #define KML_KOP_MARK 0xffff 31 32 struct presto_lml_data { 33 loff_t rec_offset; 34 }; 35 36 struct big_journal_prefix { 37 u32 len; 38 u32 version; 39 u32 pid; 40 u32 uid; 41 u32 fsuid; 42 u32 fsgid; 43 u32 opcode; 44 u32 ngroups; 45 u32 groups[NGROUPS_MAX]; 46 }; 47 48 enum kml_opcode { 49 KML_CREATE = 1, 50 KML_MKDIR, 51 KML_UNLINK, 52 KML_RMDIR, 53 KML_CLOSE, 54 KML_SYMLINK, 55 KML_RENAME, 56 KML_SETATTR, 57 KML_LINK, 58 KML_OPEN, 59 KML_MKNOD, 60 KML_ENDMARK = 0xff 61 }; 62 63 struct kml_create { 64 char *path; 65 struct presto_version new_objectv, 66 old_parentv, 67 new_parentv; 68 int mode; 69 int uid; 70 int gid; 71 }; 72 73 struct kml_open { 74 }; 75 76 struct kml_mkdir { 77 char *path; 78 struct presto_version new_objectv, 79 old_parentv, 80 new_parentv; 81 int mode; 82 int uid; 83 int gid; 84 }; 85 86 struct kml_unlink { 87 char *path, 88 *name; 89 struct presto_version old_tgtv, 90 old_parentv, 91 new_parentv; 92 }; 93 94 struct kml_rmdir { 95 char *path, 96 *name; 97 struct presto_version old_tgtv, 98 old_parentv, 99 new_parentv; 100 }; 101 102 struct kml_close { 103 int open_mode, 104 open_uid, 105 open_gid; 106 char *path; 107 struct presto_version new_objectv; 108 __u64 ino; 109 int generation; 110 }; 111 112 struct kml_symlink { 113 char *sourcepath, 114 *targetpath; 115 struct presto_version new_objectv, 116 old_parentv, 117 new_parentv; 118 int uid; 119 int gid; 120 }; 121 122 struct kml_rename { 123 char *sourcepath, 124 *targetpath; 125 struct presto_version old_objectv, 126 new_objectv, 127 old_tgtv, 128 new_tgtv; 129 }; 130 131 struct kml_setattr { 132 char *path; 133 struct presto_version old_objectv; 134 struct iattr iattr; 135 }; 136 137 struct kml_link { 138 char *sourcepath, 139 *targetpath; 140 struct presto_version new_objectv, 141 old_parentv, 142 new_parentv; 143 }; 144 145 struct kml_mknod { 146 char *path; 147 struct presto_version new_objectv, 148 old_parentv, 149 new_parentv; 150 int mode; 151 int uid; 152 int gid; 153 int major; 154 int minor; 155 }; 156 157 /* kml record items for optimizing */ 158 struct kml_kop_node 159 { 160 u32 kml_recno; 161 u32 kml_flag; 162 u32 kml_op; 163 nlink_t i_nlink; 164 u32 i_ino; 165 }; 166 167 struct kml_kop_lnode 168 { 169 struct list_head chains; 170 struct kml_kop_node node; 171 }; 172 173 struct kml_endmark { 174 u32 total; 175 struct kml_kop_node *kop; 176 }; 177 178 /* kml_flag */ 179 #define KML_REC_DELETE 1 180 #define KML_REC_EXIST 0 181 182 struct kml_optimize { 183 struct list_head kml_chains; 184 u32 kml_flag; 185 u32 kml_op; 186 nlink_t i_nlink; 187 u32 i_ino; 188 }; 189 190 struct kml_rec { 191 /* attribute of this record */ 192 int rec_size; 193 int rec_kml_offset; 194 195 struct big_journal_prefix rec_head; 196 union { 197 struct kml_create create; 198 struct kml_open open; 199 struct kml_mkdir mkdir; 200 struct kml_unlink unlink; 201 struct kml_rmdir rmdir; 202 struct kml_close close; 203 struct kml_symlink symlink; 204 struct kml_rename rename; 205 struct kml_setattr setattr; 206 struct kml_mknod mknod; 207 struct kml_link link; 208 struct kml_endmark endmark; 209 } rec_kml; 210 struct journal_suffix rec_tail; 211 212 /* for kml optimize only */ 213 struct kml_optimize kml_optimize; 214 }; 215 216 /* kml record items for optimizing */ 217 extern void kml_kop_init (struct presto_file_set *fset); 218 extern void kml_kop_addrec (struct presto_file_set *fset, 219 struct inode *ino, u32 op, u32 flag); 220 extern int kml_kop_flush (struct presto_file_set *fset); 221 222 /* defined in kml_setup.c */ 223 extern int kml_init (struct presto_file_set *fset); 224 extern int kml_cleanup (struct presto_file_set *fset); 225 226 /* defined in kml.c */ 227 extern int begin_kml_reint (struct file *file, unsigned long arg); 228 extern int do_kml_reint (struct file *file, unsigned long arg); 229 extern int end_kml_reint (struct file *file, unsigned long arg); 230 231 /* kml_utils.c */ 232 extern char *dlogit (void *tbuf, const void *sbuf, int size); 233 extern char * bdup_printf (char *format, ...); 234 235 /* defined in kml_decode.c */ 236 /* printop */ 237 #define PRINT_KML_PREFIX 0x1 238 #define PRINT_KML_SUFFIX 0x2 239 #define PRINT_KML_REC 0x4 240 #define PRINT_KML_OPTIMIZE 0x8 241 #define PRINT_KML_EXIST 0x10 242 #define PRINT_KML_DELETE 0x20 243 extern void kml_printrec (struct kml_rec *rec, int printop); 244 extern int print_allkmlrec (struct list_head *head, int printop); 245 extern int delete_kmlrec (struct list_head *head); 246 extern int kml_decoderec (char *buf, int pos, int buflen, int *size, 247 struct kml_rec **newrec); 248 extern int decode_kmlrec (struct list_head *head, char *kml_buf, int buflen); 249 extern void kml_freerec (struct kml_rec *rec); 250 251 /* defined in kml_reint.c */ 252 #define KML_CLOSE_BACKFETCH 1 253 extern int kml_reintbuf (struct kml_fsdata *kml_fsdata, 254 char *mtpt, struct kml_rec **rec); 255 256 /* defined in kml_setup.c */ 257 extern int kml_init (struct presto_file_set *fset); 258 extern int kml_cleanup (struct presto_file_set *fset); 259 260 #endif 261 262