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