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#include <linux/ext2_fs.h> 35 36#include <linux/intermezzo_fs.h> 37#include <linux/intermezzo_psdev.h> 38 39#if defined(CONFIG_EXT2_FS) 40 41/* EXT2 has no journalling, so these functions do nothing */ 42static loff_t presto_e2_freespace(struct presto_cache *cache, 43 struct super_block *sb) 44{ 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)); 48} 49 50/* start the filesystem journal operations */ 51static void *presto_e2_trans_start(struct presto_file_set *fset, struct inode *inode, int op) 52{ 53 __u32 avail_kmlblocks; 54 55 if ( presto_no_journal(fset) || 56 strcmp(fset->fset_cache->cache_type, "ext2")) 57 return NULL; 58 59 avail_kmlblocks = inode->i_sb->u.ext2_sb.s_es->s_free_blocks_count; 60 61 if ( avail_kmlblocks < 3 ) { 62 return ERR_PTR(-ENOSPC); 63 } 64 65 if ( (op != KML_OPCODE_UNLINK && op != KML_OPCODE_RMDIR) 66 && avail_kmlblocks < 6 ) { 67 return ERR_PTR(-ENOSPC); 68 } 69 return (void *) 1; 70} 71 72static void presto_e2_trans_commit(struct presto_file_set *fset, void *handle) 73{ 74 do {} while (0); 75} 76 77static int presto_e2_has_all_data(struct inode *inode) 78{ 79 BUG(); 80 return 0; 81} 82 83struct 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, 88 tr_journal_data: NULL 89}; 90 91#endif /* CONFIG_EXT2_FS */ 92

