This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / intermezzo / journal_xfs.c
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 <asm/segment.h>
31 #include <asm/uaccess.h>
32 #include <linux/string.h>
33 #if 0
34 /* XFS Support not there yet */
35 #ifdef CONFIG_FS_XFS
36 #include <linux/xfs_fs.h>
37 #endif
38 #include "intermezzo_fs.h"
39 #include "intermezzo_psdev.h"
40 #include "intermezzo_journal.h"
41
42 #if 0
43
44 /* XFS has journalling, but these functions do nothing yet... */
45
46 static unsigned long presto_xfs_freespace(struct presto_file_set *fset,
47                                          struct super_block *sb)
48 {
49
50 #if 0
51         vfs_t *vfsp = LINVFS_GET_VFS(sb);
52         struct statvfs_t stat; 
53         bhv_desc_t *bdp;
54         unsigned long avail; 
55         int rc;
56
57         VFS_STATVFS(vfsp, &stat, NULL, rc);
58         avail = statp.f_bfree;
59
60         return sbp->sb_fdblocks;
61 #endif
62         return 0x0fffffff;
63 }
64
65
66 /* start the filesystem journal operations */
67 static void *
68 presto_xfs_trans_start(struct presto_file_set *fset,
69                        struct inode *inode, int op)
70 {
71         int xfs_op;
72         /* do a free blocks check as in journal_ext3? does anything protect
73          * the space in that case or can it disappear out from under us
74          * anyway? */
75         
76 /* copied from xfs_trans.h, skipping header maze for now */
77 #define XFS_TRANS_SETATTR_NOT_SIZE      1
78 #define XFS_TRANS_SETATTR_SIZE          2
79 #define XFS_TRANS_INACTIVE              3
80 #define XFS_TRANS_CREATE                4
81 #define XFS_TRANS_CREATE_TRUNC          5
82 #define XFS_TRANS_TRUNCATE_FILE         6
83 #define XFS_TRANS_REMOVE                7
84 #define XFS_TRANS_LINK                  8
85 #define XFS_TRANS_RENAME                9
86 #define XFS_TRANS_MKDIR                 10
87 #define XFS_TRANS_RMDIR                 11
88 #define XFS_TRANS_SYMLINK               12
89
90         /* map the op onto the values for XFS so it can do reservation. if
91          * we don't have enough info to differentiate between e.g. setattr
92          * with or without size, what do we do? will it adjust? */
93         switch (op) {
94         case PRESTO_OP_SETATTR:
95                 /* or XFS_TRANS_SETATTR_NOT_SIZE? */
96                 xfs_op = XFS_TRANS_SETATTR_SIZE;
97                 break;
98         case PRESTO_OP_CREATE:
99                 /* or CREATE_TRUNC? */
100                 xfs_op = XFS_TRANS_CREATE;
101                 break;
102         case PRESTO_OP_LINK:
103                 xfs_op = XFS_TRANS_LINK;
104                 break;
105         case PRESTO_OP_UNLINK:
106                 xfs_op = XFS_TRANS_REMOVE;
107                 break;
108         case PRESTO_OP_SYMLINK:
109                 xfs_op = XFS_TRANS_SYMLINK;
110                 break;
111         case PRESTO_OP_MKDIR:
112                 xfs_op = XFS_TRANS_MKDIR;
113                 break;
114         case PRESTO_OP_RMDIR:
115                 xfs_op = XFS_TRANS_RMDIR;
116                 break;
117         case PRESTO_OP_MKNOD:
118                 /* XXX can't find an analog for mknod? */
119                 xfs_op = XFS_TRANS_CREATE;
120                 break;
121         case PRESTO_OP_RENAME:
122                 xfs_op = XFS_TRANS_RENAME;
123                 break;
124         default:
125                 CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
126                 return NULL;
127         }
128
129         return xfs_trans_start(inode, xfs_op);
130 }
131
132 static void presto_xfs_trans_commit(struct presto_file_set *fset, void *handle)
133 {
134         /* assert (handle == current->j_handle) */
135         xfs_trans_stop(handle);
136 }
137
138 static void presto_xfs_journal_file_data(struct inode *inode)
139 {
140         return; 
141 }
142
143 static int presto_xfs_has_all_data(struct inode *inode)
144 {
145         BUG();
146         return 0;
147 }
148
149 struct journal_ops presto_xfs_journal_ops = {
150         .tr_all_data     = presto_xfs_has_all_data,
151         .tr_avail        = presto_xfs_freespace,
152         .tr_start        = presto_xfs_trans_start,
153         .tr_commit       = presto_xfs_trans_commit,
154         .tr_journal_data = presto_xfs_journal_file_data
155 };
156
157 #endif
158
159
160 #endif /* CONFIG_XFS_FS */
161