Whamcloud - gitweb
LU-14291 build: use tgt_pool for lov layer 83/39683/8
authorJames Simmons <jsimmons@infradead.org>
Fri, 26 Feb 2021 21:41:09 +0000 (16:41 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 16 Mar 2021 18:17:59 +0000 (18:17 +0000)
New general code was created for target pool handling. We can
use this new code with the lov layer. Place this tgt_pool.c in
the obdclass instead of having a special target directory just to
build this code for the client.

Change-Id: I05542c1d654d79647f5e0853bb1d587ff265fdf9
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/39683
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Sergey Cheremencev <sergey.cheremencev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_internal.h
lustre/lov/lov_obd.c
lustre/lov/lov_pool.c
lustre/obdclass/Makefile.in
lustre/obdclass/lu_tgt_pool.c [moved from lustre/target/tgt_pool.c with 100% similarity]
lustre/ptlrpc/Makefile.in
lustre/target/Makefile.am

index e1062da..8a5b0cf 100644 (file)
@@ -325,13 +325,6 @@ extern struct lu_device_type lov_device_type;
 
 #define LOV_MDC_TGT_MAX 256
 
-/* lu_tgt_pool methods */
-int lov_ost_pool_init(struct lu_tgt_pool *op, unsigned int count);
-int lov_ost_pool_extend(struct lu_tgt_pool *op, unsigned int min_count);
-int lov_ost_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count);
-int lov_ost_pool_remove(struct lu_tgt_pool *op, __u32 idx);
-int lov_ost_pool_free(struct lu_tgt_pool *op);
-
 /* high level pool methods */
 int lov_pool_new(struct obd_device *obd, char *poolname);
 int lov_pool_del(struct obd_device *obd, char *poolname);
index 762e20a..49ae17a 100644 (file)
@@ -91,7 +91,7 @@ void lov_tgts_putref(struct obd_device *obd)
                         /* 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. */
-                        lov_ost_pool_remove(&lov->lov_packed, i);
+                       tgt_pool_remove(&lov->lov_packed, i);
                         lov->lov_tgts[i] = NULL;
                         lov->lov_death_row--;
                 }
@@ -542,7 +542,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
                 RETURN(-ENOMEM);
         }
 
-        rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
+       rc = tgt_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
         if (rc) {
                mutex_unlock(&lov->lov_lock);
                 OBD_FREE_PTR(tgt);
@@ -760,7 +760,7 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
        if (rc)
                GOTO(out, rc);
 
-        rc = lov_ost_pool_init(&lov->lov_packed, 0);
+       rc = tgt_pool_init(&lov->lov_packed, 0);
         if (rc)
                GOTO(out, rc);
 
@@ -797,7 +797,7 @@ static int lov_cleanup(struct obd_device *obd)
                 lov_pool_del(obd, pool->pool_name);
         }
        lov_pool_hash_destroy(&lov->lov_pools_hash_body);
-        lov_ost_pool_free(&lov->lov_packed);
+       tgt_pool_free(&lov->lov_packed);
 
        lprocfs_obd_cleanup(obd);
         if (lov->lov_tgts) {
index 73e2b6a..66e39b0 100644 (file)
@@ -86,7 +86,7 @@ void lov_pool_putref(struct pool_desc *pool)
        if (atomic_dec_and_test(&pool->pool_refcount)) {
                LASSERT(list_empty(&pool->pool_list));
                LASSERT(pool->pool_proc_entry == NULL);
-               lov_ost_pool_free(&(pool->pool_obds));
+               tgt_pool_free(&(pool->pool_obds));
                kfree_rcu(pool, pool_rcu);
                EXIT;
        }
@@ -253,116 +253,6 @@ void lov_dump_pool(int level, struct pool_desc *pool)
         lov_pool_putref(pool);
 }
 
-#define LOV_POOL_INIT_COUNT 2
-int lov_ost_pool_init(struct lu_tgt_pool *op, unsigned int count)
-{
-       ENTRY;
-
-       if (count == 0)
-               count = LOV_POOL_INIT_COUNT;
-       op->op_array = NULL;
-       op->op_count = 0;
-       init_rwsem(&op->op_rw_sem);
-       op->op_size = count * sizeof(op->op_array[0]);
-       OBD_ALLOC(op->op_array, op->op_size);
-       if (op->op_array == NULL) {
-               op->op_size = 0;
-               RETURN(-ENOMEM);
-       }
-       EXIT;
-       return 0;
-}
-
-/* Caller must hold write op_rwlock */
-int lov_ost_pool_extend(struct lu_tgt_pool *op, unsigned int min_count)
-{
-       __u32 *new;
-       __u32 new_size;
-
-       LASSERT(min_count != 0);
-
-       if (op->op_count * sizeof(op->op_array[0]) < op->op_size)
-               return 0;
-
-       new_size = max_t(__u32, min_count * sizeof(op->op_array[0]),
-                        2 * op->op_size);
-       OBD_ALLOC(new, new_size);
-       if (new == NULL)
-               return -ENOMEM;
-
-       /* copy old array to new one */
-       memcpy(new, op->op_array, op->op_size);
-       OBD_FREE(op->op_array, op->op_size);
-       op->op_array = new;
-       op->op_size = new_size;
-       return 0;
-}
-
-int lov_ost_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count)
-{
-        int rc = 0, i;
-        ENTRY;
-
-       down_write(&op->op_rw_sem);
-
-        rc = lov_ost_pool_extend(op, min_count);
-        if (rc)
-                GOTO(out, rc);
-
-        /* search ost in pool array */
-        for (i = 0; i < op->op_count; i++) {
-                if (op->op_array[i] == idx)
-                        GOTO(out, rc = -EEXIST);
-        }
-        /* ost not found we add it */
-        op->op_array[op->op_count] = idx;
-        op->op_count++;
-        EXIT;
-out:
-       up_write(&op->op_rw_sem);
-        return rc;
-}
-
-int lov_ost_pool_remove(struct lu_tgt_pool *op, __u32 idx)
-{
-        int i;
-        ENTRY;
-
-       down_write(&op->op_rw_sem);
-
-        for (i = 0; i < op->op_count; i++) {
-                if (op->op_array[i] == idx) {
-                        memmove(&op->op_array[i], &op->op_array[i + 1],
-                                (op->op_count - i - 1) * sizeof(op->op_array[0]));
-                        op->op_count--;
-                       up_write(&op->op_rw_sem);
-                        EXIT;
-                        return 0;
-                }
-        }
-
-       up_write(&op->op_rw_sem);
-        RETURN(-EINVAL);
-}
-
-int lov_ost_pool_free(struct lu_tgt_pool *op)
-{
-       ENTRY;
-
-       if (op->op_size == 0)
-               RETURN(0);
-
-       down_write(&op->op_rw_sem);
-
-       OBD_FREE(op->op_array, op->op_size);
-       op->op_array = NULL;
-       op->op_count = 0;
-       op->op_size = 0;
-
-       up_write(&op->op_rw_sem);
-       RETURN(0);
-}
-
 static void pools_hash_exit(void *vpool, void *data)
 {
        struct pool_desc *pool = vpool;
@@ -403,7 +293,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
         * up to deletion
         */
        atomic_set(&new_pool->pool_refcount, 1);
-       rc = lov_ost_pool_init(&new_pool->pool_obds, 0);
+       rc = tgt_pool_init(&new_pool->pool_obds, 0);
        if (rc)
                GOTO(out_err, rc);
 
@@ -452,7 +342,7 @@ out_err:
        lov->lov_pool_count--;
        spin_unlock(&obd->obd_dev_lock);
         lprocfs_remove(&new_pool->pool_proc_entry);
-       lov_ost_pool_free(&new_pool->pool_obds);
+       tgt_pool_free(&new_pool->pool_obds);
        OBD_FREE_PTR(new_pool);
 
        return rc;
@@ -548,7 +438,7 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)
         if (lov_idx == lov->desc.ld_tgt_count)
                 GOTO(out, rc = -EINVAL);
 
-        rc = lov_ost_pool_add(&pool->pool_obds, lov_idx, lov->lov_tgt_size);
+       rc = tgt_pool_add(&pool->pool_obds, lov_idx, lov->lov_tgt_size);
         if (rc)
                 GOTO(out, rc);
 
@@ -601,7 +491,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname)
         if (lov_idx == lov->desc.ld_tgt_count)
                 GOTO(out, rc = -EINVAL);
 
-        lov_ost_pool_remove(&pool->pool_obds, lov_idx);
+       tgt_pool_remove(&pool->pool_obds, lov_idx);
 
         CDEBUG(D_CONFIG, "%s removed from "LOV_POOLNAMEF"\n", ostname,
                poolname);
index a99989a..4882371 100644 (file)
@@ -12,7 +12,7 @@ obdclass-all-objs += cl_object.o cl_page.o cl_lock.o cl_io.o lu_ref.o
 obdclass-all-objs += linkea.o
 obdclass-all-objs += kernelcomm.o jobid.o
 obdclass-all-objs += integrity.o obd_cksum.o
-obdclass-all-objs += lu_tgt_descs.o
+obdclass-all-objs += lu_tgt_descs.o lu_tgt_pool.o
 obdclass-all-objs += range_lock.o interval_tree.o
 
 @SERVER_TRUE@obdclass-all-objs += acl.o
index 6eee21f..27cff00 100644 (file)
@@ -15,8 +15,6 @@ target_objs += $(TARGET)out_lib.o $(TARGET)update_trans.o
 target_objs += $(TARGET)update_records.o $(TARGET)update_recovery.o
 target_objs += $(TARGET)tgt_grant.o $(TARGET)tgt_fmd.o
 
-target_pool_objs := $(TARGET)tgt_pool.o
-
 ptlrpc_objs := client.o recover.o connection.o niobuf.o pack_generic.o
 ptlrpc_objs += events.o ptlrpc_module.o service.o pinger.o
 ptlrpc_objs += llog_net.o llog_client.o llog_server.o import.o ptlrpcd.o
@@ -31,7 +29,7 @@ nodemap_objs := nodemap_handler.o nodemap_lproc.o nodemap_range.o
 nodemap_objs += nodemap_idmap.o nodemap_rbtree.o nodemap_member.o
 nodemap_objs += nodemap_storage.o
 
-ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) $(TARGET)barrier.o $(target_pool_objs)
+ptlrpc-objs := $(ldlm_objs) $(ptlrpc_objs) $(TARGET)barrier.o
 @SERVER_TRUE@ptlrpc-objs += $(target_objs) $(nodemap_objs) $(nrs_server_objs)
 
 @GSS_TRUE@obj-m += gss/
index c77103d..a8165a9 100644 (file)
@@ -36,4 +36,3 @@ EXTRA_DIST = tgt_main.c tgt_lastrcvd.c tgt_handler.c tgt_internal.h \
 EXTRA_DIST += update_trans.c
 EXTRA_DIST += update_records.c
 EXTRA_DIST += update_recovery.c
-EXTRA_DIST += tgt_pool.c