*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* Implementation of cl_device and cl_device_type for LOV layer.
*
}
};
-/*****************************************************************************
- *
+/**
* Lov device and device type functions.
- *
*/
+/**
+ * Initilize and associate key(per context data) with
+ * lu_context(execution context)
+ *
+ * \param[in] ctx Execution context
+ * \param[in] key Describes Data associated with this context
+ *
+ */
static void *lov_key_init(const struct lu_context *ctx,
struct lu_context_key *key)
{
return info;
}
+/**
+ * Release execution context and disassociate key
+ *
+ * \param[in] ctx execution environment
+ * \param[in] key Key
+ * \param[in] data Data associated with this context
+ *
+ */
static void lov_key_fini(const struct lu_context *ctx,
struct lu_context_key *key, void *data)
{
.lct_fini = lov_key_fini
};
+/**
+ * Initilize and associate key(per context data) with
+ * lu_context(execution context) for a session
+ *
+ * \param[in] ctx Execution context
+ * \param[in] key Describes Data associated with this context
+ */
static void *lov_session_key_init(const struct lu_context *ctx,
struct lu_context_key *key)
{
return info;
}
+/**
+ * Release execution context and disassociate key for a session
+ *
+ * \param[in] ctx execution environment
+ * \param[in] key Key
+ * \param[in] data Data associated with this context
+ */
static void lov_session_key_fini(const struct lu_context *ctx,
struct lu_context_key *key, void *data)
{
LU_TYPE_INIT_FINI(lov, &lov_key, &lov_session_key);
+/**
+ * Add new MDC target device in LOV.
+ *
+ * This function is part of the configuration log processing. It adds new MDC
+ * device to the MDC device array indexed by their indexes.
+ *
+ * \param[in] env local execution environment
+ * \param[in] ld LU device of LOV device
+ * \param[in] mdc_dev MDC device to add
+ * \param[in] idx MDC device index
+ * \param[in] nr MDC device index
+ *
+ * \retval 0 if successful
+ * \retval Non zero value on error
+ */
static int lov_mdc_dev_init(const struct lu_env *env, struct lov_device *ld,
struct lu_device *mdc_dev, __u32 idx, __u32 nr)
{
RETURN(0);
}
+/**
+ * Free Resource associated with lov device context
+ *
+ * \param[in] env execution environment
+ * \param[in] d LU device of LOV device
+ *
+ * \retval Returns NULL
+ */
static struct lu_device *lov_device_fini(const struct lu_env *env,
struct lu_device *d)
{
RETURN(NULL);
}
+/**
+ * Initilize lov_device
+ *
+ * \param[in] env execution environment
+ * \param[in] d LU device of LOV device
+ * \param[in] name Device name
+ * \param[in] next Pointer to next lu_device
+ *
+ * \retval 0 if successful
+ * \retval negative value on error
+ */
static int lov_device_init(const struct lu_env *env, struct lu_device *d,
const char *name, struct lu_device *next)
{
RETURN(rc);
}
-/* Free the lov specific data created for the back end lu_device. */
+/**
+ * Free the lov specific data created for the back end lu_device.
+ *
+ * \param[in] env execution environment
+ * \param[in] d Backend lu_device
+ *
+ * \retval Free data and return NULL
+ */
static struct lu_device *lov_device_free(const struct lu_env *env,
struct lu_device *d)
{
return NULL;
}
+/**
+ * Delete cl_object(osc) target from lov
+ *
+ * \param[in] env execution environment
+ * \param[in] dev LU device of LOV device
+ * \param[in] index index of backend lu device
+ *
+ */
static void lov_cl_del_target(const struct lu_env *env, struct lu_device *dev,
__u32 index)
{
RETURN(result);
}
+/**
+ * Add cl_object(osc) target to lov
+ *
+ * \param[in] env execution environment
+ * \param[in] dev LU device of LOV device
+ * \param[in] index index of lu backend device
+ *
+ * \retval 0 if successful
+ * \retval negative value on error
+ */
static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev,
__u32 index)
{
{
struct lov_device *ld = lu2lov_dev(d);
struct obd_device *lov_obd = d->ld_obd;
- struct obd_device *lmv_obd;
- int next;
+ struct obd_device *lmv_obd = NULL;
+ unsigned long dev_no = 0;
int rc = 0;
ENTRY;
* to be sure LMV is set up and can be found
*/
if (!ld->ld_lmv) {
- next = 0;
- while ((lmv_obd = class_devices_in_group(&lov_obd->obd_uuid,
- &next)) != NULL) {
+ obd_device_lock();
+ obd_device_for_each_uuid(dev_no, lmv_obd,
+ &lov_obd->obd_uuid) {
if ((strncmp(lmv_obd->obd_type->typ_name,
LUSTRE_LMV_NAME,
- strlen(LUSTRE_LMV_NAME)) == 0))
+ strlen(LUSTRE_LMV_NAME)) == 0)) {
+ spin_lock(&lmv_obd->obd_dev_lock);
+ class_incref(lmv_obd, "lov", ld);
+ spin_unlock(&lmv_obd->obd_dev_lock);
break;
+ }
}
+ obd_device_unlock();
+
if (!lmv_obd) {
CERROR("%s: cannot find LMV OBD by UUID (%s)\n",
lov_obd->obd_name,
obd_uuid2str(&lmv_obd->obd_uuid));
RETURN(-ENODEV);
}
- spin_lock(&lmv_obd->obd_dev_lock);
- class_incref(lmv_obd, "lov", ld);
- spin_unlock(&lmv_obd->obd_dev_lock);
ld->ld_lmv = lmv_obd;
}
RETURN(rc);
}
+/**
+ * Called when lov configuration changes are needed
+ *
+ * \param[in] env execution environment
+ * \param[in] d LU device of LOV device
+ * \param[in] cfg setup configuration commands and arguments
+ *
+ * \retval Return a new lu_device on success
+ * \retval Error pointer on failure
+ */
static int lov_process_config(const struct lu_env *env,
struct lu_device *d, struct lustre_cfg *cfg)
{
.ldo_process_config = lov_process_config,
};
+/**
+ * Allocate a new lov lu_device
+ *
+ * \param[in] env execution environment
+ * \param[in] t Backend OSD device type (ldiskfs,zfs)
+ * \param[in] cfg setup configuration commands and arguments
+ *
+ * \retval Return a new lu_device on success
+ * \retval Error pointer on failure
+ */
static struct lu_device *lov_device_alloc(const struct lu_env *env,
struct lu_device_type *t,
struct lustre_cfg *cfg)
.ldto_stop = lov_type_stop,
.ldto_device_alloc = lov_device_alloc,
- .ldto_device_free = lov_device_free,
+ .ldto_device_free = lov_device_free,
- .ldto_device_init = lov_device_init,
- .ldto_device_fini = lov_device_fini
+ .ldto_device_init = lov_device_init,
+ .ldto_device_fini = lov_device_fini
};
struct lu_device_type lov_device_type = {