Example #1
0
static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
{
	struct dt_device		*dt;
	struct ls_device		*ls;
	struct local_oid_storage	*los, *nlos;

	LASSERT(ctxt->loc_exp->exp_obd);
	dt = ctxt->loc_exp->exp_obd->obd_lvfs_ctxt.dt;
	ls = ls_device_get(dt);
	if (IS_ERR(ls))
		RETURN(PTR_ERR(ls));

	mutex_lock(&ls->ls_los_mutex);
	los = dt_los_find(ls, FID_SEQ_LLOG);
	nlos = dt_los_find(ls, FID_SEQ_LLOG_NAME);
	mutex_unlock(&ls->ls_los_mutex);
	if (los != NULL) {
		dt_los_put(los);
		local_oid_storage_fini(env, los);
	}
	if (nlos != NULL) {
		dt_los_put(nlos);
		local_oid_storage_fini(env, nlos);
	}
	ls_device_put(env, ls);
	return 0;
}
Example #2
0
/**
 * Implementation of the llog_operations::lop_cleanup
 *
 * This function cleanups the llog on local storage.
 *
 * \param[in] env	execution environment
 * \param[in] ctxt	the llog context
 *
 * \retval		0
 */
static int llog_osd_cleanup(const struct lu_env *env, struct llog_ctxt *ctxt)
{
	if (ctxt->loc_los_nameless != NULL) {
		local_oid_storage_fini(env, ctxt->loc_los_nameless);
		ctxt->loc_los_nameless = NULL;
	}

	if (ctxt->loc_los_named != NULL) {
		local_oid_storage_fini(env, ctxt->loc_los_named);
		ctxt->loc_los_named = NULL;
	}

	return 0;
}
Example #3
0
/*
 * Helper function looking up & creating if not found an index file with a
 * dynamic fid.
 */
static struct dt_object *
lquota_disk_find_create(const struct lu_env *env, struct dt_device *dev,
			struct dt_object *parent, struct lu_fid *fid,
			const struct dt_index_features *idx_feat,
			char *name)
{
	struct lquota_thread_info	*qti = lquota_info(env);
	struct dt_object		*obj;
	struct local_oid_storage	*los;
	int				 rc;
	ENTRY;

	/* Set up local storage */
	rc = local_oid_storage_init(env, dev, fid, &los);
	if (rc)
		RETURN(ERR_PTR(rc));

	/* lookup/create slave index file */
	obj = local_index_find_or_create(env, los, parent, name, LQUOTA_MODE,
					 idx_feat);
	if (IS_ERR(obj))
		GOTO(out, obj);

	/* local_oid_storage_fini() will finalize the local storage device,
	 * we have to open the object in another device stack */
	qti->qti_fid = obj->do_lu.lo_header->loh_fid;
	lu_object_put_nocache(env, &obj->do_lu);
	obj = dt_locate(env, dev, &qti->qti_fid);
	if (IS_ERR(obj))
		GOTO(out, obj);
out:
	local_oid_storage_fini(env, los);
	RETURN(obj);
}
Example #4
0
static void mdd_device_shutdown(const struct lu_env *env, struct mdd_device *m,
				struct lustre_cfg *cfg)
{
	mdd_generic_thread_stop(&m->mdd_orph_cleanup_thread);
	lfsck_degister(env, m->mdd_bottom);
	mdd_hsm_actions_llog_fini(env, m);
	mdd_changelog_fini(env, m);
	orph_index_fini(env, m);
	mdd_dot_lustre_cleanup(env, m);
	if (m->mdd_los != NULL) {
		local_oid_storage_fini(env, m->mdd_los);
		m->mdd_los = NULL;
	}
	lu_site_purge(env, mdd2lu_dev(m)->ld_site, ~0);

	if (m->mdd_child_exp)
		obd_disconnect(m->mdd_child_exp);
}
Example #5
0
/**
 * Implementation of the llog_operations::lop_setup
 *
 * This function setup the llog on local storage.
 *
 * \param[in] env	execution environment
 * \param[in] obd	obd device the llog belongs to
 * \param[in] olg	the llog group, it is always zero group now.
 * \param[in] ctxt_idx	the llog index, it defines the purpose of this llog.
 *			Every new llog type have to use own index.
 * \param[in] disk_obd	the storage obd, where llog is stored.
 *
 * \retval		0 on successful llog setup
 * \retval		negative value on error
 */
static int llog_osd_setup(const struct lu_env *env, struct obd_device *obd,
			  struct obd_llog_group *olg, int ctxt_idx,
			  struct obd_device *disk_obd)
{
	struct llog_thread_info		*lgi = llog_info(env);
	struct llog_ctxt		*ctxt;
	int				 rc = 0;
	ENTRY;

	LASSERT(obd);
	LASSERT(olg->olg_ctxts[ctxt_idx]);

	ctxt = llog_ctxt_get(olg->olg_ctxts[ctxt_idx]);
	LASSERT(ctxt);

	/* initialize data allowing to generate new fids,
	 * literally we need a sequece */
	lgi->lgi_fid.f_seq = FID_SEQ_LLOG;
	lgi->lgi_fid.f_oid = 1;
	lgi->lgi_fid.f_ver = 0;
	rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
				    &lgi->lgi_fid,
				    &ctxt->loc_los_nameless);
	if (rc != 0)
		GOTO(out, rc);

	lgi->lgi_fid.f_seq = FID_SEQ_LLOG_NAME;
	lgi->lgi_fid.f_oid = 1;
	lgi->lgi_fid.f_ver = 0;
	rc = local_oid_storage_init(env, disk_obd->obd_lvfs_ctxt.dt,
				    &lgi->lgi_fid,
				    &ctxt->loc_los_named);
	if (rc != 0) {
		local_oid_storage_fini(env, ctxt->loc_los_nameless);
		ctxt->loc_los_nameless = NULL;
	}

	GOTO(out, rc);

out:
	llog_ctxt_put(ctxt);
	return rc;
}
Example #6
0
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;
}
Example #7
0
/*
 * Set up quota directory (either "quota_master" or "quota_slave") for a QMT or
 * QSD instance. This function is also used to create per-pool directory on
 * the quota master.
 * The directory is created with a local sequence if it does not exist already.
 * This function is called at ->ldo_prepare time when the full device stack is
 * configured.
 *
 * \param env  - is the environment passed by the caller
 * \param dev  - is the dt_device where to create the quota directory
 * \param parent  - is the parent directory. If not specified, the directory
 *                  will be created under the root directory
 * \param name - is the name of quota directory to be created
 *
 * \retval     - pointer to quota root dt_object on success, appropriate error
 *               on failure
 */
struct dt_object *lquota_disk_dir_find_create(const struct lu_env *env,
					      struct dt_device *dev,
					      struct dt_object *parent,
					      const char *name)
{
	struct lquota_thread_info	*qti = lquota_info(env);
	struct dt_object		*qt_dir = NULL;
	struct local_oid_storage	*los = NULL;
	int				 rc;
	ENTRY;

	/* Set up local storage to create the quota directory.
	 * We use the sequence reserved for local named objects */
	lu_local_name_obj_fid(&qti->qti_fid, 1);
	rc = local_oid_storage_init(env, dev, &qti->qti_fid, &los);
	if (rc)
		RETURN(ERR_PTR(rc));

	if (parent == NULL) {
		/* Fetch dt object associated with root directory */
		rc = dt_root_get(env, dev, &qti->qti_fid);
		if (rc)
			GOTO(out, rc);

		parent = dt_locate_at(env, dev, &qti->qti_fid,
				      dev->dd_lu_dev.ld_site->ls_top_dev, NULL);
		if (IS_ERR(parent))
			GOTO(out, rc = PTR_ERR(parent));
	} else {
		lu_object_get(&parent->do_lu);
	}

	/* create quota directory to be used for all quota index files */
	qt_dir = local_file_find_or_create(env, los, parent, name, S_IFDIR |
					   S_IRUGO | S_IWUSR | S_IXUGO);
	if (IS_ERR(qt_dir))
		GOTO(out, rc = PTR_ERR(qt_dir));

	/* local_oid_storage_fini() will finalize the local storage device,
	 * we have to open the object in another device stack */
	qti->qti_fid = qt_dir->do_lu.lo_header->loh_fid;
	lu_object_put_nocache(env, &qt_dir->do_lu);
	qt_dir = dt_locate(env, dev, &qti->qti_fid);
	if (IS_ERR(qt_dir))
		GOTO(out, rc = PTR_ERR(qt_dir));

	if (!dt_try_as_dir(env, qt_dir))
		GOTO(out, rc = -ENOTDIR);
	EXIT;
out:
	if (parent != NULL && !IS_ERR(parent))
		lu_object_put(env, &parent->do_lu);
	if (los != NULL)
		local_oid_storage_fini(env, los);
	if (rc) {
		if (qt_dir != NULL && !IS_ERR(qt_dir))
			lu_object_put(env, &qt_dir->do_lu);
		qt_dir = ERR_PTR(rc);
	}
	return qt_dir;
}