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