#include <lustre/lustre_idl.h>
#include <lu_object.h>
#include <dt_object.h>
-#include <lustre_linkea.h>
#include <lustre_fid.h>
#include <lustre_lib.h>
#include <lustre_net.h>
__u32 ea_off)
{
struct lfsck_thread_info *info = lfsck_env_info(env);
+ struct dt_insert_rec *dtrec = &info->lti_dt_rec;
char *name = info->lti_key;
struct lu_attr *la = &info->lti_la;
struct dt_object_format *dof = &info->lti_dof;
struct lu_buf *pbuf = NULL;
struct lu_buf *ea_buf = &info->lti_big_buf;
struct lustre_handle lh = { 0 };
+ struct linkea_data ldata = { 0 };
+ struct lu_buf linkea_buf;
+ const struct lu_name *pname;
int buflen = ea_buf->lb_len;
int idx = 0;
int rc = 0;
GOTO(put, rc);
} while (rc == 0);
+ rc = linkea_data_new(&ldata,
+ &lfsck_env_info(env)->lti_linkea_buf);
+ if (rc != 0)
+ GOTO(put, rc);
+
+ pname = lfsck_name_get_const(env, name, strlen(name));
+ rc = linkea_add_buf(&ldata, pname, lfsck_dto2fid(lfsck->li_lpf_obj));
+ if (rc != 0)
+ GOTO(put, rc);
+
memset(la, 0, sizeof(*la));
la->la_uid = rec->lor_uid;
la->la_gid = rec->lor_gid;
GOTO(stop, rc);
/* 4a. Insert the MDT-object to .lustre/lost+found/MDTxxxx/ */
+ dtrec->rec_fid = pfid;
+ dtrec->rec_type = S_IFREG;
rc = dt_declare_insert(env, lfsck->li_lpf_obj,
- (const struct dt_rec *)pfid,
+ (const struct dt_rec *)dtrec,
(const struct dt_key *)name, th);
if (rc != 0)
GOTO(stop, rc);
+ /* 5a. insert linkEA for parent. */
+ linkea_buf.lb_buf = ldata.ld_buf->lb_buf;
+ linkea_buf.lb_len = ldata.ld_leh->leh_len;
+ rc = dt_declare_xattr_set(env, pobj, &linkea_buf,
+ XATTR_NAME_LINK, 0, th);
+ if (rc != 0)
+ GOTO(stop, rc);
+
rc = dt_trans_start(env, next, th);
if (rc != 0)
GOTO(stop, rc);
GOTO(stop, rc);
/* 4b. Insert the MDT-object to .lustre/lost+found/MDTxxxx/ */
- rc = dt_insert(env, lfsck->li_lpf_obj,
- (const struct dt_rec *)pfid,
+ rc = dt_insert(env, lfsck->li_lpf_obj, (const struct dt_rec *)dtrec,
(const struct dt_key *)name, th, BYPASS_CAPA, 1);
+ if (rc != 0)
+ GOTO(stop, rc);
+
+ /* 5b. insert linkEA for parent. */
+ rc = dt_xattr_set(env, pobj, &linkea_buf,
+ XATTR_NAME_LINK, 0, th, BYPASS_CAPA);
GOTO(stop, rc);
struct lfsck_bookmark *bk = &lfsck->li_bookmark_ram;
struct thandle *handle = NULL;
size_t buflen = buf->lb_len;
+ size_t lovea_size;
struct lov_mds_md_v1 *lmm;
struct lov_ost_data_v1 *objs;
struct lustre_handle lh = { 0 };
if (rc < 0)
GOTO(unlock_layout, rc);
- if (buf->lb_len < rc) {
- lu_buf_realloc(buf, rc);
+ lovea_size = rc;
+ if (buf->lb_len < lovea_size) {
+ lu_buf_realloc(buf, lovea_size);
buflen = buf->lb_len;
if (buf->lb_buf == NULL)
GOTO(unlock_layout, rc = -ENOMEM);
LASSERT(rc != 0);
goto again;
} else if (rc == -ENODATA || rc == 0) {
- rc = lov_mds_md_size(ea_off + 1, LOV_MAGIC_V1);
+ lovea_size = lov_mds_md_size(ea_off + 1, LOV_MAGIC_V1);
/* If the declared is not big enough, re-try. */
- if (buf->lb_len < rc)
+ if (buf->lb_len < lovea_size) {
+ rc = lovea_size;
goto again;
-
+ }
fl = LU_XATTR_CREATE;
} else if (rc < 0) {
GOTO(unlock_parent, rc);
goto again;
} else {
fl = LU_XATTR_REPLACE;
+ lovea_size = rc;
}
if (fl == LU_XATTR_CREATE) {
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
- LASSERT(buf->lb_len >= rc);
+ LASSERT(buf->lb_len >= lovea_size);
- buf->lb_len = rc;
+ buf->lb_len = lovea_size;
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, false);
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
- LASSERT(buf->lb_len >= rc);
+ LASSERT(buf->lb_len >= lovea_size);
- buf->lb_len = rc;
+ buf->lb_len = lovea_size;
memset(lmm, 0, buf->lb_len);
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, true);
if (bk->lb_param & LPF_DRYRUN)
GOTO(unlock_parent, rc = 1);
- rc = lov_mds_md_size(ea_off + 1, magic);
+ lovea_size = lov_mds_md_size(ea_off + 1, magic);
/* If the declared is not big enough, re-try. */
- if (buf->lb_len < rc)
+ if (buf->lb_len < lovea_size) {
+ rc = lovea_size;
goto again;
-
- buf->lb_len = rc;
+ }
+ buf->lb_len = lovea_size;
rc = lfsck_layout_extend_lovea(env, lfsck, handle, parent, cfid,
buf, fl, ost_idx, ea_off, false);
LASSERTF(rc > 0, "invalid rc = %d\n", rc);
- buf->lb_len = rc;
+ buf->lb_len = lovea_size;
for (i = 0; i < count; i++, objs++) {
/* The MDT-object was created via lfsck_layout_recover_create()
* by others before, and we fill the dummy layout EA. */
rc = rc1;
}
+ /* flush all async updating before exit. */
+ dt_sync(env, lfsck->li_next);
+
/* Under force exit case, some requests may be just freed without
* verification, those objects should be re-handled when next run.
* So not update the on-disk tracing file under such case. */