Whamcloud - gitweb
LU-6142 lustre: convert use of container_of0 in include/
[fs/lustre-release.git] / lustre / include / md_object.h
index c43539a..baafdc4 100644 (file)
@@ -65,16 +65,17 @@ struct obd_export;
 
 /** metadata attributes */
 enum ma_valid {
-       MA_INODE     = 1 << 0,
-       MA_LOV       = 1 << 1,
-       MA_FLAGS     = 1 << 2,
-       MA_LMV       = 1 << 3,
-       MA_ACL_DEF   = 1 << 4,
-       MA_LOV_DEF   = 1 << 5,
-       MA_HSM       = 1 << 6,
-       MA_PFID      = 1 << 7,
-       MA_LMV_DEF   = 1 << 8,
-       MA_SOM       = 1 << 9,
+       MA_INODE        = BIT(0),
+       MA_LOV          = BIT(1),
+       MA_FLAGS        = BIT(2),
+       MA_LMV          = BIT(3),
+       MA_ACL_DEF      = BIT(4),
+       MA_LOV_DEF      = BIT(5),
+       MA_HSM          = BIT(6),
+       MA_PFID         = BIT(7),
+       MA_LMV_DEF      = BIT(8),
+       MA_SOM          = BIT(9),
+       MA_FORCE_LOG    = BIT(10), /* forced close logged in mdt_mfd_close */
 };
 
 typedef enum {
@@ -90,13 +91,13 @@ typedef enum {
 } mdl_mode_t;
 
 typedef enum {
-        MDT_NUL_LOCK = 0,
-        MDT_REG_LOCK = (1 << 0),
-        MDT_PDO_LOCK = (1 << 1)
+       MDT_NUL_LOCK = 0,
+       MDT_REG_LOCK = BIT(0),
+       MDT_PDO_LOCK = BIT(1),
 } mdl_type_t;
 
 /* lfs rgetfacl permission check */
-#define MAY_RGETFACL    (1 << 14)
+#define MAY_RGETFACL   BIT(14)
 
 /* memory structure for hsm attributes
  * for fields description see the on disk structure hsm_attrs
@@ -136,6 +137,7 @@ struct md_attr {
        int                      ma_lmv_size;
        int                      ma_default_lmv_size;
        int                      ma_acl_size;
+       int                      ma_enable_chprojid_gid;
 };
 
 /** Additional parameters for create */
@@ -166,7 +168,8 @@ struct md_op_spec {
                     sp_cr_lookup:1, /* do lookup sanity check or not. */
                     sp_rm_entry:1,  /* only remove name entry */
                     sp_permitted:1, /* do not check permission */
-                    sp_migrate_close:1; /* close the file during migrate */
+                    sp_migrate_close:1, /* close the file during migrate */
+                    sp_migrate_nsonly:1; /* migrate dirent only */
        /** Current lock mode for parent dir where create is performing. */
        mdl_mode_t sp_cr_mode;
 
@@ -179,19 +182,40 @@ enum md_layout_opc {
        MD_LAYOUT_WRITE,        /* FLR: write the file */
        MD_LAYOUT_RESYNC,       /* FLR: resync starts */
        MD_LAYOUT_RESYNC_DONE,  /* FLR: resync done */
+       MD_LAYOUT_ATTACH,       /* attach stripes */
+       MD_LAYOUT_DETACH,       /* detach stripes */
+       MD_LAYOUT_SHRINK,       /* shrink striped directory (destroy stripes) */
+       MD_LAYOUT_SPLIT,        /* split directory (allocate new stripes) */
+       MD_LAYOUT_MAX,
 };
 
 /**
  * Parameters for layout change API.
  */
 struct md_layout_change {
-       enum md_layout_opc       mlc_opc;
-       __u16                    mlc_mirror_id;
-       struct layout_intent    *mlc_intent;
-       struct lu_buf            mlc_buf;
-       struct lustre_som_attrs  mlc_som;
-       size_t                   mlc_resync_count;
-       __u32                   *mlc_resync_ids;
+       enum md_layout_opc                       mlc_opc;
+       struct lu_buf                            mlc_buf;
+       union {
+               struct {
+                       __u16                    mlc_mirror_id;
+                       struct layout_intent    *mlc_intent;
+                       struct lustre_som_attrs  mlc_som;
+                       size_t                   mlc_resync_count;
+                       __u32                   *mlc_resync_ids;
+               }; /* file */
+               struct {
+                       /* parent obj in plain dir split */
+                       struct md_object        *mlc_parent;
+                       /* target obj in plain dir split */
+                       struct md_object        *mlc_target;
+                       /* target attr in plain dir split */
+                       struct lu_attr          *mlc_attr;
+                       /* target name in plain dir split */
+                       const struct lu_name    *mlc_name;
+                       /* dir split spec */
+                       struct md_op_spec       *mlc_spec;
+               }; /* dir */
+       };
 };
 
 union ldlm_policy_data;
@@ -239,8 +263,8 @@ struct md_object_operations {
                             enum changelog_rec_flags clf_flags,
                             struct md_device *m, const struct lu_fid *fid);
 
-       int (*moo_open)(const struct lu_env *env,
-                       struct md_object *obj, u64 open_flags);
+       int (*moo_open)(const struct lu_env *env, struct md_object *obj,
+                       u64 open_flags, struct md_op_spec*);
 
        int (*moo_close)(const struct lu_env *env, struct md_object *obj,
                         struct md_attr *ma, u64 open_flags);
@@ -360,8 +384,8 @@ struct md_object {
 
 static inline struct md_device *lu2md_dev(const struct lu_device *d)
 {
-        LASSERT(IS_ERR(d) || lu_device_is_md(d));
-        return container_of0(d, struct md_device, md_lu_dev);
+       LASSERT(IS_ERR(d) || lu_device_is_md(d));
+       return container_of_safe(d, struct md_device, md_lu_dev);
 }
 
 static inline struct lu_device *md2lu_dev(struct md_device *d)
@@ -371,8 +395,8 @@ static inline struct lu_device *md2lu_dev(struct md_device *d)
 
 static inline struct md_object *lu2md(const struct lu_object *o)
 {
-        LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->lo_dev));
-        return container_of0(o, struct md_object, mo_lu);
+       LASSERT(o == NULL || IS_ERR(o) || lu_device_is_md(o->lo_dev));
+       return container_of_safe(o, struct md_object, mo_lu);
 }
 
 static inline int md_device_init(struct md_device *md, struct lu_device_type *t)
@@ -512,10 +536,10 @@ static inline int mo_swap_layouts(const struct lu_env *env,
 }
 
 static inline int mo_open(const struct lu_env *env, struct md_object *m,
-                         u64 open_flags)
+                         u64 open_flags, struct md_op_spec *spec)
 {
        LASSERT(m->mo_ops->moo_open);
-       return m->mo_ops->moo_open(env, m, open_flags);
+       return m->mo_ops->moo_open(env, m, open_flags, spec);
 }
 
 static inline int mo_close(const struct lu_env *env, struct md_object *m,
@@ -661,17 +685,6 @@ static inline int mdo_statfs(const struct lu_env *env,
        return m->md_ops->mdo_statfs(env, m, sfs);
 }
 
-/**
- * Used in MDD/OUT layer for object lock rule
- **/
-enum mdd_object_role {
-       MOR_SRC_PARENT,
-       MOR_SRC_CHILD,
-       MOR_TGT_PARENT,
-       MOR_TGT_CHILD,
-       MOR_TGT_ORPHAN
-};
-
 struct dt_device;
 
 void lustre_som_swab(struct lustre_som_attrs *attrs);
@@ -717,7 +730,7 @@ void lu_ucred_global_fini(void);
 
 #define md_cap_t(x) (x)
 
-#define MD_CAP_TO_MASK(x) (1 << (x))
+#define MD_CAP_TO_MASK(x) BIT(x)
 
 #define md_cap_raised(c, flag) (md_cap_t(c) & MD_CAP_TO_MASK(flag))