Whamcloud - gitweb
f8d4ac3df9c1809128fc67adcf26b8dca5e5c8a5
[fs/lustre-release.git] / lustre / obdclass / fsfilt_reiserfs.c
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  lustre/lib/fsfilt_reiserfs.c
5  *  Lustre filesystem abstraction routines
6  *
7  *  Copyright (C) 2002 Cluster File Systems, Inc.
8  *   Author: Andreas Dilger <adilger@clusterfs.com>
9  *
10  *   This file is part of Lustre, http://www.lustre.org.
11  *
12  *   Lustre 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  *   Lustre 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 Lustre; if not, write to the Free Software
23  *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24  */
25
26 /*
27  * NOTE - According to Hans Reiser, this could actually be implemented more
28  *        efficiently than creating a directory and putting ASCII objids in it.
29  *        Instead, we should return the reiserfs object ID as the lustre objid
30  *        (although I'm not sure what impact that would have on backup/restore).
31  */
32
33 #define DEBUG_SUBSYSTEM S_FILTER
34
35 #include <linux/fs.h>
36 #include <linux/jbd.h>
37 #include <linux/slab.h>
38 #include <linux/pagemap.h>
39 #include <linux/quotaops.h>
40 #include <linux/kp30.h>
41 #include <linux/lustre_fsfilt.h>
42 #include <linux/obd.h>
43 #include <linux/obd_class.h>
44 #include <linux/module.h>
45
46 static void *fsfilt_reiserfs_start(struct inode *inode, int op)
47 {
48         return (void *)0xf00f00be;
49 }
50
51 static void *fsfilt_reiserfs_brw_start(int objcount, struct fsfilt_objinfo *fso,
52                                    int niocount, struct niobuf_remote *nb)
53 {
54         return (void *)0xf00f00be;
55 }
56
57 static int fsfilt_reiserfs_commit(struct inode *inode, void *handle)
58 {
59         if (handle != (void *)0xf00f00be) {
60                 CERROR("bad handle %p", handle);
61                 return -EINVAL;
62         }
63
64         return 0;
65 }
66
67 static int fsfilt_reiserfs_setattr(struct dentry *dentry, void *handle,
68                                struct iattr *iattr)
69 {
70         struct inode *inode = dentry->d_inode;
71         int rc;
72
73         lock_kernel();
74
75         /* A _really_ horrible hack to avoid removing the data stored
76          * in the block pointers; this is really the "small" stripe MD data.
77          * We can avoid further hackery by virtue of the MDS file size being
78          * zero all the time (which doesn't invoke block truncate at unlink
79          * time), so we assert we never change the MDS file size from zero.
80          */
81         if (iattr->ia_valid & ATTR_SIZE) {
82                 CERROR("hmm, setting %*s file size to %llu\n",
83                        dentry->d_name.len, dentry->d_name.name, iattr->ia_size);
84                 LASSERT(iattr->ia_size == 0);
85 #if 0
86                 /* ATTR_SIZE would invoke truncate: clear it */
87                 iattr->ia_valid &= ~ATTR_SIZE;
88                 inode->i_size = iattr->ia_size;
89
90                 /* make sure _something_ gets set - so new inode
91                  * goes to disk (probably won't work over XFS
92                  */
93                 if (!iattr->ia_valid & ATTR_MODE) {
94                         iattr->ia_valid |= ATTR_MODE;
95                         iattr->ia_mode = inode->i_mode;
96                 }
97 #endif
98         }
99         if (inode->i_op->setattr)
100                 rc = inode->i_op->setattr(dentry, iattr);
101         else
102                 rc = inode_setattr(inode, iattr);
103
104         unlock_kernel();
105
106         return rc;
107 }
108
109 static int fsfilt_reiserfs_set_md(struct inode *inode, void *handle,
110                                   void *lmm, int lmm_size)
111 {
112         /* XXX write stripe data into MDS file itself */
113         CERROR("not implemented yet\n");
114
115         return -ENOSYS;
116 }
117
118 static int fsfilt_reiserfs_get_md(struct inode *inode, void *lmm, int lmm_size)
119 {
120         if (lmm == NULL)
121                 return inode->i_size;
122
123         CERROR("not implemented yet\n");
124         return -ENOSYS;
125 }
126
127 static ssize_t fsfilt_reiserfs_readpage(struct file *file, char *buf, size_t count,
128                                         loff_t *offset)
129 {
130         return file->f_op->read(file, buf, count, offset);
131 }
132
133 static int fsfilt_reiserfs_set_last_rcvd(struct obd_device *obd, __u64 last_rcvd,
134                                          void *handle, fsfilt_cb_t cb_func)
135 {
136         static long next = 0;
137
138         if (time_after(jiffies, next)) {
139                 CERROR("no journal callback kernel patch, faking it...\n");
140                 next = jiffies + 300 * HZ;
141         }
142
143         cb_func(obd, last_rcvd, 0);
144
145         return 0;
146 }
147
148 static int fsfilt_reiserfs_journal_data(struct file *filp)
149 {
150         CERROR("not implemented yet\n");
151         return 0;
152 }
153
154 static int fsfilt_reiserfs_statfs(struct super_block *sb, struct obd_statfs *osfs)
155 {
156         struct statfs sfs;
157         int rc = vfs_statfs(sb, &sfs);
158
159         statfs_pack(osfs, &sfs);
160         return rc;
161 }
162
163 static int fsfilt_reiserfs_sync(struct super_block *sb)
164 {
165         CERROR("not implemented yet\n");
166         return -ENOSYS;
167 }
168
169 static struct fsfilt_operations fsfilt_reiserfs_ops = {
170         fs_type:                "reiserfs",
171         fs_owner:               THIS_MODULE,
172         fs_start:               fsfilt_reiserfs_start,
173         fs_brw_start:           fsfilt_reiserfs_brw_start,
174         fs_commit:              fsfilt_reiserfs_commit,
175         fs_setattr:             fsfilt_reiserfs_setattr,
176         fs_set_md:              fsfilt_reiserfs_set_md,
177         fs_get_md:              fsfilt_reiserfs_get_md,
178         fs_readpage:            fsfilt_reiserfs_readpage,
179         fs_journal_data:        fsfilt_reiserfs_journal_data,
180         fs_set_last_rcvd:       fsfilt_reiserfs_set_last_rcvd,
181         fs_statfs:              fsfilt_reiserfs_statfs,
182         fs_sync:                fsfilt_reiserfs_sync,
183 };
184
185 static int __init fsfilt_reiserfs_init(void)
186 {
187         return fsfilt_register_ops(&fsfilt_reiserfs_ops);
188 }
189
190 static void __exit fsfilt_reiserfs_exit(void)
191 {
192         fsfilt_unregister_ops(&fsfilt_reiserfs_ops);
193 }
194
195 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
196 MODULE_DESCRIPTION("Lustre reiserfs Filesystem Helper v0.1");
197 MODULE_LICENSE("GPL");
198
199 module_init(fsfilt_reiserfs_init);
200 module_exit(fsfilt_reiserfs_exit);