Whamcloud - gitweb
LU-6245 libcfs: remove cfs_fs_time handling
[fs/lustre-release.git] / lustre / mdd / mdd_internal.h
index 8c228c3..44e97ce 100644 (file)
 #define _MDD_INTERNAL_H
 
 #include <lustre_acl.h>
+#include <lustre_compat.h>
 #include <lustre_eacl.h>
 #include <md_object.h>
 #include <dt_object.h>
 #include <lustre_lfsck.h>
 #include <lustre_fid.h>
-#include <lustre_capa.h>
 #include <lprocfs_status.h>
 #include <lustre_log.h>
 #include <lustre_linkea.h>
@@ -75,10 +75,11 @@ struct mdd_changelog {
        int                     mc_lastuser;
 };
 
-static inline __u64 cl_time(void) {
-       cfs_fs_time_t time;
+static inline __u64 cl_time(void)
+{
+       struct timespec64 time;
 
-       cfs_fs_time_current(&time);
+       ktime_get_real_ts64(&time);
        return (((__u64)time.tv_sec) << 30) + time.tv_nsec;
 }
 
@@ -160,6 +161,7 @@ struct mdd_thread_info {
        struct md_op_spec         mti_spec;
        struct dt_insert_rec      mti_dt_rec;
        struct lfsck_request      mti_lr;
+       struct lu_seq_range       mti_range;
 };
 
 enum mdd_links_add_overflow {
@@ -170,7 +172,7 @@ enum mdd_links_add_overflow {
 extern const char orph_index_name[];
 
 int mdd_la_get(const struct lu_env *env, struct mdd_object *obj,
-               struct lu_attr *la, struct lustre_capa *capa);
+              struct lu_attr *la);
 int mdd_attr_get(const struct lu_env *env, struct md_object *obj,
                 struct md_attr *ma);
 int mdd_attr_set(const struct lu_env *env, struct md_object *obj,
@@ -302,6 +304,7 @@ int mdd_changelog_ns_store(const struct lu_env *env, struct mdd_device *mdd,
                           const struct lu_name *tname,
                           const struct lu_name *sname,
                           struct thandle *handle);
+int mdd_invalidate(const struct lu_env *env, struct md_object *obj);
 int mdd_declare_object_create_internal(const struct lu_env *env,
                                       struct mdd_object *p,
                                       struct mdd_object *c,
@@ -355,8 +358,6 @@ int __mdd_permission_internal(const struct lu_env *env, struct mdd_object *obj,
 int mdd_permission(const struct lu_env *env,
                    struct md_object *pobj, struct md_object *cobj,
                    struct md_attr *ma, int mask);
-int mdd_capa_get(const struct lu_env *env, struct md_object *obj,
-                 struct lustre_capa *capa, int renewal);
 int mdd_generic_thread_start(struct mdd_generic_thread *thread,
                             int (*func)(void *), void *data, char *name);
 void mdd_generic_thread_stop(struct mdd_generic_thread *thread);
@@ -459,39 +460,6 @@ static inline struct seq_server_site *mdd_seq_site(struct mdd_device *mdd)
        return mdd2lu_dev(mdd)->ld_site->ld_seq_site;
 }
 
-static inline struct lustre_capa *mdd_object_capa(const struct lu_env *env,
-                                                 const struct mdd_object *obj)
-{
-       struct lu_capainfo *lci = lu_capainfo_get(env);
-       const struct lu_fid *fid = mdo2fid(obj);
-       int i;
-
-       /* NB: in mdt_init0 */
-       if (lci == NULL)
-               return BYPASS_CAPA;
-
-       for (i = 0; i < LU_CAPAINFO_MAX; i++)
-               if (lu_fid_eq(&lci->lci_fid[i], fid))
-                       return lci->lci_capa[i];
-       return NULL;
-}
-
-static inline void mdd_set_capainfo(const struct lu_env *env, int offset,
-                                   const struct mdd_object *obj,
-                                   struct lustre_capa *capa)
-{
-       struct lu_capainfo *lci = lu_capainfo_get(env);
-       const struct lu_fid *fid = mdo2fid(obj);
-
-       LASSERT(offset >= 0 && offset < LU_CAPAINFO_MAX);
-       /* NB: in mdt_init0 */
-       if (lci == NULL)
-               return;
-
-       lci->lci_fid[offset]  = *fid;
-       lci->lci_capa[offset] = capa;
-}
-
 static inline const char *mdd_obj_dev_name(const struct mdd_object *obj)
 {
         return lu_dev_name(obj->mod_obj.mo_lu.lo_dev);
@@ -517,10 +485,10 @@ static inline int mdd_permission_internal_locked(const struct lu_env *env,
 
 /* mdd inline func for calling osd_dt_object ops */
 static inline int mdo_attr_get(const struct lu_env *env, struct mdd_object *obj,
-                              struct lu_attr *la, struct lustre_capa *capa)
+                              struct lu_attr *la)
 {
        struct dt_object *next = mdd_object_child(obj);
-       return dt_attr_get(env, next, la, capa);
+       return dt_attr_get(env, next, la);
 }
 
 static inline int mdo_declare_attr_set(const struct lu_env *env,
@@ -535,23 +503,21 @@ static inline int mdo_declare_attr_set(const struct lu_env *env,
 static inline int mdo_attr_set(const struct lu_env *env,
                               struct mdd_object *obj,
                               const struct lu_attr *la,
-                              struct thandle *handle,
-                              struct lustre_capa *capa)
+                              struct thandle *handle)
 {
        struct dt_object *next = mdd_object_child(obj);
 
        if (!mdd_object_exists(obj))
                return -ENOENT;
 
-       return dt_attr_set(env, next, la, handle, capa);
+       return dt_attr_set(env, next, la, handle);
 }
 
 static inline int mdo_xattr_get(const struct lu_env *env,struct mdd_object *obj,
-                               struct lu_buf *buf, const char *name,
-                               struct lustre_capa *capa)
+                               struct lu_buf *buf, const char *name)
 {
        struct dt_object *next = mdd_object_child(obj);
-       return dt_xattr_get(env, next, buf, name, capa);
+       return dt_xattr_get(env, next, buf, name);
 }
 
 static inline int mdo_declare_xattr_set(const struct lu_env *env,
@@ -566,15 +532,14 @@ static inline int mdo_declare_xattr_set(const struct lu_env *env,
 
 static inline int mdo_xattr_set(const struct lu_env *env,struct mdd_object *obj,
                                const struct lu_buf *buf, const char *name,
-                               int fl, struct thandle *handle,
-                               struct lustre_capa *capa)
+                               int fl, struct thandle *handle)
 {
        struct dt_object *next = mdd_object_child(obj);
 
        if (!mdd_object_exists(obj))
                return -ENOENT;
 
-       return dt_xattr_set(env, next, buf, name, fl, handle, capa);
+       return dt_xattr_set(env, next, buf, name, fl, handle);
 }
 
 static inline int mdo_declare_xattr_del(const struct lu_env *env,
@@ -587,27 +552,32 @@ static inline int mdo_declare_xattr_del(const struct lu_env *env,
 }
 
 static inline int mdo_xattr_del(const struct lu_env *env,struct mdd_object *obj,
-                               const char *name, struct thandle *handle,
-                               struct lustre_capa *capa)
+                               const char *name, struct thandle *handle)
 {
        struct dt_object *next = mdd_object_child(obj);
 
        if (!mdd_object_exists(obj))
                return -ENOENT;
 
-       return dt_xattr_del(env, next, name, handle, capa);
+       return dt_xattr_del(env, next, name, handle);
 }
 
 static inline int
 mdo_xattr_list(const struct lu_env *env, struct mdd_object *obj,
-              struct lu_buf *buf, struct lustre_capa *capa)
+              struct lu_buf *buf)
 {
        struct dt_object *next = mdd_object_child(obj);
 
        if (!mdd_object_exists(obj))
                return -ENOENT;
 
-       return dt_xattr_list(env, next, buf, capa);
+       return dt_xattr_list(env, next, buf);
+}
+
+static inline int
+mdo_invalidate(const struct lu_env *env, struct mdd_object *obj)
+{
+       return dt_invalidate(env, mdd_object_child(obj));
 }
 
 static inline
@@ -616,33 +586,22 @@ int mdo_declare_index_insert(const struct lu_env *env, struct mdd_object *obj,
                             const char *name, struct thandle *handle)
 {
        struct dt_object *next  = mdd_object_child(obj);
-       int               rc    = 0;
+       int               rc;
 
        /*
         * if the object doesn't exist yet, then it's supposed to be created
         * and declaration of the creation should be enough to insert ./..
         */
 
-        /* FIXME: remote object should not be awared by MDD layer, but local
-         * creation does not declare insert ./.. (comments above), which
-         * is required by remote directory creation.
-         * This remote check should be removed when mdd_object_exists check is
-         * removed.
-         */
-       if (mdd_object_exists(obj) || mdd_object_remote(obj)) {
-               rc = -ENOTDIR;
-               if (dt_try_as_dir(env, next)) {
-                       struct dt_insert_rec *rec =
-                                       &mdd_env_info(env)->mti_dt_rec;
-
-                       rec->rec_fid = fid;
-                       rec->rec_type = type;
-                       rc = dt_declare_insert(env, next,
-                                              (const struct dt_rec *)rec,
-                                              (const struct dt_key *)name,
-                                              handle);
-               }
-        }
+       rc = -ENOTDIR;
+       if (dt_try_as_dir(env, next)) {
+               struct dt_insert_rec *rec = &mdd_env_info(env)->mti_dt_rec;
+
+               rec->rec_fid = fid;
+               rec->rec_type = type;
+               rc = dt_declare_insert(env, next, (const struct dt_rec *)rec,
+                                      (const struct dt_key *)name, handle);
+       }
 
         return rc;
 }
@@ -736,16 +695,4 @@ int mdo_destroy(const struct lu_env *env, struct mdd_object *o,
         return dt_destroy(env, next, handle);
 }
 
-static inline struct obd_capa *
-mdo_capa_get(const struct lu_env *env, struct mdd_object *obj,
-            struct lustre_capa *old, __u64 opc)
-{
-       struct dt_object *next = mdd_object_child(obj);
-
-       if (!mdd_object_exists(obj))
-               return ERR_PTR(-ENOENT);
-
-       return dt_capa_get(env, next, old, opc);
-}
-
 #endif