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