Whamcloud - gitweb
LU-6142 lov: chnage lsm_op_find() to a non-inline function. 77/39377/2
authorMr NeilBrown <neilb@suse.de>
Wed, 15 Jul 2020 04:57:28 +0000 (14:57 +1000)
committerOleg Drokin <green@whamcloud.com>
Fri, 26 Feb 2021 21:41:45 +0000 (21:41 +0000)
Making lsm_op_find() non-inline improves encapsulation and means that
various _ops structures can now be static.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Ifee2ab4f023e56bfa1e663a0106590cf7858856b
Reviewed-on: https://review.whamcloud.com/39377
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_ea.c
lustre/lov/lov_internal.h

index 15755a6..3f6965b 100644 (file)
@@ -364,7 +364,7 @@ lsm_unpackmd_v1(struct lov_obd *lov, void *buf, size_t buf_size)
        return lsm_unpackmd_v1v3(lov, buf, buf_size, NULL, lmm->lmm_objects);
 }
 
-const struct lsm_operations lsm_v1_ops = {
+static const struct lsm_operations lsm_v1_ops = {
        .lsm_unpackmd           = lsm_unpackmd_v1,
 };
 
@@ -377,7 +377,7 @@ lsm_unpackmd_v3(struct lov_obd *lov, void *buf, size_t buf_size)
                                 lmm->lmm_objects);
 }
 
-const struct lsm_operations lsm_v3_ops = {
+static const struct lsm_operations lsm_v3_ops = {
        .lsm_unpackmd           = lsm_unpackmd_v3,
 };
 
@@ -564,8 +564,8 @@ out_lsm:
        RETURN(ERR_PTR(rc));
 }
 
-const struct lsm_operations lsm_comp_md_v1_ops = {
-       .lsm_unpackmd         = lsm_unpackmd_comp_md_v1,
+static const struct lsm_operations lsm_comp_md_v1_ops = {
+       .lsm_unpackmd           = lsm_unpackmd_comp_md_v1,
 };
 
 static struct
@@ -602,10 +602,27 @@ lov_stripe_md *lsm_unpackmd_foreign(struct lov_obd *lov, void *buf,
        return lsm;
 }
 
-const struct lsm_operations lsm_foreign_ops = {
-       .lsm_unpackmd         = lsm_unpackmd_foreign,
+static const struct lsm_operations lsm_foreign_ops = {
+       .lsm_unpackmd           = lsm_unpackmd_foreign,
 };
 
+const struct lsm_operations *lsm_op_find(int magic)
+{
+       switch (magic) {
+       case LOV_MAGIC_V1:
+               return &lsm_v1_ops;
+       case LOV_MAGIC_V3:
+               return &lsm_v3_ops;
+       case LOV_MAGIC_COMP_V1:
+               return &lsm_comp_md_v1_ops;
+       case LOV_MAGIC_FOREIGN:
+               return &lsm_foreign_ops;
+       default:
+               CERROR("unrecognized lsm_magic %08x\n", magic);
+               return NULL;
+       }
+}
+
 void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm)
 {
        int i, j;
index 9512b3e..e1062da 100644 (file)
@@ -182,27 +182,7 @@ struct lsm_operations {
        struct lov_stripe_md *(*lsm_unpackmd)(struct lov_obd *, void *, size_t);
 };
 
-extern const struct lsm_operations lsm_v1_ops;
-extern const struct lsm_operations lsm_v3_ops;
-extern const struct lsm_operations lsm_comp_md_v1_ops;
-extern const struct lsm_operations lsm_foreign_ops;
-static inline const struct lsm_operations *lsm_op_find(int magic)
-{
-       switch (magic) {
-       case LOV_MAGIC_V1:
-               return &lsm_v1_ops;
-       case LOV_MAGIC_V3:
-               return &lsm_v3_ops;
-       case LOV_MAGIC_COMP_V1:
-               return &lsm_comp_md_v1_ops;
-       case LOV_MAGIC_FOREIGN:
-               return &lsm_foreign_ops;
-       default:
-               CERROR("unrecognized lsm_magic %08x\n", magic);
-               return NULL;
-       }
-}
-
+const struct lsm_operations *lsm_op_find(int magic);
 void lsm_free(struct lov_stripe_md *lsm);
 
 /* lov_do_div64(a, b) returns a % b, and a = a / b.