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