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