This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / fs / intermezzo / journal_ext2.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 #include <linux/ext2_fs.h> 
34
35 #include "intermezzo_fs.h"
36 #include "intermezzo_psdev.h"
37
38 #if defined(CONFIG_EXT2_FS)
39
40 /* EXT2 has no journalling, so these functions do nothing */
41 static loff_t presto_e2_freespace(struct presto_cache *cache,
42                                          struct super_block *sb)
43 {
44         unsigned long freebl = le32_to_cpu(EXT2_SB(sb)->s_es->s_free_blocks_count);
45         unsigned long avail =   freebl - le32_to_cpu(EXT2_SB(sb)->s_es->s_r_blocks_count);
46         return (avail <<  EXT2_BLOCK_SIZE_BITS(sb));
47 }
48
49 /* start the filesystem journal operations */
50 static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *inode, int op)
51 {
52         __u32 avail_kmlblocks;
53
54         if ( presto_no_journal(fset) ||
55              strcmp(fset->fset_cache->cache_type, "ext2"))
56                 return NULL;
57
58         avail_kmlblocks = EXT2_SB(inode->i_sb)->s_es->s_free_blocks_count;
59         
60         if ( avail_kmlblocks < 3 ) {
61                 return ERR_PTR(-ENOSPC);
62         }
63         
64         if (  (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR)
65               && avail_kmlblocks < 6 ) {
66                 return ERR_PTR(-ENOSPC);
67         }            
68         return (void *) 1;
69 }
70
71 static void presto_e2_trans_commit(struct presto_file_set *fset, void *handle)
72 {
73         do {} while (0);
74 }
75
76 static int presto_e2_has_all_data(struct inode *inode)
77 {
78         BUG();
79         return 0;
80 }
81
82 struct journal_ops presto_ext2_journal_ops = {
83         .tr_all_data            = presto_e2_has_all_data,
84         .tr_avail               = presto_e2_freespace,
85         .tr_start               = presto_e2_trans_start,
86         .tr_commit              = presto_e2_trans_commit,
87         .tr_journal_data        = NULL
88 };
89
90 #endif /* CONFIG_EXT2_FS */