1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * lustre/smfs/smfs_internal.h
5 * Lustre filesystem abstraction routines
7 * Copyright (C) 2004 Cluster File Systems, Inc.
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #ifndef __LINUX_SMFS_H
25 #define __LINUX_SMFS_H
28 #define SMFSDEV_NAME "/dev/smfsconf"
29 #define SMFS_PSDEV_MINOR 250
30 #define SMFS_PSDEV_MAJOR 10
32 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,10))
39 struct list_head list;
42 struct smfs_control_device {
43 struct list_head smfs_dev_list;
46 #define SMFS_TYPE "smfs"
47 #define IOC_SMFS_START _IOWR('s', 41, long)
48 #define IOC_SMFS_STOP _IOWR('s', 42, long)
49 #define IOC_SMFS_REINT _IOWR('s', 43, long)
50 #define IOC_SMFS_UNDO _IOWR('s', 44, long)
54 #define SB_OPS_CHECK 0x1
55 #define INODE_OPS_CHECK 0x2
56 #define FILE_OPS_CHECK 0x4
57 #define DENTRY_OPS_CHECK 0x8
58 #define SPECIAL_OPS_CHECK 0x10
59 #define SYMLINK_OPS_CHECK 0x20
60 #define DIR_OPS_CHECK 0x40
62 #define MYPATHLEN(buffer, path) ((buffer) + PAGE_SIZE - (path))
64 #define PACK_KML_REC_INIT(buffer, op_code) \
66 int opcode = op_code; \
67 memcpy(buffer, &opcode, sizeof(opcode)); \
68 buffer += sizeof(opcode); \
71 #define SMFS_IOPEN_INO 1
72 #define KEY_IS(str, key) (strcmp(str,key) == 0)
74 extern int init_smfs_proc_sys(void);
76 extern void sm_set_inode_ops(struct inode *);
77 extern void sm_set_sb_ops(struct super_block *cache_sb, struct super_block *sb);
78 //extern void init_smfs_cache(void);
79 //extern void cleanup_smfs_cache(void);
80 //extern void sm_set_journal_ops(struct super_block *sb, char *cache_type);
81 extern int smfs_init_sm_ops(struct smfs_super_info *smb);
82 extern void smfs_cleanup_sm_ops(struct smfs_super_info *smb);
85 void smfs_put_super(struct super_block *sb);
86 int smfs_fill_super(struct super_block *sb, void *data, int silent);
87 int smfs_post_setup(struct obd_device *, struct vfsmount *, struct dentry *);
88 void smfs_post_cleanup(struct super_block *);
89 void * smfs_get_plg_priv(struct smfs_super_info *, int);
91 extern int sm_debug_level;
93 extern long sm_kmemory;
96 extern struct inode_operations smfs_dir_iops;
97 extern struct file_operations smfs_dir_fops;
98 extern struct inode_operations smfs_iopen_iops;
99 extern struct file_operations smfs_iopen_fops;
102 extern struct inode_operations smfs_file_iops;
103 extern struct file_operations smfs_file_fops;
104 extern struct inode_operations smfs_special_iops;
105 extern int smfs_ioctl(struct inode * inode, struct file * filp,
106 unsigned int cmd, unsigned long arg);
107 extern int smfs_fsync(struct file * file, struct dentry *dentry, int datasync);
108 extern int smfs_setattr(struct dentry *dentry, struct iattr *attr);
109 extern int smfs_setxattr(struct dentry *dentry, const char *name,
110 const void *value, size_t size, int flags);
111 extern int smfs_getxattr(struct dentry *dentry, const char *name, void *buffer,
113 extern ssize_t smfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
114 extern int smfs_removexattr(struct dentry *dentry, const char *name);
115 extern int smfs_permission(struct inode *inode, int mask, struct nameidata *nd);
116 extern int smfs_open(struct inode * inode, struct file * filp);
117 extern int smfs_release(struct inode * inode, struct file * filp);
119 struct inode *smfs_get_inode(struct super_block *, struct inode*,
120 struct smfs_inode_info *, int);
122 extern struct super_operations smfs_super_ops;
124 struct smfs_iget_args {
125 struct inode *s_inode;
126 struct smfs_inode_info *s_info;
131 extern struct inode_operations smfs_sym_iops;
132 extern struct file_operations smfs_sym_fops;
134 void *smfs_trans_start(struct inode *inode, int op, void *desc_private);
135 void smfs_trans_commit(struct inode *inode, void *handle, int force_sync);
137 extern int smfs_post_rec_write(struct inode *dir, struct dentry *dentry,
138 void *data1, void *data2);
139 extern int smfs_post_rec_setattr(struct inode *dir, struct dentry *dentry,
140 void *data1, void *data2);
141 extern int smfs_post_rec_create(struct inode *dir, struct dentry *dentry,
142 void *data1, void *data2);
144 int smfs_do_rec(struct inode *inode);
145 int smfs_rec_cleanup(struct smfs_super_info *sb);
146 int smfs_rec_init(struct super_block *sb);
148 extern int smfs_rec_unpack(struct smfs_proc_args *args, char *record,
149 char **pbuf, int *opcode);
150 extern int smfs_process_rec(struct super_block *sb, int count,
151 char *dir, int flags);
153 extern int mds_rec_pack(int, char *, struct dentry *, struct inode *,
155 extern int ost_rec_pack(int, char *, struct dentry *, struct inode *,
159 extern int smfs_llog_setup(struct dentry **, struct dentry **);
160 extern int smfs_llog_cleanup(struct smfs_super_info *);
161 extern int smfs_llog_add_rec(struct smfs_super_info *, void *, int);
163 extern int init_smfs_psdev(void);
164 extern void smfs_cleanup_psdev(void);
167 /* audit_transfer.c */
168 int audit_notify(struct llog_handle *llh, void*);
169 int audit_start_transferd(void);
170 int audit_stop_transferd(void);
173 extern int do_cache_manage;
174 struct cache_purge_queue {
175 wait_queue_head_t cpq_waitq;
176 struct super_block *cpq_sb;
177 struct llog_handle *cpq_loghandle;
179 struct completion cpq_comp;
182 #define CACHE_SPACE_INSERT 0x1
183 #define CACHE_SPACE_DELETE 0x2
184 #define CACHE_SPACE_COMMIT 0x4
186 #define CACHE_LRU_LOG "CACHE_LRU_LIST"
188 extern int smfs_cache_hook(struct inode *inode);
189 extern void cache_space_pre(struct inode *inode, int op);
190 extern int cache_space_post(int op, void *handle, struct inode *old_dir,
191 struct dentry *old_dentry, struct inode *new_dir,
192 struct dentry *new_dentry);
194 int cache_space_hook_setup(struct super_block *);
195 int cache_space_hook_cleanup(void);
196 int cache_space_hook_init(struct super_block *sb);
197 int cache_space_hook_exit(struct smfs_super_info *smfs_info);
199 #define XATTR_SMFS_HOARD_MARK "hoard"
200 #define XATTR_SMFS_CACHE_LOGCOOKIE "cache"
201 #define XATTR_SMFS_ACTIVE_ENTRY "entry"
204 static inline int set_hoard_priority(struct inode *inode, void *handle,
207 struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
210 rc = fsops->fs_set_xattr(inode, handle, XATTR_SMFS_HOARD_MARK,
211 hoard, sizeof(__u32));
215 static inline int get_hoard_priority(struct inode *inode, __u32 *hoard)
217 struct fsfilt_operations *fsops = I2CSB(inode)->sm_fsfilt;
220 rc = fsops->fs_get_xattr(inode, XATTR_SMFS_HOARD_MARK,
221 hoard, sizeof(__u32));
225 static inline int set_active_entry(struct inode *dir, __u64 *active_entry,
228 struct fsfilt_operations *fsops = I2CSB(dir)->sm_fsfilt;
230 *active_entry = cpu_to_le64(*active_entry);
231 rc = fsops->fs_set_xattr(dir, handle, XATTR_SMFS_ACTIVE_ENTRY,
232 active_entry, sizeof(__u64));
235 static inline int get_active_entry(struct inode *dir, __u64 *active_entry)
237 struct fsfilt_operations *fsops = I2CSB(dir)->sm_fsfilt;
238 int rc = fsops->fs_get_xattr(dir, XATTR_SMFS_ACTIVE_ENTRY,
239 active_entry, sizeof(__u64));
240 *active_entry = le64_to_cpu(*active_entry);
253 smfs_inode2id(struct lustre_id *id, struct inode *inode)
255 mdc_pack_id(id, inode->i_ino, inode->i_generation,
256 (inode->i_mode & S_IFMT), 0, 0);
260 smfs_prepare_mdc_data(struct mdc_op_data *data, struct inode *i1,
261 struct inode *i2, const char *name, int namelen,
266 smfs_inode2id(&data->id1, i1);
268 smfs_inode2id(&data->id2, i2);
270 memset(&data->id2, 0, sizeof(data->id2));
274 data->namelen = namelen;
275 data->create_mode = mode;
276 data->mod_time = LTIME_S(CURRENT_TIME);
281 int smfs_cow_init(struct super_block *sb);
282 int smfs_cow_cleanup(struct smfs_super_info *smb);
283 int smfs_snap_test_inode(struct inode *inode, void *args);
285 #define SMFS_PRE_COW(dir, dentry, new_dir, new_dentry, op, name, rc, label)
288 #endif /* __LINUX_SMFS_H */