Whamcloud - gitweb
LU-15971 llite: implicit default LMV inherit
[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
178         /** to create directory */
179         const struct dt_index_features *sp_feat;
180 };
181
182 enum md_layout_opc {
183         MD_LAYOUT_NOP   = 0,
184         MD_LAYOUT_WRITE,        /* FLR: write the file */
185         MD_LAYOUT_RESYNC,       /* FLR: resync starts */
186         MD_LAYOUT_RESYNC_DONE,  /* FLR: resync done */
187         MD_LAYOUT_ATTACH,       /* attach stripes */
188         MD_LAYOUT_DETACH,       /* detach stripes */
189         MD_LAYOUT_SHRINK,       /* shrink striped directory (destroy stripes) */
190         MD_LAYOUT_SPLIT,        /* split directory (allocate new stripes) */
191         MD_LAYOUT_MAX,
192 };
193
194 /**
195  * Parameters for layout change API.
196  */
197 struct md_layout_change {
198         enum md_layout_opc                       mlc_opc;
199         struct lu_buf                            mlc_buf;
200         union {
201                 struct {
202                         __u16                    mlc_mirror_id;
203                         struct layout_intent    *mlc_intent;
204                         struct lustre_som_attrs  mlc_som;
205                         size_t                   mlc_resync_count;
206                         __u32                   *mlc_resync_ids;
207                 }; /* file */
208                 struct {
209                         /* parent obj in plain dir split */
210                         struct md_object        *mlc_parent;
211                         /* target obj in plain dir split */
212                         struct md_object        *mlc_target;
213                         /* target attr in plain dir split */
214                         struct lu_attr          *mlc_attr;
215                         /* target name in plain dir split */
216                         const struct lu_name    *mlc_name;
217                         /* dir split spec */
218                         struct md_op_spec       *mlc_spec;
219                 }; /* dir */
220         };
221 };
222
223 union ldlm_policy_data;
224 /**
225  * Operations implemented for each md object (both directory and leaf).
226  */
227 struct md_object_operations {
228         int (*moo_permission)(const struct lu_env *env,
229                               struct md_object *pobj, struct md_object *cobj,
230                               struct md_attr *attr, unsigned int may_mask);
231
232         int (*moo_attr_get)(const struct lu_env *env, struct md_object *obj,
233                             struct md_attr *attr);
234
235         int (*moo_attr_set)(const struct lu_env *env, struct md_object *obj,
236                             const struct md_attr *attr);
237
238         int (*moo_xattr_get)(const struct lu_env *env, struct md_object *obj,
239                              struct lu_buf *buf, const char *name);
240
241         int (*moo_xattr_list)(const struct lu_env *env, struct md_object *obj,
242                               struct lu_buf *buf);
243
244         int (*moo_xattr_set)(const struct lu_env *env, struct md_object *obj,
245                              const struct lu_buf *buf, const char *name,
246                              int fl);
247
248         int (*moo_xattr_del)(const struct lu_env *env, struct md_object *obj,
249                              const char *name);
250
251         /** This method is used to swap the layouts between 2 objects */
252         int (*moo_swap_layouts)(const struct lu_env *env,
253                                struct md_object *obj1, struct md_object *obj2,
254                                __u64 flags);
255
256         /** \retval number of bytes actually read upon success */
257         int (*moo_readpage)(const struct lu_env *env, struct md_object *obj,
258                             const struct lu_rdpg *rdpg);
259
260         int (*moo_readlink)(const struct lu_env *env, struct md_object *obj,
261                             struct lu_buf *buf);
262
263         int (*moo_changelog)(const struct lu_env *env,
264                              enum changelog_rec_type type,
265                              enum changelog_rec_flags clf_flags,
266                              struct md_device *m, const struct lu_fid *fid);
267
268         int (*moo_open)(const struct lu_env *env, struct md_object *obj,
269                         u64 open_flags, struct md_op_spec*);
270
271         int (*moo_close)(const struct lu_env *env, struct md_object *obj,
272                          struct md_attr *ma, u64 open_flags);
273
274         int (*moo_object_sync)(const struct lu_env *, struct md_object *);
275
276         int (*moo_object_lock)(const struct lu_env *env, struct md_object *obj,
277                                struct lustre_handle *lh,
278                                struct ldlm_enqueue_info *einfo,
279                                union ldlm_policy_data *policy);
280         int (*moo_object_unlock)(const struct lu_env *env,
281                                  struct md_object *obj,
282                                  struct ldlm_enqueue_info *einfo,
283                                  union ldlm_policy_data *policy);
284
285         int (*moo_invalidate)(const struct lu_env *env, struct md_object *obj);
286         /**
287          * Trying to write to un-instantiated layout component.
288          *
289          * The caller should have held layout lock.
290          *
291          * This API can be extended to support every other layout changing
292          * operations, such as component {add,del,change}, layout swap,
293          * layout merge, etc. One of the benefits by doing this is that the MDT
294          * no longer needs to understand layout.
295          *
296          * However, layout creation, removal, and fetch should still use
297          * xattr_{get,set}() because they don't interpret layout on the
298          * MDT layer.
299          *
300          * \param[in] env       execution environment
301          * \param[in] obj       MD object
302          * \param[in] layout    data structure to describe the changes to
303          *                      the MD object's layout
304          *
305          * \retval 0            success
306          * \retval -ne          error code
307          */
308         int (*moo_layout_change)(const struct lu_env *env,
309                                  struct md_object *obj,
310                                  struct md_layout_change *layout);
311 };
312
313 /**
314  * Operations implemented for each directory object.
315  */
316 struct md_dir_operations {
317         int (*mdo_is_subdir)(const struct lu_env *env, struct md_object *obj,
318                              const struct lu_fid *fid);
319
320         int (*mdo_lookup)(const struct lu_env *env, struct md_object *obj,
321                           const struct lu_name *lname, struct lu_fid *fid,
322                           struct md_op_spec *spec);
323
324         mdl_mode_t (*mdo_lock_mode)(const struct lu_env *env,
325                                     struct md_object *obj,
326                                     mdl_mode_t mode);
327
328         int (*mdo_create)(const struct lu_env *env, struct md_object *pobj,
329                           const struct lu_name *lname, struct md_object *child,
330                           struct md_op_spec *spec,
331                           struct md_attr *ma);
332
333         /** This method is used for creating data object for this meta object*/
334         int (*mdo_create_data)(const struct lu_env *env, struct md_object *p,
335                                struct md_object *o,
336                                const struct md_op_spec *spec,
337                                struct md_attr *ma);
338
339         int (*mdo_rename)(const struct lu_env *env, struct md_object *spobj,
340                           struct md_object *tpobj, const struct lu_fid *lf,
341                           const struct lu_name *lsname, struct md_object *tobj,
342                           const struct lu_name *ltname, struct md_attr *ma);
343
344         int (*mdo_link)(const struct lu_env *env, struct md_object *tgt_obj,
345                         struct md_object *src_obj, const struct lu_name *lname,
346                         struct md_attr *ma);
347
348         int (*mdo_unlink)(const struct lu_env *env, struct md_object *pobj,
349                           struct md_object *cobj, const struct lu_name *lname,
350                           struct md_attr *ma, int no_name);
351
352         int (*mdo_migrate)(const struct lu_env *env, struct md_object *spobj,
353                            struct md_object *tpobj, struct md_object *sobj,
354                            struct md_object *tobj, const struct lu_name *lname,
355                            struct md_op_spec *spec, struct md_attr *ma);
356 };
357
358 struct md_device_operations {
359         /** meta-data device related handlers. */
360         int (*mdo_root_get)(const struct lu_env *env, struct md_device *m,
361                             struct lu_fid *f);
362
363         const struct dt_device_param *(*mdo_dtconf_get)(const struct lu_env *e,
364                                                         struct md_device *m);
365
366         int (*mdo_statfs)(const struct lu_env *env, struct md_device *m,
367                           struct obd_statfs *sfs);
368
369         int (*mdo_llog_ctxt_get)(const struct lu_env *env,
370                                  struct md_device *m, int idx, void **h);
371
372         int (*mdo_iocontrol)(const struct lu_env *env, struct md_device *m,
373                              unsigned int cmd, int len, void *data);
374 };
375
376 struct md_device {
377         struct lu_device                   md_lu_dev;
378         const struct md_device_operations *md_ops;
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 static inline struct md_device *lu2md_dev(const struct lu_device *d)
388 {
389         LASSERT(IS_ERR(d) || lu_device_is_md(d));
390         return container_of_safe(d, struct md_device, md_lu_dev);
391 }
392
393 static inline struct lu_device *md2lu_dev(struct md_device *d)
394 {
395         return &d->md_lu_dev;
396 }
397
398 static inline struct md_object *lu2md(const struct lu_object *o)
399 {
400         LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->lo_dev));
401         return container_of_safe(o, struct md_object, mo_lu);
402 }
403
404 static inline int md_device_init(struct md_device *md, struct lu_device_type *t)
405 {
406         return lu_device_init(&md->md_lu_dev, t);
407 }
408
409 static inline void md_device_fini(struct md_device *md)
410 {
411         lu_device_fini(&md->md_lu_dev);
412 }
413
414 static inline struct md_object *md_object_find_slice(const struct lu_env *env,
415                                                      struct md_device *md,
416                                                      const struct lu_fid *f)
417 {
418         return lu2md(lu_object_find_slice(env, md2lu_dev(md), f, NULL));
419 }
420
421
422 /** md operations */
423 static inline int mo_permission(const struct lu_env *env, struct md_object *p,
424                                 struct md_object *c, struct md_attr *at,
425                                 unsigned int may_mask)
426 {
427         LASSERT(c->mo_ops->moo_permission);
428         return c->mo_ops->moo_permission(env, p, c, at, may_mask);
429 }
430
431 static inline int mo_attr_get(const struct lu_env *env, struct md_object *m,
432                               struct md_attr *at)
433 {
434         LASSERT(m->mo_ops->moo_attr_get);
435         return m->mo_ops->moo_attr_get(env, m, at);
436 }
437
438 static inline int mo_readlink(const struct lu_env *env,
439                               struct md_object *m,
440                               struct lu_buf *buf)
441 {
442         LASSERT(m->mo_ops->moo_readlink);
443         return m->mo_ops->moo_readlink(env, m, buf);
444 }
445
446 static inline int mo_changelog(const struct lu_env *env,
447                                enum changelog_rec_type type,
448                                enum changelog_rec_flags clf_flags,
449                                struct md_device *m, const struct lu_fid *fid)
450 {
451         struct lu_fid rootfid;
452         struct md_object *root;
453         int rc;
454
455         rc = m->md_ops->mdo_root_get(env, m, &rootfid);
456         if (rc)
457                 return rc;
458
459         root = md_object_find_slice(env, m, &rootfid);
460         if (IS_ERR(root))
461                 RETURN(PTR_ERR(root));
462
463         LASSERT(root->mo_ops->moo_changelog);
464         rc = root->mo_ops->moo_changelog(env, type, clf_flags, m, fid);
465
466         lu_object_put(env, &root->mo_lu);
467
468         return rc;
469 }
470
471 static inline int mo_attr_set(const struct lu_env *env,
472                               struct md_object *m,
473                               const struct md_attr *at)
474 {
475         LASSERT(m->mo_ops->moo_attr_set);
476         return m->mo_ops->moo_attr_set(env, m, at);
477 }
478
479 static inline int mo_xattr_get(const struct lu_env *env,
480                                struct md_object *m,
481                                struct lu_buf *buf,
482                                const char *name)
483 {
484         LASSERT(m->mo_ops->moo_xattr_get);
485         return m->mo_ops->moo_xattr_get(env, m, buf, name);
486 }
487
488 static inline int mo_xattr_del(const struct lu_env *env,
489                                struct md_object *m,
490                                const char *name)
491 {
492         LASSERT(m->mo_ops->moo_xattr_del);
493         return m->mo_ops->moo_xattr_del(env, m, name);
494 }
495
496 static inline int mo_xattr_set(const struct lu_env *env,
497                                struct md_object *m,
498                                const struct lu_buf *buf,
499                                const char *name,
500                                int flags)
501 {
502         LASSERT(m->mo_ops->moo_xattr_set);
503         return m->mo_ops->moo_xattr_set(env, m, buf, name, flags);
504 }
505
506 static inline int mo_xattr_list(const struct lu_env *env,
507                                 struct md_object *m,
508                                 struct lu_buf *buf)
509 {
510         LASSERT(m->mo_ops->moo_xattr_list);
511         return m->mo_ops->moo_xattr_list(env, m, buf);
512 }
513
514 static inline int mo_invalidate(const struct lu_env *env, struct md_object *m)
515 {
516         LASSERT(m->mo_ops->moo_invalidate);
517         return m->mo_ops->moo_invalidate(env, m);
518 }
519
520 static inline int mo_layout_change(const struct lu_env *env,
521                                    struct md_object *m,
522                                    struct md_layout_change *layout)
523 {
524         /* need instantiate objects which in the access range */
525         LASSERT(m->mo_ops->moo_layout_change);
526         return m->mo_ops->moo_layout_change(env, m, layout);
527 }
528
529 static inline int mo_swap_layouts(const struct lu_env *env,
530                                   struct md_object *o1,
531                                   struct md_object *o2, __u64 flags)
532 {
533         LASSERT(o1->mo_ops->moo_swap_layouts);
534         LASSERT(o2->mo_ops->moo_swap_layouts);
535         if (o1->mo_ops->moo_swap_layouts != o2->mo_ops->moo_swap_layouts)
536                 return -EPERM;
537         return o1->mo_ops->moo_swap_layouts(env, o1, o2, flags);
538 }
539
540 static inline int mo_open(const struct lu_env *env, struct md_object *m,
541                           u64 open_flags, struct md_op_spec *spec)
542 {
543         LASSERT(m->mo_ops->moo_open);
544         return m->mo_ops->moo_open(env, m, open_flags, spec);
545 }
546
547 static inline int mo_close(const struct lu_env *env, struct md_object *m,
548                            struct md_attr *ma, u64 open_flags)
549 {
550         LASSERT(m->mo_ops->moo_close);
551         return m->mo_ops->moo_close(env, m, ma, open_flags);
552 }
553
554 static inline int mo_readpage(const struct lu_env *env,
555                               struct md_object *m,
556                               const struct lu_rdpg *rdpg)
557 {
558         LASSERT(m->mo_ops->moo_readpage);
559         return m->mo_ops->moo_readpage(env, m, rdpg);
560 }
561
562 static inline int mo_object_sync(const struct lu_env *env, struct md_object *m)
563 {
564         LASSERT(m->mo_ops->moo_object_sync);
565         return m->mo_ops->moo_object_sync(env, m);
566 }
567
568 static inline int mo_object_lock(const struct lu_env *env,
569                                  struct md_object *m,
570                                  struct lustre_handle *lh,
571                                  struct ldlm_enqueue_info *einfo,
572                                  union ldlm_policy_data *policy)
573 {
574         LASSERT(m->mo_ops->moo_object_lock);
575         return m->mo_ops->moo_object_lock(env, m, lh, einfo, policy);
576 }
577
578 static inline int mo_object_unlock(const struct lu_env *env,
579                                    struct md_object *m,
580                                    struct ldlm_enqueue_info *einfo,
581                                    union ldlm_policy_data *policy)
582 {
583         LASSERT(m->mo_ops->moo_object_unlock);
584         return m->mo_ops->moo_object_unlock(env, m, einfo, policy);
585 }
586
587 static inline int mdo_lookup(const struct lu_env *env,
588                              struct md_object *p,
589                              const struct lu_name *lname,
590                              struct lu_fid *f,
591                              struct md_op_spec *spec)
592 {
593         LASSERT(p->mo_dir_ops->mdo_lookup);
594         return p->mo_dir_ops->mdo_lookup(env, p, lname, f, spec);
595 }
596
597 static inline mdl_mode_t mdo_lock_mode(const struct lu_env *env,
598                                        struct md_object *mo,
599                                        mdl_mode_t lm)
600 {
601         if (mo->mo_dir_ops->mdo_lock_mode == NULL)
602                 return MDL_MINMODE;
603         return mo->mo_dir_ops->mdo_lock_mode(env, mo, lm);
604 }
605
606 static inline int mdo_create(const struct lu_env *env,
607                              struct md_object *p,
608                              const struct lu_name *lchild_name,
609                              struct md_object *c,
610                              struct md_op_spec *spc,
611                              struct md_attr *at)
612 {
613         LASSERT(p->mo_dir_ops->mdo_create);
614         return p->mo_dir_ops->mdo_create(env, p, lchild_name, c, spc, at);
615 }
616
617 static inline int mdo_create_data(const struct lu_env *env,
618                                   struct md_object *p,
619                                   struct md_object *c,
620                                   const struct md_op_spec *spec,
621                                   struct md_attr *ma)
622 {
623         LASSERT(c->mo_dir_ops->mdo_create_data);
624         return c->mo_dir_ops->mdo_create_data(env, p, c, spec, ma);
625 }
626
627 static inline int mdo_rename(const struct lu_env *env,
628                              struct md_object *sp,
629                              struct md_object *tp,
630                              const struct lu_fid *lf,
631                              const struct lu_name *lsname,
632                              struct md_object *t,
633                              const struct lu_name *ltname,
634                              struct md_attr *ma)
635 {
636         LASSERT(tp->mo_dir_ops->mdo_rename);
637         return tp->mo_dir_ops->mdo_rename(env, sp, tp, lf, lsname, t, ltname,
638                                           ma);
639 }
640
641 static inline int mdo_migrate(const struct lu_env *env,
642                               struct md_object *spobj,
643                               struct md_object *tpobj,
644                               struct md_object *sobj,
645                               struct md_object *tobj,
646                               const struct lu_name *lname,
647                               struct md_op_spec *spec,
648                               struct md_attr *ma)
649 {
650         LASSERT(spobj->mo_dir_ops->mdo_migrate);
651         return spobj->mo_dir_ops->mdo_migrate(env, spobj, tpobj, sobj, tobj,
652                                               lname, spec, ma);
653 }
654
655 static inline int mdo_is_subdir(const struct lu_env *env,
656                                 struct md_object *mo,
657                                 const struct lu_fid *fid)
658 {
659         LASSERT(mo->mo_dir_ops->mdo_is_subdir);
660         return mo->mo_dir_ops->mdo_is_subdir(env, mo, fid);
661 }
662
663 static inline int mdo_link(const struct lu_env *env,
664                            struct md_object *p,
665                            struct md_object *s,
666                            const struct lu_name *lname,
667                            struct md_attr *ma)
668 {
669         LASSERT(s->mo_dir_ops->mdo_link);
670         return s->mo_dir_ops->mdo_link(env, p, s, lname, ma);
671 }
672
673 static inline int mdo_unlink(const struct lu_env *env,
674                              struct md_object *p,
675                              struct md_object *c,
676                              const struct lu_name *lname,
677                              struct md_attr *ma, int no_name)
678 {
679         LASSERT(p->mo_dir_ops->mdo_unlink);
680         return p->mo_dir_ops->mdo_unlink(env, p, c, lname, ma, no_name);
681 }
682
683 static inline int mdo_statfs(const struct lu_env *env,
684                              struct md_device *m,
685                              struct obd_statfs *sfs)
686 {
687         LASSERT(m->md_ops->mdo_statfs);
688         return m->md_ops->mdo_statfs(env, m, sfs);
689 }
690
691 struct dt_device;
692
693 void lustre_som_swab(struct lustre_som_attrs *attrs);
694 int lustre_buf2hsm(void *buf, int rc, struct md_hsm *mh);
695 void lustre_hsm2buf(void *buf, const struct md_hsm *mh);
696
697 enum {
698         UCRED_INVALID   = -1,
699         UCRED_INIT      = 0,
700         UCRED_OLD       = 1,
701         UCRED_NEW       = 2,
702 };
703
704 struct lu_ucred {
705         __u32                    uc_valid;
706         __u32                    uc_o_uid;
707         __u32                    uc_o_gid;
708         __u32                    uc_o_fsuid;
709         __u32                    uc_o_fsgid;
710         __u32                    uc_uid;
711         __u32                    uc_gid;
712         __u32                    uc_fsuid;
713         __u32                    uc_fsgid;
714         __u32                    uc_suppgids[2];
715         kernel_cap_t             uc_cap;
716         __u32                    uc_umask;
717         struct group_info       *uc_ginfo;
718         struct md_identity      *uc_identity;
719         char                     uc_jobid[LUSTRE_JOBID_SIZE];
720         lnet_nid_t               uc_nid;
721         bool                     uc_enable_audit;
722         int                      uc_rbac_file_perms:1;
723         int                      uc_rbac_dne_ops:1;
724         int                      uc_rbac_quota_ops:1;
725         int                      uc_rbac_byfid_ops:1;
726         int                      uc_rbac_chlg_ops:1;
727         int                      uc_rbac_fscrypt_admin:1;
728 };
729
730 struct lu_ucred *lu_ucred(const struct lu_env *env);
731
732 struct lu_ucred *lu_ucred_check(const struct lu_env *env);
733
734 struct lu_ucred *lu_ucred_assert(const struct lu_env *env);
735
736 int lu_ucred_global_init(void);
737
738 void lu_ucred_global_fini(void);
739
740 /** @} md */
741 #endif /* _LINUX_MD_OBJECT_H */