1) Share related linkEA functions with LFSCK.
2) Multiple linked objects are rare, and the objects with
a lot of linkea entries are more rare. It is unnecessary
to worry about performance under such cases. So drop the
linkea entries count limitation: LINKEA_MAX_COUNT.
Signed-off-by: Fan Yong <fan.yong@intel.com>
Change-Id: I75f90c9619c56f2f62063435aea26ed01337d6dd
Reviewed-on: http://review.whamcloud.com/4907
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
{
struct obd_device *obd = mdd2obd_dev(mdd);
struct llog_ctxt *ctxt = NULL, *uctxt = NULL;
- struct lu_fid rfid;
int rc;
OBD_SET_CTXT_MAGIC(&obd->obd_lvfs_ctxt);
obd->obd_lvfs_ctxt.dt = mdd->mdd_bottom;
- rc = dt_root_get(env, mdd->mdd_bottom, &rfid);
- if (rc)
- RETURN(-ENODEV);
-
rc = llog_setup(env, obd, &obd->obd_olg, LLOG_CHANGELOG_ORIG_CTXT,
obd, &changelog_orig_logops);
if (rc) {
{
struct mdd_device *mdd = mdo2mdd(obj);
struct mdd_object *root;
- struct lu_fid rootfid;
int rc = 0;
/*
* in the root
*/
if (strcmp(name, XATTR_NAME_LOV) == 0) {
- rc = dt_root_get(env, mdd->mdd_child, &rootfid);
- if (rc)
- return rc;
- root = mdd_object_find(env, mdd, &rootfid);
+ root = mdd_object_find(env, mdd, &mdd->mdd_local_root_fid);
if (IS_ERR(root))
return PTR_ERR(root);
rc = mdo_xattr_get(env, root, buf, name,
if (rc)
GOTO(out, rc);
+ rc = dt_root_get(env, mdd->mdd_child, &mdd->mdd_local_root_fid);
+ if (rc != 0)
+ GOTO(out, rc);
+
root = dt_store_open(env, mdd->mdd_child, "", mdd_root_dir_name,
&mdd->mdd_root_fid);
if (!IS_ERR(root)) {
RETURN(0);
}
case OBD_IOC_START_LFSCK: {
- struct lfsck_start *start = karg;
- struct md_lfsck *lfsck = &mdd->mdd_lfsck;
-
- /* Return the kernel service version. */
- /* XXX: version can be used for compatibility in the future. */
- start->ls_version = lfsck->ml_version;
- rc = mdd_lfsck_start(env, lfsck, start);
+ rc = mdd_lfsck_start(env, &mdd->mdd_lfsck,
+ (struct lfsck_start *)karg);
RETURN(rc);
}
case OBD_IOC_STOP_LFSCK: {
static int __mdd_lookup(const struct lu_env *env, struct md_object *pobj,
const struct lu_name *lname, struct lu_fid* fid,
int mask);
-static int mdd_declare_links_add(const struct lu_env *env,
- struct mdd_object *mdd_obj,
- struct thandle *handle);
static inline int mdd_links_add(const struct lu_env *env,
struct mdd_object *mdd_obj,
const struct lu_fid *pfid,
RETURN(rc);
}
-static int mdd_parent_fid(const struct lu_env *env, struct mdd_object *obj,
- struct lu_fid *fid)
+int mdd_parent_fid(const struct lu_env *env, struct mdd_object *obj,
+ struct lu_fid *fid)
{
return __mdd_lookup_locked(env, &obj->mod_obj, &lname_dotdot, fid, 0);
}
* \param tname - target name string
* \param handle - transacion handle
*/
-static 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)
+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)
{
struct llog_changelog_rec *rec;
struct lu_buf *buf;
dotdot, handle);
}
- if (rc == 0)
+ if (rc == 0 && (fid_is_norm(mdo2fid(child)) ||
+ fid_is_dot_lustre(mdo2fid(child))))
mdd_declare_links_add(env, child, handle);
RETURN(rc);
if (rc != 0)
mdo_ref_del(env, child, handle);
}
- if (rc == 0)
- mdd_links_add(env, child, pfid, lname, handle, 1);
- RETURN(rc);
+ if (rc == 0 && (fid_is_norm(mdo2fid(child)) ||
+ fid_is_dot_lustre(mdo2fid(child))))
+ mdd_links_add(env, child, pfid, lname, handle, 1);
+
+ RETURN(rc);
}
/* has not lock on pobj yet */
stop:
mdd_trans_stop(env, mdd, rc, handle);
- if (mdd_sobj)
- mdd_object_put(env, mdd_sobj);
out_pending:
- return rc;
+ mdd_object_put(env, mdd_sobj);
+ return rc;
}
-/**
- * The data that link search is done on.
- */
-struct mdd_link_data {
- /**
- * Buffer to keep link EA body.
- */
- struct lu_buf *ml_buf;
- /**
- * The matched header, entry and its lenght in the EA
- */
- struct link_ea_header *ml_leh;
- struct link_ea_entry *ml_lee;
- int ml_reclen;
-};
-
-static int mdd_links_new(const struct lu_env *env,
- struct mdd_link_data *ldata)
+int mdd_links_new(const struct lu_env *env, struct mdd_link_data *ldata)
{
ldata->ml_buf = mdd_buf_alloc(env, CFS_PAGE_SIZE);
if (ldata->ml_buf->lb_buf == NULL)
*
* \retval 0 or error
*/
-int mdd_links_read(const struct lu_env *env,
- struct mdd_object *mdd_obj,
+int mdd_links_read(const struct lu_env *env, struct mdd_object *mdd_obj,
struct mdd_link_data *ldata)
{
struct lustre_capa *capa;
return rc ? ERR_PTR(rc) : ldata.ml_buf;
}
-static int mdd_links_write(const struct lu_env *env,
- struct mdd_object *mdd_obj,
- struct mdd_link_data *ldata,
- struct thandle *handle)
+int mdd_links_write(const struct lu_env *env, struct mdd_object *mdd_obj,
+ struct mdd_link_data *ldata, struct thandle *handle)
{
const struct lu_buf *buf = mdd_buf_get_const(env, ldata->ml_buf->lb_buf,
ldata->ml_leh->leh_len);
lname->ln_namelen = *reclen - sizeof(struct link_ea_entry);
}
-static int mdd_declare_links_add(const struct lu_env *env,
- struct mdd_object *mdd_obj,
- struct thandle *handle)
+int mdd_declare_links_add(const struct lu_env *env,
+ struct mdd_object *mdd_obj,
+ struct thandle *handle)
{
int rc;
return rc;
}
-/* For pathologic linkers, we don't want to spend lots of time scanning the
- * link ea. Limit ourseleves to something reasonable; links not in the EA
- * can be looked up via (slower) parent lookup.
- */
-#define LINKEA_MAX_COUNT 128
-
/** Add a record to the end of link ea buf */
-static int mdd_links_add_buf(const struct lu_env *env,
- struct mdd_link_data *ldata,
- const struct lu_name *lname,
- const struct lu_fid *pfid)
+int mdd_links_add_buf(const struct lu_env *env, struct mdd_link_data *ldata,
+ const struct lu_name *lname, const struct lu_fid *pfid)
{
LASSERT(ldata->ml_leh != NULL);
if (lname == NULL || pfid == NULL)
return -EINVAL;
- /* Make sure our buf is big enough for the new one */
- if (ldata->ml_leh->leh_reccount > LINKEA_MAX_COUNT)
- return -EOVERFLOW;
-
ldata->ml_reclen = lname->ln_namelen + sizeof(struct link_ea_entry);
if (ldata->ml_leh->leh_len + ldata->ml_reclen >
ldata->ml_buf->lb_len) {
}
/** Del the current record from the link ea buf */
-static void mdd_links_del_buf(const struct lu_env *env,
- struct mdd_link_data *ldata,
- const struct lu_name *lname)
+void mdd_links_del_buf(const struct lu_env *env, struct mdd_link_data *ldata,
+ const struct lu_name *lname)
{
LASSERT(ldata->ml_leh != NULL);
* \retval -ENOENT link does not exist
* \retval -ve on error
*/
-static int mdd_links_find(const struct lu_env *env,
- struct mdd_object *mdd_obj,
- struct mdd_link_data *ldata,
- const struct lu_name *lname,
- const struct lu_fid *pfid)
+int mdd_links_find(const struct lu_env *env, struct mdd_object *mdd_obj,
+ struct mdd_link_data *ldata, const struct lu_name *lname,
+ const struct lu_fid *pfid)
{
struct lu_name *tmpname = &mdd_env_info(env)->mti_name2;
struct lu_fid *tmpfid = &mdd_env_info(env)->mti_fid;
struct dt_device *mdd_child;
struct dt_device *mdd_bottom;
struct lu_fid mdd_root_fid;
+ struct lu_fid mdd_local_root_fid;
struct dt_device_param mdd_dt_conf;
struct dt_object *mdd_orphans; /* PENDING directory */
struct dt_object *mdd_capa;
struct lu_attr mti_cattr;
struct md_attr mti_ma;
struct obd_info mti_oi;
- /* mti_orph_ent and mti_orph_key must be conjoint,
- * then mti_orph_ent::lde_name will be mti_orph_key. */
- struct lu_dirent mti_orph_ent;
- char mti_orph_key[NAME_MAX + 1];
+ /* mti_ent and mti_key must be conjoint,
+ * then mti_ent::lde_name will be mti_key. */
+ struct lu_dirent mti_ent;
+ char mti_key[NAME_MAX + 16];
struct obd_trans_info mti_oti;
struct lu_buf mti_buf;
struct lu_buf mti_big_buf; /* biggish persistent buf */
struct obd_quotactl mti_oqctl;
};
+/**
+ * The data that link search is done on.
+ */
+struct mdd_link_data {
+ /**
+ * Buffer to keep link EA body.
+ */
+ struct lu_buf *ml_buf;
+ /**
+ * The matched header, entry and its lenght in the EA
+ */
+ struct link_ea_header *ml_leh;
+ struct link_ea_entry *ml_lee;
+ int ml_reclen;
+};
+
extern const char orph_index_name[];
extern const struct dt_index_features orph_index_features;
void mdd_pdo_read_unlock(const struct lu_env *env, struct mdd_object *obj,
void *dlh);
/* mdd_dir.c */
+int mdd_parent_fid(const struct lu_env *env, struct mdd_object *obj,
+ struct lu_fid *fid);
int mdd_is_subdir(const struct lu_env *env, struct md_object *mo,
const struct lu_fid *fid, struct lu_fid *sfid);
int mdd_may_create(const struct lu_env *env, struct mdd_object *pobj,
int mdd_lookup(const struct lu_env *env,
struct md_object *pobj, const struct lu_name *lname,
struct lu_fid* fid, struct md_op_spec *spec);
+int mdd_links_read(const struct lu_env *env, struct mdd_object *mdd_obj,
+ struct mdd_link_data *ldata);
+int mdd_links_find(const struct lu_env *env, struct mdd_object *mdd_obj,
+ struct mdd_link_data *ldata, const struct lu_name *lname,
+ const struct lu_fid *pfid);
+int mdd_links_new(const struct lu_env *env, struct mdd_link_data *ldata);
+int mdd_links_add_buf(const struct lu_env *env, struct mdd_link_data *ldata,
+ const struct lu_name *lname, const struct lu_fid *pfid);
+void mdd_links_del_buf(const struct lu_env *env, struct mdd_link_data *ldata,
+ const struct lu_name *lname);
+int mdd_declare_links_add(const struct lu_env *env,
+ struct mdd_object *mdd_obj,
+ struct thandle *handle);
+int mdd_links_write(const struct lu_env *env, struct mdd_object *mdd_obj,
+ struct mdd_link_data *ldata, struct thandle *handle);
struct lu_buf *mdd_links_get(const struct lu_env *env,
struct mdd_object *mdd_obj);
void mdd_lee_unpack(const struct link_ea_entry *lee, int *reclen,
struct mdd_thread_info *mdd_env_info(const struct lu_env *env);
+const struct lu_name *mdd_name_get_const(const struct lu_env *env,
+ const void *area, ssize_t len);
struct lu_buf *mdd_buf_get(const struct lu_env *env, void *area, ssize_t len);
const struct lu_buf *mdd_buf_get_const(const struct lu_env *env,
const void *area, ssize_t len);
struct thandle *handle);
int mdd_changelog_store(const struct lu_env *env, struct mdd_device *mdd,
struct llog_changelog_rec *rec, struct thandle *th);
+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);
int mdd_declare_object_create_internal(const struct lu_env *env,
struct mdd_object *p,
struct mdd_object *c,
void mdd_object_make_hint(const struct lu_env *env, struct mdd_object *parent,
struct mdd_object *child, struct lu_attr *attr);
+static inline void mdd_object_get(struct mdd_object *o)
+{
+ lu_object_get(&o->mod_obj.mo_lu);
+}
+
static inline void mdd_object_put(const struct lu_env *env,
struct mdd_object *o)
{
* LU-974 enforce client umask in creation.
* TODO: CMD needs to handle this for remote object.
*/
- saved = xchg(¤t->fs->umask, uc->uc_umask & S_IRWXUGO);
+ if (likely(uc != NULL))
+ saved = xchg(¤t->fs->umask, uc->uc_umask & S_IRWXUGO);
rc = next->do_ops->do_create(env, next, attr, hint, dof, handle);
/* restore previous umask value */
- current->fs->umask = saved;
+ if (likely(uc != NULL))
+ current->fs->umask = saved;
return rc;
}
return info;
}
+const struct lu_name *mdd_name_get_const(const struct lu_env *env,
+ const void *area, ssize_t len)
+{
+ struct lu_name *lname;
+
+ lname = &mdd_env_info(env)->mti_name;
+ lname->ln_name = area;
+ lname->ln_namelen = len;
+ return lname;
+}
+
struct lu_buf *mdd_buf_get(const struct lu_env *env, void *area, ssize_t len)
{
struct lu_buf *buf;
static struct dt_key* orph_key_fill(const struct lu_env *env,
const struct lu_fid *lf, __u32 op)
{
- char *key = mdd_env_info(env)->mti_orph_key;
+ char *key = mdd_env_info(env)->mti_key;
int rc;
LASSERT(key);
static struct dt_key* orph_key_fill_18(const struct lu_env *env,
const struct lu_fid *lf)
{
- char *key = mdd_env_info(env)->mti_orph_key;
+ char *key = mdd_env_info(env)->mti_key;
int rc;
LASSERT(key);
struct mdd_device *mdd)
{
struct dt_object *dor = mdd->mdd_orphans;
- struct lu_dirent *ent = &mdd_env_info(env)->mti_orph_ent;
+ struct lu_dirent *ent = &mdd_env_info(env)->mti_ent;
const struct dt_it_ops *iops;
struct dt_it *it;
struct lu_fid fid;