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);
}
parent = mdd_object_find(env, mdd, pfid);
if (IS_ERR(parent)) {
GOTO(out, rc = PTR_ERR(parent));
- } else if (mdd_object_exists(parent) < 0) {
+ } else if (mdd_object_remote(parent)) {
/*FIXME: Because of the restriction of rename in Phase I.
* If the parent is remote, we just assumed lf is not the
* parent of P1 for now */
int rc = 0;
ENTRY;
- if (cobj && mdd_object_exists(cobj))
+ if (cobj && mdd_object_exists(cobj))
RETURN(-EEXIST);
if (mdd_is_dead_obj(pobj))
* \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;
if (unlikely(mdd_is_dead_obj(mdd_obj)))
RETURN(-ESTALE);
- rc = mdd_object_exists(mdd_obj);
- if (unlikely(rc == 0))
- RETURN(-ESTALE);
- else if (unlikely(rc < 0)) {
- CERROR("Object "DFID" locates on remote server\n",
- PFID(mdo2fid(mdd_obj)));
- RETURN(-EINVAL);
- }
+ if (mdd_object_remote(mdd_obj)) {
+ CDEBUG(D_INFO, "%s: Object "DFID" locates on remote server\n",
+ mdd2obd_dev(m)->obd_name, PFID(mdo2fid(mdd_obj)));
+ } else if (!mdd_object_exists(mdd_obj)) {
+ RETURN(-ESTALE);
+ }
/* The common filename length check. */
if (unlikely(lname->ln_namelen > m->mdd_dt_conf.ddp_max_name_len))
RETURN(rc);
}
-int mdd_declare_object_initialize(const struct lu_env *env,
- struct mdd_object *child,
- struct lu_attr *attr,
- struct thandle *handle)
+static int mdd_declare_object_initialize(const struct lu_env *env,
+ struct mdd_object *parent,
+ struct mdd_object *child,
+ struct lu_attr *attr,
+ struct thandle *handle)
{
int rc;
+ ENTRY;
/*
* inode mode has been set in creation time, and it's based on umask,
dot, handle);
if (rc == 0)
rc = mdo_declare_ref_add(env, child, handle);
+
+ rc = mdo_declare_index_insert(env, child, mdo2fid(parent),
+ 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;
+ RETURN(rc);
}
int mdd_object_initialize(const struct lu_env *env, const struct lu_fid *pfid,
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 */
GOTO(out, rc);
}
- rc = mdd_declare_object_initialize(env, c, attr, handle);
+ rc = mdd_declare_object_initialize(env, p, c, attr, handle);
if (rc)
GOTO(out, rc);
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);
int reclen;
fid_cpu_to_be(&tmpfid, pfid);
+ if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_CRASH))
+ tmpfid.f_ver = ~0;
memcpy(&lee->lee_parent_fid, &tmpfid, sizeof(tmpfid));
memcpy(lee->lee_name, lname->ln_name, lname->ln_namelen);
reclen = sizeof(struct link_ea_entry) + lname->ln_namelen;
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;
return -EEXIST;
}
+ if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_MORE)) {
+ struct lu_fid *tfid = &mdd_env_info(env)->mti_fid2;
+
+ *tfid = *pfid;
+ tfid->f_ver = ~0;
+ mdd_links_add_buf(env, ldata, lname, tfid);
+ }
+
return mdd_links_add_buf(env, ldata, lname, pfid);
}
int rc = 0;
ENTRY;
+ if (OBD_FAIL_CHECK(OBD_FAIL_FID_IGIF))
+ return 0;
+
LASSERT(oldpfid != NULL || newpfid != NULL);
if (mdd_obj->mod_flags & DEAD_OBJ)