1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 1998 Peter J. Braam <braam@clusterfs.com>
6 * This file is part of InterMezzo, http://www.inter-mezzo.org.
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.
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.
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.
22 #include <linux/types.h>
23 #include <linux/kernel.h>
24 #include <linux/sched.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>
34 /* XFS Support not there yet */
36 #include <linux/xfs_fs.h>
38 #include "intermezzo_fs.h"
39 #include "intermezzo_psdev.h"
40 #include "intermezzo_journal.h"
44 /* XFS has journalling, but these functions do nothing yet... */
46 static unsigned long presto_xfs_freespace(struct presto_file_set *fset,
47 struct super_block *sb)
51 vfs_t *vfsp = LINVFS_GET_VFS(sb);
52 struct statvfs_t stat;
57 VFS_STATVFS(vfsp, &stat, NULL, rc);
58 avail = statp.f_bfree;
60 return sbp->sb_fdblocks;
66 /* start the filesystem journal operations */
68 presto_xfs_trans_start(struct presto_file_set *fset,
69 struct inode *inode, int 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
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
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? */
94 case PRESTO_OP_SETATTR:
95 /* or XFS_TRANS_SETATTR_NOT_SIZE? */
96 xfs_op = XFS_TRANS_SETATTR_SIZE;
98 case PRESTO_OP_CREATE:
99 /* or CREATE_TRUNC? */
100 xfs_op = XFS_TRANS_CREATE;
103 xfs_op = XFS_TRANS_LINK;
105 case PRESTO_OP_UNLINK:
106 xfs_op = XFS_TRANS_REMOVE;
108 case PRESTO_OP_SYMLINK:
109 xfs_op = XFS_TRANS_SYMLINK;
111 case PRESTO_OP_MKDIR:
112 xfs_op = XFS_TRANS_MKDIR;
114 case PRESTO_OP_RMDIR:
115 xfs_op = XFS_TRANS_RMDIR;
117 case PRESTO_OP_MKNOD:
118 /* XXX can't find an analog for mknod? */
119 xfs_op = XFS_TRANS_CREATE;
121 case PRESTO_OP_RENAME:
122 xfs_op = XFS_TRANS_RENAME;
125 CDEBUG(D_JOURNAL, "invalid operation %d for journal\n", op);
129 return xfs_trans_start(inode, xfs_op);
132 static void presto_xfs_trans_commit(struct presto_file_set *fset, void *handle)
134 /* assert (handle == current->j_handle) */
135 xfs_trans_stop(handle);
138 static void presto_xfs_journal_file_data(struct inode *inode)
143 static int presto_xfs_has_all_data(struct inode *inode)
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
160 #endif /* CONFIG_XFS_FS */