* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
- * Copyright (c) 2011, 2012, Intel Corporation.
+ * Copyright (c) 2011, 2013, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
RETURN(rc);
}
-int mdd_declare_llog_record(const struct lu_env *env, struct mdd_device *mdd,
- int reclen, struct thandle *handle)
-{
- int rc;
-
- /* XXX: this is a temporary solution to declare llog changes
- * will be fixed in 2.3 with new llog implementation */
-
- LASSERT(mdd->mdd_capa);
-
- /* XXX: Since we use the 'mdd_capa' as fake llog object here, we
- * have to set the parameter 'size' as INT_MAX or 0 to inform
- * OSD that this record write is for a llog write or catalog
- * header update, and osd declare function will reserve less
- * credits for optimization purpose.
- *
- * Reserve 6 blocks for a llog write, since the llog file is
- * usually small, reserve 2 blocks for catalog header update,
- * because we know for sure that catalog header is already
- * allocated.
- *
- * This hack should be removed in 2.3.
- */
-
- /* record itself */
- rc = dt_declare_record_write(env, mdd->mdd_capa,
- DECLARE_LLOG_WRITE, 0, handle);
- if (rc)
- return rc;
-
- /* header will be updated as well */
- rc = dt_declare_record_write(env, mdd->mdd_capa,
- DECLARE_LLOG_WRITE, 0, handle);
- if (rc)
- return rc;
-
- /* also we should be able to create new plain log */
- rc = dt_declare_create(env, mdd->mdd_capa, NULL, NULL, NULL, handle);
- if (rc)
- return rc;
-
- /* new record referencing new plain llog */
- rc = dt_declare_record_write(env, mdd->mdd_capa,
- DECLARE_LLOG_WRITE, 0, handle);
- if (rc)
- return rc;
-
- /* catalog's header will be updated as well */
- rc = dt_declare_record_write(env, mdd->mdd_capa,
- DECLARE_LLOG_REWRITE, 0, handle);
-
- return rc;
-}
-
int mdd_declare_changelog_store(const struct lu_env *env,
struct mdd_device *mdd,
const struct lu_name *fname,
linkea_add_buf(ldata, lname, tfid);
}
+ if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_MORE2))
+ linkea_add_buf(ldata, lname, pfid);
+
return linkea_add_buf(ldata, lname, pfid);
}
LASSERT(oldpfid != NULL || newpfid != NULL);
- if (mdd_obj->mod_flags & DEAD_OBJ)
+ if (mdd_obj->mod_flags & DEAD_OBJ) {
+ /* Prevent linkea to be updated which is NOT necessary. */
+ ldata->ld_reclen = 0;
/* No more links, don't bother */
RETURN(0);
+ }
if (oldpfid != NULL) {
rc = __mdd_links_del(env, mdd_obj, ldata, oldlname, oldpfid);
GOTO(out, rc);
}
- if (ldata->ld_lee != NULL)
+ if (ldata->ld_reclen != 0)
rc = mdd_links_write(env, mdd_obj, ldata, handle);
EXIT;
out:
rc = rc2;
if (rc) {
int error = 1;
- if (rc == -EOVERFLOW || rc == -ENOENT)
+ if (rc == -EOVERFLOW || rc == -ENOENT || rc == -ENOSPC)
error = 0;
if (oldpfid == NULL)
CDEBUG(error ? D_ERROR : D_OTHER,
ea_len = ldata->ld_leh->leh_len;
linkea = ldata->ld_buf->lb_buf;
} else {
- ea_len = 4096;
+ ea_len = DEFAULT_LINKEA_SIZE;
linkea = NULL;
}
LASSERT(mdd_write_locked(env, obj) != 0);
- if (rc == 0 && (ma->ma_attr.la_nlink == 0 || is_dir)) {
+ if (ma->ma_attr.la_nlink == 0 || is_dir) {
obj->mod_flags |= DEAD_OBJ;
+
/* add new orphan and the object
* will be deleted during mdd_close() */
if (obj->mod_count) {
int rc;
ENTRY;
- /* do not let users to create stripes via .lustre/
- * mdd_obf_setup() sets IMMUTE_OBJ on this directory */
- if (pobj && mdd_pobj->mod_flags & IMMUTE_OBJ)
- RETURN(-ENOENT);
-
rc = mdd_cd_sanity_check(env, son);
if (rc)
RETURN(rc);
if (rc)
GOTO(stop, rc);
+ rc = mdd_declare_changelog_store(env, mdd, NULL, handle);
+ if (rc)
+ GOTO(stop, rc);
+
rc = mdd_trans_start(env, mdd, handle);
if (rc)
GOTO(stop, rc);
rc = dt_xattr_set(env, mdd_object_child(son), buf, XATTR_NAME_LOV,
0, handle, mdd_object_capa(env, son));
+
+ if (rc)
+ GOTO(stop, rc);
+
+ rc = mdd_changelog_data_store(env, mdd, CL_LAYOUT, 0, son, handle);
+
stop:
mdd_trans_stop(env, mdd, rc, handle);
out_free:
dotdot, handle);
}
- if (rc == 0 && (fid_is_norm(mdo2fid(child)) ||
- fid_is_dot_lustre(mdo2fid(child)) ||
- fid_is_root(mdo2fid(child))))
+ if (rc == 0)
mdd_declare_links_add(env, child, handle, ldata);
RETURN(rc);
mdo_ref_del(env, child, handle);
}
- if (rc == 0 && (fid_is_norm(mdo2fid(child)) ||
- fid_is_dot_lustre(mdo2fid(child)) ||
- fid_is_root(mdo2fid(child))))
+ if (rc == 0)
mdd_links_add(env, child, pfid, lname, handle, ldata, 1);
RETURN(rc);