Whamcloud - gitweb
LU-3778 sptlrpc: OSP and LWP don't know sptlrpc 40/14040/8
authorSebastien Buisson <sebastien.buisson@bull.net>
Wed, 11 Mar 2015 09:14:57 +0000 (10:14 +0100)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 1 Jul 2015 02:03:53 +0000 (02:03 +0000)
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 <sebastien.buisson@bull.net>
Change-Id: I3d4bc635a7076addea7bbb52ac13f74a25f625ad
Reviewed-on: http://review.whamcloud.com/14040
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd.h
lustre/ldlm/ldlm_lib.c
lustre/ofd/ofd_dev.c
lustre/osp/lproc_osp.c
lustre/osp/lwp_dev.c
lustre/ptlrpc/gss/gss_cli_upcall.c
lustre/ptlrpc/gss/gss_internal.h
lustre/ptlrpc/gss/gss_keyring.c
lustre/ptlrpc/sec_lproc.c

index ec275fa..37987ca 100644 (file)
@@ -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.
  */
index 448eb9b..603ab41 100644 (file)
@@ -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;
index 012cca3..c4b3c9b 100644 (file)
@@ -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:
index 200f61c..4d499e2 100644 (file)
@@ -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"))
index 1f0467c..dccfef4 100644 (file)
@@ -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);
 }
index d72e1ab..765082d 100644 (file)
@@ -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);
index 876ea39..bf93e65 100644 (file)
@@ -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;
 }
 
 /*
index c0438e9..2e95b10 100644 (file)
@@ -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:
index f7104a9..bf1e961 100644 (file)
@@ -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);