OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [intermezzo/] [journal_reiserfs.c] - Blame information for rev 1275

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/* -*- 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
 *  Copyright (C) 2000 Red Hat, Inc.
6
 *  Copyright (C) 2000 Los Alamos National Laboratory
7
 *  Copyright (C) 2000 TurboLinux, Inc.
8
 *  Copyright (C) 2001 Mountain View Data, Inc.
9
 *
10
 *   This file is part of InterMezzo, http://www.inter-mezzo.org.
11
 *
12
 *   InterMezzo is free software; you can redistribute it and/or
13
 *   modify it under the terms of version 2 of the GNU General Public
14
 *   License as published by the Free Software Foundation.
15
 *
16
 *   InterMezzo is distributed in the hope that it will be useful,
17
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
18
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19
 *   GNU General Public License for more details.
20
 *
21
 *   You should have received a copy of the GNU General Public License
22
 *   along with InterMezzo; if not, write to the Free Software
23
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24
 */
25
 
26
#include <linux/types.h>
27
#include <linux/param.h>
28
#include <linux/sched.h>
29
#include <linux/fs.h>
30
#include <linux/slab.h>
31
#include <linux/vmalloc.h>
32
#include <linux/stat.h>
33
#include <linux/errno.h>
34
#include <linux/smp_lock.h>
35
#include <linux/locks.h>
36
#include <asm/segment.h>
37
#include <asm/uaccess.h>
38
#include <linux/string.h>
39
#if 0
40
#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE)
41
#include <linux/reiserfs_fs.h>
42
#include <linux/reiserfs_fs_sb.h>
43
#include <linux/reiserfs_fs_i.h>
44
#endif
45
 
46
#include <linux/intermezzo_fs.h>
47
#include <linux/intermezzo_psdev.h>
48
 
49
#if defined(CONFIG_REISERFS_FS) || defined(CONFIG_REISERFS_FS_MODULE)
50
 
51
 
52
static loff_t presto_reiserfs_freespace(struct presto_cache *cache,
53
                                         struct super_block *sb)
54
{
55
        struct reiserfs_super_block * rs = SB_DISK_SUPER_BLOCK (sb);
56
        loff_t avail;
57
 
58
        avail =   le32_to_cpu(rs->s_free_blocks) *
59
                le16_to_cpu(rs->s_blocksize);
60
        return avail;
61
}
62
 
63
/* start the filesystem journal operations */
64
static void *presto_reiserfs_trans_start(struct presto_file_set *fset,
65
                                   struct inode *inode,
66
                                   int op)
67
{
68
        int jblocks;
69
        __u32 avail_kmlblocks;
70
        struct reiserfs_transaction_handle *th ;
71
 
72
        PRESTO_ALLOC(th, sizeof(*th));
73
        if (!th) {
74
                CERROR("presto: No memory for trans handle\n");
75
                return NULL;
76
        }
77
 
78
        avail_kmlblocks = presto_reiserfs_freespace(fset->fset_cache,
79
                                                    inode->i_sb);
80
        if ( presto_no_journal(fset) ||
81
             strcmp(fset->fset_cache->cache_type, "reiserfs"))
82
                {
83
                        CDEBUG(D_JOURNAL, "got cache_type \"%s\"\n",
84
                               fset->fset_cache->cache_type);
85
                        return NULL;
86
                }
87
 
88
        if ( avail_kmlblocks < 3 ) {
89
                return ERR_PTR(-ENOSPC);
90
        }
91
 
92
        if (  (op != PRESTO_OP_UNLINK && op != PRESTO_OP_RMDIR)
93
              && avail_kmlblocks < 6 ) {
94
                return ERR_PTR(-ENOSPC);
95
        }
96
 
97
        jblocks = 3 + JOURNAL_PER_BALANCE_CNT * 4;
98
        CDEBUG(D_JOURNAL, "creating journal handle (%d blocks)\n", jblocks);
99
 
100
        lock_kernel();
101
        journal_begin(th, inode->i_sb, jblocks);
102
        unlock_kernel();
103
        return th;
104
}
105
 
106
static void presto_reiserfs_trans_commit(struct presto_file_set *fset,
107
                                         void *handle)
108
{
109
        int jblocks;
110
        jblocks = 3 + JOURNAL_PER_BALANCE_CNT * 4;
111
 
112
        lock_kernel();
113
        journal_end(handle, fset->fset_cache->cache_sb, jblocks);
114
        unlock_kernel();
115
        PRESTO_FREE(handle, sizeof(struct reiserfs_transaction_handle));
116
}
117
 
118
static void presto_reiserfs_journal_file_data(struct inode *inode)
119
{
120
#ifdef EXT3_JOURNAL_DATA_FL
121
        inode->u.ext3_i.i_flags |= EXT3_JOURNAL_DATA_FL;
122
#else
123
#warning You must have a facility to enable journaled writes for recovery!
124
#endif
125
}
126
 
127
static int presto_reiserfs_has_all_data(struct inode *inode)
128
{
129
        BUG();
130
        return 0;
131
}
132
 
133
struct journal_ops presto_reiserfs_journal_ops = {
134
        .tr_all_data     = presto_reiserfs_has_all_data,
135
        .tr_avail        = presto_reiserfs_freespace,
136
        .tr_start        = presto_reiserfs_trans_start,
137
        .tr_commit       = presto_reiserfs_trans_commit,
138
        .tr_journal_data = presto_reiserfs_journal_file_data
139
};
140
 
141
#endif
142
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.