1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001 Cluster File Systems, Inc. <info@clusterfs.com>
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre 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 * Lustre 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 Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * Filesystem interface helper.
25 #ifndef _LUSTRE_FSFILT_H
26 #define _LUSTRE_FSFILT_H
30 #include <linux/obd.h>
33 typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd, int error);
35 struct fsfilt_objinfo {
36 struct dentry *fso_dentry;
40 struct fsfilt_operations {
41 struct list_head fs_list;
42 struct module *fs_owner;
44 void *(* fs_start)(struct inode *inode, int op);
45 void *(* fs_brw_start)(int objcount, struct fsfilt_objinfo *fso,
46 int niocount, struct niobuf_remote *nb);
47 int (* fs_commit)(struct inode *inode, void *handle);
48 int (* fs_setattr)(struct dentry *dentry, void *handle,
50 int (* fs_set_md)(struct inode *inode, void *handle, void *md,
52 int (* fs_get_md)(struct inode *inode, void *md, int size);
53 ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count,
55 int (* fs_journal_data)(struct file *file);
56 int (* fs_set_last_rcvd)(struct obd_device *obd, __u64 last_rcvd,
57 void *handle, fsfilt_cb_t cb_func);
58 int (* fs_statfs)(struct super_block *sb, struct obd_statfs *osfs);
59 int (* fs_sync)(struct super_block *sb);
62 extern int fsfilt_register_ops(struct fsfilt_operations *fs_ops);
63 extern void fsfilt_unregister_ops(struct fsfilt_operations *fs_ops);
64 extern struct fsfilt_operations *fsfilt_get_ops(char *type);
65 extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops);
67 #define FSFILT_OP_UNLINK 1
68 #define FSFILT_OP_RMDIR 2
69 #define FSFILT_OP_RENAME 3
70 #define FSFILT_OP_CREATE 4
71 #define FSFILT_OP_MKDIR 5
72 #define FSFILT_OP_SYMLINK 6
73 #define FSFILT_OP_MKNOD 7
74 #define FSFILT_OP_SETATTR 8
75 #define FSFILT_OP_LINK 9
77 static inline void *fsfilt_start(struct obd_device *obd,
78 struct inode *inode, int op)
80 return obd->obd_fsops->fs_start(inode, op);
83 static inline void *fsfilt_brw_start(struct obd_device *obd, int objcount,
84 struct fsfilt_objinfo *fso, int niocount,
85 struct niobuf_remote *nb)
87 return obd->obd_fsops->fs_brw_start(objcount, fso, niocount, nb);
90 static inline int fsfilt_commit(struct obd_device *obd, struct inode *inode,
93 return obd->obd_fsops->fs_commit(inode, handle);
96 static inline int fsfilt_setattr(struct obd_device *obd, struct dentry *dentry,
97 void *handle, struct iattr *iattr)
101 * NOTE: we probably don't need to take i_sem here when changing
102 * ATTR_SIZE because the MDS never needs to truncate a file.
103 * The ext2/ext3 code never truncates a directory, and files
104 * stored on the MDS are entirely sparse (no data blocks).
105 * If we do need to get it, we can do it here.
108 rc = obd->obd_fsops->fs_setattr(dentry, handle, iattr);
114 static inline int fsfilt_set_md(struct obd_device *obd, struct inode *inode,
115 void *handle, void *md, int size)
117 return obd->obd_fsops->fs_set_md(inode, handle, md, size);
120 static inline int fsfilt_get_md(struct obd_device *obd, struct inode *inode,
123 return obd->obd_fsops->fs_get_md(inode, md, size);
126 static inline ssize_t fsfilt_readpage(struct obd_device *obd,
127 struct file *file, char *buf,
128 size_t count, loff_t *offset)
130 return obd->obd_fsops->fs_readpage(file, buf, count, offset);
133 static inline int fsfilt_journal_data(struct obd_device *obd, struct file *file)
135 return obd->obd_fsops->fs_journal_data(file);
138 static inline int fsfilt_set_last_rcvd(struct obd_device *obd, __u64 last_rcvd,
139 void *handle, fsfilt_cb_t cb_func)
141 return obd->obd_fsops->fs_set_last_rcvd(obd, last_rcvd,handle,cb_func);
144 static inline int fsfilt_statfs(struct obd_device *obd, struct super_block *fs,
145 struct obd_statfs *osfs)
147 return obd->obd_fsops->fs_statfs(fs, osfs);
150 static inline int fsfilt_sync(struct obd_device *obd, struct super_block *fs)
152 return obd->obd_fsops->fs_sync(fs);
155 #endif /* __KERNEL__ */