1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- 2 * vim:expandtab:shiftwidth=8:tabstop=8: 3 * 4 * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com> 5 * 6 * This file is part of InterMezzo, http://www.inter-mezzo.org. 7 * 8 * InterMezzo is free software; you can redistribute it and/or 9 * modify it under the terms of version 2 of the GNU General Public 10 * License as published by the Free Software Foundation. 11 * 12 * InterMezzo is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with InterMezzo; if not, write to the Free Software 19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 */ 21 22 #include <linux/types.h> 23 #include <linux/kernel.h> 24 #include <linux/sched.h> 25 #include <linux/fs.h> 26 #include <linux/slab.h> 27 #include <linux/vmalloc.h> 28 #include <linux/stat.h> 29 #include <linux/errno.h> 30 #include <linux/locks.h> 31 #include <asm/segment.h> 32 #include <asm/uaccess.h> 33 #include <linux/string.h> 34 #if 0 35 /* XFS Support not there yet */ 36 #ifdef CONFIG_FS_XFS 37 #include <linux/xfs_fs.h> 38 #endif 39 #include <linux/intermezzo_fs.h> 40 #include <linux/intermezzo_psdev.h> 41 #include <linux/intermezzo_journal.h> 42 43 #if 0 44 45 /* XFS has journalling, but these functions do nothing yet... */ 46 47 static unsigned long presto_xfs_freespace(struct presto_file_set *fset, 48 struct super_block *sb) 49 { 50 51 #if 0 52 vfs_t *vfsp = LINVFS_GET_VFS(sb); 53 struct statvfs_t stat; 54 bhv_desc_t *bdp; 55 unsigned long avail; 56 int rc; 57 58 VFS_STATVFS(vfsp, &stat, NULL, rc); 59 avail = statp.f_bfree; 60 61 return sbp->sb_fdblocks; 62 #endif 63 return 0x0fffffff; 64 } 65 66 67 /* start the filesystem journal operations */ 68 static void * 69 presto_xfs_trans_start(struct presto_file_set *fset, 70 struct inode *inode, int op) 71 { 72 int xfs_op; 73 /* do a free blocks check as in journal_ext3? does anything protect 74 * the space in that case or can it disappear out from under us 75 * anyway? */ 76 77 /* copied from xfs_trans.h, skipping header maze for now */ 78 #define XFS_TRANS_SETATTR_NOT_SIZE 1 79 #define XFS_TRANS_SETATTR_SIZE 2 80 #define XFS_TRANS_INACTIVE 3 81 #define XFS_TRANS_CREATE 4 82 #define XFS_TRANS_CREATE_TRUNC 5 83 #define XFS_TRANS_TRUNCATE_FILE 6 84 #define XFS_TRANS_REMOVE 7 85 #define XFS_TRANS_LINK 8 86 #define XFS_TRANS_RENAME 9 87 #define XFS_TRANS_MKDIR 10 88 #define XFS_TRANS_RMDIR 11 89 #define XFS_TRANS_SYMLINK 12 90 91 /* map the op onto the values for XFS so it can do reservation. if 92 * we don't have enough info to differentiate between e.g. setattr 93 * with or without size, what do we do? will it adjust? */ 94 switch (op) { 95 case PRESTO_OP_SETATTR: 96 /* or XFS_TRANS_SETATTR_NOT_SIZE? */ 97 xfs_op = XFS_TRANS_SETATTR_SIZE; 98 break; 99 case PRESTO_OP_CREATE: 100 /* or CREATE_TRUNC? */ 101 xfs_op = XFS_TRANS_CREATE; 102 break; 103 case PRESTO_OP_LINK: 104 xfs_op = XFS_TRANS_LINK; 105 break; 106 case PRESTO_OP_UNLINK: 107 xfs_op = XFS_TRANS_REMOVE; 108 break; 109 case PRESTO_OP_SYMLINK: 110 xfs_op = XFS_TRANS_SYMLINK; 111 break; 112 case PRESTO_OP_MKDIR: 113 xfs_op = XFS_TRANS_MKDIR; 114 break; 115 case PRESTO_OP_RMDIR: 116 xfs_op = XFS_TRANS_RMDIR; 117 break; 118 case PRESTO_OP_MKNOD: 119 /* XXX can't find an analog for mknod? */ 120 xfs_op = XFS_TRANS_CREATE; 121 break; 122 case PRESTO_OP_RENAME: 123 xfs_op = XFS_TRANS_RENAME; 124 break; 125 default: 126 CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op); 127 return NULL; 128 } 129 130 return xfs_trans_start(inode, xfs_op); 131 } 132 133 static void presto_xfs_trans_commit(struct presto_file_set *fset, void *handle) 134 { 135 /* assert (handle == current->j_handle) */ 136 xfs_trans_stop(handle); 137 } 138 139 static void presto_xfs_journal_file_data(struct inode *inode) 140 { 141 return; 142 } 143 144 static int presto_xfs_has_all_data(struct inode *inode) 145 { 146 BUG(); 147 return 0; 148 } 149 150 struct journal_ops presto_xfs_journal_ops = { 151 .tr_all_data = presto_xfs_has_all_data, 152 .tr_avail = presto_xfs_freespace, 153 .tr_start = presto_xfs_trans_start, 154 .tr_commit = presto_xfs_trans_commit, 155 .tr_journal_data = presto_xfs_journal_file_data 156 }; 157 158 #endif 159 160 161 #endif /* CONFIG_XFS_FS */ 162 163