Whamcloud - gitweb
LU-8569 linkea: linkEA size limitation
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License version 2 for more details (a copy is included
14  * in the LICENSE file that accompanied this code).
15  *
16  * You should have received a copy of the GNU General Public License
17  * version 2 along with this program; If not, see
18  * http://www.gnu.org/licenses/gpl-2.0.html
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2011, 2016, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  * Lustre is a trademark of Sun Microsystems, Inc.
31  *
32  * lustre/mdd/mdd_internal.h
33  *
34  * Author: Wang Di <wangdi@clusterfs.com>
35  */
36
37 #ifndef _MDD_INTERNAL_H
38 #define _MDD_INTERNAL_H
39
40 #include <lustre_acl.h>
41 #include <lustre_compat.h>
42 #include <lustre_eacl.h>
43 #include <md_object.h>
44 #include <dt_object.h>
45 #include <lustre_lfsck.h>
46 #include <lustre_fid.h>
47 #include <lprocfs_status.h>
48 #include <lustre_log.h>
49 #include <lustre_linkea.h>
50
51 /* Changelog flags */
52 /** changelog is recording */
53 #define CLM_ON    0x00001
54 /** internal error prevented changelogs from starting */
55 #define CLM_ERR   0x00002
56 /* Marker flags */
57 /** changelogs turned on */
58 #define CLM_START 0x10000
59 /** changelogs turned off */
60 #define CLM_FINI  0x20000
61 /** some changelog records purged */
62 #define CLM_PURGE 0x40000
63
64 struct mdd_changelog {
65         spinlock_t              mc_lock;        /* for index */
66         int                     mc_flags;
67         int                     mc_mask;
68         __u64                   mc_index;
69         __u64                   mc_starttime;
70         spinlock_t              mc_user_lock;
71         int                     mc_lastuser;
72 };
73
74 static inline __u64 cl_time(void)
75 {
76         struct timespec64 time;
77
78         ktime_get_real_ts64(&time);
79         return (((__u64)time.tv_sec) << 30) + time.tv_nsec;
80 }
81
82 /** Objects in .lustre dir */
83 struct mdd_dot_lustre_objs {
84         struct mdd_object *mdd_obf;
85         struct mdd_object *mdd_lpf;
86 };
87
88 struct mdd_generic_thread {
89         struct completion       mgt_started;
90         struct completion       mgt_finished;
91         void                   *mgt_data;
92         bool                    mgt_abort;
93         bool                    mgt_init;
94 };
95
96 struct mdd_device {
97         struct md_device                 mdd_md_dev;
98         struct obd_export               *mdd_child_exp;
99         struct dt_device                *mdd_child;
100         struct dt_device                *mdd_bottom;
101         struct lu_fid                    mdd_root_fid; /* /ROOT */
102         struct lu_fid                    mdd_local_root_fid;
103         struct dt_device_param           mdd_dt_conf;
104         struct dt_object                *mdd_orphans; /* PENDING directory */
105         struct proc_dir_entry            *mdd_proc_entry;
106         struct mdd_changelog             mdd_cl;
107         unsigned long                    mdd_atime_diff;
108         struct mdd_object               *mdd_dot_lustre;
109         struct mdd_dot_lustre_objs       mdd_dot_lustre_objs;
110         unsigned int                     mdd_sync_permission;
111         int                              mdd_connects;
112         struct local_oid_storage        *mdd_los;
113         struct mdd_generic_thread        mdd_orph_cleanup_thread;
114 };
115
116 enum mod_flags {
117         /* The dir object has been unlinked */
118         DEAD_OBJ   = 1 << 0,
119         ORPHAN_OBJ = 1 << 1,
120 };
121
122 struct mdd_object {
123         struct md_object   mod_obj;
124         /* open count */
125         __u32             mod_count;
126         __u32             mod_valid;
127         __u64             mod_cltime;
128         unsigned long     mod_flags;
129 };
130
131 struct mdd_thread_info {
132         struct lu_fid             mti_fid;
133         struct lu_fid             mti_fid2; /* used for be & cpu converting */
134         /**
135         * only be used by MDD interfaces, can be passed into local MDD APIs.
136         */
137         struct lu_attr            mti_pattr;
138         struct lu_attr            mti_cattr;
139         struct lu_attr            mti_tpattr;
140         struct lu_attr            mti_tattr;
141         /** used to set c/mtime */
142         struct lu_attr            mti_la_for_fix;
143         /* Only used in mdd_object_start */
144         struct lu_attr            mti_la_for_start;
145         /* mti_ent and mti_key must be conjoint,
146         * then mti_ent::lde_name will be mti_key. */
147         struct lu_dirent          mti_ent;
148         char                      mti_key[NAME_MAX + 16];
149         struct lu_buf             mti_buf[4];
150         struct lu_buf             mti_big_buf; /* biggish persistent buf */
151         struct lu_buf             mti_link_buf; /* buf for link ea */
152         struct obdo               mti_oa;
153         char                      mti_xattr_buf[LUSTRE_POSIX_ACL_MAX_SIZE];
154         struct dt_allocation_hint mti_hint;
155         struct dt_object_format   mti_dof;
156         struct linkea_data        mti_link_data;
157         struct md_op_spec         mti_spec;
158         struct dt_insert_rec      mti_dt_rec;
159         struct lfsck_request      mti_lr;
160         struct lu_seq_range       mti_range;
161 };
162
163 extern const char orph_index_name[];
164
165 int mdd_la_get(const struct lu_env *env, struct mdd_object *obj,
166                struct lu_attr *la);
167 int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
168                  struct md_attr *ma);
169 int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
170                  const struct md_attr *ma);
171 int mdd_attr_set_internal(const struct lu_env *env,
172                           struct mdd_object *obj,
173                           const struct lu_attr *attr,
174                           struct thandle *handle,
175                           int needacl);
176 int mdd_update_time(const struct lu_env *env, struct mdd_object *obj,
177                     const struct lu_attr *oattr, struct lu_attr *attr,
178                     struct thandle *handle);
179 int mdd_object_create_internal(const struct lu_env *env, struct mdd_object *p,
180                                struct mdd_object *c, struct lu_attr *attr,
181                                struct thandle *handle,
182                                const struct md_op_spec *spec,
183                                struct dt_allocation_hint *hint);
184
185 /* mdd_lock.c */
186 void mdd_write_lock(const struct lu_env *env, struct mdd_object *obj,
187                     enum mdd_object_role role);
188 void mdd_read_lock(const struct lu_env *env, struct mdd_object *obj,
189                    enum mdd_object_role role);
190 void mdd_write_unlock(const struct lu_env *env, struct mdd_object *obj);
191 void mdd_read_unlock(const struct lu_env *env, struct mdd_object *obj);
192 int mdd_write_locked(const struct lu_env *env, struct mdd_object *obj);
193
194 /* mdd_dir.c */
195 int mdd_is_subdir(const struct lu_env *env, struct md_object *mo,
196                   const struct lu_fid *fid, struct lu_fid *sfid);
197 int mdd_may_create(const struct lu_env *env, struct mdd_object *pobj,
198                    const struct lu_attr *pattr, struct mdd_object *cobj,
199                    bool check_perm);
200 int mdd_may_unlink(const struct lu_env *env, struct mdd_object *pobj,
201                    const struct lu_attr *pattr, const struct lu_attr *attr);
202 int mdd_may_delete(const struct lu_env *env, struct mdd_object *tpobj,
203                    const struct lu_attr *tpattr, struct mdd_object *tobj,
204                    const struct lu_attr *tattr, const struct lu_attr *cattr,
205                    int check_perm, int check_empty);
206 int mdd_unlink_sanity_check(const struct lu_env *env, struct mdd_object *pobj,
207                             const struct lu_attr *pattr,
208                             struct mdd_object *cobj,
209                             const struct lu_attr *cattr);
210 int mdd_finish_unlink(const struct lu_env *env, struct mdd_object *obj,
211                       struct md_attr *ma, const struct mdd_object *pobj,
212                       const struct lu_name *lname, struct thandle *th);
213
214 int mdd_is_root(struct mdd_device *mdd, const struct lu_fid *fid);
215 int mdd_lookup(const struct lu_env *env,
216                struct md_object *pobj, const struct lu_name *lname,
217                struct lu_fid* fid, struct md_op_spec *spec);
218 int mdd_links_write(const struct lu_env *env, struct mdd_object *mdd_obj,
219                     struct linkea_data *ldata, struct thandle *handle);
220 struct lu_buf *mdd_links_get(const struct lu_env *env,
221                              struct mdd_object *mdd_obj);
222 int mdd_links_rename(const struct lu_env *env,
223                      struct mdd_object *mdd_obj,
224                      const struct lu_fid *oldpfid,
225                      const struct lu_name *oldlname,
226                      const struct lu_fid *newpfid,
227                      const struct lu_name *newlname,
228                      struct thandle *handle,
229                      struct linkea_data *ldata,
230                      int first, int check);
231
232 struct mdd_thread_info *mdd_env_info(const struct lu_env *env);
233
234 #define MDD_ENV_VAR(env, var) (&mdd_env_info(env)->mti_##var)
235
236 struct lu_buf *mdd_buf_get(const struct lu_env *env, void *area, ssize_t len);
237 const struct lu_buf *mdd_buf_get_const(const struct lu_env *env,
238                                        const void *area, ssize_t len);
239
240 int mdd_orphan_cleanup(const struct lu_env *env, struct mdd_device *d);
241 int __mdd_orphan_add(const struct lu_env *, struct mdd_object *,
242                      struct thandle *);
243 int __mdd_orphan_del(const struct lu_env *, struct mdd_object *,
244                      struct thandle *);
245 int orph_index_init(const struct lu_env *env, struct mdd_device *mdd);
246 void orph_index_fini(const struct lu_env *env, struct mdd_device *mdd);
247 int orph_declare_index_insert(const struct lu_env *, struct mdd_object *,
248                               umode_t mode, struct thandle *);
249 int orph_declare_index_delete(const struct lu_env *, struct mdd_object *,
250                               struct thandle *);
251
252 /* mdd_lproc.c */
253 int mdd_procfs_init(struct mdd_device *mdd, const char *name);
254 void mdd_procfs_fini(struct mdd_device *mdd);
255
256 /* mdd_object.c */
257 extern struct kmem_cache *mdd_object_kmem;
258 extern const struct md_dir_operations    mdd_dir_ops;
259 extern const struct md_object_operations mdd_obj_ops;
260 int mdd_readlink(const struct lu_env *env, struct md_object *obj,
261                  struct lu_buf *buf);
262 int accmode(const struct lu_env *env, const struct lu_attr *la, int flags);
263 extern struct lu_context_key mdd_thread_key;
264 extern const struct lu_device_operations mdd_lu_ops;
265
266 struct mdd_object *mdd_object_find(const struct lu_env *env,
267                                    struct mdd_device *d,
268                                    const struct lu_fid *f);
269 int mdd_readpage(const struct lu_env *env, struct md_object *obj,
270                  const struct lu_rdpg *rdpg);
271 int mdd_declare_changelog_store(const struct lu_env *env,
272                                        struct mdd_device *mdd,
273                                        const struct lu_name *tname,
274                                        const struct lu_name *sname,
275                                        struct thandle *handle);
276 void mdd_changelog_rec_ext_jobid(struct changelog_rec *rec, const char *jobid);
277 int mdd_changelog_store(const struct lu_env *env, struct mdd_device *mdd,
278                         struct llog_changelog_rec *rec, struct thandle *th);
279 int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd,
280                              enum changelog_rec_type type, int flags,
281                              struct mdd_object *mdd_obj,
282                              struct thandle *handle);
283 int mdd_changelog_ns_store(const struct lu_env *env, struct mdd_device *mdd,
284                            enum changelog_rec_type type,
285                            enum changelog_rec_flags crf,
286                            struct mdd_object *target,
287                            const struct lu_fid *tpfid,
288                            const struct lu_fid *sfid,
289                            const struct lu_fid *spfid,
290                            const struct lu_name *tname,
291                            const struct lu_name *sname,
292                            struct thandle *handle);
293 int mdd_invalidate(const struct lu_env *env, struct md_object *obj);
294 int mdd_declare_object_create_internal(const struct lu_env *env,
295                                        struct mdd_object *p,
296                                        struct mdd_object *c,
297                                        struct lu_attr *attr,
298                                        struct thandle *handle,
299                                        const struct md_op_spec *spec,
300                                        struct dt_allocation_hint *hint);
301 int mdd_get_lov_ea(const struct lu_env *env, struct mdd_object *obj,
302                    struct lu_buf *lmm_buf);
303
304 /* mdd_trans.c */
305 void mdd_object_make_hint(const struct lu_env *env, struct mdd_object *parent,
306                           struct mdd_object *child, const struct lu_attr *attr,
307                           const struct md_op_spec *spec,
308                           struct dt_allocation_hint *hint);
309
310 static inline void mdd_object_get(struct mdd_object *o)
311 {
312         lu_object_get(&o->mod_obj.mo_lu);
313 }
314
315 static inline void mdd_object_put(const struct lu_env *env,
316                                   struct mdd_object *o)
317 {
318         lu_object_put(env, &o->mod_obj.mo_lu);
319 }
320
321 struct thandle *mdd_trans_create(const struct lu_env *env,
322                                  struct mdd_device *mdd);
323 int mdd_trans_start(const struct lu_env *env, struct mdd_device *mdd,
324                     struct thandle *th);
325 int mdd_trans_stop(const struct lu_env *env, struct mdd_device *mdd,
326                    int rc, struct thandle *handle);
327
328 /* mdd_device.c */
329 struct lu_object *mdd_object_alloc(const struct lu_env *env,
330                                    const struct lu_object_header *hdr,
331                                    struct lu_device *d);
332 int mdd_local_file_create(const struct lu_env *env, struct mdd_device *mdd,
333                           const struct lu_fid *pfid, const char *name,
334                           __u32 mode, struct lu_fid *fid);
335
336 int mdd_acl_chmod(const struct lu_env *env, struct mdd_object *o, __u32 mode,
337                   struct thandle *handle);
338 int mdd_acl_set(const struct lu_env *env, struct mdd_object *obj,
339                 struct lu_attr *attr, const struct lu_buf *buf, int fl);
340 int __mdd_fix_mode_acl(const struct lu_env *env, struct lu_buf *buf,
341                        __u32 *mode);
342 int __mdd_permission_internal(const struct lu_env *env, struct mdd_object *obj,
343                               const struct lu_attr *la, int mask, int role);
344 int mdd_permission(const struct lu_env *env,
345                    struct md_object *pobj, struct md_object *cobj,
346                    struct md_attr *ma, int mask);
347 int mdd_generic_thread_start(struct mdd_generic_thread *thread,
348                              int (*func)(void *), void *data, char *name);
349 void mdd_generic_thread_stop(struct mdd_generic_thread *thread);
350
351 /* mdd_prepare.c */
352 int mdd_compat_fixes(const struct lu_env *env, struct mdd_device *mdd);
353
354 /* inline functions */
355 static inline int lu_device_is_mdd(struct lu_device *d)
356 {
357         return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &mdd_lu_ops);
358 }
359
360 static inline struct mdd_device* lu2mdd_dev(struct lu_device *d)
361 {
362         LASSERT(lu_device_is_mdd(d));
363         return container_of0(d, struct mdd_device, mdd_md_dev.md_lu_dev);
364 }
365
366 static inline struct lu_device *mdd2lu_dev(struct mdd_device *d)
367 {
368         return (&d->mdd_md_dev.md_lu_dev);
369 }
370
371 static inline struct mdd_object *lu2mdd_obj(struct lu_object *o)
372 {
373         LASSERT(ergo(o != NULL, lu_device_is_mdd(o->lo_dev)));
374         return container_of0(o, struct mdd_object, mod_obj.mo_lu);
375 }
376
377 static inline struct mdd_device* mdo2mdd(struct md_object *mdo)
378 {
379         return lu2mdd_dev(mdo->mo_lu.lo_dev);
380 }
381
382 static inline struct mdd_object* md2mdd_obj(struct md_object *mdo)
383 {
384         return container_of0(mdo, struct mdd_object, mod_obj);
385 }
386
387 static inline const struct dt_device_operations *
388 mdd_child_ops(struct mdd_device *d)
389 {
390         return d->mdd_child->dd_ops;
391 }
392
393 static inline struct lu_object *mdd2lu_obj(struct mdd_object *obj)
394 {
395         return &obj->mod_obj.mo_lu;
396 }
397
398 static inline struct dt_object* mdd_object_child(struct mdd_object *o)
399 {
400         return container_of0(lu_object_next(mdd2lu_obj(o)),
401                              struct dt_object, do_lu);
402 }
403
404 static inline struct obd_device *mdd2obd_dev(struct mdd_device *mdd)
405 {
406         return (mdd->mdd_md_dev.md_lu_dev.ld_obd);
407 }
408
409 static inline struct mdd_device *mdd_obj2mdd_dev(struct mdd_object *obj)
410 {
411         return mdo2mdd(&obj->mod_obj);
412 }
413
414 static inline const struct lu_fid *mdo2fid(const struct mdd_object *obj)
415 {
416         return lu_object_fid(&obj->mod_obj.mo_lu);
417 }
418
419 static inline umode_t mdd_object_type(const struct mdd_object *obj)
420 {
421         return lu_object_attr(&obj->mod_obj.mo_lu);
422 }
423
424 static inline int mdd_is_dead_obj(struct mdd_object *obj)
425 {
426         return obj && obj->mod_flags & DEAD_OBJ;
427 }
428
429 static inline int mdd_object_exists(struct mdd_object *obj)
430 {
431         return lu_object_exists(mdd2lu_obj(obj));
432 }
433
434 static inline int mdd_object_remote(struct mdd_object *obj)
435 {
436         return lu_object_remote(mdd2lu_obj(obj));
437 }
438
439 static inline const struct lu_fid *mdd_object_fid(struct mdd_object *obj)
440 {
441         return lu_object_fid(mdd2lu_obj(obj));
442 }
443
444 static inline struct seq_server_site *mdd_seq_site(struct mdd_device *mdd)
445 {
446         return mdd2lu_dev(mdd)->ld_site->ld_seq_site;
447 }
448
449 static inline const char *mdd_obj_dev_name(const struct mdd_object *obj)
450 {
451         return lu_dev_name(obj->mod_obj.mo_lu.lo_dev);
452 }
453
454 #define MAX_ATIME_DIFF 60
455
456 static inline int mdd_permission_internal(const struct lu_env *env,
457                                           struct mdd_object *obj,
458                                           const struct lu_attr *la, int mask)
459 {
460         return __mdd_permission_internal(env, obj, la, mask, -1);
461 }
462
463 static inline int mdd_permission_internal_locked(const struct lu_env *env,
464                                                 struct mdd_object *obj,
465                                                 const struct lu_attr *la,
466                                                 int mask,
467                                                 enum mdd_object_role role)
468 {
469         return __mdd_permission_internal(env, obj, la, mask, role);
470 }
471
472 /* mdd inline func for calling osd_dt_object ops */
473 static inline int mdo_attr_get(const struct lu_env *env, struct mdd_object *obj,
474                                struct lu_attr *la)
475 {
476         struct dt_object *next = mdd_object_child(obj);
477         return dt_attr_get(env, next, la);
478 }
479
480 static inline int mdo_declare_attr_set(const struct lu_env *env,
481                                        struct mdd_object *obj,
482                                        const struct lu_attr *la,
483                                        struct thandle *handle)
484 {
485         struct dt_object *next = mdd_object_child(obj);
486         return dt_declare_attr_set(env, next, la, handle);
487 }
488
489 static inline int mdo_attr_set(const struct lu_env *env,
490                                struct mdd_object *obj,
491                                const struct lu_attr *la,
492                                struct thandle *handle)
493 {
494         struct dt_object *next = mdd_object_child(obj);
495
496         if (!mdd_object_exists(obj))
497                 return -ENOENT;
498
499         return dt_attr_set(env, next, la, handle);
500 }
501
502 static inline int mdo_xattr_get(const struct lu_env *env,struct mdd_object *obj,
503                                 struct lu_buf *buf, const char *name)
504 {
505         struct dt_object *next = mdd_object_child(obj);
506         return dt_xattr_get(env, next, buf, name);
507 }
508
509 static inline int mdo_declare_xattr_set(const struct lu_env *env,
510                                         struct mdd_object *obj,
511                                         const struct lu_buf *buf,
512                                         const char *name,
513                                         int fl, struct thandle *handle)
514 {
515         struct dt_object *next = mdd_object_child(obj);
516         return dt_declare_xattr_set(env, next, buf, name, fl, handle);
517 }
518
519 static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj,
520                                 const struct lu_buf *buf, const char *name,
521                                 int fl, struct thandle *handle)
522 {
523         struct dt_object *next = mdd_object_child(obj);
524
525         if (!mdd_object_exists(obj))
526                 return -ENOENT;
527
528         return dt_xattr_set(env, next, buf, name, fl, handle);
529 }
530
531 static inline int mdo_declare_xattr_del(const struct lu_env *env,
532                                         struct mdd_object *obj,
533                                         const char *name,
534                                         struct thandle *handle)
535 {
536         struct dt_object *next = mdd_object_child(obj);
537         return dt_declare_xattr_del(env, next, name, handle);
538 }
539
540 static inline int mdo_xattr_del(const struct lu_env *env,struct mdd_object *obj,
541                                 const char *name, struct thandle *handle)
542 {
543         struct dt_object *next = mdd_object_child(obj);
544
545         if (!mdd_object_exists(obj))
546                 return -ENOENT;
547
548         return dt_xattr_del(env, next, name, handle);
549 }
550
551 static inline int
552 mdo_xattr_list(const struct lu_env *env, struct mdd_object *obj,
553                struct lu_buf *buf)
554 {
555         struct dt_object *next = mdd_object_child(obj);
556
557         if (!mdd_object_exists(obj))
558                 return -ENOENT;
559
560         return dt_xattr_list(env, next, buf);
561 }
562
563 static inline int
564 mdo_invalidate(const struct lu_env *env, struct mdd_object *obj)
565 {
566         return dt_invalidate(env, mdd_object_child(obj));
567 }
568
569 static inline
570 int mdo_declare_index_insert(const struct lu_env *env, struct mdd_object *obj,
571                              const struct lu_fid *fid, __u32 type,
572                              const char *name, struct thandle *handle)
573 {
574         struct dt_object *next  = mdd_object_child(obj);
575         int               rc;
576
577         /*
578          * if the object doesn't exist yet, then it's supposed to be created
579          * and declaration of the creation should be enough to insert ./..
580          */
581
582         rc = -ENOTDIR;
583         if (dt_try_as_dir(env, next)) {
584                 struct dt_insert_rec *rec = &mdd_env_info(env)->mti_dt_rec;
585
586                 rec->rec_fid = fid;
587                 rec->rec_type = type;
588                 rc = dt_declare_insert(env, next, (const struct dt_rec *)rec,
589                                        (const struct dt_key *)name, handle);
590         }
591
592          return rc;
593 }
594
595 static inline
596 int mdo_declare_index_delete(const struct lu_env *env, struct mdd_object *obj,
597                              const char *name, struct thandle *handle)
598 {
599         struct dt_object *next = mdd_object_child(obj);
600
601         if (!dt_try_as_dir(env, next))
602                 return -ENOTDIR;
603
604         return dt_declare_delete(env, next, (const struct dt_key *)name,
605                                  handle);
606 }
607
608 static inline int mdo_declare_ref_add(const struct lu_env *env,
609                                       struct mdd_object *obj,
610                                       struct thandle *handle)
611 {
612         struct dt_object *next = mdd_object_child(obj);
613         return dt_declare_ref_add(env, next, handle);
614 }
615
616 static inline int mdo_ref_add(const struct lu_env *env, struct mdd_object *obj,
617                               struct thandle *handle)
618 {
619         struct dt_object *next = mdd_object_child(obj);
620
621         if (!mdd_object_exists(obj))
622                 return -ENOENT;
623
624         return dt_ref_add(env, next, handle);
625 }
626
627 static inline int mdo_declare_ref_del(const struct lu_env *env,
628                                       struct mdd_object *obj,
629                                       struct thandle *handle)
630 {
631         struct dt_object *next = mdd_object_child(obj);
632         return dt_declare_ref_del(env, next, handle);
633 }
634
635 static inline int mdo_ref_del(const struct lu_env *env, struct mdd_object *obj,
636                               struct thandle *handle)
637 {
638         struct dt_object *next = mdd_object_child(obj);
639
640         if (!mdd_object_exists(obj))
641                 return -ENOENT;
642
643         return dt_ref_del(env, next, handle);
644 }
645
646 static inline int
647 mdo_declare_create_obj(const struct lu_env *env, struct mdd_object *o,
648                        struct lu_attr *attr,
649                        struct dt_allocation_hint *hint,
650                        struct dt_object_format *dof,
651                        struct thandle *handle)
652 {
653         struct dt_object *next = mdd_object_child(o);
654         return dt_declare_create(env, next, attr, hint, dof, handle);
655 }
656
657 static inline int
658 mdo_create_obj(const struct lu_env *env, struct mdd_object *o,
659                struct lu_attr *attr,
660                struct dt_allocation_hint *hint,
661                struct dt_object_format *dof,
662                struct thandle *handle)
663 {
664         struct dt_object *next = mdd_object_child(o);
665         return dt_create(env, next, attr, hint, dof, handle);
666 }
667
668 static inline
669 int mdo_declare_destroy(const struct lu_env *env, struct mdd_object *o,
670                         struct thandle *handle)
671 {
672         struct dt_object *next = mdd_object_child(o);
673         return dt_declare_destroy(env, next, handle);
674 }
675
676 static inline
677 int mdo_destroy(const struct lu_env *env, struct mdd_object *o,
678                 struct thandle *handle)
679 {
680         struct dt_object *next = mdd_object_child(o);
681         return dt_destroy(env, next, handle);
682 }
683
684 #endif