Whamcloud - gitweb
5c9ecd07108129b893a9c4def573631e8ba31dfa
[fs/lustre-release.git] / lustre / include / linux / lustre_fsfilt.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  *  Copyright (C) 2001-2004 Cluster File Systems, Inc. <info@clusterfs.com>
5  *
6  *   This file is part of Lustre, http://www.lustre.org.
7  *
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.
11  *
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.
16  *
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.
20  *
21  * Filesystem interface helper.
22  *
23  */
24
25 #ifndef _LUSTRE_FSFILT_H
26 #define _LUSTRE_FSFILT_H
27
28 #ifdef __KERNEL__
29
30 #include <linux/obd.h>
31 #include <linux/lustre_log.h>
32 #include <linux/obd_class.h>
33
34 typedef void (*fsfilt_cb_t)(struct obd_device *obd, __u64 last_rcvd,
35                             void *data, int error);
36
37 struct fsfilt_objinfo {
38         struct dentry *fso_dentry;
39         int fso_bufcnt;
40 };
41
42 /* lustre EA type (MEA, LOV, etc.) */
43 enum ea_type {
44         EA_LOV   = (1 << 0),
45         EA_MEA   = (1 << 1),
46         EA_SID   = (1 << 2),
47         EA_MID   = (1 << 3)
48 };
49
50 struct fsfilt_operations {
51         struct list_head fs_list;
52         struct module *fs_owner;
53         char   *fs_type;
54         
55         void   *(* fs_start)(struct inode *inode, int op, void *desc_private,
56                              int logs);
57         void   *(* fs_brw_start)(int objcount, struct fsfilt_objinfo *fso,
58                                  int niocount, struct niobuf_local *nb,
59                                  void *desc_private, int logs);
60         int     (* fs_commit)(struct super_block *sb, struct inode *inode, 
61                               void *handle,int force_sync);
62         int     (* fs_commit_async)(struct inode *inode, void *handle,
63                                         void **wait_handle);
64         int     (* fs_commit_wait)(struct inode *inode, void *handle);
65         int     (* fs_setattr)(struct dentry *dentry, void *handle,
66                                struct iattr *iattr, int do_trunc);
67         int     (* fs_iocontrol)(struct inode *inode, struct file *file,
68                                  unsigned int cmd, unsigned long arg);
69
70         /* two methods for setting getting diff. kind of EAs from inode. */
71         int     (* fs_set_md)(struct inode *inode, void *handle, void *md,
72                               int size, enum ea_type type);
73         int     (* fs_get_md)(struct inode *inode, void *md, int size,
74                               enum ea_type type);
75
76         int     (* fs_send_bio)(int rw, struct inode *inode, void *bio);
77
78         /* methods for getting page from backing fs and putting page there
79          * during IO. Used on OST. */
80         int (* fs_putpage)(struct inode *inode, struct page *page);
81         struct page *(* fs_getpage)(struct inode *inode, long int index);
82
83         ssize_t (* fs_readpage)(struct file *file, char *buf, size_t count,
84                                 loff_t *offset);
85         int     (* fs_add_journal_cb)(struct obd_device *obd,
86                                       struct super_block *sb,
87                                       __u64 last_rcvd, void *handle,
88                                       fsfilt_cb_t cb_func, void *cb_data);
89         int     (* fs_statfs)(struct super_block *sb, struct obd_statfs *osfs);
90         int     (* fs_sync)(struct super_block *sb);
91         int     (* fs_map_inode_pages)(struct inode *inode, struct page **page,
92                                        int pages, unsigned long *blocks,
93                                        int *created, int create,
94                                        struct semaphore *sem);
95         int     (* fs_prep_san_write)(struct inode *inode, long *blocks,
96                                       int nblocks, loff_t newsize);
97         int     (* fs_write_record)(struct file *, void *, int size, loff_t *,
98                                     int force_sync);
99         int     (* fs_read_record)(struct file *, void *, int size, loff_t *);
100         int     (* fs_setup)(struct obd_device *, struct super_block *);
101         
102         int     (* fs_post_setup)(struct obd_device *obd, struct vfsmount *mnt,
103                                   struct dentry *dentry);
104         int     (* fs_post_cleanup)(struct obd_device *obd, struct vfsmount *mnt);
105         int     (* fs_get_reint_log_ctxt)(struct super_block *sb, 
106                                           struct llog_ctxt **ctxt);
107         int     (* fs_set_fs_flags)(struct inode *inode, int flags);
108         int     (* fs_clear_fs_flags)(struct inode *inode, int flags);
109         int     (* fs_set_ost_flags)(struct super_block *sb);
110         int     (* fs_set_mds_flags)(struct super_block *sb);
111         int     (* fs_precreate_rec)(struct dentry *dentry, int *num, 
112                                      struct obdo *oa);
113         int     (* fs_set_xattr)(struct inode *inode, void *handle, char *name,
114                                  void *buffer, int buffer_size);
115         int     (* fs_get_xattr)(struct inode *inode, char *name,
116                                  void *buffer, int buffer_size); 
117         
118         int     (* fs_init_extents_ea)(struct inode *inode); 
119         int     (* fs_insert_extents_ea)(struct inode *inode, unsigned long from, 
120                                          unsigned long num); 
121         int     (* fs_do_write_cow)(struct dentry *dentry, void *extents, int nexts);
122         int     (* fs_write_extents)(struct dentry *dentry, 
123                                      unsigned long offset, unsigned long blks);
124         int     (* fs_get_fs_flags)(struct dentry *dentry);
125         int     (* fs_remove_extents_ea)(struct inode *inode, unsigned long from, 
126                                          unsigned long num); 
127         int     (* fs_get_ino_write_extents)(struct super_block *sb, ino_t ino, 
128                                              char **pbuf, int *size);
129         int     (* fs_free_write_extents)(struct super_block *sb, ino_t ino, 
130                                           char *pbuf, int size);
131         int     (* fs_get_inode_write_extents)(struct inode *inode, char **pbuf, 
132                                                int *size);
133         int     (* fs_get_write_extents_num)(struct inode *inode, int* size);
134
135         int     (* fs_get_op_len)(int, struct fsfilt_objinfo *, int);
136         int     (* fs_add_dir_entry)(struct obd_device *, struct dentry *,
137                                      char *, int, unsigned long, unsigned long,
138                                      unsigned long, unsigned long);
139         int     (* fs_del_dir_entry)(struct obd_device *, struct dentry *);
140         /*snap operations*/
141         int     (* fs_is_redirector)(struct inode *inode);
142         int     (* fs_is_indirect)(struct inode *inode);
143         
144         struct inode * (* fs_create_indirect)(struct inode *pri, int index,
145                                               unsigned int gen, 
146                                               struct inode *parent,
147                                               int del);
148         struct inode * (* fs_get_indirect)(struct inode *pri, int *table,
149                                           int slot);
150         ino_t   (* fs_get_indirect_ino)(struct super_block *sb, ino_t pri, 
151                                         int index);
152         int     (* fs_destroy_indirect)(struct inode *pri, int index,
153                                         struct inode *next_ind);
154         int     (* fs_restore_indirect)(struct inode *pri, int index);
155         int     (* fs_iterate)(struct super_block *sb,
156                               int (*repeat)(struct inode *inode, void *priv),
157                               struct inode **start, void *priv, int flag);
158         int     (* fs_copy_block)(struct inode *dst, struct inode *src, 
159                                   int blk);
160         int     (* fs_set_indirect)(struct inode *pri, int index,
161                                     ino_t ind_ino, ino_t parent_ino);
162         int     (* fs_snap_feature)(struct super_block *sb, int feature, 
163                                     int op);
164         int     (* fs_set_snap_info)(struct inode *inode, void* key, 
165                                      __u32 keylen, void *val, __u32 *vallen); 
166         int     (* fs_get_snap_info)(struct inode *inode, void* key, 
167                                      __u32 keylen, void *val, __u32 *vallen); 
168         int     (* fs_set_snap_item)(struct super_block *sb, char *name);
169         int     (* fs_read_dotsnap_dir_page)(struct file *file, char *buf, 
170                                              size_t count, loff_t *ppos);
171         int     (* fs_dir_ent_size)(char *name);
172         int     (* fs_set_dir_ent)(struct super_block *sb, char *name, 
173                                    char *buf, int buf_off, int nlen, 
174                                    size_t count);
175 };
176
177 extern int fsfilt_register_ops(struct fsfilt_operations *fs_ops);
178 extern void fsfilt_unregister_ops(struct fsfilt_operations *fs_ops);
179 extern struct fsfilt_operations *fsfilt_get_ops(const char *type);
180 extern void fsfilt_put_ops(struct fsfilt_operations *fs_ops);
181
182 #define FSFILT_OP_UNLINK         1
183 #define FSFILT_OP_RMDIR          2
184 #define FSFILT_OP_RENAME         3
185 #define FSFILT_OP_CREATE         4
186 #define FSFILT_OP_MKDIR          5
187 #define FSFILT_OP_SYMLINK        6
188 #define FSFILT_OP_MKNOD          7
189 #define FSFILT_OP_SETATTR        8
190 #define FSFILT_OP_LINK           9
191 #define FSFILT_OP_CANCEL_UNLINK 10
192 #define FSFILT_OP_NOOP          15
193
194 /* XXX BUG 3188 -- must return to one set of opcodes */
195 #define KML_UNLINK              0x11
196 #define KML_RMDIR               0x12
197 #define KML_RENAME              0x13
198 #define KML_CREATE              0x14
199 #define KML_MKDIR               0x15
200 #define KML_SYMLINK             0x16
201 #define KML_MKNOD               0x17
202 #define KML_LINK                0x19
203
204 #define CACHE_UNLINK            0x21
205 #define CACHE_RMDIR             0x22
206 #define CACHE_RENAME            0x23
207 #define CACHE_CREATE            0x24
208 #define CACHE_MKDIR             0x25
209 #define CACHE_SYMLINK           0x26
210 #define CACHE_MKNOD             0x27
211 #define CACHE_LINK              0x29
212 #define CACHE_NOOP              0x2f
213
214 #define KML_CACHE_UNLINK        0x31
215 #define KML_CACHE_RMDIR         0x32
216 #define KML_CACHE_RENAME        0x33
217 #define KML_CACHE_CREATE        0x34
218 #define KML_CACHE_MKDIR         0x35
219 #define KML_CACHE_SYMLINK       0x36
220 #define KML_CACHE_MKNOD         0x37
221 #define KML_CACHE_LINK          0x39
222 #define KML_CACHE_NOOP          0x3f
223
224 /*for fsfilt set md ea*/
225 #define LMV_EA  1
226 #define LOV_EA  0
227
228 #define fsfilt_check_slow(start, timeout, msg)                          \
229 do {                                                                    \
230         if (time_before(jiffies, start + 15 * HZ))                      \
231                 break;                                                  \
232         else if (time_before(jiffies, start + timeout / 2 * HZ))        \
233                 CWARN("slow %s %lus\n", msg, (jiffies - start) / HZ);   \
234         else                                                            \
235                 CERROR("slow %s %lus\n", msg, (jiffies - start) / HZ);  \
236 } while (0)
237
238 static inline void *
239 fsfilt_start_ops(struct fsfilt_operations *ops, struct inode *inode,
240                  int op, struct obd_trans_info *oti, int logs)
241 {
242         unsigned long now = jiffies;
243         void *parent_handle = oti ? oti->oti_handle : NULL;
244         void *handle = ops->fs_start(inode, op, parent_handle, logs);
245         CDEBUG(D_INFO, "started handle %p (%p)\n", handle, parent_handle);
246
247         if (oti != NULL) {
248                 if (parent_handle == NULL) {
249                         oti->oti_handle = handle;
250                 } else if (handle != parent_handle) {
251                         CERROR("mismatch: parent %p, handle %p, oti %p\n",
252                                parent_handle, handle, oti);
253                         LBUG();
254                 }
255         }
256         fsfilt_check_slow(now, 60, "journal start");
257         return handle;
258 }
259
260 static inline void *
261 fsfilt_start_log(struct obd_device *obd, struct inode *inode,
262                  int op, struct obd_trans_info *oti, int logs)
263 {
264         return fsfilt_start_ops(obd->obd_fsops, inode, op, oti, logs);
265 }
266
267 static inline void *
268 fsfilt_start(struct obd_device *obd, struct inode *inode,
269              int op, struct obd_trans_info *oti)
270 {
271         return fsfilt_start_ops(obd->obd_fsops, inode, op, oti, 0);
272 }
273
274 static inline void *
275 llog_fsfilt_start(struct llog_ctxt *ctxt, struct inode *inode,
276                   int op, struct obd_trans_info *oti)
277 {
278         return fsfilt_start_ops(ctxt->loc_fsops, inode, op, oti, 1);
279 }
280
281 static inline int
282 fsfilt_commit_ops(struct fsfilt_operations *ops, struct super_block *sb,
283                   struct inode *inode, void *handle, int force_sync)
284 {
285         unsigned long now = jiffies;
286         int rc = ops->fs_commit(sb, inode, handle, force_sync);
287         CDEBUG(D_INFO, "committing handle %p\n", handle);
288
289         fsfilt_check_slow(now, 60, "journal start");
290
291         return rc;
292 }
293
294 static inline int
295 fsfilt_commit(struct obd_device *obd, struct super_block *sb, 
296               struct inode *inode, void *handle, int force_sync)
297 {
298         return fsfilt_commit_ops(obd->obd_fsops, sb, inode, handle, force_sync);
299 }
300
301 static inline int
302 llog_fsfilt_commit(struct llog_ctxt *ctxt, struct inode *inode,
303                    void *handle, int force_sync)
304 {
305         return fsfilt_commit_ops(ctxt->loc_fsops, inode->i_sb, inode, handle, 
306                                  force_sync);
307 }
308
309 static inline void *
310 fsfilt_brw_start_log(struct obd_device *obd, int objcount,
311                      struct fsfilt_objinfo *fso, int niocount,
312                      struct niobuf_local *nb, struct obd_trans_info *oti,
313                      int logs)
314 {
315         unsigned long now = jiffies;
316         void *parent_handle = oti ? oti->oti_handle : NULL;
317         void *handle = obd->obd_fsops->fs_brw_start(objcount, fso, niocount, nb,
318                                                     parent_handle, logs);
319         CDEBUG(D_INFO, "started handle %p (%p)\n", handle, parent_handle);
320
321         if (oti != NULL) {
322                 if (parent_handle == NULL) {
323                         oti->oti_handle = handle;
324                 } else if (handle != parent_handle) {
325                         CERROR("mismatch: parent %p, handle %p, oti %p\n",
326                                parent_handle, handle, oti);
327                         LBUG();
328                 }
329         }
330         fsfilt_check_slow(now, obd_timeout, "journal start");
331
332         return handle;
333 }
334
335 static inline void *
336 fsfilt_brw_start(struct obd_device *obd, int objcount,
337                  struct fsfilt_objinfo *fso, int niocount,
338                  struct niobuf_local *nb, struct obd_trans_info *oti)
339 {
340         return fsfilt_brw_start_log(obd, objcount, fso, niocount, nb, oti, 0);
341 }
342
343 static inline int
344 fsfilt_commit_async(struct obd_device *obd, struct inode *inode,
345                     void *handle, void **wait_handle)
346 {
347         unsigned long now = jiffies;
348         int rc = obd->obd_fsops->fs_commit_async(inode, handle, wait_handle);
349
350         CDEBUG(D_INFO, "committing handle %p (async)\n", *wait_handle);
351         fsfilt_check_slow(now, obd_timeout, "journal start");
352
353         return rc;
354 }
355
356 static inline int
357 fsfilt_commit_wait(struct obd_device *obd, struct inode *inode, void *handle)
358 {
359         unsigned long now = jiffies;
360         int rc = obd->obd_fsops->fs_commit_wait(inode, handle);
361         CDEBUG(D_INFO, "waiting for completion %p\n", handle);
362         fsfilt_check_slow(now, obd_timeout, "journal start");
363         return rc;
364 }
365
366 static inline int
367 fsfilt_setattr(struct obd_device *obd, struct dentry *dentry,
368                void *handle, struct iattr *iattr, int do_trunc)
369 {
370         unsigned long now = jiffies;
371         int rc;
372         rc = obd->obd_fsops->fs_setattr(dentry, handle, iattr, do_trunc);
373         fsfilt_check_slow(now, obd_timeout, "setattr");
374         return rc;
375 }
376
377 static inline int
378 fsfilt_iocontrol(struct obd_device *obd, struct inode *inode,
379                  struct file *file, unsigned int cmd,
380                  unsigned long arg)
381 {
382         return obd->obd_fsops->fs_iocontrol(inode, file, cmd, arg);
383 }
384
385 static inline int fsfilt_setup(struct obd_device *obd,
386                                struct super_block *fs)
387 {
388         if (obd->obd_fsops->fs_setup)
389                 return obd->obd_fsops->fs_setup(obd, fs);
390         return 0;
391 }
392
393 static inline int
394 fsfilt_set_md(struct obd_device *obd, struct inode *inode,
395               void *handle, void *md, int size, enum ea_type type)
396 {
397         if (!obd->obd_fsops->fs_set_md)
398                 return -ENOSYS;
399         
400         return obd->obd_fsops->fs_set_md(inode, handle, md,
401                                          size, type);
402 }
403
404 static inline int
405 fsfilt_get_md(struct obd_device *obd, struct inode *inode,
406               void *md, int size, enum ea_type type)
407 {
408         if (!obd->obd_fsops->fs_get_md)
409                 return -ENOSYS;
410         
411         return obd->obd_fsops->fs_get_md(inode, md, size,
412                                          type);
413 }
414
415 static inline int fsfilt_send_bio(int rw, struct obd_device *obd,
416                                   struct inode *inode, void *bio)
417 {
418         LASSERTF(rw == OBD_BRW_WRITE || rw == OBD_BRW_READ, "%x\n", rw);
419
420         if (rw == OBD_BRW_READ)
421                 return obd->obd_fsops->fs_send_bio(READ, inode, bio);
422         else
423                 return obd->obd_fsops->fs_send_bio(WRITE, inode, bio);
424 }
425
426 static inline int
427 fsfilt_putpage(struct obd_device *obd, struct inode *inode,
428                struct page *page)
429 {
430         int rc = 0;
431         struct filter_obd *filter;
432         unsigned long now = jiffies;
433
434         LASSERT(obd != NULL);
435         LASSERT(inode != NULL);
436         LASSERT(page != NULL);
437
438         filter = &obd->u.filter;
439
440         if (!obd->obd_fsops->fs_putpage)
441                 return -ENOSYS;
442
443         CDEBUG(D_INFO, "putpage %lx\n", page->index);
444
445         rc = obd->obd_fsops->fs_putpage(inode, page);
446
447         fsfilt_check_slow(now, obd_timeout, "putpage");
448
449         return rc;
450 }
451
452 static inline struct page *
453 fsfilt_getpage(struct obd_device *obd, struct inode *inode,
454                unsigned long index)
455 {
456         struct page *page;
457         unsigned long now = jiffies;
458
459         LASSERT(obd != NULL);
460         LASSERT(inode != NULL);
461
462         if (!obd->obd_fsops->fs_getpage)
463                 return ERR_PTR(-ENOSYS);
464
465         CDEBUG(D_INFO, "getpage %lx\n", index);
466
467         page = obd->obd_fsops->fs_getpage(inode, index);
468
469         fsfilt_check_slow(now, obd_timeout, "getpage");
470
471         return page;
472 }
473
474 static inline ssize_t
475 fsfilt_readpage(struct obd_device *obd, struct file *file, char *buf,
476                 size_t count, loff_t *offset)
477 {
478         return obd->obd_fsops->fs_readpage(file, buf, count, offset);
479 }
480
481 static inline int
482 fsfilt_add_journal_cb(struct obd_device *obd, struct super_block *sb,
483                       __u64 last_num, void *handle, fsfilt_cb_t cb_func,
484                       void *cb_data)
485 {
486         return obd->obd_fsops->fs_add_journal_cb(obd, sb, last_num, handle,
487                                                  cb_func, cb_data);
488 }
489
490 /* very similar to obd_statfs(), but caller already holds obd_osfs_lock */
491 static inline int
492 fsfilt_statfs(struct obd_device *obd, struct super_block *sb,
493               unsigned long max_age)
494 {
495         int rc = 0;
496
497         CDEBUG(D_SUPER, "osfs %lu, max_age %lu\n", obd->obd_osfs_age, max_age);
498         if (time_before(obd->obd_osfs_age, max_age)) {
499                 rc = obd->obd_fsops->fs_statfs(sb, &obd->obd_osfs);
500                 if (rc == 0) /* N.B. statfs can't really fail */
501                         obd->obd_osfs_age = jiffies;
502         } else {
503                 CDEBUG(D_SUPER, "using cached obd_statfs data\n");
504         }
505
506         return rc;
507 }
508
509 static inline int
510 fsfilt_sync(struct obd_device *obd, struct super_block *sb)
511 {
512         return obd->obd_fsops->fs_sync(sb);
513 }
514
515 static inline int fsfilt_map_inode_pages(struct obd_device *obd,
516                                          struct inode *inode,
517                                          struct page **page, int pages,
518                                          unsigned long *blocks, int *created,
519                                          int create, struct semaphore *sem)
520 {
521         return obd->obd_fsops->fs_map_inode_pages(inode, page, pages, blocks,
522                                                   created, create, sem);
523 }
524 static inline int fsfilt_get_fs_flags(struct obd_device *obd, 
525                                       struct dentry *dentry)
526 {
527         if (obd->obd_fsops->fs_get_fs_flags) 
528                 return obd->obd_fsops->fs_get_fs_flags(dentry);
529         return 0;
530 }
531
532 static inline int 
533 fsfilt_write_extents(struct obd_device *obd, struct dentry *dentry, 
534                      unsigned long offset, unsigned long blks)
535 {
536         if (obd->obd_fsops->fs_write_extents)
537                 return obd->obd_fsops->fs_write_extents(dentry, 
538                                                         offset, blks);
539         return 0;
540 }
541 static inline int
542 fsfilt_do_write_cow(struct obd_device *obd, struct dentry *dentry,
543                     void *extents, int num_extents)
544 {
545         if (obd->obd_fsops->fs_do_write_cow)
546                 return obd->obd_fsops->fs_do_write_cow(dentry, extents,
547                                                        num_extents);
548         return 0;
549 }
550 static inline int
551 fs_prep_san_write(struct obd_device *obd, struct inode *inode,
552                   long *blocks, int nblocks, loff_t newsize)
553 {
554         return obd->obd_fsops->fs_prep_san_write(inode, blocks,
555                                                  nblocks, newsize);
556 }
557
558 static inline int
559 fsfilt_read_record(struct obd_device *obd, struct file *file,
560                    void *buf, loff_t size, loff_t *offs)
561 {
562         return obd->obd_fsops->fs_read_record(file, buf, size, offs);
563 }
564
565 static inline int 
566 llog_fsfilt_read_record(struct llog_ctxt *ctxt, struct file *file, 
567                         void *buf, loff_t size, loff_t *offs)
568 {
569         return ctxt->loc_fsops->fs_read_record(file, buf, size, offs);
570 }
571
572 static inline int
573 fsfilt_write_record(struct obd_device *obd, struct file *file,
574                     void *buf, loff_t size, loff_t *offs, int force_sync)
575 {
576         return obd->obd_fsops->fs_write_record(file, buf, size, offs,
577                                                force_sync);
578 }
579
580 static inline int
581 llog_fsfilt_write_record(struct llog_ctxt *ctxt, struct file *file,
582                          void *buf, loff_t size, loff_t *offs,
583                          int force_sync)
584 {
585         return ctxt->loc_fsops->fs_write_record(file, buf, size, offs,
586                                                 force_sync);
587 }
588
589 static inline int 
590 fsfilt_set_fs_flags(struct obd_device *obd, struct inode *inode, int flags)
591 {
592         if (obd->obd_fsops->fs_set_fs_flags)
593                 return obd->obd_fsops->fs_set_fs_flags(inode, flags);
594         return 0;
595 }
596
597 static inline int 
598 fsfilt_clear_fs_flags(struct obd_device *obd, struct inode *inode, int flags)
599 {
600         if (obd->obd_fsops->fs_clear_fs_flags)
601                 return obd->obd_fsops->fs_clear_fs_flags(inode, flags);
602         return 0;
603 }
604
605 static inline int 
606 fsfilt_precreate_rec(struct obd_device *obd, struct dentry *dentry,
607                      int *num, struct obdo *oa)
608 {
609         if (obd->obd_fsops->fs_precreate_rec)
610                 return obd->obd_fsops->fs_precreate_rec(dentry, num, oa);
611         return 0;
612 }
613
614 static inline int 
615 fsfilt_post_setup(struct obd_device *obd, struct dentry *de)
616 {
617         if (obd->obd_fsops->fs_post_setup)
618                 return obd->obd_fsops->fs_post_setup(obd, 
619                                 obd->obd_lvfs_ctxt.pwdmnt, de);
620         return 0;
621 }
622
623 static inline int 
624 fsfilt_post_cleanup(struct obd_device *obd)
625 {
626         if (obd->obd_fsops->fs_post_cleanup)
627                 return obd->obd_fsops->fs_post_cleanup(obd, 
628                                 obd->obd_lvfs_ctxt.pwdmnt);
629         return 0;
630 }
631
632 static inline int 
633 fsfilt_get_ino_write_extents(struct obd_device *obd, 
634                              struct super_block *sb, 
635                              int ino, char **buf, int *size)
636 {
637         if (obd->obd_fsops->fs_get_ino_write_extents)
638                 return obd->obd_fsops->fs_get_ino_write_extents(sb, ino, 
639                                                                 buf, size);
640         return 0;
641 }
642
643 static inline int 
644 fsfilt_free_write_extents(struct obd_device *obd, 
645                           struct super_block *sb, 
646                           int ino, char *buf, int size)
647 {
648         if (obd->obd_fsops->fs_free_write_extents)
649                 return obd->obd_fsops->fs_free_write_extents(sb, ino, 
650                                                              buf, size);
651         return 0;
652 }
653
654 static inline int 
655 fsfilt_get_reint_log_ctxt(struct obd_device *obd,
656                           struct super_block *sb, 
657                           struct llog_ctxt **ctxt)
658 {
659         if (obd->obd_fsops->fs_get_reint_log_ctxt)
660                 return obd->obd_fsops->fs_get_reint_log_ctxt(sb, ctxt);
661         return 0;
662 }
663
664 static inline int 
665 fsfilt_set_ost_flags(struct obd_device *obd, struct super_block *sb) 
666 {
667         if (obd->obd_fsops->fs_set_ost_flags)
668                 return obd->obd_fsops->fs_set_ost_flags(sb);
669         return 0;
670 }
671
672 static inline int 
673 fsfilt_set_mds_flags(struct obd_device *obd, struct super_block *sb) 
674 {
675         if (obd->obd_fsops->fs_set_mds_flags)
676                 return obd->obd_fsops->fs_set_mds_flags(sb);
677         return 0;
678 }
679
680 static inline int 
681 fsfilt_add_dir_entry(struct obd_device *obd, struct dentry *dir,
682                      char *name, int namelen, unsigned long ino,
683                      unsigned long generation, unsigned long mds,
684                      unsigned long fid)
685 {
686         LASSERT(obd->obd_fsops->fs_add_dir_entry);
687         
688         return obd->obd_fsops->fs_add_dir_entry(obd, dir, name,
689                                                 namelen, ino,
690                                                 generation, mds,
691                                                 fid);
692 }
693
694 static inline int 
695 fsfilt_del_dir_entry(struct obd_device *obd, struct dentry *dentry)
696 {
697         LASSERT(obd->obd_fsops->fs_del_dir_entry);
698         return obd->obd_fsops->fs_del_dir_entry(obd, dentry);
699 }
700
701 static inline int 
702 fsfilt_set_snap_item(struct obd_device *obd, struct super_block *sb,
703                      char *name)
704 {
705          if (obd->obd_fsops->fs_set_snap_item)
706                 return obd->obd_fsops->fs_set_snap_item(sb, name);
707         return 0;
708
709 #endif /* __KERNEL__ */
710
711 #endif