Whamcloud - gitweb
mdc_ost_add mdc_ost_del
authorlincent <lincent>
Thu, 10 Nov 2005 18:30:12 +0000 (18:30 +0000)
committerlincent <lincent>
Thu, 10 Nov 2005 18:30:12 +0000 (18:30 +0000)
lustre/mgc/mgc_request.c
lustre/ptlrpc/pack_generic.c
lustre/ptlrpc/ptlrpc_module.c

index 21b5136..f626fec 100644 (file)
 #endif
 
 #include <linux/obd_class.h>
-//#include <linux/lustre_mds.h>
 #include <linux/lustre_dlm.h>
 #include <linux/lustre_log.h>
 #include <linux/lustre_fsfilt.h>
 #include <linux/lustre_disk.h>
+//#include <linux/lustre_mgs.h>
 
 #include "mgc_internal.h"
-          
+
+int mgc_ost_add(struct obd_export *exp, struct ost_info *oinfo,
+                struct mds_info *minfo)
+{
+        struct ptlrpc_request *req;
+        struct ost_info *req_oinfo;
+        int size = sizeof(*req_oinfo);
+        int rep_size[2] = { sizeof(*oinfo),
+                            sizeof(*minfo)};
+        int rc;
+        ENTRY;
+
+        req = ptlrpc_prep_req(class_exp2cliimp(exp),
+                              MGS_OST_ADD, 1, &size, NULL);
+        if (!req)
+                RETURN(rc = -ENOMEM);
+
+        req_oinfo = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_oinfo));
+        memcpy(req_oinfo, oinfo, sizeof(*req_oinfo));
+
+        req->rq_replen = lustre_msg_size(2, rep_size);
+
+        rc = ptlrpc_queue_wait(req);
+        if (!rc) {
+                struct ost_info *rep_oinfo;
+                struct mds_info *rep_minfo;
+                rep_oinfo = lustre_swab_repbuf(req, 0, sizeof(*rep_oinfo),
+                                               lustre_swab_ost_info);
+                rep_minfo = lustre_swab_repbuf(req, 1, sizeof(*rep_minfo),
+                                               lustre_swab_mds_info);
+                if (rep_oinfo->osi_stripe_index == -1) {
+                        CERROR ("Register failed\n");
+                        GOTO (out, rc = -EINVAL);
+                }
+                CERROR("register OK.(index = %d)\n",
+                        rep_oinfo->osi_stripe_index);
+                memcpy(oinfo, rep_oinfo, sizeof(*oinfo));
+                memcpy(minfo, rep_minfo, sizeof(*minfo));
+        }
+
+out:
+        ptlrpc_req_finished(req);
+
+        RETURN(rc);
+}
+EXPORT_SYMBOL(mgc_ost_add);
+
+int mgc_ost_del(struct obd_export *exp, struct ost_info *oinfo)
+{
+        struct ptlrpc_request *req;
+        struct ost_info *req_oinfo;
+        int size = sizeof(*req_oinfo);
+        int rc;
+        ENTRY;
+
+        req = ptlrpc_prep_req(class_exp2cliimp(exp), MGS_OST_DEL,
+                              1, &size, NULL);
+        if (!req)
+                RETURN(rc = -ENOMEM);
+
+        req_oinfo = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*req_oinfo));
+        memcpy(req_oinfo, oinfo, sizeof(*req_oinfo));
+
+        rc = ptlrpc_queue_wait(req);
+        if (!rc)
+                CERROR("unregister OK.(old index = %d)\n", 
+                        oinfo->osi_stripe_index);
+        else {
+                CERROR ("Unregister failed\n");
+                GOTO (out, rc = -EINVAL);
+        }
+out:
+        ptlrpc_req_finished(req);
+
+        RETURN(rc);
+}
+EXPORT_SYMBOL(mgc_ost_del);
+
 static int mgc_fs_setup(struct obd_device *obd, struct super_block *sb, 
                         struct vfsmount *mnt)
 {
index 1abbdab..b51c01f 100644 (file)
@@ -556,6 +556,18 @@ void lustre_swab_mds_body (struct mds_body *b)
         __swab32s (&b->padding_4);
 }
 
+void lustre_swab_ost_info(struct ost_info *oinfo)
+{
+        __swab64s(&oinfo->osi_nid);
+        __swab32s(&oinfo->osi_nal);
+        __swab32s(&oinfo->osi_stripe_index);
+}
+
+void lustre_swab_mds_info(struct mds_info *minfo)
+{
+        __swab64s(&minfo->mds_nid);
+}
+
 static void lustre_swab_obd_dqinfo (struct obd_dqinfo *i)
 {
         __swab64s (&i->dqi_bgrace);
index 35d91ee..a0c2421 100644 (file)
@@ -186,6 +186,8 @@ EXPORT_SYMBOL(lustre_swab_ptlbd_op);
 EXPORT_SYMBOL(lustre_swab_ptlbd_niob);
 EXPORT_SYMBOL(lustre_swab_ptlbd_rsp);
 EXPORT_SYMBOL(lustre_swab_qdata);
+EXPORT_SYMBOL(lustre_swab_ost_info);
+EXPORT_SYMBOL(lustre_swab_mds_info);
 
 /* recover.c */
 EXPORT_SYMBOL(ptlrpc_run_recovery_over_upcall);