Whamcloud - gitweb
LU-14470 dne: striped mkdir replay by client request
[fs/lustre-release.git] / lustre / include / md_object.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, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * lustre/include/md_object.h
32  *
33  * Extention of lu_object.h for metadata objects
34  */
35
36 #ifndef _LUSTRE_MD_OBJECT_H
37 #define _LUSTRE_MD_OBJECT_H
38
39 #ifndef HAVE_SERVER_SUPPORT
40 # error "client code should not depend on md_object.h"
41 #endif /* !HAVE_SERVER_SUPPORT */
42
43 /** \defgroup md md
44  * Sub-class of lu_object with methods common for "meta-data" objects in MDT
45  * stack.
46  *
47  * Meta-data objects implement namespace operations: you can link, unlink
48  * them, and treat them as directories.
49  *
50  * Examples: mdt, cmm, and mdt are implementations of md interface.
51  * @{
52  */
53
54
55 /*
56  * super-class definitions.
57  */
58 #include <dt_object.h>
59
60 struct md_device;
61 struct md_device_operations;
62 struct md_object;
63 struct obd_export;
64
65 /** metadata attributes */
66 enum ma_valid {
67         MA_INODE        = BIT(0),
68         MA_LOV          = BIT(1),
69         MA_FLAGS        = BIT(2),
70         MA_LMV          = BIT(3),
71         MA_ACL_DEF      = BIT(4),
72         MA_LOV_DEF      = BIT(5),
73         MA_HSM          = BIT(6),
74         MA_PFID         = BIT(7),
75         MA_LMV_DEF      = BIT(8),
76         MA_SOM          = BIT(9),
77         MA_FORCE_LOG    = BIT(10), /* forced close logged in mdt_mfd_close */
78 };
79
80 typedef enum {
81         MDL_MINMODE  = 0,
82         MDL_EX       = 1,
83         MDL_PW       = 2,
84         MDL_PR       = 4,
85         MDL_CW       = 8,
86         MDL_CR       = 16,
87         MDL_NL       = 32,
88         MDL_GROUP    = 64,
89         MDL_MAXMODE
90 } mdl_mode_t;
91
92 typedef enum {
93         MDT_NUL_LOCK = 0,
94         MDT_REG_LOCK = BIT(0),
95         MDT_PDO_LOCK = BIT(1),
96 } mdl_type_t;
97
98 /* lfs rgetfacl permission check */
99 #define MAY_RGETFACL    BIT(14)
100
101 /* memory structure for hsm attributes
102  * for fields description see the on disk structure hsm_attrs
103  * which is defined in lustre_idl.h
104  */
105 struct md_hsm {
106         __u32   mh_compat;
107         __u32   mh_flags;
108         __u64   mh_arch_id;
109         __u64   mh_arch_ver;
110 };
111
112
113 /* memory structure for SOM attributes
114  * for fields description see the on disk structure som_attrs
115  * which is defined in lustre_idl.h
116  */
117 struct md_som {
118         __u16   ms_valid;
119         __u64   ms_size;
120         __u64   ms_blocks;
121 };
122
123 struct md_attr {
124         __u64                    ma_valid;
125         __u64                    ma_need;
126         __u64                    ma_attr_flags;
127         struct lu_attr           ma_attr;
128         struct lu_fid            ma_pfid;
129         struct md_hsm            ma_hsm;
130         struct md_som            ma_som;
131         struct lov_mds_md       *ma_lmm;
132         union lmv_mds_md        *ma_lmv;
133         struct lmv_user_md      *ma_default_lmv;
134         void                    *ma_acl;
135         int                      ma_lmm_size;
136         int                      ma_lmv_size;
137         int                      ma_default_lmv_size;
138         int                      ma_acl_size;
139         int                      ma_enable_chprojid_gid;
140 };
141
142 /** Additional parameters for create */
143 struct md_op_spec {
144         union {
145                 /** symlink target */
146                 struct lu_name sp_symname;
147                 /** eadata for regular files */
148                 struct md_spec_reg {
149                         void *eadata;
150                         int  eadatalen;
151                 } sp_ea;
152         } u;
153
154         /** Open flags from client: such as MDS_OPEN_CREAT, and others. */
155         __u64      sp_cr_flags;
156
157         /* File security context for creates. */
158         const char      *sp_cr_file_secctx_name; /* (security) xattr name */
159         void            *sp_cr_file_secctx; /* xattr value */
160         size_t           sp_cr_file_secctx_size; /* xattr value size */
161
162         /* File encryption context for creates. */
163         void            *sp_cr_file_encctx; /* enc ctx value */
164         size_t           sp_cr_file_encctx_size; /* enc ctx size */
165
166         /* Archive ID used for auto PCC attach when create newly files. */
167         __u32            sp_archive_id;
168
169         /** don't create lov objects or llog cookie - this replay */
170         unsigned int no_create:1,
171                      sp_cr_lookup:1, /* do lookup sanity check or not. */
172                      sp_rm_entry:1,  /* only remove name entry */
173                      sp_permitted:1, /* do not check permission */
174                      sp_migrate_close:1, /* close the file during migrate */
175                      sp_migrate_nsonly:1, /* migrate dirent only */
176                      sp_dmv_imp_inherit:1, /* implicit default LMV inherit */
177                      sp_replay:1; /* replay, op may be partially executed */
178
179         /** to create directory */
180         const struct dt_index_features *sp_feat;
181
182         /* name of xattr used to store jobid in inode, or empty if disabled */
183         char sp_cr_job_xattr[XATTR_JOB_MAX_LEN];
184 };
185
186 enum md_layout_opc {
187         MD_LAYOUT_NOP   = 0,
188         MD_LAYOUT_WRITE,        /* FLR: write the file */
189         MD_LAYOUT_RESYNC,       /* FLR: resync starts */
190         MD_LAYOUT_RESYNC_DONE,  /* FLR: resync done */
191         MD_LAYOUT_ATTACH,       /* attach stripes */
192         MD_LAYOUT_DETACH,       /* detach stripes */
193         MD_LAYOUT_SHRINK,       /* shrink striped directory (destroy stripes) */
194         MD_LAYOUT_SPLIT,        /* split directory (allocate new stripes) */
195         MD_LAYOUT_MAX,
196 };
197
198 /**
199  * Parameters for layout change API.
200  */
201 struct md_layout_change {
202         enum md_layout_opc                       mlc_opc;
203         struct lu_buf                            mlc_buf;
204         union {
205                 struct {
206                         __u16                    mlc_mirror_id;
207                         struct layout_intent    *mlc_intent;
208                         struct lustre_som_attrs  mlc_som;
209                         size_t                   mlc_resync_count;
210                         __u32                   *mlc_resync_ids;
211                 }; /* file */
212                 struct {
213                         /* parent obj in plain dir split */
214                         struct md_object        *mlc_parent;
215                         /* target obj in plain dir split */
216                         struct md_object        *mlc_target;
217                         /* target attr in plain dir split */
218                         struct lu_attr          *mlc_attr;
219                         /* target name in plain dir split */
220                         const struct lu_name    *mlc_name;
221                         /* dir split spec */
222                         struct md_op_spec       *mlc_spec;
223                 }; /* dir */
224         };
225 };
226
227 union ldlm_policy_data;
228 /**
229  * Operations implemented for each md object (both directory and leaf).
230  */
231 struct md_object_operations {
232         int (*moo_permission)(const struct lu_env *env,
233                               struct md_object *pobj, struct md_object *cobj,
234                               struct md_attr *attr, unsigned int may_mask);
235
236         int (*moo_attr_get)(const struct lu_env *env, struct md_object *obj,
237                             struct md_attr *attr);
238
239         int (*moo_attr_set)(const struct lu_env *env, struct md_object *obj,
240                             const struct md_attr *attr);
241
242         int (*moo_xattr_get)(const struct lu_env *env, struct md_object *obj,
243                              struct lu_buf *buf, const char *name);
244
245         int (*moo_xattr_list)(const struct lu_env *env, struct md_object *obj,
246                               struct lu_buf *buf);
247
248         int (*moo_xattr_set)(const struct lu_env *env, struct md_object *obj,
249                              const struct lu_buf *buf, const char *name,
250                              int fl);
251
252         int (*moo_xattr_del)(const struct lu_env *env, struct md_object *obj,
253                              const char *name);
254
255         /** This method is used to swap the layouts between 2 objects */
256         int (*moo_swap_layouts)(const struct lu_env *env,
257                                struct md_object *obj1, struct md_object *obj2,
258                                __u64 flags);
259
260         /** \retval number of bytes actually read upon success */
261         int (*moo_readpage)(const struct lu_env *env, struct md_object *obj,
262                             const struct lu_rdpg *rdpg);
263
264         int (*moo_readlink)(const struct lu_env *env, struct md_object *obj,
265                             struct lu_buf *buf);
266
267         int (*moo_changelog)(const struct lu_env *env,
268                              enum changelog_rec_type type,
269                              enum changelog_rec_flags clf_flags,
270                              struct md_device *m, const struct lu_fid *fid);
271
272         int (*moo_open)(const struct lu_env *env, struct md_object *obj,
273                         u64 open_flags, struct md_op_spec*);
274
275         int (*moo_close)(const struct lu_env *env, struct md_object *obj,
276                          struct md_attr *ma, u64 open_flags);
277
278         int (*moo_object_sync)(const struct lu_env *, struct md_object *);
279
280         int (*moo_object_lock)(const struct lu_env *env, struct md_object *obj,
281                                struct lustre_handle *lh,
282                                struct ldlm_enqueue_info *einfo,
283                                union ldlm_policy_data *policy);
284         int (*moo_object_unlock)(const struct lu_env *env,
285                                  struct md_object *obj,
286                                  struct ldlm_enqueue_info *einfo,
287                                  union ldlm_policy_data *policy);
288
289         int (*moo_invalidate)(const struct lu_env *env, struct md_object *obj);
290         /**
291          * Trying to write to un-instantiated layout component.
292          *
293          * The caller should have held layout lock.
294          *
295          * This API can be extended to support every other layout changing
296          * operations, such as component {add,del,change}, layout swap,
297          * layout merge, etc. One of the benefits by doing this is that the MDT
298          * no longer needs to understand layout.
299          *
300          * However, layout creation, removal, and fetch should still use
301          * xattr_{get,set}() because they don't interpret layout on the
302          * MDT layer.
303          *
304          * \param[in] env       execution environment
305          * \param[in] obj       MD object
306          * \param[in] layout    data structure to describe the changes to
307          *                      the MD object's layout
308          *
309          * \retval 0            success
310          * \retval -ne          error code
311          */
312         int (*moo_layout_change)(const struct lu_env *env,
313                                  struct md_object *obj,
314                                  struct md_layout_change *layout);
315 };
316
317 /**
318  * Operations implemented for each directory object.
319  */
320 struct md_dir_operations {
321         int (*mdo_is_subdir)(const struct lu_env *env, struct md_object *obj,
322                              const struct lu_fid *fid);
323
324         int (*mdo_lookup)(const struct lu_env *env, struct md_object *obj,
325                           const struct lu_name *lname, struct lu_fid *fid,
326                           struct md_op_spec *spec);
327
328         mdl_mode_t (*mdo_lock_mode)(const struct lu_env *env,
329                                     struct md_object *obj,
330                                     mdl_mode_t mode);
331
332         int (*mdo_create)(const struct lu_env *env, struct md_object *pobj,
333                           const struct lu_name *lname, struct md_object *child,
334                           struct md_op_spec *spec,
335                           struct md_attr *ma);
336
337         /** This method is used for creating data object for this meta object*/
338         int (*mdo_create_data)(const struct lu_env *env, struct md_object *p,
339                                struct md_object *o,
340                                const struct md_op_spec *spec,
341                                struct md_attr *ma);
342
343         int (*mdo_rename)(const struct lu_env *env, struct md_object *spobj,
344                           struct md_object *tpobj, const struct lu_fid *lf,
345                           const struct lu_name *lsname, struct md_object *tobj,
346                           const struct lu_name *ltname, struct md_attr *ma);
347
348         int (*mdo_link)(const struct lu_env *env, struct md_object *tgt_obj,
349                         struct md_object *src_obj, const struct lu_name *lname,
350                         struct md_attr *ma);
351
352         int (*mdo_unlink)(const struct lu_env *env, struct md_object *pobj,
353                           struct md_object *cobj, const struct lu_name *lname,
354                           struct md_attr *ma, int no_name);
355
356         int (*mdo_migrate)(const struct lu_env *env, struct md_object *spobj,
357                            struct md_object *tpobj, struct md_object *sobj,
358                            struct md_object *tobj, const struct lu_name *lname,
359                            struct md_op_spec *spec, struct md_attr *ma);
360 };
361
362 struct md_device_operations {
363         /** meta-data device related handlers. */
364         int (*mdo_root_get)(const struct lu_env *env, struct md_device *m,
365                             struct lu_fid *f);
366
367         const struct dt_device_param *(*mdo_dtconf_get)(const struct lu_env *e,
368                                                         struct md_device *m);
369
370         int (*mdo_statfs)(const struct lu_env *env, struct md_device *m,
371                           struct obd_statfs *sfs);
372
373         int (*mdo_llog_ctxt_get)(const struct lu_env *env,
374                                  struct md_device *m, int idx, void **h);
375
376         int (*mdo_iocontrol)(const struct lu_env *env, struct md_device *m,
377                              unsigned int cmd, int len, void *data);
378 };
379
380 struct md_device {
381         struct lu_device                   md_lu_dev;
382         const struct md_device_operations *md_ops;
383 };
384
385 struct md_object {
386         struct lu_object                   mo_lu;
387         const struct md_object_operations *mo_ops;
388         const struct md_dir_operations    *mo_dir_ops;
389 };
390
391 static inline struct md_device *lu2md_dev(const struct lu_device *d)
392 {
393         LASSERT(IS_ERR(d) || lu_device_is_md(d));
394         return container_of_safe(d, struct md_device, md_lu_dev);
395 }
396
397 static inline struct lu_device *md2lu_dev(struct md_device *d)
398 {
399         return &d->md_lu_dev;
400 }
401
402 static inline struct md_object *lu2md(const struct lu_object *o)
403 {
404         LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->lo_dev));
405         return container_of_safe(o, struct md_object, mo_lu);
406 }
407
408 static inline int md_device_init(struct md_device *md, struct lu_device_type *t)
409 {
410         return lu_device_init(&md->md_lu_dev, t);
411 }
412
413 static inline void md_device_fini(struct md_device *md)
414 {
415         lu_device_fini(&md->md_lu_dev);
416 }
417
418 static inline struct md_object *md_object_find_slice(const struct lu_env *env,
419                                                      struct md_device *md,
420                                                      const struct lu_fid *f)
421 {
422         return lu2md(lu_object_find_slice(env, md2lu_dev(md), f, NULL));
423 }
424
425
426 /** md operations */
427 static inline int mo_permission(const struct lu_env *env, struct md_object *p,
428                                 struct md_object *c, struct md_attr *at,
429                                 unsigned int may_mask)
430 {
431         LASSERT(c->mo_ops->moo_permission);
432         return c->mo_ops->moo_permission(env, p, c, at, may_mask);
433 }
434
435 static inline int mo_attr_get(const struct lu_env *env, struct md_object *m,
436                               struct md_attr *at)
437 {
438         LASSERT(m->mo_ops->moo_attr_get);
439         return m->mo_ops->moo_attr_get(env, m, at);
440 }
441
442 static inline int mo_readlink(const struct lu_env *env,
443                               struct md_object *m,
444                               struct lu_buf *buf)
445 {
446         LASSERT(m->mo_ops->moo_readlink);
447         return m->mo_ops->moo_readlink(env, m, buf);
448 }
449
450 static inline int mo_changelog(const struct lu_env *env,
451                                enum changelog_rec_type type,
452                                enum changelog_rec_flags clf_flags,
453                                struct md_device *m, const struct lu_fid *fid)
454 {
455         struct lu_fid rootfid;
456         struct md_object *root;
457         int rc;
458
459         rc = m->md_ops->mdo_root_get(env, m, &rootfid);
460         if (rc)
461                 return rc;
462
463         root = md_object_find_slice(env, m, &rootfid);
464         if (IS_ERR(root))
465                 RETURN(PTR_ERR(root));
466
467         LASSERT(root->mo_ops->moo_changelog);
468         rc = root->mo_ops->moo_changelog(env, type, clf_flags, m, fid);
469
470         lu_object_put(env, &root->mo_lu);
471
472         return rc;
473 }
474
475 static inline int mo_attr_set(const struct lu_env *env,
476                               struct md_object *m,
477                               const struct md_attr *at)
478 {
479         LASSERT(m->mo_ops->moo_attr_set);
480         return m->mo_ops->moo_attr_set(env, m, at);
481 }
482
483 static inline int mo_xattr_get(const struct lu_env *env,
484                                struct md_object *m,
485                                struct lu_buf *buf,
486                                const char *name)
487 {
488         LASSERT(m->mo_ops->moo_xattr_get);
489         return m->mo_ops->moo_xattr_get(env, m, buf, name);
490 }
491
492 static inline int mo_xattr_del(const struct lu_env *env,
493                                struct md_object *m,
494                                const char *name)
495 {
496         LASSERT(m->mo_ops->moo_xattr_del);
497         return m->mo_ops->moo_xattr_del(env, m, name);
498 }
499
500 static inline int mo_xattr_set(const struct lu_env *env,
501                                struct md_object *m,
502                                const struct lu_buf *buf,
503                                const char *name,
504                                int flags)
505 {
506         LASSERT(m->mo_ops->moo_xattr_set);
507         return m->mo_ops->moo_xattr_set(env, m, buf, name, flags);
508 }
509
510 static inline int mo_xattr_list(const struct lu_env *env,
511                                 struct md_object *m,
512                                 struct lu_buf *buf)
513 {
514         LASSERT(m->mo_ops->moo_xattr_list);
515         return m->mo_ops->moo_xattr_list(env, m, buf);
516 }
517
518 static inline int mo_invalidate(const struct lu_env *env, struct md_object *m)
519 {
520         LASSERT(m->mo_ops->moo_invalidate);
521         return m->mo_ops->moo_invalidate(env, m);
522 }
523
524 static inline int mo_layout_change(const struct lu_env *env,
525                                    struct md_object *m,
526                                    struct md_layout_change *layout)
527 {
528         /* need instantiate objects which in the access range */
529         LASSERT(m->mo_ops->moo_layout_change);
530         return m->mo_ops->moo_layout_change(env, m, layout);
531 }
532
533 static inline int mo_swap_layouts(const struct lu_env *env,
534                                   struct md_object *o1,
535                                   struct md_object *o2, __u64 flags)
536 {
537         LASSERT(o1->mo_ops->moo_swap_layouts);
538         LASSERT(o2->mo_ops->moo_swap_layouts);
539         if (o1->mo_ops->moo_swap_layouts != o2->mo_ops->moo_swap_layouts)
540                 return -EPERM;
541         return o1->mo_ops->moo_swap_layouts(env, o1, o2, flags);
542 }
543
544 static inline int mo_open(const struct lu_env *env, struct md_object *m,
545                           u64 open_flags, struct md_op_spec *spec)
546 {
547         LASSERT(m->mo_ops->moo_open);
548         return m->mo_ops->moo_open(env, m, open_flags, spec);
549 }
550
551 static inline int mo_close(const struct lu_env *env, struct md_object *m,
552                            struct md_attr *ma, u64 open_flags)
553 {
554         LASSERT(m->mo_ops->moo_close);
555         return m->mo_ops->moo_close(env, m, ma, open_flags);
556 }
557
558 static inline int mo_readpage(const struct lu_env *env,
559                               struct md_object *m,
560                               const struct lu_rdpg *rdpg)
561 {
562         LASSERT(m->mo_ops->moo_readpage);
563         return m->mo_ops->moo_readpage(env, m, rdpg);
564 }
565
566 static inline int mo_object_sync(const struct lu_env *env, struct md_object *m)
567 {
568         LASSERT(m->mo_ops->moo_object_sync);
569         return m->mo_ops->moo_object_sync(env, m);
570 }
571
572 static inline int mo_object_lock(const struct lu_env *env,
573                                  struct md_object *m,
574                                  struct lustre_handle *lh,
575                                  struct ldlm_enqueue_info *einfo,
576                                  union ldlm_policy_data *policy)
577 {
578         LASSERT(m->mo_ops->moo_object_lock);
579         return m->mo_ops->moo_object_lock(env, m, lh, einfo, policy);
580 }
581
582 static inline int mo_object_unlock(const struct lu_env *env,
583                                    struct md_object *m,
584                                    struct ldlm_enqueue_info *einfo,
585                                    union ldlm_policy_data *policy)
586 {
587         LASSERT(m->mo_ops->moo_object_unlock);
588         return m->mo_ops->moo_object_unlock(env, m, einfo, policy);
589 }
590
591 static inline int mdo_lookup(const struct lu_env *env,
592                              struct md_object *p,
593                              const struct lu_name *lname,
594                              struct lu_fid *f,
595                              struct md_op_spec *spec)
596 {
597         LASSERT(p->mo_dir_ops->mdo_lookup);
598         return p->mo_dir_ops->mdo_lookup(env, p, lname, f, spec);
599 }
600
601 static inline mdl_mode_t mdo_lock_mode(const struct lu_env *env,
602                                        struct md_object *mo,
603                                        mdl_mode_t lm)
604 {
605         if (mo->mo_dir_ops->mdo_lock_mode == NULL)
606                 return MDL_MINMODE;
607         return mo->mo_dir_ops->mdo_lock_mode(env, mo, lm);
608 }
609
610 static inline int mdo_create(const struct lu_env *env,
611                              struct md_object *p,
612                              const struct lu_name *lchild_name,
613                              struct md_object *c,
614                              struct md_op_spec *spc,
615                              struct md_attr *at)
616 {
617         LASSERT(p->mo_dir_ops->mdo_create);
618         return p->mo_dir_ops->mdo_create(env, p, lchild_name, c, spc, at);
619 }
620
621 static inline int mdo_create_data(const struct lu_env *env,
622                                   struct md_object *p,
623                                   struct md_object *c,
624                                   const struct md_op_spec *spec,
625                                   struct md_attr *ma)
626 {
627         LASSERT(c->mo_dir_ops->mdo_create_data);
628         return c->mo_dir_ops->mdo_create_data(env, p, c, spec, ma);
629 }
630
631 static inline int mdo_rename(const struct lu_env *env,
632                              struct md_object *sp,
633                              struct md_object *tp,
634                              const struct lu_fid *lf,
635                              const struct lu_name *lsname,
636                              struct md_object *t,
637                              const struct lu_name *ltname,
638                              struct md_attr *ma)
639 {
640         LASSERT(tp->mo_dir_ops->mdo_rename);
641         return tp->mo_dir_ops->mdo_rename(env, sp, tp, lf, lsname, t, ltname,
642                                           ma);
643 }
644
645 static inline int mdo_migrate(const struct lu_env *env,
646                               struct md_object *spobj,
647                               struct md_object *tpobj,
648                               struct md_object *sobj,
649                               struct md_object *tobj,
650                               const struct lu_name *lname,
651                               struct md_op_spec *spec,
652                               struct md_attr *ma)
653 {
654         LASSERT(spobj->mo_dir_ops->mdo_migrate);
655         return spobj->mo_dir_ops->mdo_migrate(env, spobj, tpobj, sobj, tobj,
656                                               lname, spec, ma);
657 }
658
659 static inline int mdo_is_subdir(const struct lu_env *env,
660                                 struct md_object *mo,
661                                 const struct lu_fid *fid)
662 {
663         LASSERT(mo->mo_dir_ops->mdo_is_subdir);
664         return mo->mo_dir_ops->mdo_is_subdir(env, mo, fid);
665 }
666
667 static inline int mdo_link(const struct lu_env *env,
668                            struct md_object *p,
669                            struct md_object *s,
670                            const struct lu_name *lname,
671                            struct md_attr *ma)
672 {
673         LASSERT(s->mo_dir_ops->mdo_link);
674         return s->mo_dir_ops->mdo_link(env, p, s, lname, ma);
675 }
676
677 static inline int mdo_unlink(const struct lu_env *env,
678                              struct md_object *p,
679                              struct md_object *c,
680                              const struct lu_name *lname,
681                              struct md_attr *ma, int no_name)
682 {
683         LASSERT(p->mo_dir_ops->mdo_unlink);
684         return p->mo_dir_ops->mdo_unlink(env, p, c, lname, ma, no_name);
685 }
686
687 static inline int mdo_statfs(const struct lu_env *env,
688                              struct md_device *m,
689                              struct obd_statfs *sfs)
690 {
691         LASSERT(m->md_ops->mdo_statfs);
692         return m->md_ops->mdo_statfs(env, m, sfs);
693 }
694
695 struct dt_device;
696
697 void lustre_som_swab(struct lustre_som_attrs *attrs);
698 int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh);
699 void lustre_hsm2buf(void *buf, const struct md_hsm *mh);
700
701 enum {
702         UCRED_INVALID   = -1,
703         UCRED_INIT      = 0,
704         UCRED_OLD       = 1,
705         UCRED_NEW       = 2,
706 };
707
708 struct lu_ucred {
709         __u32                    uc_valid;
710         __u32                    uc_o_uid;
711         __u32                    uc_o_gid;
712         __u32                    uc_o_fsuid;
713         __u32                    uc_o_fsgid;
714         __u32                    uc_uid;
715         __u32                    uc_gid;
716         __u32                    uc_fsuid;
717         __u32                    uc_fsgid;
718         __u32                    uc_suppgids[2];
719         kernel_cap_t             uc_cap;
720         __u32                    uc_umask;
721         struct group_info       *uc_ginfo;
722         struct md_identity      *uc_identity;
723         char                     uc_jobid[LUSTRE_JOBID_SIZE];
724         lnet_nid_t               uc_nid;
725         bool                     uc_enable_audit;
726         int                      uc_rbac_file_perms:1;
727         int                      uc_rbac_dne_ops:1;
728         int                      uc_rbac_quota_ops:1;
729         int                      uc_rbac_byfid_ops:1;
730         int                      uc_rbac_chlg_ops:1;
731         int                      uc_rbac_fscrypt_admin:1;
732 };
733
734 struct lu_ucred *lu_ucred(const struct lu_env *env);
735
736 struct lu_ucred *lu_ucred_check(const struct lu_env *env);
737
738 struct lu_ucred *lu_ucred_assert(const struct lu_env *env);
739
740 int lu_ucred_global_init(void);
741
742 void lu_ucred_global_fini(void);
743
744 /** @} md */
745 #endif /* _LINUX_MD_OBJECT_H */