Whamcloud - gitweb
Merge from posix_stable.
authoradilger <adilger>
Thu, 20 Jun 2002 18:27:12 +0000 (18:27 +0000)
committeradilger <adilger>
Thu, 20 Jun 2002 18:27:12 +0000 (18:27 +0000)
lustre/ldlm/ldlm_lockd.c
lustre/llite/dir.c

index a149d3f..8ecb2c9 100644 (file)
@@ -356,61 +356,46 @@ static int ldlm_iocontrol(long cmd, struct obd_conn *conn, int len, void *karg,
         return err;
 }
 
+#define LDLM_NUM_THREADS        8
+
 static int ldlm_setup(struct obd_device *obddev, obd_count len, void *buf)
 {
         struct ldlm_obd *ldlm = &obddev->u.ldlm;
-        int err;
+        int rc;
+        int i;
         ENTRY;
 
+        MOD_INC_USE_COUNT;
         ldlm->ldlm_service =
                 ptlrpc_init_svc(64 * 1024, LDLM_REQUEST_PORTAL,
                                 LDLM_REPLY_PORTAL, "self", lustre_handle);
-        if (!ldlm->ldlm_service)
-                LBUG();
-
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
-        }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
-        }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
-        }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
-        }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
+        if (!ldlm->ldlm_service) {
                 LBUG();
+                GOTO(out_dec, rc = -ENOMEM);
         }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
-        }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
-        }
-        err = ptlrpc_start_thread(obddev, ldlm->ldlm_service, "lustre_dlm");
-        if (err) {
-                CERROR("cannot start thread\n");
-                LBUG();
+
+        for (i = 0; i < LDLM_NUM_THREADS; i++) {
+                rc = ptlrpc_start_thread(obddev, ldlm->ldlm_service,
+                                         "lustre_dlm");
+                /* XXX We could just continue if we had started at least
+                 *     a few threads here.
+                 */
+                if (rc) {
+                        CERROR("cannot start LDLM thread #%d: rc %d\n", i, rc);
+                        LBUG();
+                        GOTO(out_thread, rc);
+                }
         }
 
-        MOD_INC_USE_COUNT;
         RETURN(0);
+
+out_thread:
+        ptlrpc_stop_all_threads(ldlm->ldlm_service);
+        rpc_unregister_service(ldlm->ldlm_service);
+        OBD_FREE(ldlm->ldlm_service, sizeof(*ldlm->ldlm_service));
+out_dec:
+        MOD_DEC_USE_COUNT;
+        return rc;
 }
 
 static int ldlm_cleanup(struct obd_device *obddev)
index ffb3696..6f2e813 100644 (file)
@@ -347,7 +347,7 @@ static inline void ext2_set_de_type(ext2_dirent *de, struct inode *inode)
 }
 
 int
-new_ll_readdir (struct file * filp, void * dirent, filldir_t filldir)
+ll_readdir (struct file * filp, void * dirent, filldir_t filldir)
 {
         loff_t pos = filp->f_pos;
         struct inode *inode = filp->f_dentry->d_inode;
@@ -710,5 +710,5 @@ not_empty:
 
 struct file_operations ll_dir_operations = {
         read: generic_read_dir,
-        readdir: new_ll_readdir
+        readdir: ll_readdir
 };