Whamcloud - gitweb
LU-4974 lod: Change pool_desc to "[lod|lov]_pool_desc" 14/11114/8
authorArshad Hussain <arshad.hussain@aeoncomputing.com>
Thu, 26 Oct 2023 16:42:11 +0000 (22:12 +0530)
committerOleg Drokin <green@whamcloud.com>
Wed, 8 Nov 2023 22:01:00 +0000 (22:01 +0000)
This patch changes 'struct pool_desc' under lov and lod
to 'lov_pool_struct' and 'lod_pool_struct' respectively.
This is the first step to check if there is anything
common and can be unify. Although both layer uses
'struct pool_desc' to define the pool_desc struct
respectively. 'struct pool_desc' under lod has changed
and grown. Therefore to remove ambiguity, prefix lod/lov
is added to pool_desc struct for respective layer.

This patch also adds function description wherever
applicable

This patch also changes space/tabs reported by
checkpatch

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Change-Id: I3fee3f2e9c321145779d9177a8e4582d123f1e8d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/11114
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Timothy Day <timday@amazon.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
17 files changed:
lustre/lod/lod_internal.h
lustre/lod/lod_lov.c
lustre/lod/lod_pool.c
lustre/lod/lod_qos.c
lustre/lod/lproc_lod.c
lustre/lov/lov_dev.c
lustre/lov/lov_internal.h
lustre/lov/lov_io.c
lustre/lov/lov_lock.c
lustre/lov/lov_merge.c
lustre/lov/lov_obd.c
lustre/lov/lov_object.c
lustre/lov/lov_page.c
lustre/lov/lov_pool.c
lustre/lov/lovsub_dev.c
lustre/lov/lovsub_object.c
lustre/lov/lproc_lov.c

index 9c308d6..bd14482 100644 (file)
@@ -55,7 +55,7 @@ enum lod_uses_hint {
 #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;
@@ -699,10 +699,10 @@ int lod_fill_mirrors(struct lod_object *lo);
 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);
@@ -852,8 +852,8 @@ int lod_sub_prep_llog(const struct lu_env *env, struct lod_device *lod,
 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,
index 2b4d5ec..ca90629 100644 (file)
@@ -1721,7 +1721,7 @@ static int lod_verify_v1v3(struct lod_device *d, const struct lu_buf *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;
@@ -2562,7 +2562,7 @@ out_hash:
 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) {
index 3f05f3f..9553229 100644 (file)
@@ -75,7 +75,7 @@
  *
  * \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);
@@ -93,7 +93,7 @@ static void pool_getref(struct pool_desc *pool)
  *
  * \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)) {
@@ -116,7 +116,7 @@ static u32 pool_hashfh(const void *data, u32 len, u32 seed)
 
 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);
@@ -124,8 +124,8 @@ static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
 
 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,
@@ -139,7 +139,7 @@ static const struct rhashtable_params pools_hash_params = {
 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;
 };
 
 /**
@@ -201,7 +201,7 @@ static void *pool_proc_next(struct seq_file *seq, void *v, loff_t *pos)
  */
 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);
@@ -337,7 +337,7 @@ const static struct proc_ops pool_proc_operations = {
  * \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;
 
@@ -361,7 +361,7 @@ void lod_dump_pool(int level, struct pool_desc *pool)
 
 static void pools_hash_exit(void *vpool, void *data)
 {
-       struct pool_desc *pool = vpool;
+       struct lod_pool_desc *pool = vpool;
 
        lod_pool_putref(pool);
 }
@@ -378,7 +378,7 @@ void lod_pool_hash_destroy(struct rhashtable *tbl)
 
 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,
@@ -388,9 +388,9 @@ bool lod_pool_exists(struct lod_device *lod, char *poolname)
        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,
@@ -404,7 +404,7 @@ struct pool_desc *lod_pool_find(struct lod_device *lod, char *poolname)
 
 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);
@@ -415,7 +415,7 @@ lod_ost_pool_weights_seq_write(struct file *file, const char __user *buf,
                               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,
@@ -447,7 +447,7 @@ static struct ldebugfs_vars ldebugfs_lod_pool_vars[] = {
 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;
 
@@ -558,7 +558,7 @@ out_free_pool:
 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 */
@@ -613,7 +613,7 @@ int lod_pool_add(struct obd_device *obd, char *poolname, char *ostname)
 {
        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;
@@ -672,7 +672,7 @@ int lod_pool_remove(struct obd_device *obd, char *poolname, char *ostname)
        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;
 
@@ -720,7 +720,7 @@ out:
  * \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;
 
@@ -740,9 +740,9 @@ int lod_check_index_in_pool(__u32 idx, struct pool_desc *pool)
  * \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;
@@ -765,7 +765,7 @@ struct pool_desc *lod_find_pool(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 lod_pool_desc *pool)
 {
        __u64 avail_bytes = 0, total_bytes = 0;
        struct lu_tgt_pool *osts;
@@ -817,7 +817,7 @@ out_sem:
 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;
index da645a9..1ad75fb 100644 (file)
@@ -711,7 +711,7 @@ static int lod_ost_alloc_rr(const struct lu_env *env, struct lod_object *lo,
 {
        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;
@@ -1200,7 +1200,7 @@ static int lod_ost_alloc_specific(const struct lu_env *env,
        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;
@@ -1380,7 +1380,7 @@ static void process_semaphore_timer(struct timer_list *t)
  *                     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 = &ltd->ltd_qos;
@@ -1506,7 +1506,7 @@ static int lod_ost_alloc_qos(const struct lu_env *env, struct lod_object *lo,
        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;
@@ -2268,7 +2268,7 @@ static void lod_qos_set_pool(struct lod_object *lo, int pos, char *pool_name,
 {
        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;
 
index 8f8ecc2..f4a6a9e 100644 (file)
@@ -258,8 +258,8 @@ static ssize_t stripeoffset_show(struct kobject *kobj, struct attribute *attr,
  * 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);
@@ -314,7 +314,7 @@ static ssize_t max_stripecount_store(struct kobject *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);
@@ -323,8 +323,8 @@ static ssize_t max_mdt_stripecount_show(struct kobject *kobj,
 }
 
 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);
@@ -409,8 +409,8 @@ static ssize_t mdt_stripetype_store(struct kobject *kobj,
 }
 
 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);
 }
@@ -1139,7 +1139,7 @@ static const struct proc_ops lod_proc_mdt_fops = {
 
 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);
@@ -1152,7 +1152,7 @@ lod_spill_threshold_pct_seq_write(struct file *file, const char __user *buffer,
                                  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;
 
@@ -1178,7 +1178,7 @@ LPROC_SEQ_FOPS(lod_spill_threshold_pct);
 
 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);
@@ -1193,7 +1193,7 @@ static int lod_spill_check_loop(struct lod_device *lod,
                                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));
@@ -1225,7 +1225,7 @@ lod_spill_target_seq_write(struct file *file, const char __user *buffer,
                           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;
@@ -1272,7 +1272,7 @@ LPROC_SEQ_FOPS(lod_spill_target);
 
 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;
@@ -1296,7 +1296,7 @@ LPROC_SEQ_FOPS_RO(lod_spill_is_active);
 
 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));
@@ -1306,7 +1306,7 @@ LPROC_SEQ_FOPS_RO(lod_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;
index ec53d02..3adfb55 100644 (file)
@@ -78,12 +78,18 @@ struct lu_kmem_descr lov_caches[] = {
        }
 };
 
-/*****************************************************************************
- *
+/**
  * 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)
 {
@@ -95,6 +101,14 @@ static void *lov_key_init(const struct lu_context *ctx,
        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)
 {
@@ -108,6 +122,13 @@ struct lu_context_key lov_key = {
        .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)
 {
@@ -119,6 +140,13 @@ static void *lov_session_key_init(const struct lu_context *ctx,
        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)
 {
@@ -137,6 +165,21 @@ struct lu_context_key lov_session_key = {
 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)
 {
@@ -153,6 +196,14 @@ static int lov_mdc_dev_init(const struct lu_env *env, struct lov_device *ld,
        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)
 {
@@ -191,6 +242,17 @@ static struct lu_device *lov_device_fini(const struct lu_env *env,
        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)
 {
@@ -246,7 +308,14 @@ out_err:
        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)
 {
@@ -274,6 +343,14 @@ static struct lu_device *lov_device_free(const struct lu_env *env,
        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)
 {
@@ -319,6 +396,16 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
        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)
 {
@@ -448,6 +535,16 @@ static int lov_add_mdc_target(const struct lu_env *env, struct lu_device *d,
        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)
 {
@@ -511,6 +608,16 @@ static const struct lu_device_operations lov_lu_ops = {
        .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)
@@ -579,10 +686,10 @@ static const struct lu_device_type_operations lov_device_type_ops = {
        .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 = {
index 581c167..2350e45 100644 (file)
@@ -194,7 +194,7 @@ static inline bool lov_supported_comp_magic(unsigned int magic)
 #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;
@@ -342,6 +342,6 @@ static inline void lov_lsm2layout(struct lov_stripe_md *lsm,
        }
 }
 
-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
index 49615cb..9a9a66d 100644 (file)
  *  @{
  */
 
+/**
+ * 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;
@@ -64,6 +73,13 @@ static inline struct lov_io_sub *lov_sub_alloc(struct lov_io *lio, int index)
        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) {
@@ -190,13 +206,11 @@ out:
        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;
 
@@ -311,7 +325,7 @@ static int lov_io_mirror_write_intent(struct lov_io *lio,
 }
 
 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;
@@ -890,7 +904,8 @@ static int lov_io_iter_init(const struct lu_env *env,
                        }
 
                        /* 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,
@@ -1132,7 +1147,7 @@ lov_io_data_version_end(const struct lu_env *env, const struct cl_io_slice *ios)
 }
 
 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;
@@ -1152,7 +1167,7 @@ static void lov_io_iter_fini(const struct lu_env *env,
 }
 
 static void lov_io_unlock(const struct lu_env *env,
-                          const struct cl_io_slice *ios)
+                         const struct cl_io_slice *ios)
 {
        int rc;
 
@@ -1749,14 +1764,11 @@ static const struct cl_io_operations lov_io_ops = {
        .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;
@@ -1774,7 +1786,7 @@ static int lov_empty_io_submit(const struct lu_env *env,
 }
 
 static void lov_empty_impossible(const struct lu_env *env,
-                                 struct cl_io_slice *ios)
+                                struct cl_io_slice *ios)
 {
        LBUG();
 }
@@ -1859,7 +1871,7 @@ out:
 }
 
 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);
@@ -1901,7 +1913,7 @@ int lov_io_init_empty(const struct lu_env *env, struct cl_object *obj,
 }
 
 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);
index d9d162e..ff1bcb1 100644 (file)
  *  @{
  */
 
-/*****************************************************************************
- *
+/**
  * 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)
@@ -220,7 +217,7 @@ init_sublock:
 }
 
 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;
index 09d2299..1532ebd 100644 (file)
@@ -95,9 +95,10 @@ int lov_merge_lvb_kms(struct lov_stripe_md *lsm, int index,
 
                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) {
index 1a49e77..a0c0cf7 100644 (file)
@@ -56,7 +56,7 @@
 #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;
@@ -83,18 +83,18 @@ void lov_tgts_putref(struct obd_device *obd)
                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) {
@@ -195,32 +195,31 @@ int lov_connect_osc(struct obd_device *obd, u32 index, int activate,
        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);
 
@@ -235,22 +234,22 @@ static int lov_connect(const struct lu_env *env,
                        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);
 
@@ -292,8 +291,8 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
 
        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;
        }
 
@@ -541,50 +540,50 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                       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);
@@ -600,43 +599,45 @@ out:
 }
 
 /* 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);
@@ -647,27 +648,26 @@ out:
 
 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)
@@ -688,13 +688,13 @@ 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;
@@ -722,32 +722,34 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
        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;
@@ -766,7 +768,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
                GOTO(out, rc);
 
        rc = lu_tgt_pool_init(&lov->lov_packed, 0);
-        if (rc)
+       if (rc)
                GOTO(out, rc);
 
        rc = lov_tunables_init(obd);
@@ -775,16 +777,15 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
 
        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);
@@ -792,20 +793,21 @@ static int lov_cleanup(struct obd_device *obd)
        }
 
        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;
 
@@ -830,7 +832,7 @@ static int lov_cleanup(struct obd_device *obd)
                lov->lov_cache = NULL;
        }
 
-        RETURN(0);
+       RETURN(0);
 }
 
 int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
@@ -884,21 +886,21 @@ 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,
@@ -1252,7 +1254,7 @@ static int lov_quotactl(struct obd_device *obd, 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;
@@ -1276,15 +1278,15 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
                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))
@@ -1302,27 +1304,27 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp,
                        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 = {
@@ -1350,31 +1352,31 @@ static int __init lov_init(void)
        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)
index dfa879f..787f2e1 100644 (file)
@@ -49,32 +49,29 @@ static inline struct lov_device *lov_object_dev(struct lov_object *obj)
  *  @{
  */
 
-/*****************************************************************************
- *
+/**
  * 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);
 };
@@ -88,12 +85,9 @@ static void lov_lsm_put(struct lov_stripe_md *lsm)
                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,
@@ -291,16 +285,16 @@ static void lov_subobject_kill(const struct lu_env *env, struct lov_object *lov,
        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() */
@@ -316,7 +310,7 @@ static int lov_delete_raid0(const struct lu_env *env, struct lov_object *lov,
 
        ENTRY;
 
-        if (r0->lo_sub != NULL) {
+       if (r0->lo_sub != NULL) {
                int i;
 
                for (i = 0; i < r0->lo_nr; ++i) {
@@ -956,11 +950,11 @@ static void lov_fini_released(const struct lu_env *env, struct lov_object *lov,
 }
 
 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,
@@ -995,7 +989,7 @@ 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;
@@ -1034,10 +1028,10 @@ static int lov_print_foreign(const struct lu_env *env, void *cookie,
  * 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,
@@ -1223,16 +1217,16 @@ static inline void lov_conf_thaw(struct lov_object *lov)
 
 #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;                                                       \
 })
 
 /**
@@ -1243,13 +1237,13 @@ static inline void lov_conf_thaw(struct lov_object *lov)
 
 #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)
 
@@ -1353,10 +1347,8 @@ out:
        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)
@@ -1400,7 +1392,7 @@ out_lsm:
 }
 
 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);
@@ -1547,28 +1539,28 @@ out_lsm:
 
 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,
@@ -1606,11 +1598,11 @@ static int lov_io_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,
@@ -1623,7 +1615,7 @@ 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,
index 5812d43..3bf4721 100644 (file)
  *  @{
  */
 
-/*****************************************************************************
- *
+/**
  * Lov page operations.
- *
  */
 int lov_page_init_composite(const struct lu_env *env, struct cl_object *obj,
                            struct cl_page *page, pgoff_t index)
index afccd05..d8c76d5 100644 (file)
 #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;
@@ -57,9 +66,18 @@ static u32 pool_hashfh(const void *data, u32 len, u32 seed)
                                               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);
@@ -67,20 +85,42 @@ static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
 
 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)) {
@@ -104,11 +144,27 @@ void lov_pool_putref(struct pool_desc *pool)
  */
 #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;
@@ -132,76 +188,112 @@ static void *pool_proc_next(struct seq_file *s, void *v, loff_t *pos)
        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 = {
@@ -211,16 +303,28 @@ 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 = {
@@ -233,7 +337,7 @@ 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);
 }
@@ -248,22 +352,36 @@ void lov_pool_hash_destroy(struct rhashtable *tbl)
        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;
@@ -277,7 +395,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 
 #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);
@@ -309,17 +427,17 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
                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);
@@ -327,9 +445,9 @@ out_free_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();
@@ -343,13 +461,22 @@ struct pool_desc *lov_pool_find(struct obd_device *obd, char *poolname)
        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();
@@ -363,11 +490,11 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
        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);
@@ -380,17 +507,28 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
        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,
@@ -401,30 +539,29 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
        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);
@@ -432,16 +569,30 @@ out:
        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();
@@ -453,29 +604,29 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname)
        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);
index 4f2640b..4f836b7 100644 (file)
  *  @{
  */
 
-/*****************************************************************************
- *
+/**
  * 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)
 {
index cd23973..da0d661 100644 (file)
  *  @{
  */
 
-/*****************************************************************************
- *
+/**
  * Lovsub object operations.
- *
  */
 
 static int lovsub_object_init(const struct lu_env *env, struct lu_object *obj,
index ac73581..865f043 100644 (file)
@@ -227,7 +227,7 @@ static void *lov_tgt_seq_next(struct seq_file *p, void *v, loff_t *pos)
 
 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),
@@ -236,10 +236,10 @@ static int lov_tgt_seq_show(struct seq_file *p, void *v)
 }
 
 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)