Whamcloud - gitweb
A patch only a mother could love to notify LOVs when OSCs are disabled due to
authorshaver <shaver>
Thu, 24 Oct 2002 00:32:56 +0000 (00:32 +0000)
committershaver <shaver>
Thu, 24 Oct 2002 00:32:56 +0000 (00:32 +0000)
OST failure or partition.

Remember to re-enable it in your upcall, after reconnecting!

lustre/include/linux/obd.h
lustre/llite/recover.c
lustre/lov/lov_obd.c
lustre/osc/osc_request.c

index b6abe9d..e5af36b 100644 (file)
@@ -109,8 +109,14 @@ struct client_obd {
         obd_uuid_t           cl_target_uuid; /* XXX -> lustre_name */
         int                  cl_max_mds_easize;
         int                  cl_max_ost_easize;
+        struct obd_device   *cl_containing_lov;
 };
 
+#define IOC_OSC_TYPE         'h'
+#define IOC_OSC_MIN_NR       20
+#define IOC_OSC_REGISTER_LOV _IOWR('h', 20, struct obd_device *)
+#define IOC_OSC_MAX_NR       50
+
 struct mds_obd {
         struct ptlrpc_service *mds_service;
 
@@ -192,7 +198,7 @@ struct lov_tgt_desc {
 struct lov_obd {
         spinlock_t lov_lock;
         struct obd_device *mdcobd;
       struct lov_desc desc;
+ struct lov_desc desc;
         int bufsize;
         int refcount;
         struct lov_tgt_desc *tgts;
index d21954c..a7d4228 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/lustre_ha.h>
 #include <linux/lustre_dlm.h>
 #include <linux/lustre_idl.h>
+#include <linux/obd_lov.h> /* for IOC_LOV_SET_OSC_ACTIVE */
 
 static int ll_retry_recovery(struct ptlrpc_connection *conn)
 {
@@ -25,8 +26,8 @@ static void abort_inflight_for_import(struct obd_import *imp)
         struct list_head *tmp, *n;
 
         /* Make sure that no new requests get processed for this import.
-         * ptlrpc_queue_wait must (and does) hold c_lock while testing this flags and
-         * then putting requests on sending_head or delayed_head.
+         * ptlrpc_queue_wait must (and does) hold c_lock while testing this
+         * flags and then putting requests on sending_head or delayed_head.
          */
         spin_lock(&imp->imp_connection->c_lock);
         imp->imp_flags |= IMP_INVALID;
@@ -68,10 +69,12 @@ static void abort_inflight_for_import(struct obd_import *imp)
         }
 }
 
-static void reconnect_ost(struct obd_import *imp)
+static void prepare_ost(struct obd_import *imp)
 {
+        int rc;
         struct ldlm_namespace *ns = imp->imp_obd->obd_namespace;
-        
+        struct obd_device *notify_obd = imp->imp_obd->u.cli.cl_containing_lov;
+
         CDEBUG(D_HA, "invalidating all locks for OST imp %p (to %s):\n",
                imp, imp->imp_connection->c_remote_uuid);
         ldlm_namespace_dump(ns);
@@ -79,6 +82,46 @@ static void reconnect_ost(struct obd_import *imp)
 
         abort_inflight_for_import(imp);
 
+        /* How gross is _this_? */
+        if (!list_empty(&notify_obd->obd_exports)) {
+                struct lustre_handle fakeconn;
+                struct obd_ioctl_data ioc_data;
+                struct obd_export *exp = 
+                        list_entry(&notify_obd->obd_exports.next, 
+                                   struct obd_export, exp_obd_chain);
+                fakeconn.addr = (__u64)(unsigned long)exp;
+                fakeconn.cookie = exp->exp_cookie;
+                ioc_data.ioc_inlbuf1 = imp->imp_obd->obd_uuid;
+                ioc_data.ioc_offset = 0; /* inactive */
+                rc = obd_iocontrol(IOC_LOV_SET_OSC_ACTIVE, &fakeconn,
+                                   sizeof ioc_data, &ioc_data, NULL);
+                if (rc) 
+                        CERROR("disabling %s on LOV %p/%s: %d\n", 
+                               imp->imp_obd->obd_uuid, notify_obd,
+                               notify_obd->obd_uuid, rc);
+        } else {
+                CDEBUG(D_HA, "No exports for obd %p/%s, can't notify about %p\n",
+                       notify_obd, notify_obd->obd_uuid, imp->imp_obd->obd_uuid);
+        }
+}
+
+static int ll_prepare_recovery(struct ptlrpc_connection *conn)
+{
+        struct list_head *tmp;
+
+        list_for_each(tmp, &conn->c_imports) {
+                struct obd_import *imp = list_entry(tmp, struct obd_import,
+                                                    imp_chain);
+
+                if (imp->imp_obd->obd_type->typ_ops->o_brw)
+                        prepare_ost(imp);
+        }
+
+        return ptlrpc_run_recovery_upcall(conn);
+}
+
+static void reconnect_ost(struct obd_import *imp)
+{
         (void)ptlrpc_reconnect_import(imp, OST_CONNECT);
 }
 
@@ -136,7 +179,7 @@ int ll_recover(struct recovd_data *rd, int phase)
 
         switch (phase) {
             case PTLRPC_RECOVD_PHASE_PREPARE:
-                RETURN(ptlrpc_run_recovery_upcall(conn));
+                RETURN(ll_prepare_recovery(conn));
             case PTLRPC_RECOVD_PHASE_RECOVER:
                 RETURN(ll_reconnect(conn));
             case PTLRPC_RECOVD_PHASE_FAILURE:
index 0617614..41f5ad8 100644 (file)
@@ -143,6 +143,13 @@ static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
                                uuidarray[i], rc);
                         GOTO(out_disc, rc);
                 }
+                rc = obd_iocontrol(IOC_OSC_REGISTER_LOV, &lov->tgts[i].conn,
+                                   sizeof(struct obd_device *), obd, NULL); 
+                if (rc) {
+                        CERROR("Target %s REGISTER_LOV error %d\n",
+                               uuidarray[i], rc);
+                        GOTO(out_disc, rc);
+                }
                 desc->ld_active_tgt_count++;
                 lov->tgts[i].active = 1;
         }
@@ -1150,7 +1157,9 @@ static int lov_iocontrol(long cmd, struct lustre_handle *conn, int len,
                 rc = lov_set_osc_active(lov,data->ioc_inlbuf1,data->ioc_offset);
                 break;
         default:
-                rc = -ENOTTY;
+                if (lov->desc.ld_tgt_count == 0)
+                        RETURN(-ENOTTY);
+                rc = 0;
                 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
                         int err = obd_iocontrol(cmd, &lov->tgts[i].conn,
                                                 len, data, NULL);
index c6ac09d..64a1e26 100644 (file)
@@ -729,13 +729,6 @@ static int osc_iocontrol(long cmd, struct lustre_handle *conn, int len,
         int err = 0;
         ENTRY;
 
-        if (_IOC_TYPE(cmd) != IOC_LDLM_TYPE ||
-            _IOC_NR(cmd) < IOC_LDLM_MIN_NR || _IOC_NR(cmd) > IOC_LDLM_MAX_NR) {
-                CDEBUG(D_IOCTL, "invalid ioctl (type %ld, nr %ld, size %ld)\n",
-                       _IOC_TYPE(cmd), _IOC_NR(cmd), _IOC_SIZE(cmd));
-                RETURN(-EINVAL);
-        }
-
         switch (cmd) {
         case IOC_LDLM_TEST: {
                 err = ldlm_test(obddev, conn);
@@ -784,8 +777,15 @@ static int osc_iocontrol(long cmd, struct lustre_handle *conn, int len,
                 CERROR("-- done err %d\n", err);
                 GOTO(out, err);
         }
+        case IOC_OSC_REGISTER_LOV: {
+                if (obddev->u.cli.cl_containing_lov)
+                        GOTO(out, err = -EALREADY);
+                obddev->u.cli.cl_containing_lov = (struct obd_device *)karg;
+                GOTO(out, err);
+        }
+            
         default:
-                GOTO(out, err = -EINVAL);
+                GOTO(out, err = -ENOTTY);
         }
 out:
         return err;