#define LMVEA_DELETE_VALUES(count, offset) \
((count) == 0 && (offset) == (typeof(offset))(-1))
-struct pool_desc {
+struct lod_pool_desc {
char pool_name[LOV_MAXPOOLNAME + 1];
struct lu_tgt_pool pool_obds; /* pool members */
atomic_t pool_refcount;
int lod_init_comp_foreign(struct lod_layout_component *lod_comp, void *lmm);
/* lod_pool.c */
-struct pool_desc *lod_find_pool(struct lod_device *lod, char *poolname);
-void lod_pool_putref(struct pool_desc *pool);
+struct lod_pool_desc *lod_find_pool(struct lod_device *lod, char *poolname);
+void lod_pool_putref(struct lod_pool_desc *pool);
int lod_pool_del(struct obd_device *obd, char *poolname);
-int lod_check_index_in_pool(__u32 idx, struct pool_desc *pool);
+int lod_check_index_in_pool(__u32 idx, struct lod_pool_desc *pool);
int lod_pool_new(struct obd_device *obd, char *poolname);
int lod_pool_add(struct obd_device *obd, char *poolname, char *ostname);
int lod_pool_remove(struct obd_device *obd, char *poolname, char *ostname);
void lod_check_and_spill_pool(const struct lu_env *env, struct lod_device *lod,
char **poolname);
void lod_spill_target_refresh(const struct lu_env *env, struct lod_device *lod,
- struct pool_desc *pool);
-struct pool_desc *lod_pool_find(struct lod_device *lod, char *poolname);
+ struct lod_pool_desc *pool);
+struct lod_pool_desc *lod_pool_find(struct lod_device *lod, char *poolname);
int lod_tgt_weights_seq_show(struct seq_file *m, struct lod_device *lod,
struct lu_tgt_pool *tgts, bool mdt);
int lod_tgt_weights_seq_write(struct seq_file *m, const char __user *buf,
{
struct lov_user_md_v1 *lum;
struct lov_user_md_v3 *lum3;
- struct pool_desc *pool = NULL;
+ struct lod_pool_desc *pool = NULL;
__u32 magic;
__u32 stripe_size;
__u16 stripe_count;
int lod_pools_fini(struct lod_device *lod)
{
struct obd_device *obd = lod2obd(lod);
- struct pool_desc *pool, *tmp;
+ struct lod_pool_desc *pool, *tmp;
ENTRY;
list_for_each_entry_safe(pool, tmp, &lod->lod_pool_list, pool_list) {
*
* \param[in] pool pool descriptor on which to gain reference
*/
-static void pool_getref(struct pool_desc *pool)
+static void pool_getref(struct lod_pool_desc *pool)
{
CDEBUG(D_INFO, "pool %p\n", pool);
atomic_inc(&pool->pool_refcount);
*
* \param[in] pool pool descriptor to drop reference on and possibly free
*/
-void lod_pool_putref(struct pool_desc *pool)
+void lod_pool_putref(struct lod_pool_desc *pool)
{
CDEBUG(D_INFO, "pool %p\n", pool);
if (atomic_dec_and_test(&pool->pool_refcount)) {
static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
{
- const struct pool_desc *pool = obj;
+ const struct lod_pool_desc *pool = obj;
const char *pool_name = arg->key;
return strcmp(pool_name, pool->pool_name);
static const struct rhashtable_params pools_hash_params = {
.key_len = 1, /* actually variable */
- .key_offset = offsetof(struct pool_desc, pool_name),
- .head_offset = offsetof(struct pool_desc, pool_hash),
+ .key_offset = offsetof(struct lod_pool_desc, pool_name),
+ .head_offset = offsetof(struct lod_pool_desc, pool_hash),
.hashfn = pool_hashfh,
.obj_cmpfn = pool_cmpfn,
.automatic_shrinking = true,
struct lod_pool_iterator {
unsigned int lpi_magic; /* POOL_IT_MAGIC */
unsigned int lpi_idx; /* from 0 to pool_tgt_size - 1 */
- struct pool_desc *lpi_pool;
+ struct lod_pool_desc *lpi_pool;
};
/**
*/
static void *pool_proc_start(struct seq_file *seq, loff_t *pos)
{
- struct pool_desc *pool = seq->private;
+ struct lod_pool_desc *pool = seq->private;
struct lod_pool_iterator *iter;
pool_getref(pool);
* \param[in] level Lustre debug level (D_INFO, D_WARN, D_ERROR, etc)
* \param[in] pool pool descriptor to be dumped
*/
-void lod_dump_pool(int level, struct pool_desc *pool)
+void lod_dump_pool(int level, struct lod_pool_desc *pool)
{
unsigned int i;
static void pools_hash_exit(void *vpool, void *data)
{
- struct pool_desc *pool = vpool;
+ struct lod_pool_desc *pool = vpool;
lod_pool_putref(pool);
}
bool lod_pool_exists(struct lod_device *lod, char *poolname)
{
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
rcu_read_lock();
pool = rhashtable_lookup(&lod->lod_pools_hash_body,
return pool != NULL;
}
-struct pool_desc *lod_pool_find(struct lod_device *lod, char *poolname)
+struct lod_pool_desc *lod_pool_find(struct lod_device *lod, char *poolname)
{
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
rcu_read_lock();
pool = rhashtable_lookup(&lod->lod_pools_hash_body,
static int lod_ost_pool_weights_seq_show(struct seq_file *m, void *data)
{
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
struct lod_device *lod = lu2lod_dev(pool->pool_lobd->obd_lu_dev);
return lod_tgt_weights_seq_show(m, lod, &pool->pool_obds, false);
size_t count, loff_t *off)
{
struct seq_file *m = file->private_data;
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
struct lod_device *lod = lu2lod_dev(pool->pool_lobd->obd_lu_dev);
return lod_tgt_weights_seq_write(m, buf, count, lod, &pool->pool_obds,
int lod_pool_new(struct obd_device *obd, char *poolname)
{
struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
- struct pool_desc *new_pool;
+ struct lod_pool_desc *new_pool;
int rc;
ENTRY;
int lod_pool_del(struct obd_device *obd, char *poolname)
{
struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
ENTRY;
/* lookup and kill hash reference */
{
struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
struct obd_uuid ost_uuid;
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
struct lu_tgt_desc *tgt;
int rc = -EINVAL;
ENTRY;
struct lod_device *lod = lu2lod_dev(obd->obd_lu_dev);
struct lu_tgt_desc *ost;
struct obd_uuid ost_uuid;
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
int rc = -EINVAL;
ENTRY;
* \retval 0 successfully found index in \a pool
* \retval negative error if device not found in \a pool
*/
-int lod_check_index_in_pool(__u32 idx, struct pool_desc *pool)
+int lod_check_index_in_pool(__u32 idx, struct lod_pool_desc *pool)
{
int rc;
* \retval pointer to pool descriptor on success
* \retval NULL if \a poolname could not be found or poolname is empty
*/
-struct pool_desc *lod_find_pool(struct lod_device *lod, char *poolname)
+struct lod_pool_desc *lod_find_pool(struct lod_device *lod, char *poolname)
{
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
if (poolname[0] == '\0' || lov_pool_is_reserved(poolname))
return NULL;
}
void lod_spill_target_refresh(const struct lu_env *env, struct lod_device *lod,
- struct pool_desc *pool)
+ struct lod_pool_desc *pool)
{
__u64 avail_bytes = 0, total_bytes = 0;
struct lu_tgt_pool *osts;
void lod_check_and_spill_pool(const struct lu_env *env, struct lod_device *lod,
char **poolname)
{
- struct pool_desc *pool;
+ struct lod_pool_desc *pool;
if (!poolname || !*poolname || (*poolname)[0] == '\0')
return;
{
struct lod_layout_component *lod_comp;
struct lod_device *m = lu2lod_dev(lo->ldo_obj.do_lu.lo_dev);
- struct pool_desc *pool = NULL;
+ struct lod_pool_desc *pool = NULL;
struct lu_tgt_pool *osts;
struct lu_qos_rr *lqr;
unsigned int i, array_idx;
unsigned int i, array_idx, ost_count;
int rc, stripe_num = 0;
int speed = 0;
- struct pool_desc *pool = NULL;
+ struct lod_pool_desc *pool = NULL;
struct lu_tgt_pool *osts;
int stripes_per_ost = 1;
bool overstriped = false;
* almost the same
*/
static int lod_pool_qos_penalties_calc(struct lod_device *lod,
- struct pool_desc *pool)
+ struct lod_pool_desc *pool)
{
struct lu_tgt_descs *ltd = &lod->lod_ost_descs;
struct lu_qos *qos = <d->ltd_qos;
struct lod_tgt_desc *ost;
struct dt_object *o;
__u64 total_weight = 0;
- struct pool_desc *pool = NULL;
+ struct lod_pool_desc *pool = NULL;
struct lu_tgt_pool *osts;
unsigned int i;
__u32 nfound, good_osts, stripe_count, stripe_count_min;
{
struct lod_device *d = lu2lod_dev(lod2lu_obj(lo)->lo_dev);
struct lod_layout_component *lod_comp;
- struct pool_desc *pool = NULL;
+ struct lod_pool_desc *pool = NULL;
__u32 idx;
int j, rc = 0;
* otherwise may cause severe OST imbalance.
*/
static ssize_t stripeoffset_store(struct kobject *kobj,
- struct attribute *attr,
- const char *buffer, size_t count)
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
struct dt_device *dt = container_of(kobj, struct dt_device,
dd_kobj);
LUSTRE_RW_ATTR(max_stripecount);
static ssize_t max_mdt_stripecount_show(struct kobject *kobj,
- struct attribute *attr, char *buf)
+ struct attribute *attr, char *buf)
{
struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
struct lod_device *lod = dt2lod_dev(dt);
}
static ssize_t max_mdt_stripecount_store(struct kobject *kobj,
- struct attribute *attr,
- const char *buffer, size_t count)
+ struct attribute *attr,
+ const char *buffer, size_t count)
{
struct dt_device *dt = container_of(kobj, struct dt_device, dd_kobj);
struct lod_device *lod = dt2lod_dev(dt);
}
static ssize_t stripetype_store(struct kobject *kobj,
- struct attribute *attr, const char *buffer,
- size_t count)
+ struct attribute *attr, const char *buffer,
+ size_t count)
{
return __stripetype_store(kobj, attr, buffer, count, false);
}
static int lod_spill_threshold_pct_seq_show(struct seq_file *m, void *v)
{
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
LASSERT(pool != NULL);
seq_printf(m, "%d\n", pool->pool_spill_threshold_pct);
size_t count, loff_t *off)
{
struct seq_file *m = file->private_data;
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
int rc;
int val;
static int lod_spill_target_seq_show(struct seq_file *m, void *v)
{
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
LASSERT(pool != NULL);
seq_printf(m, "%s\n", pool->pool_spill_target);
const char *destarg)
{
char dest[LOV_MAXPOOLNAME + 1];
- struct pool_desc *tgt;
+ struct lod_pool_desc *tgt;
int rc = 0;
strncpy(dest, destarg, sizeof(dest));
size_t count, loff_t *off)
{
struct seq_file *m = file->private_data;
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
struct lod_device *lod;
char tgt_name[LOV_MAXPOOLNAME + 1];
int rc;
static int lod_spill_is_active_seq_show(struct seq_file *m, void *v)
{
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
struct lod_device *lod;
struct lu_env env;
int rc;
static int lod_spill_hit_seq_show(struct seq_file *m, void *v)
{
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
LASSERT(pool != NULL);
seq_printf(m, "%d\n", atomic_read(&pool->pool_spill_hit));
static int lod_spill_status_seq_show(struct seq_file *m, void *v)
{
- struct pool_desc *pool = m->private;
+ struct lod_pool_desc *pool = m->private;
__u64 avail_bytes = 0, total_bytes = 0;
struct lu_tgt_pool *osts;
struct lod_device *lod;
}
};
-/*****************************************************************************
- *
+/**
* 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)
{
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 = {
#define pool_tgt_array(p) ((p)->pool_obds.op_array)
#define pool_tgt_rw_sem(p) ((p)->pool_obds.op_rw_sem)
-struct pool_desc {
+struct lov_pool_desc {
char pool_name[LOV_MAXPOOLNAME + 1];
struct lu_tgt_pool pool_obds;
atomic_t pool_refcount;
}
}
-struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname);
-void lov_pool_putref(struct pool_desc *pool);
+struct lov_pool_desc *lov_pool_find(struct obd_device *obd, char *poolname);
+void lov_pool_putref(struct lov_pool_desc *pool);
#endif
* @{
*/
+/**
+ * Allocate a new sub IO
+ *
+ * \param[in] lio top level lov IO structure
+ * \param[in] index index into lov (stripe)
+ *
+ * \retval Pointer to allocated lov_io_sub
+ * structure
+ */
static inline struct lov_io_sub *lov_sub_alloc(struct lov_io *lio, int index)
{
struct lov_io_sub *sub;
return sub;
}
+/**
+ * Release a sub IO
+ *
+ * \param[in] lio top level lov IO structure
+ * \param[in] sub sub io to individual stripe
+ *
+ */
static inline void lov_sub_free(struct lov_io *lio, struct lov_io_sub *sub)
{
if (sub->sub_subio_index == lio->lis_single_subio_index) {
RETURN(sub);
}
-/*****************************************************************************
- *
+/**
* Lov io operations.
- *
*/
static int lov_io_subio_init(const struct lu_env *env, struct lov_io *lio,
- struct cl_io *io)
+ struct cl_io *io)
{
ENTRY;
}
static int lov_io_mirror_init(struct lov_io *lio, struct lov_object *obj,
- struct cl_io *io)
+ struct cl_io *io)
{
struct lov_layout_composite *comp = &obj->u.composite;
int index;
}
/* if the last stripe is the trunc stripeno */
- if (is_trunc && lio->lis_trunc_stripe_index[index] == stripe)
+ if (is_trunc &&
+ lio->lis_trunc_stripe_index[index] == stripe)
lio->lis_trunc_stripe_index[index] = -1;
sub = lov_sub_get(env, lio,
}
static void lov_io_iter_fini(const struct lu_env *env,
- const struct cl_io_slice *ios)
+ const struct cl_io_slice *ios)
{
struct lov_io *lio = cl2lov_io(env, ios);
int rc;
}
static void lov_io_unlock(const struct lu_env *env,
- const struct cl_io_slice *ios)
+ const struct cl_io_slice *ios)
{
int rc;
.cio_commit_async = lov_io_commit_async,
};
-/*****************************************************************************
- *
+/**
* Empty lov io operations.
- *
*/
-
static void lov_empty_io_fini(const struct lu_env *env,
- const struct cl_io_slice *ios)
+ const struct cl_io_slice *ios)
{
struct lov_object *lov = cl2lov(ios->cis_obj);
ENTRY;
}
static void lov_empty_impossible(const struct lu_env *env,
- struct cl_io_slice *ios)
+ struct cl_io_slice *ios)
{
LBUG();
}
}
int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
- struct cl_io *io)
+ struct cl_io *io)
{
struct lov_object *lov = cl2lov(obj);
struct lov_io *lio = lov_env_io(env);
}
int lov_io_init_released(const struct lu_env *env, struct cl_object *obj,
- struct cl_io *io)
+ struct cl_io *io)
{
struct lov_object *lov = cl2lov(obj);
struct lov_io *lio = lov_env_io(env);
* @{
*/
-/*****************************************************************************
- *
+/**
* Lov lock operations.
- *
*/
-
static struct lov_sublock_env *lov_sublock_env_get(const struct lu_env *env,
const struct cl_lock *parent,
struct lov_lock_sub *lls)
}
static void lov_lock_fini(const struct lu_env *env,
- struct cl_lock_slice *slice)
+ struct cl_lock_slice *slice)
{
struct lov_lock *lovlck;
int i;
CDEBUG(D_INODE, "MDT ID "DOSTID" on OST[%u]: s=%llu (%d) m=%llu"
" a=%llu c=%llu b=%llu\n", POSTID(&lsm->lsm_oi),
- loi->loi_ost_idx, loi->loi_lvb.lvb_size, loi->loi_kms_valid,
- loi->loi_lvb.lvb_mtime, loi->loi_lvb.lvb_atime,
- loi->loi_lvb.lvb_ctime, loi->loi_lvb.lvb_blocks);
+ loi->loi_ost_idx, loi->loi_lvb.lvb_size,
+ loi->loi_kms_valid, loi->loi_lvb.lvb_mtime,
+ loi->loi_lvb.lvb_atime, loi->loi_lvb.lvb_ctime,
+ loi->loi_lvb.lvb_blocks);
}
if (!rc) {
#include "lov_internal.h"
/* Keep a refcount of lov->tgt usage to prevent racing with addition/deletion.
- Any function that expects lov_tgts to remain stationary must take a ref. */
+ * Any function that expects lov_tgts to remain stationary must take a ref. */
void lov_tgts_getref(struct obd_device *obd)
{
struct lov_obd *lov = &obd->u.lov;
CDEBUG(D_CONFIG, "destroying %d lov targets\n",
lov->lov_death_row);
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- tgt = lov->lov_tgts[i];
+ tgt = lov->lov_tgts[i];
- if (!tgt || !tgt->ltd_reap)
- continue;
+ if (!tgt || !tgt->ltd_reap)
+ continue;
list_add(&tgt->ltd_kill, &kill);
- /* XXX - right now there is a dependency on ld_tgt_count
- * being the maximum tgt index for computing the
- * mds_max_easize. So we can't shrink it. */
+ /* XXX - right now there is a dependency on ld_tgt_count
+ * being the maximum tgt index for computing the
+ * mds_max_easize. So we can't shrink it. */
lu_tgt_pool_remove(&lov->lov_packed, i);
- lov->lov_tgts[i] = NULL;
- lov->lov_death_row--;
- }
+ lov->lov_tgts[i] = NULL;
+ lov->lov_death_row--;
+ }
mutex_unlock(&lov->lov_lock);
list_for_each_entry_safe(tgt, n, &kill, ltd_kill) {
RETURN(0);
}
-static int lov_connect(const struct lu_env *env,
- struct obd_export **exp, struct obd_device *obd,
- struct obd_uuid *cluuid, struct obd_connect_data *data,
- void *localdata)
+static int lov_connect(const struct lu_env *env, struct obd_export **exp,
+ struct obd_device *obd, struct obd_uuid *cluuid,
+ struct obd_connect_data *data, void *localdata)
{
- struct lov_obd *lov = &obd->u.lov;
- struct lov_tgt_desc *tgt;
- struct lustre_handle conn;
- int i, rc;
- ENTRY;
+ struct lov_obd *lov = &obd->u.lov;
+ struct lov_tgt_desc *tgt;
+ struct lustre_handle conn;
+ int i, rc;
+ ENTRY;
- CDEBUG(D_CONFIG, "connect #%d\n", lov->lov_connects);
+ CDEBUG(D_CONFIG, "connect #%d\n", lov->lov_connects);
- rc = class_connect(&conn, obd, cluuid);
- if (rc)
- RETURN(rc);
+ rc = class_connect(&conn, obd, cluuid);
+ if (rc)
+ RETURN(rc);
- *exp = class_conn2export(&conn);
+ *exp = class_conn2export(&conn);
- /* Why should there ever be more than 1 connect? */
- lov->lov_connects++;
- LASSERT(lov->lov_connects == 1);
+ /* Why should there ever be more than 1 connect? */
+ lov->lov_connects++;
+ LASSERT(lov->lov_connects == 1);
- memset(&lov->lov_ocd, 0, sizeof(lov->lov_ocd));
- if (data)
- lov->lov_ocd = *data;
+ memset(&lov->lov_ocd, 0, sizeof(lov->lov_ocd));
+ if (data)
+ lov->lov_ocd = *data;
lov_tgts_getref(obd);
continue;
/* Flags will be lowest common denominator */
rc = lov_connect_osc(obd, i, tgt->ltd_activate, &lov->lov_ocd);
- if (rc) {
- CERROR("%s: lov connect tgt %d failed: %d\n",
- obd->obd_name, i, rc);
- continue;
- }
- /* connect to administrative disabled ost */
- if (!lov->lov_tgts[i]->ltd_exp)
- continue;
+ if (rc) {
+ CERROR("%s: lov connect tgt %d failed: rc = %d\n",
+ obd->obd_name, i, rc);
+ continue;
+ }
+ /* connect to administrative disabled ost */
+ if (!lov->lov_tgts[i]->ltd_exp)
+ continue;
rc = lov_notify(obd, lov->lov_tgts[i]->ltd_exp->exp_obd,
OBD_NOTIFY_CONNECT);
- if (rc) {
- CERROR("%s error sending notify %d\n",
- obd->obd_name, rc);
- }
- }
+ if (rc) {
+ CERROR("%s error sending notify: rc = %d\n",
+ obd->obd_name, rc);
+ }
+ }
lov_tgts_putref(obd);
rc = obd_disconnect(tgt->ltd_exp);
if (rc) {
- CERROR("Target %s disconnect error %d\n",
- tgt->ltd_uuid.uuid, rc);
+ CERROR("%s: Target %s disconnect error %d\n",
+ obd->obd_name, tgt->ltd_uuid.uuid, rc);
rc = 0;
}
lov->lov_tgts, lov->lov_tgt_size);
}
- OBD_ALLOC_PTR(tgt);
- if (!tgt) {
+ OBD_ALLOC_PTR(tgt);
+ if (!tgt) {
mutex_unlock(&lov->lov_lock);
- RETURN(-ENOMEM);
- }
+ RETURN(-ENOMEM);
+ }
rc = lu_tgt_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
- if (rc) {
+ if (rc) {
mutex_unlock(&lov->lov_lock);
- OBD_FREE_PTR(tgt);
- RETURN(rc);
- }
-
- tgt->ltd_uuid = *uuidp;
- tgt->ltd_obd = tgt_obd;
- /* XXX - add a sanity check on the generation number. */
- tgt->ltd_gen = gen;
- tgt->ltd_index = index;
- tgt->ltd_activate = active;
- lov->lov_tgts[index] = tgt;
- if (index >= lov->desc.ld_tgt_count)
- lov->desc.ld_tgt_count = index + 1;
+ OBD_FREE_PTR(tgt);
+ RETURN(rc);
+ }
+
+ tgt->ltd_uuid = *uuidp;
+ tgt->ltd_obd = tgt_obd;
+ /* XXX - add a sanity check on the generation number. */
+ tgt->ltd_gen = gen;
+ tgt->ltd_index = index;
+ tgt->ltd_activate = active;
+ lov->lov_tgts[index] = tgt;
+ if (index >= lov->desc.ld_tgt_count)
+ lov->desc.ld_tgt_count = index + 1;
mutex_unlock(&lov->lov_lock);
- CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n",
- index, tgt->ltd_gen, lov->desc.ld_tgt_count);
+ CDEBUG(D_CONFIG, "idx=%d ltd_gen=%d ld_tgt_count=%d\n",
+ index, tgt->ltd_gen, lov->desc.ld_tgt_count);
if (lov->lov_connects == 0) {
/* lov_connect hasn't been called yet. We'll do the
- lov_connect_osc on this target when that fn first runs,
- because we don't know the connect flags yet. */
+ * lov_connect_osc on this target when that fn first runs,
+ * because we don't know the connect flags yet. */
RETURN(0);
}
lov_tgts_getref(obd);
rc = lov_connect_osc(obd, index, active, &lov->lov_ocd);
- if (rc)
- GOTO(out, rc);
+ if (rc)
+ GOTO(out, rc);
- /* connect to administrative disabled ost */
- if (!tgt->ltd_exp)
- GOTO(out, rc = 0);
+ /* connect to administrative disabled ost */
+ if (!tgt->ltd_exp)
+ GOTO(out, rc = 0);
rc = lov_notify(obd, tgt->ltd_exp->exp_obd,
active ? OBD_NOTIFY_CONNECT : OBD_NOTIFY_INACTIVE);
}
/* Schedule a target for deletion */
-int lov_del_target(struct obd_device *obd, u32 index,
- struct obd_uuid *uuidp, int gen)
+int lov_del_target(struct obd_device *obd, u32 index, struct obd_uuid *uuidp,
+ int gen)
{
- struct lov_obd *lov = &obd->u.lov;
- int count = lov->desc.ld_tgt_count;
- int rc = 0;
- ENTRY;
+ struct lov_obd *lov = &obd->u.lov;
+ int count = lov->desc.ld_tgt_count;
+ int rc = 0;
+ ENTRY;
- if (index >= count) {
- CERROR("LOV target index %d >= number of LOV OBDs %d.\n",
- index, count);
- RETURN(-EINVAL);
- }
+ if (index >= count) {
+ CERROR("%s: LOV target index %d >= number of LOV OBDs %d: rc = %d\n",
+ obd->obd_name, index, count, -EINVAL);
+ RETURN(-EINVAL);
+ }
/* to make sure there's no ongoing lov_notify() now */
down_write(&lov->lov_notify_lock);
lov_tgts_getref(obd);
- if (!lov->lov_tgts[index]) {
- CERROR("LOV target at index %d is not setup.\n", index);
- GOTO(out, rc = -EINVAL);
- }
-
- if (uuidp && !obd_uuid_equals(uuidp, &lov->lov_tgts[index]->ltd_uuid)) {
- CERROR("LOV target UUID %s at index %d doesn't match %s.\n",
- lov_uuid2str(lov, index), index,
- obd_uuid2str(uuidp));
- GOTO(out, rc = -EINVAL);
- }
-
- CDEBUG(D_CONFIG, "uuid: %s idx: %d gen: %d exp: %p active: %d\n",
- lov_uuid2str(lov, index), index,
- lov->lov_tgts[index]->ltd_gen, lov->lov_tgts[index]->ltd_exp,
- lov->lov_tgts[index]->ltd_active);
-
- lov->lov_tgts[index]->ltd_reap = 1;
- lov->lov_death_row++;
+ if (!lov->lov_tgts[index]) {
+ CERROR("%s: LOV target at index %d is not setup: rc = %d\n",
+ obd->obd_name, index, -EINVAL);
+ GOTO(out, rc = -EINVAL);
+ }
+
+ if (uuidp && !obd_uuid_equals(uuidp, &lov->lov_tgts[index]->ltd_uuid)) {
+ CERROR("%s: LOV target UUID %s at index %d doesn't match %s: rc = %d\n",
+ obd->obd_name, lov_uuid2str(lov, index), index,
+ obd_uuid2str(uuidp), -EINVAL);
+
+ GOTO(out, rc = -EINVAL);
+ }
+
+ CDEBUG(D_CONFIG, "uuid: %s idx: %d gen: %d exp: %p active: %d\n",
+ lov_uuid2str(lov, index), index,
+ lov->lov_tgts[index]->ltd_gen, lov->lov_tgts[index]->ltd_exp,
+ lov->lov_tgts[index]->ltd_active);
+
+ lov->lov_tgts[index]->ltd_reap = 1;
+ lov->lov_death_row++;
/* we really delete it from lov_tgts_putref() */
out:
lov_tgts_putref(obd);
static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
{
- struct obd_device *osc_obd;
+ struct obd_device *osc_obd;
- LASSERT(tgt);
- LASSERT(tgt->ltd_reap);
+ LASSERT(tgt);
+ LASSERT(tgt->ltd_reap);
- osc_obd = class_exp2obd(tgt->ltd_exp);
+ osc_obd = class_exp2obd(tgt->ltd_exp);
- CDEBUG(D_CONFIG, "Removing tgt %s : %s\n",
- tgt->ltd_uuid.uuid,
- osc_obd ? osc_obd->obd_name : "<no obd>");
+ CDEBUG(D_CONFIG, "Removing tgt %s : %s\n", tgt->ltd_uuid.uuid,
+ osc_obd ? osc_obd->obd_name : "<no obd>");
- if (tgt->ltd_exp)
- lov_disconnect_obd(obd, tgt);
+ if (tgt->ltd_exp)
+ lov_disconnect_obd(obd, tgt);
- OBD_FREE_PTR(tgt);
+ OBD_FREE_PTR(tgt);
- /* Manual cleanup - no cleanup logs to clean up the osc's. We must
- do it ourselves. And we can't do it from lov_cleanup,
- because we just lost our only reference to it. */
- if (osc_obd)
- class_manual_cleanup(osc_obd);
+ /* Manual cleanup - no cleanup logs to clean up the osc's. We must
+ * do it ourselves. And we can't do it from lov_cleanup,
+ * because we just lost our only reference to it. */
+ if (osc_obd)
+ class_manual_cleanup(osc_obd);
}
void lov_fix_desc_stripe_size(__u64 *val)
void lov_fix_desc_stripe_count(__u32 *val)
{
- if (*val == 0)
- *val = 1;
+ if (*val == 0)
+ *val = 1;
}
void lov_fix_desc_pattern(__u32 *val)
{
- /* from lov_setstripe */
+ /* from lov_setstripe */
if ((*val != 0) && !lov_pattern_supported_normal_comp(*val)) {
LCONSOLE_WARN("lov: Unknown stripe pattern: %#x\n", *val);
*val = 0;
int rc;
ENTRY;
- if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
- CERROR("LOV setup requires a descriptor\n");
- RETURN(-EINVAL);
- }
-
- desc = (struct lov_desc *)lustre_cfg_buf(lcfg, 1);
-
- if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
- CERROR("descriptor size wrong: %d > %d\n",
- (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1));
- RETURN(-EINVAL);
- }
-
- if (desc->ld_magic != LOV_DESC_MAGIC) {
- if (desc->ld_magic == __swab32(LOV_DESC_MAGIC)) {
- CDEBUG(D_OTHER, "%s: Swabbing lov desc %p\n",
- obd->obd_name, desc);
- lustre_swab_lov_desc(desc);
- } else {
- CERROR("%s: Bad lov desc magic: %#x\n",
- obd->obd_name, desc->ld_magic);
- RETURN(-EINVAL);
- }
- }
-
- lov_fix_desc(desc);
+ if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
+ CERROR("%s: LOV setup requires a descriptor: rc = %d\n",
+ obd->obd_name, -EINVAL);
+ RETURN(-EINVAL);
+ }
+
+ desc = (struct lov_desc *)lustre_cfg_buf(lcfg, 1);
+
+ if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
+ CERROR("%s: descriptor size wrong: %d > %d: rc = %d\n",
+ obd->obd_name, (int)sizeof(*desc),
+ LUSTRE_CFG_BUFLEN(lcfg, 1), -EINVAL);
+ RETURN(-EINVAL);
+ }
+
+ if (desc->ld_magic != LOV_DESC_MAGIC) {
+ if (desc->ld_magic == __swab32(LOV_DESC_MAGIC)) {
+ CDEBUG(D_OTHER, "%s: Swabbing lov desc %p\n",
+ obd->obd_name, desc);
+ lustre_swab_lov_desc(desc);
+ } else {
+ CERROR("%s: Bad lov desc magic: %#x: rc = %d\n",
+ obd->obd_name, desc->ld_magic, -EINVAL);
+ RETURN(-EINVAL);
+ }
+ }
+
+ lov_fix_desc(desc);
desc->ld_active_tgt_count = 0;
lov->desc = *desc;
GOTO(out, rc);
rc = lu_tgt_pool_init(&lov->lov_packed, 0);
- if (rc)
+ if (rc)
GOTO(out, rc);
rc = lov_tunables_init(obd);
lov->lov_tgts_kobj = kobject_create_and_add("target_obds",
&obd->obd_kset.kobj);
-
out:
return rc;
}
static int lov_cleanup(struct obd_device *obd)
{
- struct lov_obd *lov = &obd->u.lov;
- struct pool_desc *pool, *tmp;
- ENTRY;
+ struct lov_obd *lov = &obd->u.lov;
+ struct lov_pool_desc *pool, *tmp;
+ ENTRY;
if (lov->lov_tgts_kobj) {
kobject_put(lov->lov_tgts_kobj);
}
list_for_each_entry_safe(pool, tmp, &lov->lov_pool_list, pool_list) {
- /* free pool structs */
- CDEBUG(D_INFO, "delete pool %p\n", pool);
+ /* free pool structs */
+ CDEBUG(D_INFO, "delete pool %p\n", pool);
/* In the function below, .hs_keycmp resolves to
* pool_hashkey_keycmp() */
- lov_pool_del(obd, pool->pool_name);
- }
+ lov_pool_del(obd, pool->pool_name);
+ }
lov_pool_hash_destroy(&lov->lov_pools_hash_body);
lu_tgt_pool_free(&lov->lov_packed);
lprocfs_obd_cleanup(obd);
- if (lov->lov_tgts) {
- int i;
+ if (lov->lov_tgts) {
+ int i;
+
lov_tgts_getref(obd);
- for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+ for (i = 0; i < lov->desc.ld_tgt_count; i++) {
if (!lov->lov_tgts[i])
continue;
lov->lov_cache = NULL;
}
- RETURN(0);
+ RETURN(0);
}
int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
count = class_modify_config(lcfg, PARAM_LOV,
&obd->obd_kset.kobj);
GOTO(out, rc = count < 0 ? count : 0);
- }
- case LCFG_POOL_NEW:
- case LCFG_POOL_ADD:
- case LCFG_POOL_DEL:
- case LCFG_POOL_REM:
- GOTO(out, rc);
-
- default: {
- CERROR("Unknown command: %d\n", lcfg->lcfg_command);
- GOTO(out, rc = -EINVAL);
-
- }
- }
+ }
+ case LCFG_POOL_NEW:
+ case LCFG_POOL_ADD:
+ case LCFG_POOL_DEL:
+ case LCFG_POOL_REM:
+ GOTO(out, rc);
+
+ default: {
+ CERROR("%s: Unknown command: %d: rc = %d\n",
+ obd->obd_name, lcfg->lcfg_command, -EINVAL);
+ GOTO(out, rc = -EINVAL);
+ }
+ } /* end switch */
out:
- RETURN(rc);
+ RETURN(rc);
}
static int lov_statfs(const struct lu_env *env, struct obd_export *exp,
{
struct lov_obd *lov = &obd->u.lov;
struct lov_tgt_desc *tgt;
- struct pool_desc *pool = NULL;
+ struct lov_pool_desc *pool = NULL;
__u64 curspace = 0;
__u64 bhardlimit = 0;
int i, rc = 0;
oqctl->qc_cmd = Q_GETOQUOTA;
}
- /* for lov tgt */
+ /* for lov tgt */
lov_tgts_getref(obd);
- for (i = 0; i < lov->desc.ld_tgt_count; i++) {
- int err;
+ for (i = 0; i < lov->desc.ld_tgt_count; i++) {
+ int err;
- tgt = lov->lov_tgts[i];
+ tgt = lov->lov_tgts[i];
- if (!tgt)
- continue;
+ if (!tgt)
+ continue;
if (pool &&
lu_tgt_check_index(tgt->ltd_index, &pool->pool_obds))
continue;
}
- err = obd_quotactl(tgt->ltd_exp, oqctl);
- if (err) {
- if (tgt->ltd_active && !rc)
- rc = err;
- continue;
- }
-
- if (oqctl->qc_cmd == Q_GETOQUOTA) {
- curspace += oqctl->qc_dqblk.dqb_curspace;
- bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit;
- }
- }
+ err = obd_quotactl(tgt->ltd_exp, oqctl);
+ if (err) {
+ if (tgt->ltd_active && !rc)
+ rc = err;
+ continue;
+ }
+
+ if (oqctl->qc_cmd == Q_GETOQUOTA) {
+ curspace += oqctl->qc_dqblk.dqb_curspace;
+ bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit;
+ }
+ }
lov_tgts_putref(obd);
if (pool)
lov_pool_putref(pool);
- if (oqctl->qc_cmd == Q_GETOQUOTA) {
- oqctl->qc_dqblk.dqb_curspace = curspace;
- oqctl->qc_dqblk.dqb_bhardlimit = bhardlimit;
- }
- RETURN(rc);
+ if (oqctl->qc_cmd == Q_GETOQUOTA) {
+ oqctl->qc_dqblk.dqb_curspace = curspace;
+ oqctl->qc_dqblk.dqb_bhardlimit = bhardlimit;
+ }
+ RETURN(rc);
}
static const struct obd_ops lov_obd_ops = {
int rc;
ENTRY;
- /* print an address of _any_ initialized kernel symbol from this
- * module, to allow debugging with gdb that doesn't support data
- * symbols from modules.*/
- CDEBUG(D_INFO, "Lustre LOV module (%p).\n", &lov_caches);
+ /* print an address of _any_ initialized kernel symbol from this
+ * module, to allow debugging with gdb that doesn't support data
+ * symbols from modules.*/
+ CDEBUG(D_INFO, "Lustre LOV module (%p).\n", &lov_caches);
- rc = lu_kmem_init(lov_caches);
- if (rc)
- return rc;
+ rc = lu_kmem_init(lov_caches);
+ if (rc)
+ return rc;
lov_oinfo_slab = kmem_cache_create("lov_oinfo",
sizeof(struct lov_oinfo), 0,
SLAB_HWCACHE_ALIGN, NULL);
- if (lov_oinfo_slab == NULL) {
- lu_kmem_fini(lov_caches);
- return -ENOMEM;
- }
+ if (lov_oinfo_slab == NULL) {
+ lu_kmem_fini(lov_caches);
+ return -ENOMEM;
+ }
rc = class_register_type(&lov_obd_ops, NULL, true,
LUSTRE_LOV_NAME, &lov_device_type);
- if (rc) {
+ if (rc) {
kmem_cache_destroy(lov_oinfo_slab);
- lu_kmem_fini(lov_caches);
- }
+ lu_kmem_fini(lov_caches);
+ }
- RETURN(rc);
+ RETURN(rc);
}
static void __exit lov_exit(void)
* @{
*/
-/*****************************************************************************
- *
+/**
* Layout operations.
- *
*/
-
struct lov_layout_operations {
int (*llo_init)(const struct lu_env *env, struct lov_device *dev,
struct lov_object *lov, struct lov_stripe_md *lsm,
const struct cl_object_conf *conf,
union lov_layout_state *state);
int (*llo_delete)(const struct lu_env *env, struct lov_object *lov,
- union lov_layout_state *state);
- void (*llo_fini)(const struct lu_env *env, struct lov_object *lov,
- union lov_layout_state *state);
- int (*llo_print)(const struct lu_env *env, void *cookie,
- lu_printer_t p, const struct lu_object *o);
- int (*llo_page_init)(const struct lu_env *env, struct cl_object *obj,
+ union lov_layout_state *state);
+ void (*llo_fini)(const struct lu_env *env, struct lov_object *lov,
+ union lov_layout_state *state);
+ int (*llo_print)(const struct lu_env *env, void *cookie,
+ lu_printer_t p, const struct lu_object *o);
+ int (*llo_page_init)(const struct lu_env *env, struct cl_object *obj,
struct cl_page *page, pgoff_t index);
- int (*llo_lock_init)(const struct lu_env *env,
- struct cl_object *obj, struct cl_lock *lock,
- const struct cl_io *io);
- int (*llo_io_init)(const struct lu_env *env,
- struct cl_object *obj, struct cl_io *io);
- int (*llo_getattr)(const struct lu_env *env, struct cl_object *obj,
- struct cl_attr *attr);
+ int (*llo_lock_init)(const struct lu_env *env,
+ struct cl_object *obj, struct cl_lock *lock,
+ const struct cl_io *io);
+ int (*llo_io_init)(const struct lu_env *env,
+ struct cl_object *obj, struct cl_io *io);
+ int (*llo_getattr)(const struct lu_env *env, struct cl_object *obj,
+ struct cl_attr *attr);
int (*llo_flush)(const struct lu_env *env, struct cl_object *obj,
struct ldlm_lock *lock);
};
lov_free_memmd(&lsm);
}
-/*****************************************************************************
- *
+/**
* Lov object layout operations.
- *
*/
-
static struct cl_object *lov_sub_find(const struct lu_env *env,
struct cl_device *dev,
const struct lu_fid *fid,
struct lu_site *site;
wait_queue_head_t *wq;
- LASSERT(r0->lo_sub[idx] == los);
+ LASSERT(r0->lo_sub[idx] == los);
sub = lovsub2cl(los);
site = sub->co_lu.lo_dev->ld_site;
wq = lu_site_wq_from_fid(site, &sub->co_lu.lo_header->loh_fid);
- cl_object_kill(env, sub);
- /* release a reference to the sub-object and ... */
- lu_object_ref_del(&sub->co_lu, "lov-parent", lov);
- cl_object_put(env, sub);
+ cl_object_kill(env, sub);
+ /* release a reference to the sub-object and ... */
+ lu_object_ref_del(&sub->co_lu, "lov-parent", lov);
+ cl_object_put(env, sub);
/* ... wait until it is actually destroyed---sub-object clears its
* ->lo_sub[] slot in lovsub_object_free() */
ENTRY;
- if (r0->lo_sub != NULL) {
+ if (r0->lo_sub != NULL) {
int i;
for (i = 0; i < r0->lo_nr; ++i) {
}
static int lov_print_empty(const struct lu_env *env, void *cookie,
- lu_printer_t p, const struct lu_object *o)
+ lu_printer_t p, const struct lu_object *o)
{
- (*p)(env, cookie, "empty %d\n",
+ (*p)(env, cookie, "empty %d\n",
test_bit(LO_LAYOUT_INVALID, &lu2lov(o)->lo_obj_flags));
- return 0;
+ return 0;
}
static int lov_print_composite(const struct lu_env *env, void *cookie,
}
static int lov_print_released(const struct lu_env *env, void *cookie,
- lu_printer_t p, const struct lu_object *o)
+ lu_printer_t p, const struct lu_object *o)
{
struct lov_object *lov = lu2lov(o);
struct lov_stripe_md *lsm = lov->lo_lsm;
* cl_attr::cat_blocks---it's 0.
*/
static int lov_attr_get_empty(const struct lu_env *env, struct cl_object *obj,
- struct cl_attr *attr)
+ struct cl_attr *attr)
{
- attr->cat_blocks = 0;
- return 0;
+ attr->cat_blocks = 0;
+ return 0;
}
static int lov_attr_get_composite(const struct lu_env *env,
#define LOV_2DISPATCH_MAYLOCK(obj, op, lock, ...) \
({ \
- struct lov_object *__obj = (obj); \
- int __lock = !!(lock); \
- typeof(lov_dispatch[0].op(__VA_ARGS__)) __result; \
+ struct lov_object *__obj = (obj); \
+ int __lock = !!(lock); \
+ typeof(lov_dispatch[0].op(__VA_ARGS__)) __result; \
\
- if (__lock) \
- lov_conf_freeze(__obj); \
- __result = LOV_2DISPATCH_NOLOCK(obj, op, __VA_ARGS__); \
- if (__lock) \
- lov_conf_thaw(__obj); \
- __result; \
+ if (__lock) \
+ lov_conf_freeze(__obj); \
+ __result = LOV_2DISPATCH_NOLOCK(obj, op, __VA_ARGS__); \
+ if (__lock) \
+ lov_conf_thaw(__obj); \
+ __result; \
})
/**
#define LOV_2DISPATCH_VOID(obj, op, ...) \
do { \
- struct lov_object *__obj = (obj); \
- enum lov_layout_type __llt; \
+ struct lov_object *__obj = (obj); \
+ enum lov_layout_type __llt; \
\
lov_conf_freeze(__obj); \
- __llt = __obj->lo_type; \
+ __llt = __obj->lo_type; \
LASSERT(__llt < ARRAY_SIZE(lov_dispatch)); \
- lov_dispatch[__llt].op(__VA_ARGS__); \
+ lov_dispatch[__llt].op(__VA_ARGS__); \
lov_conf_thaw(__obj); \
} while (0)
RETURN(rc);
}
-/*****************************************************************************
- *
+/**
* Lov object operations.
- *
*/
static int lov_object_init(const struct lu_env *env, struct lu_object *obj,
const struct lu_object_conf *conf)
}
static int lov_conf_set(const struct lu_env *env, struct cl_object *obj,
- const struct cl_object_conf *conf)
+ const struct cl_object_conf *conf)
{
struct lov_stripe_md *lsm = NULL;
struct lov_object *lov = cl2lov(obj);
static void lov_object_delete(const struct lu_env *env, struct lu_object *obj)
{
- struct lov_object *lov = lu2lov(obj);
+ struct lov_object *lov = lu2lov(obj);
- ENTRY;
- LOV_2DISPATCH_VOID(lov, llo_delete, env, lov, &lov->u);
- EXIT;
+ ENTRY;
+ LOV_2DISPATCH_VOID(lov, llo_delete, env, lov, &lov->u);
+ EXIT;
}
static void lov_object_free(const struct lu_env *env, struct lu_object *obj)
{
- struct lov_object *lov = lu2lov(obj);
+ struct lov_object *lov = lu2lov(obj);
- ENTRY;
- LOV_2DISPATCH_VOID(lov, llo_fini, env, lov, &lov->u);
- lu_object_fini(obj);
- OBD_SLAB_FREE_PTR(lov, lov_object_kmem);
- EXIT;
+ ENTRY;
+ LOV_2DISPATCH_VOID(lov, llo_fini, env, lov, &lov->u);
+ lu_object_fini(obj);
+ OBD_SLAB_FREE_PTR(lov, lov_object_kmem);
+ EXIT;
}
static int lov_object_print(const struct lu_env *env, void *cookie,
- lu_printer_t p, const struct lu_object *o)
+ lu_printer_t p, const struct lu_object *o)
{
- return LOV_2DISPATCH_NOLOCK(lu2lov(o), llo_print, env, cookie, p, o);
+ return LOV_2DISPATCH_NOLOCK(lu2lov(o), llo_print, env, cookie, p, o);
}
static int lov_page_init(const struct lu_env *env, struct cl_object *obj,
* sub-objects.
*/
static int lov_attr_get(const struct lu_env *env, struct cl_object *obj,
- struct cl_attr *attr)
+ struct cl_attr *attr)
{
- /* do not take lock, as this function is called under a
- * spin-lock. Layout is protected from changing by ongoing IO. */
- return LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_getattr, env, obj, attr);
+ /* do not take lock, as this function is called under a
+ * spin-lock. Layout is protected from changing by ongoing IO. */
+ return LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_getattr, env, obj, attr);
}
static int lov_attr_update(const struct lu_env *env, struct cl_object *obj,
}
static int lov_lock_init(const struct lu_env *env, struct cl_object *obj,
- struct cl_lock *lock, const struct cl_io *io)
+ struct cl_lock *lock, const struct cl_io *io)
{
/* No need to lock because we've taken one refcount of layout. */
return LOV_2DISPATCH_NOLOCK(cl2lov(obj), llo_lock_init, env, obj, lock,
* @{
*/
-/*****************************************************************************
- *
+/**
* Lov page operations.
- *
*/
int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
struct cl_page *page, pgoff_t index)
#define pool_tgt(_p, _i) \
_p->pool_lobd->u.lov.lov_tgts[_p->pool_obds.op_array[_i]]
+/**
+ * Hash the pool name for use by the hashtable handlers.
+ *
+ * \param[in] data poolname (null-terminated string to be hashed or key)
+ * \param[in] len length of key
+ * \param[in] seed Random seed or previous hash
+ *
+ * \retval computed hash value of the key(poolname)
+ */
static u32 pool_hashfh(const void *data, u32 len, u32 seed)
{
const char *pool_name = data;
pool_name));
}
+/**
+ * Compare the pool name with key
+ *
+ * \param[in] arg key (poolname) to compare against
+ * \param[in] obj Entry that is being compared
+ *
+ * \retval 0 if matched
+ * \retval 1 if not matched
+ */
static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
{
- const struct pool_desc *pool = obj;
+ const struct lov_pool_desc *pool = obj;
const char *pool_name = arg->key;
return strcmp(pool_name, pool->pool_name);
static const struct rhashtable_params pools_hash_params = {
.key_len = 1, /* actually variable */
- .key_offset = offsetof(struct pool_desc, pool_name),
- .head_offset = offsetof(struct pool_desc, pool_hash),
+ .key_offset = offsetof(struct lov_pool_desc, pool_name),
+ .head_offset = offsetof(struct lov_pool_desc, pool_hash),
.hashfn = pool_hashfh,
.obj_cmpfn = pool_cmpfn,
.automatic_shrinking = true,
};
-static void lov_pool_getref(struct pool_desc *pool)
+/**
+ * Get a reference on the specified lov pool.
+ *
+ * To ensure the pool descriptor is not freed before the caller is finished
+ * with it. Any process that is accessing \a pool directly needs to hold
+ * reference on it, including /proc since a userspace thread may be holding
+ * the /proc file open and busy in the kernel.
+ *
+ * \param[in] pool pool descriptor on which to gain reference
+ */
+static void lov_pool_getref(struct lov_pool_desc *pool)
{
CDEBUG(D_INFO, "pool %p\n", pool);
atomic_inc(&pool->pool_refcount);
}
-void lov_pool_putref(struct pool_desc *pool)
+/**
+ * Drop a reference on the specified lov pool and free its memory if needed
+ *
+ * One reference is held by the LOD OBD device while it is configured, from
+ * the time the configuration log defines the pool until the time when it is
+ * dropped when the LOD OBD is cleaned up or the pool is deleted. This means
+ * that the pool will not be freed while the LOD device is configured, unless
+ * it is explicitly destroyed by the sysadmin. The pool structure is freed
+ * after the last reference on the structure is released.
+ *
+ * \param[in] pool pool descriptor to drop reference on and possibly free
+ */
+void lov_pool_putref(struct lov_pool_desc *pool)
{
CDEBUG(D_INFO, "pool %p\n", pool);
if (atomic_dec_and_test(&pool->pool_refcount)) {
*/
#define POOL_IT_MAGIC 0xB001CEA0
struct pool_iterator {
- int magic;
- struct pool_desc *pool;
- int idx; /* from 0 to pool_tgt_size - 1 */
+ int magic; /* POOL_IT_MAGIC */
+ int idx; /* from 0 to pool_tgt_size - 1 */
+ struct lov_pool_desc *pool;
};
+/**
+ * Return the next configured target within one pool for seq_file iteration
+ *
+ * Iterator is used to go through the target entries of a single pool
+ * (i.e. the list of OSTs configured for a named pool).
+ * lpi_idx is the current target index in the pool's op_array[].
+ *
+ * The return type is a void * because this function is one of the
+ * struct seq_operations methods and must match the function template.
+ *
+ * \param[in] seq /proc sequence file iteration tracking structure
+ * \param[in] v unused
+ * \param[in] pos position within iteration; 0 to number of targets - 1
+ *
+ * \retval struct pool_iterator of the next pool descriptor
+ */
static void *pool_proc_next(struct seq_file *s, void *v, loff_t *pos)
{
struct pool_iterator *iter = (struct pool_iterator *)s->private;
return iter;
}
+/**
+ * Start seq_file iteration via /proc for a single pool
+ *
+ * The \a pos parameter may be non-zero, indicating that the iteration
+ * is starting at some offset in the target list. Use the seq_file
+ * private field to memorize the iterator so we can free it at stop().
+ * Need to restore the private pointer to the pool before freeing it.
+ *
+ * \param[in] seq new sequence file structure to initialize
+ * \param[in] pos initial target number at which to start iteration
+ *
+ * \retval initialized pool iterator private structure
+ * \retval NULL if \a pos exceeds the number of targets in \a pool
+ * \retval negative error number on failure
+ */
static void *pool_proc_start(struct seq_file *s, loff_t *pos)
{
- struct pool_desc *pool = (struct pool_desc *)s->private;
- struct pool_iterator *iter;
-
- lov_pool_getref(pool);
- if ((pool_tgt_count(pool) == 0) ||
- (*pos >= pool_tgt_count(pool))) {
- /* iter is not created, so stop() has no way to
- * find pool to dec ref */
- lov_pool_putref(pool);
- return NULL;
- }
-
- OBD_ALLOC_PTR(iter);
- if (!iter)
- return ERR_PTR(-ENOMEM);
- iter->magic = POOL_IT_MAGIC;
- iter->pool = pool;
- iter->idx = 0;
-
- /* we use seq_file private field to memorized iterator so
- * we can free it at stop() */
- /* /!\ do not forget to restore it to pool before freeing it */
- s->private = iter;
+ struct lov_pool_desc *pool = (struct lov_pool_desc *)s->private;
+ struct pool_iterator *iter;
+
+ lov_pool_getref(pool);
+ if ((pool_tgt_count(pool) == 0) || (*pos >= pool_tgt_count(pool))) {
+ /* iter is not created, so stop() has no way to
+ * find pool to dec ref */
+ lov_pool_putref(pool);
+ return NULL;
+ }
+
+ OBD_ALLOC_PTR(iter);
+ if (!iter)
+ return ERR_PTR(-ENOMEM);
+ iter->magic = POOL_IT_MAGIC;
+ iter->pool = pool;
+ iter->idx = 0;
+
+ /* we use seq_file private field to memorized iterator so
+ * we can free it at stop() */
+ /* /!\ do not forget to restore it to pool before freeing it */
+ s->private = iter;
down_read(&pool_tgt_rw_sem(pool));
- if (*pos > 0) {
- loff_t i;
- void *ptr;
-
- i = 0;
- do {
- ptr = pool_proc_next(s, &iter, &i);
- } while ((i < *pos) && (ptr != NULL));
- return ptr;
- }
- return iter;
+ if (*pos > 0) {
+ loff_t i;
+ void *ptr;
+
+ i = 0;
+ do {
+ ptr = pool_proc_next(s, &iter, &i);
+ } while ((i < *pos) && (ptr != NULL));
+ return ptr;
+ }
+ return iter;
}
+/**
+ * Finish seq_file iteration for a single pool
+ *
+ * Once iteration has been completed, the pool_iterator struct must be
+ * freed, and the seq_file private pointer restored to the pool, as it
+ * was initially when pool_proc_start() was called.
+ *
+ * In some cases the stop() method may be called 2 times, without calling
+ * the start() method (see seq_read() from fs/seq_file.c). We have to free
+ * the private iterator struct only if seq->private points to the iterator.
+ *
+ * \param[in] seq sequence file structure to clean up
+ * \param[in] v (unused)
+ */
static void pool_proc_stop(struct seq_file *s, void *v)
{
- struct pool_iterator *iter = (struct pool_iterator *)s->private;
+ struct pool_iterator *iter = (struct pool_iterator *)s->private;
- /* in some cases stop() method is called 2 times, without
- * calling start() method (see seq_read() from fs/seq_file.c)
- * we have to free only if s->private is an iterator */
- if ((iter) && (iter->magic == POOL_IT_MAGIC)) {
+ /* in some cases stop() method is called 2 times, without
+ * calling start() method (see seq_read() from fs/seq_file.c)
+ * we have to free only if s->private is an iterator */
+ if ((iter) && (iter->magic == POOL_IT_MAGIC)) {
up_read(&pool_tgt_rw_sem(iter->pool));
- /* we restore s->private so next call to pool_proc_start()
- * will work */
- s->private = iter->pool;
- lov_pool_putref(iter->pool);
- OBD_FREE_PTR(iter);
- }
+ /* we restore s->private so next call to pool_proc_start()
+ * will work */
+ s->private = iter->pool;
+ lov_pool_putref(iter->pool);
+ OBD_FREE_PTR(iter);
+ }
}
+/**
+ * Print out one target entry from the pool for seq_file iteration
+ *
+ * The currently referenced pool target is given by op_array[lpi_idx].
+ *
+ * \param[in] seq new sequence file structure to initialize
+ * \param[in] v (unused)
+ */
static int pool_proc_show(struct seq_file *s, void *v)
{
- struct pool_iterator *iter = (struct pool_iterator *)v;
- struct lov_tgt_desc *tgt;
+ struct pool_iterator *iter = (struct pool_iterator *)v;
+ struct lov_tgt_desc *tgt;
LASSERTF(iter->magic == POOL_IT_MAGIC, "%08X\n", iter->magic);
LASSERT(iter->pool != NULL);
LASSERT(iter->idx <= pool_tgt_count(iter->pool));
- tgt = pool_tgt(iter->pool, iter->idx);
- if (tgt)
- seq_printf(s, "%s\n", obd_uuid2str(&(tgt->ltd_uuid)));
+ tgt = pool_tgt(iter->pool, iter->idx);
+ if (tgt)
+ seq_printf(s, "%s\n", obd_uuid2str(&(tgt->ltd_uuid)));
- return 0;
+ return 0;
}
static const struct seq_operations pool_proc_ops = {
.show = pool_proc_show,
};
+/**
+ * Open a new /proc file for seq_file iteration of targets in one pool
+ *
+ * Initialize the seq_file private pointer to reference the pool.
+ *
+ * \param[in] inode inode to store iteration state for /proc
+ * \param[in] file file descriptor to store iteration methods
+ *
+ * \retval 0 for success
+ * \retval negative error number on failure
+ */
static int pool_proc_open(struct inode *inode, struct file *file)
{
- int rc;
+ int rc;
+
+ rc = seq_open(file, &pool_proc_ops);
+ if (!rc) {
+ struct seq_file *s = file->private_data;
- rc = seq_open(file, &pool_proc_ops);
- if (!rc) {
- struct seq_file *s = file->private_data;
s->private = pde_data(inode);
- }
- return rc;
+ }
+ return rc;
}
const static struct proc_ops pool_proc_operations = {
static void pools_hash_exit(void *vpool, void *data)
{
- struct pool_desc *pool = vpool;
+ struct lov_pool_desc *pool = vpool;
lov_pool_putref(pool);
}
rhashtable_free_and_destroy(tbl, pools_hash_exit, NULL);
}
+/**
+ * Allocate a new pool for the specified device
+ *
+ * Allocate a new pool_desc structure for the specified \a new_pool
+ * device to create a pool with the given \a poolname. The new pool
+ * structure is created with a single refrence, and is freed when the
+ * reference count drops to zero.
+ *
+ * \param[in] obd Lustre OBD device on which to add a pool iterator
+ * \param[in] poolname the name of the pool to be created
+ *
+ * \retval 0 in case of success
+ * \retval negative error code in case of error
+ */
int lov_pool_new(struct obd_device *obd, char *poolname)
{
- struct lov_obd *lov;
- struct pool_desc *new_pool;
- int rc;
- ENTRY;
+ struct lov_obd *lov;
+ struct lov_pool_desc *new_pool;
+ int rc;
+ ENTRY;
- lov = &(obd->u.lov);
+ lov = &(obd->u.lov);
- if (strlen(poolname) > LOV_MAXPOOLNAME)
- RETURN(-ENAMETOOLONG);
+ if (strlen(poolname) > LOV_MAXPOOLNAME)
+ RETURN(-ENAMETOOLONG);
/* OBD_ALLOC doesn't work with direct use of kfree_rcu */
new_pool = kmalloc(sizeof(*new_pool), GFP_KERNEL);
- if (new_pool == NULL)
- RETURN(-ENOMEM);
+ if (new_pool == NULL)
+ RETURN(-ENOMEM);
strlcpy(new_pool->pool_name, poolname, sizeof(new_pool->pool_name));
new_pool->pool_lobd = obd;
#ifdef CONFIG_PROC_FS
/* get ref for /proc file */
- lov_pool_getref(new_pool);
+ lov_pool_getref(new_pool);
new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
poolname, new_pool,
&pool_proc_operations);
GOTO(out_err, rc);
}
- CDEBUG(D_CONFIG, LOV_POOLNAMEF" is pool #%d\n",
- poolname, lov->lov_pool_count);
+ CDEBUG(D_CONFIG, LOV_POOLNAMEF" is pool #%d\n", poolname,
+ lov->lov_pool_count);
- RETURN(0);
+ RETURN(0);
out_err:
spin_lock(&obd->obd_dev_lock);
list_del_init(&new_pool->pool_list);
lov->lov_pool_count--;
spin_unlock(&obd->obd_dev_lock);
- lprocfs_remove(&new_pool->pool_proc_entry);
+ lprocfs_remove(&new_pool->pool_proc_entry);
lu_tgt_pool_free(&new_pool->pool_obds);
out_free_pool:
OBD_FREE_PTR(new_pool);
return rc;
}
-struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname)
+struct lov_pool_desc *lov_pool_find(struct obd_device *obd, char *poolname)
{
- struct pool_desc *pool;
+ struct lov_pool_desc *pool;
struct lov_obd *lov = &obd->u.lov;
rcu_read_lock();
return pool;
}
+/**
+ * Remove the named pool from the OBD device
+ *
+ * \param[in] obd OBD device on which pool was previously created
+ * \param[in] poolname name of pool to remove from \a obd
+ *
+ * \retval 0 on successfully removing the pool
+ * \retval negative error numbers for failures
+ */
int lov_pool_del(struct obd_device *obd, char *poolname)
{
- struct lov_obd *lov;
- struct pool_desc *pool;
- ENTRY;
+ struct lov_obd *lov;
+ struct lov_pool_desc *pool;
+ ENTRY;
- lov = &(obd->u.lov);
+ lov = &(obd->u.lov);
/* lookup and kill hash reference */
rcu_read_lock();
if (!pool)
RETURN(-ENOENT);
- if (pool->pool_proc_entry != NULL) {
- CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry);
- lprocfs_remove(&pool->pool_proc_entry);
- lov_pool_putref(pool);
- }
+ if (pool->pool_proc_entry != NULL) {
+ CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry);
+ lprocfs_remove(&pool->pool_proc_entry);
+ lov_pool_putref(pool);
+ }
spin_lock(&obd->obd_dev_lock);
list_del_init(&pool->pool_list);
RETURN(0);
}
-
+/**
+ * Add a single target device to the named pool
+ *
+ * Add the target specified by \a ostname to the specified \a poolname.
+ *
+ * \param[in] obd OBD device on which to add the pool
+ * \param[in] poolname name of the pool to which to add the target \a ostname
+ * \param[in] ostname name of the target device to be added
+ *
+ * \retval 0 if \a ostname was (previously) added to the named pool
+ * \retval negative error number on failure
+ */
int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
{
- struct obd_uuid ost_uuid;
- struct lov_obd *lov;
- struct pool_desc *pool;
- unsigned int lov_idx;
- int rc;
- ENTRY;
+ struct obd_uuid ost_uuid;
+ struct lov_obd *lov;
+ struct lov_pool_desc *pool;
+ unsigned int lov_idx;
+ int rc;
+ ENTRY;
- lov = &(obd->u.lov);
+ lov = &(obd->u.lov);
rcu_read_lock();
pool = rhashtable_lookup(&lov->lov_pools_hash_body, poolname,
if (!pool)
RETURN(-ENOENT);
- obd_str2uuid(&ost_uuid, ostname);
-
+ obd_str2uuid(&ost_uuid, ostname);
- /* search ost in lov array */
+ /* search ost in lov array */
lov_tgts_getref(obd);
- for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
- if (!lov->lov_tgts[lov_idx])
- continue;
- if (obd_uuid_equals(&ost_uuid,
- &(lov->lov_tgts[lov_idx]->ltd_uuid)))
- break;
- }
- /* test if ost found in lov */
- if (lov_idx == lov->desc.ld_tgt_count)
- GOTO(out, rc = -EINVAL);
+ for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
+ if (!lov->lov_tgts[lov_idx])
+ continue;
+ if (obd_uuid_equals(&ost_uuid,
+ &(lov->lov_tgts[lov_idx]->ltd_uuid)))
+ break;
+ }
+ /* test if ost found in lov */
+ if (lov_idx == lov->desc.ld_tgt_count)
+ GOTO(out, rc = -EINVAL);
rc = lu_tgt_pool_add(&pool->pool_obds, lov_idx, lov->lov_tgt_size);
- if (rc)
- GOTO(out, rc);
+ if (rc)
+ GOTO(out, rc);
- CDEBUG(D_CONFIG, "Added %s to "LOV_POOLNAMEF" as member %d\n",
- ostname, poolname, pool_tgt_count(pool));
+ CDEBUG(D_CONFIG, "Added %s to "LOV_POOLNAMEF" as member %d\n",
+ ostname, poolname, pool_tgt_count(pool));
- EXIT;
+ EXIT;
out:
lov_tgts_putref(obd);
lov_pool_putref(pool);
return rc;
}
+/**
+ * Remove the named target from the specified pool
+ *
+ * Remove one target named \a ostname from \a poolname. The \a ostname
+ * is searched for in the lod_device lod_ost_bitmap array, to ensure the
+ * specified name actually exists in the pool.
+ *
+ * \param[in] obd OBD device from which to remove \a poolname
+ * \param[in] poolname name of the pool to be changed
+ * \param[in] ostname name of the target to remove from \a poolname
+ *
+ * \retval 0 on successfully removing \a ostname from the pool
+ * \retval negative number on error (e.g. \a ostname not in pool)
+ */
int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname)
{
- struct obd_uuid ost_uuid;
- struct lov_obd *lov;
- struct pool_desc *pool;
- unsigned int lov_idx;
- int rc = 0;
- ENTRY;
+ struct obd_uuid ost_uuid;
+ struct lov_obd *lov;
+ struct lov_pool_desc *pool;
+ unsigned int lov_idx;
+ int rc = 0;
+ ENTRY;
- lov = &(obd->u.lov);
+ lov = &(obd->u.lov);
/* lookup and kill hash reference */
rcu_read_lock();
if (!pool)
RETURN(-ENOENT);
- obd_str2uuid(&ost_uuid, ostname);
+ obd_str2uuid(&ost_uuid, ostname);
lov_tgts_getref(obd);
- /* search ost in lov array, to get index */
- for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
- if (!lov->lov_tgts[lov_idx])
- continue;
-
- if (obd_uuid_equals(&ost_uuid,
- &(lov->lov_tgts[lov_idx]->ltd_uuid)))
- break;
- }
+ /* search ost in lov array, to get index */
+ for (lov_idx = 0; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {
+ if (!lov->lov_tgts[lov_idx])
+ continue;
+
+ if (obd_uuid_equals(&ost_uuid,
+ &(lov->lov_tgts[lov_idx]->ltd_uuid)))
+ break;
+ }
- /* test if ost found in lov */
- if (lov_idx == lov->desc.ld_tgt_count)
- GOTO(out, rc = -EINVAL);
+ /* test if ost found in lov */
+ if (lov_idx == lov->desc.ld_tgt_count)
+ GOTO(out, rc = -EINVAL);
lu_tgt_pool_remove(&pool->pool_obds, lov_idx);
- CDEBUG(D_CONFIG, "%s removed from "LOV_POOLNAMEF"\n", ostname,
- poolname);
+ CDEBUG(D_CONFIG, "%s removed from "LOV_POOLNAMEF"\n", ostname,
+ poolname);
- EXIT;
+ EXIT;
out:
lov_tgts_putref(obd);
lov_pool_putref(pool);
* @{
*/
-/*****************************************************************************
- *
+/**
* Lov-sub device and device type functions.
- *
*/
-
static int lovsub_device_init(const struct lu_env *env, struct lu_device *d,
const char *name, struct lu_device *next)
{
* @{
*/
-/*****************************************************************************
- *
+/**
* Lovsub object operations.
- *
*/
static int lovsub_object_init(const struct lu_env *env, struct lu_object *obj,
static int lov_tgt_seq_show(struct seq_file *p, void *v)
{
- struct lov_tgt_desc *tgt = v;
+ struct lov_tgt_desc *tgt = v;
seq_printf(p, "%d: %s %sACTIVE\n", tgt->ltd_index,
obd_uuid2str(&tgt->ltd_uuid),
}
static const struct seq_operations lov_tgt_sops = {
- .start = lov_tgt_seq_start,
- .stop = lov_tgt_seq_stop,
- .next = lov_tgt_seq_next,
- .show = lov_tgt_seq_show,
+ .start = lov_tgt_seq_start,
+ .stop = lov_tgt_seq_stop,
+ .next = lov_tgt_seq_next,
+ .show = lov_tgt_seq_show,
};
static int lov_target_seq_open(struct inode *inode, struct file *file)