/** * open the PENDING directory for device \a mdd * * The PENDING directory persistently tracks files and directories that were * unlinked from the namespace (nlink == 0) but are still held open by clients. * Those inodes shouldn't be deleted if the MDS crashes, because the clients * would not be able to recover and reopen those files. Instead, these inodes * are linked into the PENDING directory on disk, and only deleted if all * clients close them, or the MDS finishes client recovery without any client * reopening them (i.e. former clients didn't join recovery). * \param d mdd device being started. * * \retval 0 success * \retval -ve index operation error. * */ int orph_index_init(const struct lu_env *env, struct mdd_device *mdd) { struct lu_fid fid; struct dt_object *d; int rc = 0; ENTRY; /* create PENDING dir */ fid_zero(&fid); rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid, orph_index_name, S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO, &fid); if (rc < 0) RETURN(rc); d = dt_locate(env, mdd->mdd_child, &fid); if (IS_ERR(d)) RETURN(PTR_ERR(d)); LASSERT(lu_object_exists(&d->do_lu)); if (!dt_try_as_dir(env, d)) { CERROR("%s: \"%s\" is not an index: rc = %d\n", mdd2obd_dev(mdd)->obd_name, orph_index_name, rc); lu_object_put(env, &d->do_lu); RETURN(-ENOTDIR); } mdd->mdd_orphans = d; RETURN(0); }
static int mdd_lpf_setup(const struct lu_env *env, struct mdd_device *m) { struct md_object *mdo; struct mdd_object *mdd_lpf; struct lu_fid fid = LU_LPF_FID; int rc; ENTRY; rc = mdd_local_file_create(env, m, mdd_object_fid(m->mdd_dot_lustre), mdd_lpf_dir_name, S_IFDIR | S_IRUSR | S_IXUSR, &fid); if (rc != 0) RETURN(rc); mdo = mdo_locate(env, &m->mdd_md_dev, &fid); if (IS_ERR(mdo)) RETURN(PTR_ERR(mdo)); LASSERT(lu_object_exists(&mdo->mo_lu)); mdd_lpf = md2mdd_obj(mdo); mdd_lpf->mod_obj.mo_dir_ops = &mdd_lpf_dir_ops; m->mdd_dot_lustre_objs.mdd_lpf = mdd_lpf; RETURN(0); }
/** Setup ".lustre" directory object */ static int mdd_dot_lustre_setup(const struct lu_env *env, struct mdd_device *m) { struct md_object *mdo; struct lu_fid fid; int rc; ENTRY; /* Create ".lustre" directory in ROOT. */ fid = LU_DOT_LUSTRE_FID; rc = mdd_local_file_create(env, m, &m->mdd_root_fid, dot_lustre_name, S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO, &fid); if (rc < 0) RETURN(rc); mdo = mdo_locate(env, &m->mdd_md_dev, &fid); if (IS_ERR(mdo)) RETURN(PTR_ERR(mdo)); LASSERT(lu_object_exists(&mdo->mo_lu)); m->mdd_dot_lustre = md2mdd_obj(mdo); rc = mdd_obf_setup(env, m); if (rc) { CERROR("%s: error initializing \"fid\" object: rc = %d.\n", mdd2obd_dev(m)->obd_name, rc); GOTO(out, rc); } rc = mdd_lpf_setup(env, m); if (rc != 0) { CERROR("%s: error initializing \"lost+found\": rc = %d.\n", mdd2obd_dev(m)->obd_name, rc); GOTO(out, rc); } RETURN(0); out: mdd_dot_lustre_cleanup(env, m); return rc; }
static int mdd_prepare(const struct lu_env *env, struct lu_device *pdev, struct lu_device *cdev) { struct mdd_device *mdd = lu2mdd_dev(cdev); struct lu_device *next = &mdd->mdd_child->dd_lu_dev; struct lu_fid fid; int rc; ENTRY; rc = next->ld_ops->ldo_prepare(env, cdev, next); if (rc) RETURN(rc); /* Setup local dirs */ fid.f_seq = FID_SEQ_LOCAL_NAME; fid.f_oid = 1; fid.f_ver = 0; rc = local_oid_storage_init(env, mdd->mdd_bottom, &fid, &mdd->mdd_los); if (rc) RETURN(rc); rc = dt_root_get(env, mdd->mdd_child, &mdd->mdd_local_root_fid); if (rc < 0) GOTO(out_los, rc); lu_root_fid(&fid); if (mdd_seq_site(mdd)->ss_node_id == 0) { rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid, mdd_root_dir_name, S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO, &fid); if (rc != 0) { CERROR("%s: create root fid failed: rc = %d\n", mdd2obd_dev(mdd)->obd_name, rc); GOTO(out_los, rc); } mdd->mdd_root_fid = fid; rc = mdd_dot_lustre_setup(env, mdd); if (rc != 0) { CERROR("%s: initializing .lustre failed: rc = %d\n", mdd2obd_dev(mdd)->obd_name, rc); GOTO(out_los, rc); } rc = mdd_compat_fixes(env, mdd); if (rc != 0) GOTO(out_dot, rc); } else { /* Normal client usually send root access to MDT0 directly, * the root FID on non-MDT0 will only be used by echo client. */ mdd->mdd_root_fid = fid; } rc = orph_index_init(env, mdd); if (rc < 0) GOTO(out_dot, rc); rc = mdd_changelog_init(env, mdd); if (rc != 0) { CERROR("%s: failed to initialize changelog: rc = %d\n", mdd2obd_dev(mdd)->obd_name, rc); GOTO(out_orph, rc); } rc = mdd_hsm_actions_llog_init(env, mdd); if (rc != 0) GOTO(out_changelog, rc); rc = lfsck_register(env, mdd->mdd_bottom, mdd->mdd_child, mdd2obd_dev(mdd), mdd_lfsck_out_notify, mdd, true); if (rc != 0) { CERROR("%s: failed to initialize lfsck: rc = %d\n", mdd2obd_dev(mdd)->obd_name, rc); GOTO(out_hsm, rc); } RETURN(0); out_hsm: mdd_hsm_actions_llog_fini(env, mdd); out_changelog: mdd_changelog_fini(env, mdd); out_orph: orph_index_fini(env, mdd); out_dot: if (mdd_seq_site(mdd)->ss_node_id == 0) mdd_dot_lustre_cleanup(env, mdd); out_los: local_oid_storage_fini(env, mdd->mdd_los); mdd->mdd_los = NULL; return rc; }