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 <linux/locks.h>
31 #include <asm/segment.h>
32 #include <asm/uaccess.h>
33 #include <linux/string.h>
34 #include <linux/ext2_fs.h>
36 #include <linux/intermezzo_fs.h>
37 #include <linux/intermezzo_psdev.h>
39 #if defined(CONFIG_EXT2_FS)
41 /* EXT2 has no journalling, so these functions do nothing */
42 static loff_t presto_e2_freespace(struct presto_cache *cache,
43 struct super_block *sb)
45 unsigned long freebl = le32_to_cpu(sb->u.ext2_sb.s_es->s_free_blocks_count);
46 unsigned long avail = freebl - le32_to_cpu(sb->u.ext2_sb.s_es->s_r_blocks_count);
47 return (avail << EXT2_BLOCK_SIZE_BITS(sb));
50 /* start the filesystem journal operations */
51 static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *inode, int op)
53 __u32 avail_kmlblocks;
55 if ( presto_no_journal(fset) ||
56 strcmp(fset->fset_cache->cache_type, "ext2"))
59 avail_kmlblocks = inode->i_sb->u.ext2_sb.s_es->s_free_blocks_count;
61 if ( avail_kmlblocks < 3 ) {
62 return ERR_PTR(-ENOSPC);
65 if ( (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR)
66 && avail_kmlblocks < 6 ) {
67 return ERR_PTR(-ENOSPC);
72 static void presto_e2_trans_commit(struct presto_file_set *fset, void *handle)
77 static int presto_e2_has_all_data(struct inode *inode)
83 struct journal_ops presto_ext2_journal_ops = {
84 tr_all_data: presto_e2_has_all_data,
85 tr_avail: presto_e2_freespace,
86 tr_start: presto_e2_trans_start,
87 tr_commit: presto_e2_trans_commit,
91 #endif /* CONFIG_EXT2_FS */