From cf57dfc4c9bf4b9d36e356d6f33550676b21e066 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 11 Mar 2015 10:14:57 +0100 Subject: [PATCH] LU-3778 sptlrpc: OSP and LWP don't know sptlrpc The sptlrpc subsystem must be initialized for OSP and LWP connections, by calling sptlrpc_lprocfs_cliobd_attach(). Moreover, GSS related functions must not return an LBUG when dealing with OSP and LWP OBDs. Signed-off-by: Sebastien Buisson Change-Id: I3d4bc635a7076addea7bbb52ac13f74a25f625ad Reviewed-on: http://review.whamcloud.com/14040 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/obd.h | 52 ++++++++++++++++++++++++++++++++++++++ lustre/ldlm/ldlm_lib.c | 26 +++++++++++-------- lustre/ofd/ofd_dev.c | 2 ++ lustre/osp/lproc_osp.c | 1 + lustre/osp/lwp_dev.c | 4 ++- lustre/ptlrpc/gss/gss_cli_upcall.c | 4 ++- lustre/ptlrpc/gss/gss_internal.h | 22 ++++++++-------- lustre/ptlrpc/gss/gss_keyring.c | 11 ++++++++ lustre/ptlrpc/sec_lproc.c | 32 +++++++++++++---------- 9 files changed, 119 insertions(+), 35 deletions(-) diff --git a/lustre/include/obd.h b/lustre/include/obd.h index ec275fa..37987ca 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -445,6 +445,58 @@ struct niobuf_local { #define LUSTRE_MGS_OBDNAME "MGS" #define LUSTRE_MGC_OBDNAME "MGC" +static inline int is_lwp_on_mdt(char *name) +{ + char *ptr; + + ptr = strrchr(name, '-'); + if (ptr == NULL) { + CERROR("%s is not a obdname\n", name); + return 0; + } + + /* LWP name on MDT is fsname-MDTxxxx-lwp-MDTxxxx */ + + if (strncmp(ptr + 1, "MDT", 3) != 0) + return 0; + + while (*(--ptr) != '-' && ptr != name); + + if (ptr == name) + return 0; + + if (strncmp(ptr + 1, LUSTRE_LWP_NAME, strlen(LUSTRE_LWP_NAME)) != 0) + return 0; + + return 1; +} + +static inline int is_lwp_on_ost(char *name) +{ + char *ptr; + + ptr = strrchr(name, '-'); + if (ptr == NULL) { + CERROR("%s is not a obdname\n", name); + return 0; + } + + /* LWP name on OST is fsname-MDTxxxx-lwp-OSTxxxx */ + + if (strncmp(ptr + 1, "OST", 3) != 0) + return 0; + + while (*(--ptr) != '-' && ptr != name); + + if (ptr == name) + return 0; + + if (strncmp(ptr + 1, LUSTRE_LWP_NAME, strlen(LUSTRE_LWP_NAME)) != 0) + return 0; + + return 1; +} + /* * Events signalled through obd_notify() upcall-chain. */ diff --git a/lustre/ldlm/ldlm_lib.c b/lustre/ldlm/ldlm_lib.c index 448eb9b..603ab41 100644 --- a/lustre/ldlm/ldlm_lib.c +++ b/lustre/ldlm/ldlm_lib.c @@ -260,14 +260,15 @@ static int osc_on_mdt(char *obdname) */ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) { - struct client_obd *cli = &obddev->u.cli; - struct obd_import *imp; - struct obd_uuid server_uuid; - int rq_portal, rp_portal, connect_op; - char *name = obddev->obd_type->typ_name; - ldlm_ns_type_t ns_type = LDLM_NS_TYPE_UNKNOWN; - int rc; - ENTRY; + struct client_obd *cli = &obddev->u.cli; + struct obd_import *imp; + struct obd_uuid server_uuid; + int rq_portal, rp_portal, connect_op; + char *name = obddev->obd_type->typ_name; + ldlm_ns_type_t ns_type = LDLM_NS_TYPE_UNKNOWN; + int rc; + char *cli_name = lustre_cfg_buf(lcfg, 0); + ENTRY; /* In a more perfect world, we would hang a ptlrpc_client off of * obd_type and just use the values from there. */ @@ -283,7 +284,12 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) rq_portal = MDS_REQUEST_PORTAL; rp_portal = MDC_REPLY_PORTAL; connect_op = MDS_CONNECT; - cli->cl_sp_me = LUSTRE_SP_CLI; + if (is_lwp_on_ost(cli_name)) + cli->cl_sp_me = LUSTRE_SP_OST; + else if (is_lwp_on_mdt(cli_name)) + cli->cl_sp_me = LUSTRE_SP_MDT; + else + cli->cl_sp_me = LUSTRE_SP_CLI; cli->cl_sp_to = LUSTRE_SP_MDT; ns_type = LDLM_NS_TYPE_MDC; } else if (!strcmp(name, LUSTRE_OSP_NAME)) { @@ -301,7 +307,7 @@ int client_obd_setup(struct obd_device *obddev, struct lustre_cfg *lcfg) rq_portal = OST_REQUEST_PORTAL; } rp_portal = OSC_REPLY_PORTAL; - cli->cl_sp_me = LUSTRE_SP_CLI; + cli->cl_sp_me = LUSTRE_SP_MDT; } else if (!strcmp(name, LUSTRE_MGC_NAME)) { rq_portal = MGS_REQUEST_PORTAL; rp_portal = MGC_REPLY_PORTAL; diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 012cca3..c4b3c9b 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -2846,6 +2846,8 @@ static int ofd_init0(const struct lu_env *env, struct ofd_device *m, if (rc != 0) GOTO(err_fini_fs, rc); + tgt_adapt_sptlrpc_conf(&m->ofd_lut, 1); + RETURN(0); err_fini_fs: diff --git a/lustre/osp/lproc_osp.c b/lustre/osp/lproc_osp.c index 200f61c..4d499e2 100644 --- a/lustre/osp/lproc_osp.c +++ b/lustre/osp/lproc_osp.c @@ -823,6 +823,7 @@ void osp_lprocfs_init(struct osp_device *osp) return; } + sptlrpc_lprocfs_cliobd_attach(obd); ptlrpc_lprocfs_register_obd(obd); if (osp->opd_connect_mdt || !strstr(obd->obd_name, "osc")) diff --git a/lustre/osp/lwp_dev.c b/lustre/osp/lwp_dev.c index 1f0467c..dccfef4 100644 --- a/lustre/osp/lwp_dev.c +++ b/lustre/osp/lwp_dev.c @@ -268,8 +268,10 @@ static int lwp_init0(const struct lu_env *env, struct lwp_device *lwp, RETURN(rc); } - if (lprocfs_obd_setup(lwp->lpd_obd) == 0) + if (lprocfs_obd_setup(lwp->lpd_obd) == 0) { + sptlrpc_lprocfs_cliobd_attach(lwp->lpd_obd); ptlrpc_lprocfs_register_obd(lwp->lpd_obd); + } RETURN(0); } diff --git a/lustre/ptlrpc/gss/gss_cli_upcall.c b/lustre/ptlrpc/gss/gss_cli_upcall.c index d72e1ab..765082d 100644 --- a/lustre/ptlrpc/gss/gss_cli_upcall.c +++ b/lustre/ptlrpc/gss/gss_cli_upcall.c @@ -282,7 +282,9 @@ int gss_do_ctx_init_rpc(__user char *buffer, unsigned long count) if (strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) && strcmp(obd->obd_type->typ_name, LUSTRE_OSC_NAME) && - strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME)) { + strcmp(obd->obd_type->typ_name, LUSTRE_MGC_NAME) && + strcmp(obd->obd_type->typ_name, LUSTRE_LWP_NAME) && + strcmp(obd->obd_type->typ_name, LUSTRE_OSP_NAME)) { CERROR("obd %s is not a client device\n", obdname); spin_unlock(&obd->obd_dev_lock); RETURN(-EINVAL); diff --git a/lustre/ptlrpc/gss/gss_internal.h b/lustre/ptlrpc/gss/gss_internal.h index 876ea39..bf93e65 100644 --- a/lustre/ptlrpc/gss/gss_internal.h +++ b/lustre/ptlrpc/gss/gss_internal.h @@ -119,16 +119,18 @@ enum ptlrpc_gss_header_flags { static inline __u32 import_to_gss_svc(struct obd_import *imp) { - const char *name = imp->imp_obd->obd_type->typ_name; - - if (!strcmp(name, LUSTRE_MGC_NAME)) - return LUSTRE_GSS_TGT_MGS; - if (!strcmp(name, LUSTRE_MDC_NAME)) - return LUSTRE_GSS_TGT_MDS; - if (!strcmp(name, LUSTRE_OSC_NAME)) - return LUSTRE_GSS_TGT_OSS; - LBUG(); - return 0; + const char *name = imp->imp_obd->obd_type->typ_name; + + if (!strcmp(name, LUSTRE_MGC_NAME)) + return LUSTRE_GSS_TGT_MGS; + if (!strcmp(name, LUSTRE_MDC_NAME) || + !strcmp(name, LUSTRE_LWP_NAME)) + return LUSTRE_GSS_TGT_MDS; + if (!strcmp(name, LUSTRE_OSC_NAME) || + !strcmp(name, LUSTRE_OSP_NAME)) + return LUSTRE_GSS_TGT_OSS; + + return 0; } /* diff --git a/lustre/ptlrpc/gss/gss_keyring.c b/lustre/ptlrpc/gss/gss_keyring.c index c0438e9..2e95b10 100644 --- a/lustre/ptlrpc/gss/gss_keyring.c +++ b/lustre/ptlrpc/gss/gss_keyring.c @@ -747,6 +747,17 @@ struct ptlrpc_cli_ctx * gss_sec_lookup_ctx_kr(struct ptlrpc_sec *sec, * encode real uid/gid into callout info. */ + /* But first we need to make sure the obd type is supported */ + if (strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_MDC_NAME) && + strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_OSC_NAME) && + strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_MGC_NAME) && + strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_LWP_NAME) && + strcmp(imp->imp_obd->obd_type->typ_name, LUSTRE_OSP_NAME)) { + CERROR("obd %s is not a supported device\n", + imp->imp_obd->obd_name); + RETURN(NULL); + } + construct_key_desc(desc, sizeof(desc), sec, vcred->vc_uid); /* callout info format: diff --git a/lustre/ptlrpc/sec_lproc.c b/lustre/ptlrpc/sec_lproc.c index f7104a9..bf1e961 100644 --- a/lustre/ptlrpc/sec_lproc.c +++ b/lustre/ptlrpc/sec_lproc.c @@ -82,9 +82,11 @@ static int sptlrpc_info_lprocfs_seq_show(struct seq_file *seq, void *v) struct ptlrpc_sec *sec = NULL; char str[32]; - LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 || - strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || - strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0); + LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0); if (cli->cl_import) sec = sptlrpc_import_sec_ref(cli->cl_import); @@ -120,9 +122,11 @@ static int sptlrpc_ctxs_lprocfs_seq_show(struct seq_file *seq, void *v) struct client_obd *cli = &dev->u.cli; struct ptlrpc_sec *sec = NULL; - LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 || - strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || - strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0); + LASSERT(strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) == 0 || + strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) == 0); if (cli->cl_import) sec = sptlrpc_import_sec_ref(cli->cl_import); @@ -142,13 +146,15 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev) { int rc; - if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 && - strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 && - strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0) { - CERROR("can't register lproc for obd type %s\n", - dev->obd_type->typ_name); - return -EINVAL; - } + if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 && + strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 && + strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0 && + strcmp(dev->obd_type->typ_name, LUSTRE_LWP_NAME) != 0 && + strcmp(dev->obd_type->typ_name, LUSTRE_OSP_NAME) != 0) { + CERROR("can't register lproc for obd type %s\n", + dev->obd_type->typ_name); + return -EINVAL; + } rc = lprocfs_obd_seq_create(dev, "srpc_info", 0444, &sptlrpc_info_lprocfs_fops, dev); -- 1.8.3.1