Whamcloud - gitweb
moi/mmi --> mti
authorlincent <lincent>
Wed, 30 Nov 2005 21:03:52 +0000 (21:03 +0000)
committerlincent <lincent>
Wed, 30 Nov 2005 21:03:52 +0000 (21:03 +0000)
lustre/include/linux/lustre_disk.h
lustre/include/linux/lustre_export.h
lustre/include/linux/lustre_idl.h
lustre/include/linux/lustre_mgs.h
lustre/mgc/mgc_request.c
lustre/mgs/mgs_handler.c
lustre/mgs/mgs_llog.c

index 3453c4b..a3ee122 100644 (file)
@@ -46,7 +46,7 @@
 #define LDD_F_SV_TYPE_OST   0x0002
 #define LDD_F_SV_TYPE_MGMT  0x0004
 #define LDD_F_NEED_INDEX    0x0010
-#define LDD_F_FIRST_START   0x0020
+#define LDD_F_NEED_REGISTER 0x0020
 
 enum ldd_mount_type {
         LDD_MT_EXT3 = 0, 
index dd25d4c..ef8b458 100644 (file)
@@ -74,7 +74,6 @@ struct obd_export {
                                   exp_replay_needed:1,
                                   exp_libclient:1; /* liblustre client? */
         union {
-                struct mgs_export_data    eu_mgs_data;
                 struct mds_export_data    eu_mds_data;
                 struct filter_export_data eu_filter_data;
                 struct ec_export_data     eu_ec_data;
index f09e8ee..7c0f85d 100644 (file)
@@ -942,6 +942,7 @@ typedef enum {
 #define NAME_MAXLEN 64
 #define UUID_MAXLEN NAME_MAXLEN + 5
 
+
 struct mgmt_ost_info {
         struct list_head moi_list;
         char             moi_fullfsname[NAME_MAXLEN];
@@ -969,6 +970,13 @@ struct mgmt_mds_info {
 extern void lustre_swab_mgmt_mds_info(struct mgmt_mds_info *oinfo);
 
 
+struct mgmt_target_info{
+        __u32 mti_flags;
+        union {
+                struct mgmt_ost_info moi;
+                struct mgmt_mds_info mmi;
+        } u;
+};
 /*
  * Opcodes for multiple servers.
  */
index 80b935f..8ab6bca 100644 (file)
@@ -55,5 +55,5 @@ int mgs_fs_cleanup(struct obd_device *obddev);
 extern int mgs_iocontrol(unsigned int cmd, struct obd_export *exp, 
                          int len, void *karg, void *uarg);
 
-extern int mgs_mds_register(struct ptlrpc_request*);
+extern int mgs_mds_register(struct ptlrpc_request *req);
 #endif
index 9593239..cf1408e 100644 (file)
@@ -86,7 +86,7 @@ out:
 
         RETURN(rc);
 }
-EXPORT_SYMBOL(mgc_ost_add);
+EXPORT_SYMBOL(mgc_target_add); 
 
 /* Remove from config llog */
 int mgc_target_del(struct obd_export *exp, struct mgmt_ost_info *moi)
@@ -122,7 +122,7 @@ out:
 
         RETURN(rc);
 }
-EXPORT_SYMBOL(mgc_ost_del);
+EXPORT_SYMBOL(mgc_target_del);
 
 static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, 
                         struct vfsmount *mnt)
@@ -383,7 +383,7 @@ int mgc_set_info(struct obd_export *exp, obd_count keylen,
         if (keylen == strlen("register") &&
             memcmp(key, "register", keylen) == 0) {
                 struct mgmt_ost_info *moi;
-                if (vallen != sizeof(mgmt_ost_info))
+                if (vallen != sizeof(struct mgmt_ost_info))
                         RETURN(-EINVAL);
                 moi = (struct mgmt_ost_info *)val;
                 CERROR("register %s %#x\n", moi->moi_ostname, moi->moi_flags);
index f83d5b2..b26cad5 100644 (file)
@@ -350,23 +350,23 @@ int mgs_handle(struct ptlrpc_request *req)
                 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOG_CANCEL_NET, 0);
                 rc = -ENOTSUPP; /* la la la */
                 break;
-        case MGMT_FIRST_CONNECT:
-                CDEBUG(D_INODE, "server connect at first time\n");
-                OBD_FAIL_RETURN(OBD_FAIL_MGMT_FIRST_CONNECT, 0);
-                rc = mgmt_handle_first_connect(req);
-                break;
//       case MGMT_FIRST_CONNECT:
//               CDEBUG(D_INODE, "server connect at first time\n");
//               OBD_FAIL_RETURN(OBD_FAIL_MGMT_FIRST_CONNECT, 0);
//               rc = mgmt_handle_first_connect(req);
+//                break;
         case MGMT_TARGET_ADD:
                 CDEBUG(D_INODE, "target add\n");
                 rc = mgmt_handle_target_add(req);
                 break;
         case MGMT_TARGET_DEL:
                 CDEBUG(D_INODE, "target del\n");
-                rc = mgmt_handle_target_del(req);
-                break;
-        case MGMT_MDS_ADD:
-                CDEBUG(D_INODE, "mds add\n");
-                rc = mgmt_handle_mds_add(req);
+//                rc = mgmt_handle_target_del(req);
                 break;
+//        case MGMT_MDS_ADD:
+//                CDEBUG(D_INODE, "mds add\n");
+//                rc = mgmt_handle_mds_add(req);
+//                break;
         case LLOG_ORIGIN_HANDLE_CREATE:
                 DEBUG_REQ(D_INODE, req, "llog_init");
                 OBD_FAIL_RETURN(OBD_FAIL_OBD_LOGD_NET, 0);
index 657b85b..9deda3e 100644 (file)
@@ -5,7 +5,6 @@
  *  Lustre Management Server (mgs) llog controller
  *
  *  Copyright (C) 2001-2005 Cluster File Systems, Inc.
- *   Author LinSongTao <lincent@clusterfs.com>
  *
  *   This file is part of Lustre, http://www.lustre.org.
  *
@@ -142,7 +141,8 @@ static int get_ost_number(void *index_map, int map_len)
                         num++;
        return num;
 }
-static int mgs_get_index(struct obd_device *obd, char *full_fsname,
+
+int mgs_get_index(struct obd_device *obd, char *full_fsname,
                          int disk_type, int *new_index)
 {
         struct mgs_obd *mgs = &obd->u.mgs;
@@ -182,7 +182,8 @@ clean:
         OBD_FREE(db, sizeof(*db));
         goto out;
 }
-                          
+EXPORT_SYMBOL(mgs_get_index);                         
+
 static int mgs_do_record(struct obd_device *obd, struct llog_handle *llh,
                          void *cfg_buf)
 {
@@ -749,9 +750,7 @@ int mgmt_handle_first_connect(struct ptlrpc_request *req)
 
         disk_type = lustre_swab_reqbuf(req, 0, sizeof(*disk_type),
                                        __swab32s);
-
         full_fsname = lustre_swab_reqbuf(req, 1, NAME_MAXLEN, NULL);
-
         node_name = lustre_swab_reqbuf(req, 2, NAME_MAXLEN, NULL);
 
         if (*disk_type & LDD_F_SV_TYPE_MDT) {
@@ -763,7 +762,6 @@ int mgmt_handle_first_connect(struct ptlrpc_request *req)
                 CDEBUG(D_INODE,
                        "New OST Server belong to FILESYSTEM[/POOL]%s\n",
                        full_fsname);
-
         }
         else {
                 CERROR("Wrong disk type register.\n");
@@ -790,7 +788,147 @@ out:
         return rc;
 }
 
-static int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi)
+int llog_add_ost(struct obd_device *obd, struct mgmt_ost_info *moi)
+{
+        struct mgs_obd *mgs = &obd->u.mgs;
+        struct llog_handle *llh;
+        struct system_db *db = NULL;
+        struct list_head *tmp;
+        char logname[64], lov_name[64];
+        char ost_node_uuid[64];
+        char osc_name[64];
+        char uuid[64];
+        char setup_argv[2];
+        char index[16];
+        int rc = 0;
+
+        list_for_each(tmp, &mgs->mgs_system_db_list) {
+                struct system_db *tmp_db;
+                tmp_db = list_entry(tmp, struct system_db, db_list);
+                if (!strcmp(tmp_db->fsname, moi->moi_fullfsname)) {
+                        db = tmp_db;
+                        break;
+                }
+        }
+        if (!db)
+                RETURN(-EINVAL);
+
+        llh = llog_alloc_handle();
+        if (llh == NULL)
+                RETURN(-ENOMEM);
+
+        /* Two phases: 1. writing mds log. 
+                       2. writing client log
+         */
+
+        /*First phase: writing mds log  */
+        sprintf(logname, "%s/mds1", moi->moi_fullfsname);
+
+        rc = mgs_start_record(obd, llh, logname);
+        if (rc) {
+                CERROR("failed to record log %s: %d\n", logname, rc);
+                GOTO(out, rc);
+        }
+        sprintf(ost_node_uuid, "%s_UUID", moi->moi_nodename);
+        sprintf(osc_name, "OSC_%s_%s_MNT_client",
+                db->fsname, moi->moi_ostname);
+
+        rc = record_add_uuid(obd, llh, moi->moi_nid, ost_node_uuid);
+        if (rc) {
+                CERROR("failed to record log(add_uuid) %s: %d\n",
+                        logname, rc);
+                GOTO(out, rc);
+        }
+        sprintf(uuid, "%s_lov_UUID", moi->moi_fullfsname);
+
+        rc = record_attach(obd, llh, osc_name, "osc", uuid);
+        if (rc) {
+                CERROR("failed to record log(attach_uuid) %s: %d\n",
+                        logname, rc);
+                GOTO(out, rc);
+        }
+
+        setup_argv[0] = moi->moi_ostuuid;
+        setup_argv[1] = ost_node_uuid;
+        rc = record_setup(obd, llh, osc_name, 2, setup_argv);
+        if (rc) {
+                CERROR("failed to record log(setup) %s: %d\n",
+                       logname, rc);
+                GOTO(out, rc);
+        }
+
+        sprintf(index, "%d", moi->moi_stripe_index);
+        rc = record_lov_modify_tgts(obd, llh, lov_name, "add",
+                                    moi->moi_ostuuid, index, "1");
+        if (rc) {
+                CERROR("failed to record log(lov_modify_tgts) %s: %d\n",
+                       logname, rc);
+                GOTO(out, rc);
+        }
+
+        rc = mgs_end_record(obd, llh, logname);
+        if (rc) {
+                CERROR("failed to record log %s: %d\n", logname, rc);
+                GOTO(out, rc);
+        }
+
+        /*Second Phase : writing client llog */
+        sprintf(logname, "%s/client", moi->moi_fullfsname);
+
+        rc = mgs_start_record(obd, llh, logname);
+        if (rc) {
+                CERROR("failed to record log %s: %d\n", logname, rc);
+                GOTO(out, rc);
+        }
+
+        sprintf(ost_node_uuid, "%s_UUID", moi->moi_nodename);
+        sprintf(osc_name, "OSC_%s_%s_MNT_client",
+                db->fsname, moi->moi_ostname);
+
+        rc = record_add_uuid(obd, llh, moi->moi_nid, ost_node_uuid);
+        if (rc) {
+                CERROR("failed to record log(add_uuid) %s: %d\n",
+                        logname, rc);
+                GOTO(out, rc);
+        }
+
+        rc = record_attach(obd, llh, osc_name, "osc", uuid);
+        if (rc) {
+                CERROR("failed to record log(attach_uuid) %s: %d\n",
+                       logname, rc);
+                GOTO(out, rc);
+        }
+
+        setup_argv[0] = moi->moi_ostuuid;
+        setup_argv[1] = ost_node_uuid;
+        rc = record_setup(obd, llh, osc_name, 2, setup_argv);
+        if (rc) {
+                CERROR("failed to record log(setup) %s: %d\n",
+                       logname, rc);
+                GOTO(out, rc);
+        }
+
+        sprintf(index, "%d", moi->moi_stripe_index);
+        rc = record_lov_modify_tgts(obd, llh, lov_name, "add",
+                                    moi->moi_ostuuid, index, "1");
+        if (rc) {
+                CERROR("failed to record log(lov_modify_tgts) %s: %d\n",
+                        logname, rc);
+                GOTO(out, rc);
+        }
+
+        rc = mgs_end_record(obd, llh, logname);
+        if (rc) {
+                CERROR("failed to record log %s: %d\n", logname, rc);
+                GOTO(out, rc);
+        }
+out:
+        llog_free_handle(llh);
+        return rc;
+}
+EXPORT_SYMBOL(llog_add_ost);
+
+int llog_add_mds(struct obd_device *obd, struct mgmt_mds_info *mmi)
 {
         struct mgs_obd *mgs = &obd->u.mgs;
         struct llog_handle *llh;
@@ -945,6 +1083,7 @@ out:
         llog_free_handle(llh);
         return rc;
 }
+EXPORT_SYMBOL(llog_add_mds);
 
 int mgmt_handle_mds_add(struct ptlrpc_request *req)
 {