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