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