Whamcloud - gitweb
Fixups to handle error recovery when we are out of memory. Some of them
authoradilger <adilger>
Wed, 24 Apr 2002 06:00:47 +0000 (06:00 +0000)
committeradilger <adilger>
Wed, 24 Apr 2002 06:00:47 +0000 (06:00 +0000)
need a bit closer inspection, but should be mostly correct.

lustre/ldlm/ldlm_resource.c
lustre/llite/super.c
lustre/mds/handler.c
lustre/osc/osc_request.c
lustre/ptlrpc/recovd.c

index 33723d7..5e765ee 100644 (file)
@@ -40,45 +40,55 @@ struct ldlm_namespace *ldlm_namespace_find(__u32 id)
 }
 
 /* this must be called with ldlm_lock() held */
-static void res_hash_init(struct ldlm_namespace *ns)
+static int res_hash_init(struct ldlm_namespace *ns)
 {
         struct list_head *res_hash;
         struct list_head *bucket;
 
         if (ns->ns_hash != NULL)
-                return;
+                RETURN(0);
 
         /* FIXME: this memory appears to be leaked */
         OBD_ALLOC(res_hash, sizeof(*res_hash) * RES_HASH_SIZE);
-        if (!res_hash)
+        if (!res_hash) {
                 LBUG();
+                RETURN(-ENOMEM);
+        }
 
         for (bucket = res_hash + RES_HASH_SIZE - 1; bucket >= res_hash;
              bucket--)
                 INIT_LIST_HEAD(bucket);
 
         ns->ns_hash = res_hash;
+
+        return 0;
 }
 
 ldlm_error_t ldlm_namespace_new(struct obd_device *obddev, __u32 id,
                                 struct ldlm_namespace **ns_out)
 {
         struct ldlm_namespace *ns;
+        int rc;
 
         if (ldlm_namespace_find(id))
-                return -ELDLM_NAMESPACE_EXISTS;
+                RETURN(-ELDLM_NAMESPACE_EXISTS);
 
         OBD_ALLOC(ns, sizeof(*ns));
-        if (!ns)
+        if (!ns) {
                 LBUG();
+                RETURN(-ENOMEM);
+        }
 
         ns->ns_id = id;
         ns->ns_obddev = obddev;
         INIT_LIST_HEAD(&ns->ns_root_list);
 
+        rc = res_hash_init(ns);
+        if (rc) {
+                OBD_FREE(ns, sizeof(*ns));
+                RETURN(rc);
+        }
         list_add(&ns->ns_link, &ldlm_namespaces);
-
-        res_hash_init(ns); 
         atomic_set(&ns->ns_refcount, 0);
 
         *ns_out = ns;
index e08e1cb..ce5d130 100644 (file)
@@ -393,7 +393,7 @@ struct super_operations ll_super_operations =
         read_inode2: ll_read_inode2,
         delete_inode: ll_delete_inode,
         put_super: ll_put_super,
-        // statfs: ll_statfs
+        statfs: ll_statfs
 };
 
 struct file_system_type lustre_lite_fs_type = {
index 2c0a159..d5ff2ea 100644 (file)
@@ -543,7 +543,7 @@ static int mds_prep(struct obd_device *obddev)
 
         rc = ptlrpc_start_thread(obddev, mds->mds_service, "lustre_mds");
         if (rc) {
-                CERROR("cannot start thread\n");
+                CERROR("cannot start thread: rc = %d\n", rc);
                 GOTO(err_svc, rc);
         }
 
index 152f886..aca92f1 100644 (file)
@@ -520,7 +520,7 @@ int osc_brw_write(struct obd_conn *conn, obd_count num_oa, struct obdo **oa,
                 GOTO(out, rc = -EINVAL);
 
         if (request->rq_repmsg->buflens[1] != pages * sizeof(struct niobuf)) {
-                CERROR("buffer length wrong (%d vs. %ld)\n",
+                CERROR("buffer length wrong (%d vs. %d)\n",
                        request->rq_repmsg->buflens[1],
                        pages * sizeof(struct niobuf));
                 GOTO(out, rc = -EINVAL);
index 4a84101..579b122 100644 (file)
@@ -60,13 +60,17 @@ static int connmgr_upcall(void)
         return call_usermodehelper(argv[0], argv, envp);
 }
 
-static void connmgr_unpack_body(struct ptlrpc_request *req)
+static int connmgr_unpack_body(struct ptlrpc_request *req)
 {
         struct connmgr_body *b = lustre_msg_buf(req->rq_repmsg, 0);
-        if (b == NULL)
+        if (b == NULL) {
                 LBUG();
+                RETURN(-EINVAL);
+        }
 
         b->generation = NTOH__u32(b->generation);
+
+        return 0;
 }
 
 int connmgr_connect(struct recovd_obd *recovd, struct ptlrpc_connection *conn)
@@ -80,6 +84,7 @@ int connmgr_connect(struct recovd_obd *recovd, struct ptlrpc_connection *conn)
         if (!recovd) {
                 CERROR("no manager\n");
                 LBUG();
+                GOTO(out, rc = -EINVAL);
         }
         cl = recovd->recovd_client;
 
@@ -97,7 +102,9 @@ int connmgr_connect(struct recovd_obd *recovd, struct ptlrpc_connection *conn)
         rc = ptlrpc_queue_wait(req);
         rc = ptlrpc_check_status(req, rc);
         if (!rc) {
-                connmgr_unpack_body(req);
+                rc = connmgr_unpack_body(req);
+                if (rc)
+                        GOTO(out_free, rc);
                 body = lustre_msg_buf(req->rq_repmsg, 0);
                 CDEBUG(D_NET, "remote generation: %o\n", body->generation);
                 conn->c_level = LUSTRE_CONN_CON;
@@ -105,10 +112,10 @@ int connmgr_connect(struct recovd_obd *recovd, struct ptlrpc_connection *conn)
                 conn->c_remote_token = body->conn_token;
         }
 
+out_free:
         ptlrpc_free_req(req);
-        EXIT;
- out:
-        return rc;
+out:
+        RETURN(rc);
 }
 
 static int connmgr_handle_connect(struct ptlrpc_request *req)
@@ -125,7 +132,11 @@ static int connmgr_handle_connect(struct ptlrpc_request *req)
         }
 
         body = lustre_msg_buf(req->rq_reqmsg, 0);
-        connmgr_unpack_body(req);
+        rc = connmgr_unpack_body(req);
+        if (rc) {
+                req->rq_status = rc;
+                RETURN(0);
+        }
 
         req->rq_connection->c_remote_conn = body->conn;
         req->rq_connection->c_remote_token = body->conn_token;