Whamcloud - gitweb
556728df9d0b65957b12322bef0f01738f37d938
[fs/lustre-release.git] / lustre / include / md_object.h
1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=8:tabstop=8:
3  *
4  * GPL HEADER START
5  *
6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 only,
10  * as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * General Public License version 2 for more details (a copy is included
16  * in the LICENSE file that accompanied this code).
17  *
18  * You should have received a copy of the GNU General Public License
19  * version 2 along with this program; If not, see
20  * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
21  *
22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23  * CA 95054 USA or visit www.sun.com if you need additional information or
24  * have any questions.
25  *
26  * GPL HEADER END
27  */
28 /*
29  * Copyright  2008 Sun Microsystems, Inc. All rights reserved
30  * Use is subject to license terms.
31  */
32 /*
33  * This file is part of Lustre, http://www.lustre.org/
34  * Lustre is a trademark of Sun Microsystems, Inc.
35  *
36  * lustre/include/md_object.h
37  *
38  * Extention of lu_object.h for metadata objects
39  */
40
41 #ifndef _LUSTRE_MD_OBJECT_H
42 #define _LUSTRE_MD_OBJECT_H
43
44 /** \defgroup md md
45  * Sub-class of lu_object with methods common for "meta-data" objects in MDT
46  * stack.
47  *
48  * Meta-data objects implement namespace operations: you can link, unlink
49  * them, and treat them as directories.
50  *
51  * Examples: mdt, cmm, and mdt are implementations of md interface.
52  * @{
53  */
54
55
56 /*
57  * super-class definitions.
58  */
59 #include <lu_object.h>
60 #include <lvfs.h>
61
62 struct md_device;
63 struct md_device_operations;
64 struct md_object;
65
66
67 enum {
68         UCRED_INVALID   = -1,
69         UCRED_INIT      = 0,
70         UCRED_OLD       = 1,
71         UCRED_NEW       = 2
72 };
73
74 struct md_ucred {
75         __u32               mu_valid;
76         __u32                   mu_o_uid;
77         __u32                   mu_o_gid;
78         __u32                   mu_o_fsuid;
79         __u32                   mu_o_fsgid;
80         __u32                   mu_uid;
81         __u32                   mu_gid;
82         __u32                   mu_fsuid;
83         __u32                   mu_fsgid;
84         __u32                   mu_suppgids[2];
85         cfs_cap_t               mu_cap;
86         __u32                   mu_umask;
87         struct group_info      *mu_ginfo;
88         struct md_identity *mu_identity;
89 };
90
91 #define MD_CAPAINFO_MAX 5
92
93 /** there are at most 5 fids in one operation, see rename, NOTE the last one
94  * is a temporary one used for is_subdir() */
95 struct md_capainfo {
96         const struct lu_fid    *mc_fid[MD_CAPAINFO_MAX];
97         struct lustre_capa     *mc_capa[MD_CAPAINFO_MAX];
98 };
99
100 /**
101  * Implemented in mdd/mdd_handler.c.
102  *
103  * XXX should be moved into separate .h/.c together with all md security
104  * related definitions.
105  */
106 struct md_ucred *md_ucred(const struct lu_env *env);
107 struct md_capainfo *md_capainfo(const struct lu_env *env);
108
109 /** metadata attributes */
110 enum ma_valid {
111         MA_INODE     = (1 << 0),
112         MA_LOV       = (1 << 1),
113         MA_COOKIE    = (1 << 2),
114         MA_FLAGS     = (1 << 3),
115         MA_LMV       = (1 << 4),
116         MA_ACL_DEF   = (1 << 5),
117         MA_LOV_DEF   = (1 << 6)
118 };
119
120 typedef enum {
121         MDL_MINMODE  = 0,
122         MDL_EX       = 1,
123         MDL_PW       = 2,
124         MDL_PR       = 4,
125         MDL_CW       = 8,
126         MDL_CR       = 16,
127         MDL_NL       = 32,
128         MDL_GROUP    = 64,
129         MDL_MAXMODE
130 } mdl_mode_t;
131
132 typedef enum {
133         MDT_NUL_LOCK = 0,
134         MDT_REG_LOCK = (1 << 0),
135         MDT_PDO_LOCK = (1 << 1)
136 } mdl_type_t;
137
138 struct md_attr {
139         __u64                   ma_valid;
140         __u64                   ma_need;
141         __u64                   ma_attr_flags;
142         struct lu_attr          ma_attr;
143         struct lov_mds_md      *ma_lmm;
144         int                     ma_lmm_size;
145         struct lmv_stripe_md   *ma_lmv;
146         int                     ma_lmv_size;
147         void                   *ma_acl;
148         int                     ma_acl_size;
149         struct llog_cookie     *ma_cookie;
150         int                     ma_cookie_size;
151         struct lustre_capa     *ma_capa;
152 };
153
154 /** Additional parameters for create */
155 struct md_op_spec {
156         union {
157                 /** symlink target */
158                 const char               *sp_symname;
159                 /** parent FID for cross-ref mkdir */
160                 const struct lu_fid      *sp_pfid;
161                 /** eadata for regular files */
162                 struct md_spec_reg {
163                         /** lov objs exist already */
164                         const struct lu_fid   *fid;
165                         int no_lov_create;
166                         const void *eadata;
167                         int  eadatalen;
168                 } sp_ea;
169         } u;
170
171         /** Create flag from client: such as MDS_OPEN_CREAT, and others. */
172         __u32      sp_cr_flags;
173
174         /** Should mdd do lookup sanity check or not. */
175         int        sp_cr_lookup;
176
177         /** Current lock mode for parent dir where create is performing. */
178         mdl_mode_t sp_cr_mode;
179
180         /** Check for split */
181         int        sp_ck_split;
182 };
183
184 /**
185  * Operations implemented for each md object (both directory and leaf).
186  */
187 struct md_object_operations {
188         int (*moo_permission)(const struct lu_env *env,
189                               struct md_object *pobj, struct md_object *cobj,
190                               struct md_attr *attr, int mask);
191
192         int (*moo_attr_get)(const struct lu_env *env, struct md_object *obj,
193                             struct md_attr *attr);
194
195         int (*moo_attr_set)(const struct lu_env *env, struct md_object *obj,
196                             const struct md_attr *attr);
197
198         int (*moo_xattr_get)(const struct lu_env *env, struct md_object *obj,
199                              struct lu_buf *buf, const char *name);
200
201         int (*moo_xattr_list)(const struct lu_env *env, struct md_object *obj,
202                               struct lu_buf *buf);
203
204         int (*moo_xattr_set)(const struct lu_env *env, struct md_object *obj,
205                              const struct lu_buf *buf, const char *name,
206                              int fl);
207
208         int (*moo_xattr_del)(const struct lu_env *env, struct md_object *obj,
209                              const char *name);
210
211         int (*moo_readpage)(const struct lu_env *env, struct md_object *obj,
212                             const struct lu_rdpg *rdpg);
213
214         int (*moo_readlink)(const struct lu_env *env, struct md_object *obj,
215                             struct lu_buf *buf);
216
217         /** part of cross-ref operation */
218         int (*moo_object_create)(const struct lu_env *env,
219                                  struct md_object *obj,
220                                  const struct md_op_spec *spec,
221                                  struct md_attr *ma);
222
223         int (*moo_ref_add)(const struct lu_env *env,
224                            struct md_object *obj,
225                            const struct md_attr *ma);
226
227         int (*moo_ref_del)(const struct lu_env *env,
228                            struct md_object *obj,
229                            struct md_attr *ma);
230
231         int (*moo_open)(const struct lu_env *env,
232                         struct md_object *obj, int flag);
233
234         int (*moo_close)(const struct lu_env *env, struct md_object *obj,
235                          struct md_attr *ma);
236
237         int (*moo_capa_get)(const struct lu_env *, struct md_object *,
238                             struct lustre_capa *, int renewal);
239         int (*moo_object_sync)(const struct lu_env *, struct md_object *);
240 };
241
242 /**
243  * Operations implemented for each directory object.
244  */
245 struct md_dir_operations {
246         int (*mdo_is_subdir) (const struct lu_env *env, struct md_object *obj,
247                               const struct lu_fid *fid, struct lu_fid *sfid);
248
249         int (*mdo_lookup)(const struct lu_env *env, struct md_object *obj,
250                           const struct lu_name *lname, struct lu_fid *fid,
251                           struct md_op_spec *spec);
252
253         mdl_mode_t (*mdo_lock_mode)(const struct lu_env *env,
254                                     struct md_object *obj,
255                                     mdl_mode_t mode);
256
257         int (*mdo_create)(const struct lu_env *env, struct md_object *pobj,
258                           const struct lu_name *lname, struct md_object *child,
259                           struct md_op_spec *spec,
260                           struct md_attr *ma);
261
262         /** This method is used for creating data object for this meta object*/
263         int (*mdo_create_data)(const struct lu_env *env, struct md_object *p,
264                                struct md_object *o,
265                                const struct md_op_spec *spec,
266                                struct md_attr *ma);
267
268         int (*mdo_rename)(const struct lu_env *env, struct md_object *spobj,
269                           struct md_object *tpobj, const struct lu_fid *lf,
270                           const struct lu_name *lsname, struct md_object *tobj,
271                           const struct lu_name *ltname, struct md_attr *ma);
272
273         int (*mdo_link)(const struct lu_env *env, struct md_object *tgt_obj,
274                         struct md_object *src_obj, const struct lu_name *lname,
275                         struct md_attr *ma);
276
277         int (*mdo_unlink)(const struct lu_env *env, struct md_object *pobj,
278                           struct md_object *cobj, const struct lu_name *lname,
279                           struct md_attr *ma);
280
281         /** partial ops for cross-ref case */
282         int (*mdo_name_insert)(const struct lu_env *env,
283                                struct md_object *obj,
284                                const struct lu_name *lname,
285                                const struct lu_fid *fid,
286                                const struct md_attr *ma);
287
288         int (*mdo_name_remove)(const struct lu_env *env,
289                                struct md_object *obj,
290                                const struct lu_name *lname,
291                                const struct md_attr *ma);
292
293         int (*mdo_rename_tgt)(const struct lu_env *env, struct md_object *pobj,
294                               struct md_object *tobj, const struct lu_fid *fid,
295                               const struct lu_name *lname, struct md_attr *ma);
296 };
297
298 struct md_device_operations {
299         /** meta-data device related handlers. */
300         int (*mdo_root_get)(const struct lu_env *env, struct md_device *m,
301                             struct lu_fid *f);
302
303         int (*mdo_maxsize_get)(const struct lu_env *env, struct md_device *m,
304                                int *md_size, int *cookie_size);
305
306         int (*mdo_statfs)(const struct lu_env *env, struct md_device *m,
307                           struct kstatfs *sfs);
308
309         int (*mdo_init_capa_ctxt)(const struct lu_env *env, struct md_device *m,
310                                   int mode, unsigned long timeout, __u32 alg,
311                                   struct lustre_capa_key *keys);
312
313         int (*mdo_update_capa_key)(const struct lu_env *env,
314                                    struct md_device *m,
315                                    struct lustre_capa_key *key);
316 };
317
318 enum md_upcall_event {
319         /**sync the md layer*/
320         MD_LOV_SYNC = (1 << 0),
321         /** Just for split, no need trans, for replay */
322         MD_NO_TRANS = (1 << 1),
323         MD_LOV_CONFIG = (1 << 2)
324 };
325
326 struct md_upcall {
327         /** this lock protects upcall using against its removal
328          * read lock is for usage the upcall, write - for init/fini */
329         struct rw_semaphore     mu_upcall_sem;
330         /** device to call, upper layer normally */
331         struct md_device       *mu_upcall_dev;
332         /** upcall function */
333         int (*mu_upcall)(const struct lu_env *env, struct md_device *md,
334                          enum md_upcall_event ev);
335 };
336
337 struct md_device {
338         struct lu_device             md_lu_dev;
339         const struct md_device_operations *md_ops;
340         struct md_upcall             md_upcall;
341 };
342
343 static inline void md_upcall_init(struct md_device *m, void *upcl)
344 {
345         init_rwsem(&m->md_upcall.mu_upcall_sem);
346         m->md_upcall.mu_upcall_dev = NULL;
347         m->md_upcall.mu_upcall = upcl;
348 }
349
350 static inline void md_upcall_dev_set(struct md_device *m, struct md_device *up)
351 {
352         down_write(&m->md_upcall.mu_upcall_sem);
353         m->md_upcall.mu_upcall_dev = up;
354         up_write(&m->md_upcall.mu_upcall_sem);
355 }
356
357 static inline void md_upcall_fini(struct md_device *m)
358 {
359         down_write(&m->md_upcall.mu_upcall_sem);
360         m->md_upcall.mu_upcall_dev = NULL;
361         m->md_upcall.mu_upcall = NULL;
362         up_write(&m->md_upcall.mu_upcall_sem);
363 }
364
365 static inline int md_do_upcall(const struct lu_env *env, struct md_device *m,
366                                enum md_upcall_event ev)
367 {
368         int rc = 0;
369         down_read(&m->md_upcall.mu_upcall_sem);
370         if (m->md_upcall.mu_upcall_dev != NULL &&
371             m->md_upcall.mu_upcall_dev->md_upcall.mu_upcall != NULL) {
372                 rc = m->md_upcall.mu_upcall_dev->md_upcall.mu_upcall(env,
373                                               m->md_upcall.mu_upcall_dev, ev);
374         }
375         up_read(&m->md_upcall.mu_upcall_sem);
376         return rc;
377 }
378
379 struct md_object {
380         struct lu_object             mo_lu;
381         const struct md_object_operations *mo_ops;
382         const struct md_dir_operations    *mo_dir_ops;
383 };
384
385 /**
386  * md-server site.
387  */
388 struct md_site {
389         struct lu_site ms_lu;
390         /**
391          * mds number of this site.
392          */
393         mdsno_t               ms_node_id;
394         /**
395          * Fid location database
396          */
397         struct lu_server_fld *ms_server_fld;
398         struct lu_client_fld *ms_client_fld;
399
400         /**
401          * Server Seq Manager
402          */
403         struct lu_server_seq *ms_server_seq;
404
405         /**
406          * Controller Seq Manager
407          */
408         struct lu_server_seq *ms_control_seq;
409         struct obd_export    *ms_control_exp;
410
411         /**
412          * Client Seq Manager
413          */
414         struct lu_client_seq *ms_client_seq;
415 };
416
417 static inline int lu_device_is_md(const struct lu_device *d)
418 {
419         return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_MD);
420 }
421
422 static inline struct md_device *lu2md_dev(const struct lu_device *d)
423 {
424         LASSERT(IS_ERR(d) || lu_device_is_md(d));
425         return container_of0(d, struct md_device, md_lu_dev);
426 }
427
428 static inline struct lu_device *md2lu_dev(struct md_device *d)
429 {
430         return &d->md_lu_dev;
431 }
432
433 static inline struct md_object *lu2md(const struct lu_object *o)
434 {
435         LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->lo_dev));
436         return container_of0(o, struct md_object, mo_lu);
437 }
438
439 static inline struct md_object *md_object_next(const struct md_object *obj)
440 {
441         return (obj ? lu2md(lu_object_next(&obj->mo_lu)) : NULL);
442 }
443
444 static inline struct md_device *md_obj2dev(const struct md_object *o)
445 {
446         LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->mo_lu.lo_dev));
447         return container_of0(o->mo_lu.lo_dev, struct md_device, md_lu_dev);
448 }
449
450 static inline struct md_site *lu_site2md(const struct lu_site *s)
451 {
452         return container_of0(s, struct md_site, ms_lu);
453 }
454
455 static inline int md_device_init(struct md_device *md, struct lu_device_type *t)
456 {
457         return lu_device_init(&md->md_lu_dev, t);
458 }
459
460 static inline void md_device_fini(struct md_device *md)
461 {
462         lu_device_fini(&md->md_lu_dev);
463 }
464
465 static inline struct md_object *md_object_find_slice(const struct lu_env *env,
466                                                      struct md_device *md,
467                                                      const struct lu_fid *f)
468 {
469         return lu2md(lu_object_find_slice(env, md2lu_dev(md), f, NULL));
470 }
471
472
473 /** md operations */
474 static inline int mo_permission(const struct lu_env *env,
475                                 struct md_object *p,
476                                 struct md_object *c,
477                                 struct md_attr *at,
478                                 int mask)
479 {
480         LASSERT(c->mo_ops->moo_permission);
481         return c->mo_ops->moo_permission(env, p, c, at, mask);
482 }
483
484 static inline int mo_attr_get(const struct lu_env *env,
485                               struct md_object *m,
486                               struct md_attr *at)
487 {
488         LASSERT(m->mo_ops->moo_attr_get);
489         return m->mo_ops->moo_attr_get(env, m, at);
490 }
491
492 static inline int mo_readlink(const struct lu_env *env,
493                               struct md_object *m,
494                               struct lu_buf *buf)
495 {
496         LASSERT(m->mo_ops->moo_readlink);
497         return m->mo_ops->moo_readlink(env, m, buf);
498 }
499
500 static inline int mo_attr_set(const struct lu_env *env,
501                               struct md_object *m,
502                               const struct md_attr *at)
503 {
504         LASSERT(m->mo_ops->moo_attr_set);
505         return m->mo_ops->moo_attr_set(env, m, at);
506 }
507
508 static inline int mo_xattr_get(const struct lu_env *env,
509                                struct md_object *m,
510                                struct lu_buf *buf,
511                                const char *name)
512 {
513         LASSERT(m->mo_ops->moo_xattr_get);
514         return m->mo_ops->moo_xattr_get(env, m, buf, name);
515 }
516
517 static inline int mo_xattr_del(const struct lu_env *env,
518                                struct md_object *m,
519                                const char *name)
520 {
521         LASSERT(m->mo_ops->moo_xattr_del);
522         return m->mo_ops->moo_xattr_del(env, m, name);
523 }
524
525 static inline int mo_xattr_set(const struct lu_env *env,
526                                struct md_object *m,
527                                const struct lu_buf *buf,
528                                const char *name,
529                                int flags)
530 {
531         LASSERT(m->mo_ops->moo_xattr_set);
532         return m->mo_ops->moo_xattr_set(env, m, buf, name, flags);
533 }
534
535 static inline int mo_xattr_list(const struct lu_env *env,
536                                 struct md_object *m,
537                                 struct lu_buf *buf)
538 {
539         LASSERT(m->mo_ops->moo_xattr_list);
540         return m->mo_ops->moo_xattr_list(env, m, buf);
541 }
542
543 static inline int mo_open(const struct lu_env *env,
544                           struct md_object *m,
545                           int flags)
546 {
547         LASSERT(m->mo_ops->moo_open);
548         return m->mo_ops->moo_open(env, m, flags);
549 }
550
551 static inline int mo_close(const struct lu_env *env,
552                            struct md_object *m,
553                            struct md_attr *ma)
554 {
555         LASSERT(m->mo_ops->moo_close);
556         return m->mo_ops->moo_close(env, m, ma);
557 }
558
559 static inline int mo_readpage(const struct lu_env *env,
560                               struct md_object *m,
561                               const struct lu_rdpg *rdpg)
562 {
563         LASSERT(m->mo_ops->moo_readpage);
564         return m->mo_ops->moo_readpage(env, m, rdpg);
565 }
566
567 static inline int mo_object_create(const struct lu_env *env,
568                                    struct md_object *m,
569                                    const struct md_op_spec *spc,
570                                    struct md_attr *at)
571 {
572         LASSERT(m->mo_ops->moo_object_create);
573         return m->mo_ops->moo_object_create(env, m, spc, at);
574 }
575
576 static inline int mo_ref_add(const struct lu_env *env,
577                              struct md_object *m,
578                              const struct md_attr *ma)
579 {
580         LASSERT(m->mo_ops->moo_ref_add);
581         return m->mo_ops->moo_ref_add(env, m, ma);
582 }
583
584 static inline int mo_ref_del(const struct lu_env *env,
585                              struct md_object *m,
586                              struct md_attr *ma)
587 {
588         LASSERT(m->mo_ops->moo_ref_del);
589         return m->mo_ops->moo_ref_del(env, m, ma);
590 }
591
592 static inline int mo_capa_get(const struct lu_env *env,
593                               struct md_object *m,
594                               struct lustre_capa *c,
595                               int renewal)
596 {
597         LASSERT(m->mo_ops->moo_capa_get);
598         return m->mo_ops->moo_capa_get(env, m, c, renewal);
599 }
600
601 static inline int mo_object_sync(const struct lu_env *env, struct md_object *m)
602 {
603         LASSERT(m->mo_ops->moo_object_sync);
604         return m->mo_ops->moo_object_sync(env, m);
605 }
606
607 static inline int mdo_lookup(const struct lu_env *env,
608                              struct md_object *p,
609                              const struct lu_name *lname,
610                              struct lu_fid *f,
611                              struct md_op_spec *spec)
612 {
613         LASSERT(p->mo_dir_ops->mdo_lookup);
614         return p->mo_dir_ops->mdo_lookup(env, p, lname, f, spec);
615 }
616
617 static inline mdl_mode_t mdo_lock_mode(const struct lu_env *env,
618                                        struct md_object *mo,
619                                        mdl_mode_t lm)
620 {
621         if (mo->mo_dir_ops->mdo_lock_mode == NULL)
622                 return MDL_MINMODE;
623         return mo->mo_dir_ops->mdo_lock_mode(env, mo, lm);
624 }
625
626 static inline int mdo_create(const struct lu_env *env,
627                              struct md_object *p,
628                              const struct lu_name *lchild_name,
629                              struct md_object *c,
630                              struct md_op_spec *spc,
631                              struct md_attr *at)
632 {
633         LASSERT(c->mo_dir_ops->mdo_create);
634         return c->mo_dir_ops->mdo_create(env, p, lchild_name, c, spc, at);
635 }
636
637 static inline int mdo_create_data(const struct lu_env *env,
638                                   struct md_object *p,
639                                   struct md_object *c,
640                                   const struct md_op_spec *spec,
641                                   struct md_attr *ma)
642 {
643         LASSERT(c->mo_dir_ops->mdo_create_data);
644         return c->mo_dir_ops->mdo_create_data(env, p, c, spec, ma);
645 }
646
647 static inline int mdo_rename(const struct lu_env *env,
648                              struct md_object *sp,
649                              struct md_object *tp,
650                              const struct lu_fid *lf,
651                              const struct lu_name *lsname,
652                              struct md_object *t,
653                              const struct lu_name *ltname,
654                              struct md_attr *ma)
655 {
656         LASSERT(tp->mo_dir_ops->mdo_rename);
657         return tp->mo_dir_ops->mdo_rename(env, sp, tp, lf, lsname, t, ltname,
658                                           ma);
659 }
660
661 static inline int mdo_is_subdir(const struct lu_env *env,
662                                 struct md_object *mo,
663                                 const struct lu_fid *fid,
664                                 struct lu_fid *sfid)
665 {
666         LASSERT(mo->mo_dir_ops->mdo_is_subdir);
667         return mo->mo_dir_ops->mdo_is_subdir(env, mo, fid, sfid);
668 }
669
670 static inline int mdo_link(const struct lu_env *env,
671                            struct md_object *p,
672                            struct md_object *s,
673                            const struct lu_name *lname,
674                            struct md_attr *ma)
675 {
676         LASSERT(s->mo_dir_ops->mdo_link);
677         return s->mo_dir_ops->mdo_link(env, p, s, lname, ma);
678 }
679
680 static inline int mdo_unlink(const struct lu_env *env,
681                              struct md_object *p,
682                              struct md_object *c,
683                              const struct lu_name *lname,
684                              struct md_attr *ma)
685 {
686         LASSERT(c->mo_dir_ops->mdo_unlink);
687         return c->mo_dir_ops->mdo_unlink(env, p, c, lname, ma);
688 }
689
690 static inline int mdo_name_insert(const struct lu_env *env,
691                                   struct md_object *p,
692                                   const struct lu_name *lname,
693                                   const struct lu_fid *f,
694                                   const struct md_attr *ma)
695 {
696         LASSERT(p->mo_dir_ops->mdo_name_insert);
697         return p->mo_dir_ops->mdo_name_insert(env, p, lname, f, ma);
698 }
699
700 static inline int mdo_name_remove(const struct lu_env *env,
701                                   struct md_object *p,
702                                   const struct lu_name *lname,
703                                   const struct md_attr *ma)
704 {
705         LASSERT(p->mo_dir_ops->mdo_name_remove);
706         return p->mo_dir_ops->mdo_name_remove(env, p, lname, ma);
707 }
708
709 static inline int mdo_rename_tgt(const struct lu_env *env,
710                                  struct md_object *p,
711                                  struct md_object *t,
712                                  const struct lu_fid *lf,
713                                  const struct lu_name *lname,
714                                  struct md_attr *ma)
715 {
716         if (t) {
717                 LASSERT(t->mo_dir_ops->mdo_rename_tgt);
718                 return t->mo_dir_ops->mdo_rename_tgt(env, p, t, lf, lname, ma);
719         } else {
720                 LASSERT(p->mo_dir_ops->mdo_rename_tgt);
721                 return p->mo_dir_ops->mdo_rename_tgt(env, p, t, lf, lname, ma);
722         }
723 }
724
725 /** @} md */
726
727 #endif /* _LINUX_MD_OBJECT_H */