From 7b237bd306e796cd08b3df43a9c697ed8d8d9332 Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Wed, 15 Jul 2020 14:57:28 +1000 Subject: [PATCH] LU-6142 lov: chnage lsm_op_find() to a non-inline function. 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 Change-Id: Ifee2ab4f023e56bfa1e663a0106590cf7858856b Reviewed-on: https://review.whamcloud.com/39377 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: Shaun Tancheff Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/lov/lov_ea.c | 29 +++++++++++++++++++++++------ lustre/lov/lov_internal.h | 22 +--------------------- 2 files changed, 24 insertions(+), 27 deletions(-) diff --git a/lustre/lov/lov_ea.c b/lustre/lov/lov_ea.c index 15755a6..3f6965b 100644 --- a/lustre/lov/lov_ea.c +++ b/lustre/lov/lov_ea.c @@ -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; diff --git a/lustre/lov/lov_internal.h b/lustre/lov/lov_internal.h index 9512b3e..e1062da 100644 --- a/lustre/lov/lov_internal.h +++ b/lustre/lov/lov_internal.h @@ -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. -- 1.8.3.1