* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2013, Intel Corporation.
+ * Copyright (c) 2011, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
#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>
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;
}
struct mdd_object *mdd_lpf;
};
+struct mdd_generic_thread {
+ struct completion mgt_started;
+ struct completion mgt_finished;
+ void *mgt_data;
+ bool mgt_abort;
+ bool mgt_init;
+};
+
struct mdd_device {
struct md_device mdd_md_dev;
struct obd_export *mdd_child_exp;
struct lu_fid mdd_local_root_fid;
struct dt_device_param mdd_dt_conf;
struct dt_object *mdd_orphans; /* PENDING directory */
- cfs_proc_dir_entry_t *mdd_proc_entry;
+ struct proc_dir_entry *mdd_proc_entry;
struct mdd_changelog mdd_cl;
unsigned long mdd_atime_diff;
struct mdd_object *mdd_dot_lustre;
unsigned int mdd_sync_permission;
int mdd_connects;
struct local_oid_storage *mdd_los;
+ struct mdd_generic_thread mdd_orph_cleanup_thread;
};
enum mod_flags {
/* The dir object has been unlinked */
DEAD_OBJ = 1 << 0,
- APPEND_OBJ = 1 << 1,
- IMMUTE_OBJ = 1 << 2,
- ORPHAN_OBJ = 1 << 3,
+ ORPHAN_OBJ = 1 << 1,
};
struct mdd_object {
struct dt_object_format mti_dof;
struct linkea_data mti_link_data;
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 {
+ MLAO_IGNORE = false,
+ MLAO_CHECK = true,
};
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);
-void mdd_flags_xlate(struct mdd_object *obj, __u32 flags);
+ 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,
const struct lu_fid *fid, struct lu_fid *sfid);
int mdd_may_create(const struct lu_env *env, struct mdd_object *pobj,
const struct lu_attr *pattr, struct mdd_object *cobj,
- bool check_perm, bool check_nlink);
+ bool check_perm);
int mdd_may_unlink(const struct lu_env *env, struct mdd_object *pobj,
const struct lu_attr *pattr, const struct lu_attr *attr);
int mdd_may_delete(const struct lu_env *env, struct mdd_object *tpobj,
int mdd_links_read(const struct lu_env *env, struct mdd_object *mdd_obj,
struct linkea_data *ldata);
int mdd_declare_links_add(const struct lu_env *env, struct mdd_object *mdd_obj,
- struct thandle *handle, struct linkea_data *ldata);
+ struct thandle *handle, struct linkea_data *ldata,
+ enum mdd_links_add_overflow overflow);
int mdd_links_write(const struct lu_env *env, struct mdd_object *mdd_obj,
struct linkea_data *ldata, struct thandle *handle);
struct lu_buf *mdd_links_get(const struct lu_env *env,
const struct lu_buf *mdd_buf_get_const(const struct lu_env *env,
const void *area, ssize_t len);
-int __mdd_orphan_cleanup(const struct lu_env *env, struct mdd_device *d);
+int mdd_orphan_cleanup(const struct lu_env *env, struct mdd_device *d);
int __mdd_orphan_add(const struct lu_env *, struct mdd_object *,
struct thandle *);
int __mdd_orphan_del(const struct lu_env *, struct mdd_object *,
struct thandle *);
/* mdd_lproc.c */
-void lprocfs_mdd_init_vars(struct lprocfs_static_vars *lvars);
int mdd_procfs_init(struct mdd_device *mdd, const char *name);
-int mdd_procfs_fini(struct mdd_device *mdd);
+void mdd_procfs_fini(struct mdd_device *mdd);
/* mdd_object.c */
extern struct kmem_cache *mdd_object_kmem;
int mdd_readpage(const struct lu_env *env, struct md_object *obj,
const struct lu_rdpg *rdpg);
int mdd_declare_changelog_store(const struct lu_env *env,
- struct mdd_device *mdd,
- const struct lu_name *fname,
- struct thandle *handle);
+ struct mdd_device *mdd,
+ const struct lu_name *tname,
+ const struct lu_name *sname,
+ struct thandle *handle);
+void mdd_changelog_rec_ext_jobid(struct changelog_rec *rec, const char *jobid);
int mdd_changelog_store(const struct lu_env *env, struct mdd_device *mdd,
struct llog_changelog_rec *rec, struct thandle *th);
int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd,
struct mdd_object *mdd_obj,
struct thandle *handle);
int mdd_changelog_ns_store(const struct lu_env *env, struct mdd_device *mdd,
- enum changelog_rec_type type, unsigned flags,
- struct mdd_object *target, struct mdd_object *parent,
- const struct lu_name *tname, struct thandle *handle);
+ enum changelog_rec_type type,
+ enum changelog_rec_flags crf,
+ struct mdd_object *target,
+ const struct lu_fid *tpfid,
+ const struct lu_fid *sfid,
+ const struct lu_fid *spfid,
+ 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,
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);
/* mdd_prepare.c */
int mdd_compat_fixes(const struct lu_env *env, struct mdd_device *mdd);
return lu_object_attr(&obj->mod_obj.mo_lu);
}
-static inline int mdd_is_immutable(struct mdd_object *obj)
-{
- return obj->mod_flags & IMMUTE_OBJ;
-}
-
static inline int mdd_is_dead_obj(struct mdd_object *obj)
{
return obj && obj->mod_flags & DEAD_OBJ;
}
-static inline int mdd_is_append(struct mdd_object *obj)
-{
- return obj->mod_flags & APPEND_OBJ;
-}
-
static inline int mdd_object_exists(struct mdd_object *obj)
{
return lu_object_exists(mdd2lu_obj(obj));
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);
/* 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 next->do_ops->do_attr_get(env, next, la, capa);
+ struct dt_object *next = mdd_object_child(obj);
+ return dt_attr_get(env, next, la);
}
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 mdd_object *obj,
+ const struct lu_attr *la,
+ struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(obj);
- if (mdd_object_exists(obj) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return -ENOENT;
- }
- return next->do_ops->do_attr_set(env, next, la, handle, capa);
+ struct dt_object *next = mdd_object_child(obj);
+
+ if (!mdd_object_exists(obj))
+ return -ENOENT;
+
+ 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 next->do_ops->do_xattr_get(env, next, buf, name, capa);
+ struct dt_object *next = mdd_object_child(obj);
+ return dt_xattr_get(env, next, buf, name);
}
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)
+ const struct lu_buf *buf, const char *name,
+ int fl, struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(obj);
- if (mdd_object_exists(obj) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return -ENOENT;
- }
- return next->do_ops->do_xattr_set(env, next, buf, name, fl, handle,
- capa);
+ 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);
}
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) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return -ENOENT;
- }
- return next->do_ops->do_xattr_del(env, next, name, handle, capa);
+ struct dt_object *next = mdd_object_child(obj);
+
+ if (!mdd_object_exists(obj))
+ return -ENOENT;
+
+ 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)
+static inline int
+mdo_xattr_list(const struct lu_env *env, struct mdd_object *obj,
+ struct lu_buf *buf)
{
- struct dt_object *next = mdd_object_child(obj);
- if (mdd_object_exists(obj) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return -ENOENT;
- }
- return next->do_ops->do_xattr_list(env, next, buf, capa);
+ struct dt_object *next = mdd_object_child(obj);
+
+ if (!mdd_object_exists(obj))
+ return -ENOENT;
+
+ 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
int mdo_declare_index_insert(const struct lu_env *env, struct mdd_object *obj,
- const struct lu_fid *fid, const char *name,
- struct thandle *handle)
+ const struct lu_fid *fid, __u32 type,
+ const char *name, struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(obj);
- int rc = 0;
-
- /*
- * 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))
- rc = dt_declare_insert(env, next,
- (struct dt_rec *)fid,
- (const struct dt_key *)name,
- handle);
- }
-
- return rc;
+ struct dt_object *next = mdd_object_child(obj);
+ 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 ./..
+ */
+
+ 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;
}
static inline
}
static inline int mdo_ref_add(const struct lu_env *env, struct mdd_object *obj,
- struct thandle *handle)
+ struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(obj);
- if (mdd_object_exists(obj) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return -ENOENT;
- }
- return next->do_ops->do_ref_add(env, next, handle);
+ struct dt_object *next = mdd_object_child(obj);
+
+ if (!mdd_object_exists(obj))
+ return -ENOENT;
+
+ return dt_ref_add(env, next, handle);
}
static inline int mdo_declare_ref_del(const struct lu_env *env,
}
static inline int mdo_ref_del(const struct lu_env *env, struct mdd_object *obj,
- struct thandle *handle)
+ struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(obj);
- if (mdd_object_exists(obj) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return -ENOENT;
- }
- return next->do_ops->do_ref_del(env, next, handle);
+ struct dt_object *next = mdd_object_child(obj);
+
+ if (!mdd_object_exists(obj))
+ return -ENOENT;
+
+ return dt_ref_del(env, next, handle);
}
-static inline
-int mdo_declare_create_obj(const struct lu_env *env, struct mdd_object *o,
- struct lu_attr *attr,
- struct dt_allocation_hint *hint,
- struct dt_object_format *dof,
- struct thandle *handle)
+static inline int
+mdo_declare_create_obj(const struct lu_env *env, struct mdd_object *o,
+ struct lu_attr *attr,
+ struct dt_allocation_hint *hint,
+ struct dt_object_format *dof,
+ struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(o);
- return next->do_ops->do_declare_create(env, next, attr, hint,
- dof, handle);
+ struct dt_object *next = mdd_object_child(o);
+ return dt_declare_create(env, next, attr, hint, dof, handle);
}
-static inline
-int mdo_create_obj(const struct lu_env *env, struct mdd_object *o,
- struct lu_attr *attr,
- struct dt_allocation_hint *hint,
- struct dt_object_format *dof,
- struct thandle *handle)
+static inline int
+mdo_create_obj(const struct lu_env *env, struct mdd_object *o,
+ struct lu_attr *attr,
+ struct dt_allocation_hint *hint,
+ struct dt_object_format *dof,
+ struct thandle *handle)
{
- struct dt_object *next = mdd_object_child(o);
- int rc;
-
- rc = next->do_ops->do_create(env, next, attr, hint, dof, handle);
-
- return rc;
+ struct dt_object *next = mdd_object_child(o);
+ return dt_create(env, next, attr, hint, dof, handle);
}
static inline
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) == 0) {
- CERROR("%s: object "DFID" not found: rc = -2\n",
- mdd_obj_dev_name(obj), PFID(mdd_object_fid(obj)));
- return ERR_PTR(-ENOENT);
- }
- return next->do_ops->do_capa_get(env, next, old, opc);
-}
-
#endif