Whamcloud - gitweb
Branch b1_4_mountconf
authornathan <nathan>
Tue, 29 Nov 2005 22:17:45 +0000 (22:17 +0000)
committernathan <nathan>
Tue, 29 Nov 2005 22:17:45 +0000 (22:17 +0000)
b=8007
add LCFG_PARAM parsing for lov (#9)

lustre/include/liblustre.h
lustre/include/linux/lustre_idl.h
lustre/lov/lov_obd.c
lustre/mds/handler.c
lustre/obdclass/obd_config.c
lustre/utils/lctl.c
lustre/utils/lustre_cfg.c
lustre/utils/obdctl.h

index b8c467e..57cb267 100644 (file)
@@ -319,6 +319,8 @@ static inline void spin_unlock_irqrestore(spinlock_t *a, unsigned long b) {}
         ({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 #endif
 
+#define simple_strtol strtol
+
 /* registering symbols */
 #ifndef ERESTARTSYS
 #define ERESTARTSYS ERESTART
index 0b96a4e..9b4515c 100644 (file)
@@ -935,9 +935,9 @@ typedef enum {
         MGMT_DISCONNECT,
         MGMT_EXCEPTION,         /* node died, etc. */
         MGMT_FIRST_CONNECT,     /* first connect. */
-        MGMT_MDS_ADD,
         MGMT_OST_ADD,
         MGMT_OST_DEL,
+        MGMT_MDS_ADD,
         MGMT_LAST_OPC
 } mgs_cmd_t;
 
index 48266ce..39ee540 100644 (file)
@@ -599,6 +599,31 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
         }
 }
 
+static void lov_fix_desc(struct lov_desc *desc)
+{
+        if (desc->ld_default_stripe_size < PTLRPC_MAX_BRW_SIZE) {
+                CWARN("Increasing default_stripe_size "LPU64" to %u\n",
+                      desc->ld_default_stripe_size, PTLRPC_MAX_BRW_SIZE);
+                desc->ld_default_stripe_size = PTLRPC_MAX_BRW_SIZE;
+        } else if (desc->ld_default_stripe_size & (LOV_MIN_STRIPE_SIZE - 1)) {
+                CWARN("default_stripe_size "LPU64" isn't a multiple of %u\n",
+                      desc->ld_default_stripe_size, LOV_MIN_STRIPE_SIZE);
+                desc->ld_default_stripe_size &= ~(LOV_MIN_STRIPE_SIZE - 1);
+                CWARN("changing to "LPU64"\n", desc->ld_default_stripe_size);
+       }
+
+        if (desc->ld_default_stripe_count == 0)
+                desc->ld_default_stripe_count = 1;
+
+        /* from lov_setstripe */
+        if ((desc->ld_pattern != 0) && 
+            (desc->ld_pattern != LOV_PATTERN_RAID0)) {
+                CDEBUG(D_IOCTL, "bad userland stripe pattern: %#x\n",
+                       desc->ld_pattern);
+                desc->ld_pattern = 0;
+        }
+}
+
 static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
 {
         struct lprocfs_static_vars lvars;
@@ -633,22 +658,7 @@ static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
                 }
         }
 
-        if (desc->ld_default_stripe_size < PTLRPC_MAX_BRW_SIZE) {
-                CWARN("Increasing default_stripe_size "LPU64" to %u\n",
-                      desc->ld_default_stripe_size, PTLRPC_MAX_BRW_SIZE);
-                CWARN("Please update config and run --write-conf on MDS\n");
-
-                desc->ld_default_stripe_size = PTLRPC_MAX_BRW_SIZE;
-        } else if (desc->ld_default_stripe_size & (LOV_MIN_STRIPE_SIZE - 1)) {
-                CWARN("default_stripe_size "LPU64" isn't a multiple of %u\n",
-                      desc->ld_default_stripe_size, LOV_MIN_STRIPE_SIZE);
-                CWARN("Please update config and run --write-conf on MDS\n");
-
-                desc->ld_default_stripe_size &= ~(LOV_MIN_STRIPE_SIZE - 1);
-       }
-
-        if (desc->ld_default_stripe_count == 0)
-                desc->ld_default_stripe_count = 1;
+        lov_fix_desc(desc);
 
         /* Because of 64-bit divide/mod operations only work with a 32-bit
          * divisor in a 32-bit kernel, we cannot support a stripe width
@@ -755,6 +765,7 @@ static int lov_process_config(struct obd_device *obd, obd_count len, void *buf)
         switch(cmd = lcfg->lcfg_command) {
         case LCFG_LOV_ADD_OBD:
         case LCFG_LOV_DEL_OBD: {
+                /* lov_modify_tgts add  0:lov_mdsA  1:ost1_UUID  2:0  3:1 */
                 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(obd_uuid.uuid))
                         GOTO(out, rc = -EINVAL);
 
@@ -770,6 +781,47 @@ static int lov_process_config(struct obd_device *obd, obd_count len, void *buf)
                         rc = lov_del_obd(obd, &obd_uuid, index, gen);
                 GOTO(out, rc);
         }
+        case LCFG_PARAM: {
+                int i;
+                struct lov_obd *lov = &obd->u.lov;
+                struct lov_desc *desc = &(lov->desc);
+                if (!desc)
+                        GOTO(out, rc = -EINVAL);
+                /* see jt_obd_lov_getconfig for variable names */
+                /* setparam 0:lov_mdsA 1:default_stripe_size=1048576 
+                   2:default_stripe_pattern=0 3:default_stripe_offset=0 */
+                for (i = 1; i < lcfg->lcfg_bufcount; i++) {
+                        char *key, *sval;
+                        long val;
+                        key = lustre_cfg_buf(lcfg, i);
+                        sval = strchr(key, '=');
+                        if (!sval || (*(sval + 1) == 0)) {
+                                CERROR("Can't parse param %s\n", key);
+                                rc = -EINVAL;
+                                /* continue parsing other params */
+                                continue;
+                        }
+                        *sval = 0;
+                        val = simple_strtol(sval + 1, NULL, 0);
+                        if (strcmp(key, "default_stripe_size") == 0)
+                                desc->ld_default_stripe_size = val;
+                        else if (strcmp(key, "default_stripe_count") == 0)
+                                desc->ld_default_stripe_count = val;
+                        else if (strcmp(key, "default_stripe_offset") == 0)
+                                desc->ld_default_stripe_offset = val;
+                        else if (strcmp(key, "default_stripe_pattern") == 0)
+                                desc->ld_pattern = val;
+                        else {
+                                CERROR("Unknown param %s\n", key);
+                                rc = -EINVAL;
+                                /* continue parsing other params */
+                                continue;
+                        }
+                        LCONSOLE_INFO("set %s to %ld\n", key, val);
+                }
+                lov_fix_desc(desc);
+                GOTO(out, rc);
+        }
         default: {
                 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
                 GOTO(out, rc = -EINVAL);
index d2d0a6f..17e7010 100644 (file)
@@ -1659,13 +1659,8 @@ static int mds_postsetup(struct obd_device *obd)
                 RETURN(rc);
 
         if (mds->mds_profile) {
-                struct lvfs_run_ctxt saved;
                 struct lustre_profile *lprof;
-                struct config_llog_instance cfg;
-
-                cfg.cfg_instance = NULL;
-                cfg.cfg_uuid = mds->mds_lov_uuid;
-                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
+#if 0
                 /* This will no longer be used.  mgc should have already
                    parsed the mds setup log.  The last steps in the log must be
                         attach mds mdsA mdsA_UUID
@@ -1673,6 +1668,11 @@ static int mds_postsetup(struct obd_device *obd)
                    or, better,
                         setup mountconf mountconf mdsA
                    then we can decide if we're using old or new methods. */
+                struct lvfs_run_ctxt saved;
+                struct config_llog_instance cfg;
+                cfg.cfg_instance = NULL;
+                cfg.cfg_uuid = mds->mds_lov_uuid;
+                push_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
                 rc = class_config_parse_llog(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT),
                                              mds->mds_profile, &cfg);
                 pop_ctxt(&saved, &obd->obd_lvfs_ctxt, NULL);
@@ -1692,6 +1692,7 @@ static int mds_postsetup(struct obd_device *obd)
                         GOTO(err_llog, rc);
                         break;
                 }
+#endif
 
                 /* The profile defines which osc and mdc to connect to, for a 
                    client.  We reuse that here, ignoring lprof->lp_mdc.
@@ -1711,7 +1712,7 @@ static int mds_postsetup(struct obd_device *obd)
 
 err_cleanup:
         mds_lov_clean(obd);
-err_llog:
+//err_llog:
         llog_cleanup(llog_get_context(obd, LLOG_CONFIG_ORIG_CTXT));
         RETURN(rc);
 }
index 0055635..4a7f16a 100644 (file)
@@ -642,7 +642,6 @@ int class_process_config(struct lustre_cfg *lcfg)
                         sizeof (obd_lustre_upcall));
                 GOTO(out, err = 0);
         }
-        case LCFG_PARAM: 
         case LCFG_MARKER: {
                 LCONSOLE_WARN("LCFG_MARKER not yet implemented.\n");
                 GOTO(out, err = 0);
index a60a892..2b371d5 100644 (file)
@@ -96,7 +96,7 @@ command_t cmdlist[] = {
          "setup for elan/myrinet networks.\n"
          "usage: mynid [<nid>]"},
         {"add_uuid", jt_lcfg_add_uuid, 0, "associate a UUID with a nid\n"
-         "usage: add_uuid <uuid> <nid> <net_type>"},
+         "usage: add_uuid <uuid> <nid>"},
         {"close_uuid", jt_obd_close_uuid, 0, "disconnect a UUID\n"
          "usage: close_uuid <uuid> <net_type>"},
         {"del_uuid", jt_lcfg_del_uuid, 0, "delete a UUID association\n"
@@ -142,8 +142,8 @@ command_t cmdlist[] = {
         /* Device configuration commands */
         {"==== device config =====", jt_noop, 0, "device config"},
         {"attach", jt_lcfg_attach, 0,
-         "set the type of the current device (with <name> and <uuid>)\n"
-         "usage: attach type [name [uuid]]"},
+         "set the type, name, and uuid of the current device\n"
+         "usage: attach type name uuid"},
         {"setup", jt_lcfg_setup, 0,
          "type specific device configuration information\n"
          "usage: setup <args...>"},
@@ -236,6 +236,8 @@ command_t cmdlist[] = {
          "usage: add_conn <conn_uuid> [priority]\n"},
         {"del_conn ", jt_lcfg_del_conn, 0,
          "usage: del_conn <conn_uuid> \n"},
+        {"param", jt_lcfg_param, 0,
+         "usage: param <keyword=val> ...\n"},
        
         /* Llog operations */ 
         {"llog_catlist", jt_llog_catlist, 0, 
index a2a20a9..f8a280c 100644 (file)
@@ -97,23 +97,14 @@ int jt_lcfg_attach(int argc, char **argv)
         struct lustre_cfg *lcfg;
         int rc;
 
-        if (argc != 2 && argc != 3 && argc != 4)
+        if (argc != 4)
                 return CMD_HELP;
 
         lustre_cfg_bufs_reset(&bufs, NULL);
 
         lustre_cfg_bufs_set_string(&bufs, 1, argv[1]);
-        if (argc >= 3) {
-                lustre_cfg_bufs_set_string(&bufs, 0, argv[2]);
-        } else {
-                fprintf(stderr, "error: %s: LCFG_ATTACH requires a name\n",
-                        jt_cmdname(argv[0])); 
-                return -EINVAL;
-        }
-
-        if (argc == 4) {
-                lustre_cfg_bufs_set_string(&bufs, 2, argv[3]);
-        }
+        lustre_cfg_bufs_set_string(&bufs, 0, argv[2]);
+        lustre_cfg_bufs_set_string(&bufs, 2, argv[3]);
 
         lcfg = lustre_cfg_new(LCFG_ATTACH, &bufs);
         rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
@@ -653,3 +644,30 @@ int jt_lcfg_del_conn(int argc, char **argv)
 
         return rc;
 }
+
+int jt_lcfg_param(int argc, char **argv)
+{
+        int i, rc;
+        struct lustre_cfg_bufs bufs;
+        struct lustre_cfg *lcfg;
+
+        if (argc >= LUSTRE_CFG_MAX_BUFCOUNT)
+                return CMD_HELP;
+
+        lustre_cfg_bufs_reset(&bufs, lcfg_devname);
+
+        for (i = 1; i < argc; i++) {
+                lustre_cfg_bufs_set_string(&bufs, i, argv[i]);
+        }
+
+        lcfg = lustre_cfg_new(LCFG_PARAM, &bufs);
+        
+        rc = lcfg_ioctl(argv[0], OBD_DEV_ID, lcfg);
+        lustre_cfg_free(lcfg);
+        if (rc < 0) {
+                fprintf(stderr, "error: %s: %s\n", jt_cmdname(argv[0]),
+                        strerror(rc = errno));
+        }
+        return rc;
+}
+
index 7883dbd..4155770 100644 (file)
@@ -88,6 +88,7 @@ int jt_lcfg_set_timeout(int argc, char **argv);
 int jt_lcfg_set_lustre_upcall(int argc, char **argv);
 int jt_lcfg_add_conn(int argc, char **argv);
 int jt_lcfg_del_conn(int argc, char **argv);
+int jt_lcfg_param(int argc, char **argv);
 
 int obd_add_uuid(char *uuid, lnet_nid_t nid);