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