- cfs_sema_init(&ost->ost_health_sem, 1);
-
- if (oss_num_threads) {
- /* If oss_num_threads is set, it is the min and the max. */
- if (oss_num_threads > OSS_THREADS_MAX)
- oss_num_threads = OSS_THREADS_MAX;
- if (oss_num_threads < OSS_THREADS_MIN)
- oss_num_threads = OSS_THREADS_MIN;
- oss_max_threads = oss_min_threads = oss_num_threads;
- } else {
- /* Base min threads on memory and cpus */
- oss_min_threads =
- cfs_num_possible_cpus() * CFS_NUM_CACHEPAGES >>
- (27 - CFS_PAGE_SHIFT);
- if (oss_min_threads < OSS_THREADS_MIN)
- oss_min_threads = OSS_THREADS_MIN;
- /* Insure a 4x range for dynamic threads */
- if (oss_min_threads > OSS_THREADS_MAX / 4)
- oss_min_threads = OSS_THREADS_MAX / 4;
- oss_max_threads = min(OSS_THREADS_MAX, oss_min_threads * 4 + 1);
- }
-
- ost->ost_service =
- ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
- OST_MAXREPSIZE, OST_REQUEST_PORTAL,
- OSC_REPLY_PORTAL, OSS_SERVICE_WATCHDOG_FACTOR,
- ost_handle, LUSTRE_OSS_NAME,
- obd->obd_proc_entry, target_print_req,
- oss_min_threads, oss_max_threads,
- "ll_ost", LCT_DT_THREAD, NULL);
- if (ost->ost_service == NULL) {
- CERROR("failed to start service\n");
- GOTO(out_lprocfs, rc = -ENOMEM);
- }
-
- rc = ptlrpc_start_threads(ost->ost_service);
- if (rc)
- GOTO(out_service, rc = -EINVAL);
-
- if (oss_num_create_threads) {
- if (oss_num_create_threads > OSS_MAX_CREATE_THREADS)
- oss_num_create_threads = OSS_MAX_CREATE_THREADS;
- if (oss_num_create_threads < OSS_MIN_CREATE_THREADS)
- oss_num_create_threads = OSS_MIN_CREATE_THREADS;
- oss_min_create_threads = oss_max_create_threads =
- oss_num_create_threads;
- } else {
- oss_min_create_threads = OSS_MIN_CREATE_THREADS;
- oss_max_create_threads = OSS_MAX_CREATE_THREADS;
- }
-
- ost->ost_create_service =
- ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
- OST_MAXREPSIZE, OST_CREATE_PORTAL,
- OSC_REPLY_PORTAL, OSS_SERVICE_WATCHDOG_FACTOR,
- ost_handle, "ost_create",
- obd->obd_proc_entry, target_print_req,
- oss_min_create_threads, oss_max_create_threads,
- "ll_ost_creat", LCT_DT_THREAD, NULL);
- if (ost->ost_create_service == NULL) {
- CERROR("failed to start OST create service\n");
- GOTO(out_service, rc = -ENOMEM);
- }
-
- rc = ptlrpc_start_threads(ost->ost_create_service);
- if (rc)
- GOTO(out_create, rc = -EINVAL);
-
- ost->ost_io_service =
- ptlrpc_init_svc(OST_NBUFS, OST_BUFSIZE, OST_MAXREQSIZE,
- OST_MAXREPSIZE, OST_IO_PORTAL,
- OSC_REPLY_PORTAL, OSS_SERVICE_WATCHDOG_FACTOR,
- ost_handle, "ost_io",
- obd->obd_proc_entry, target_print_req,
- oss_min_threads, oss_max_threads,
- "ll_ost_io", LCT_DT_THREAD, ost_hpreq_handler);
- if (ost->ost_io_service == NULL) {
- CERROR("failed to start OST I/O service\n");
- GOTO(out_create, rc = -ENOMEM);
- }
-
- ost->ost_io_service->srv_init = ost_thread_init;
- ost->ost_io_service->srv_done = ost_thread_done;
- ost->ost_io_service->srv_cpu_affinity = 1;
- rc = ptlrpc_start_threads(ost->ost_io_service);
- if (rc)
- GOTO(out_io, rc = -EINVAL);
+ mutex_init(&ost->ost_health_mutex);
+
+ svc_conf = (typeof(svc_conf)) {
+ .psc_name = LUSTRE_OSS_NAME,
+ .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
+ .psc_buf = {
+ .bc_nbufs = OST_NBUFS,
+ .bc_buf_size = OST_BUFSIZE,
+ .bc_req_max_size = OST_MAXREQSIZE,
+ .bc_rep_max_size = OST_MAXREPSIZE,
+ .bc_req_portal = OST_REQUEST_PORTAL,
+ .bc_rep_portal = OSC_REPLY_PORTAL,
+ },
+ .psc_thr = {
+ .tc_thr_name = "ll_ost",
+ .tc_thr_factor = OSS_THR_FACTOR,
+ .tc_nthrs_init = OSS_NTHRS_INIT,
+ .tc_nthrs_base = OSS_NTHRS_BASE,
+ .tc_nthrs_max = OSS_NTHRS_MAX,
+ .tc_nthrs_user = oss_num_threads,
+ .tc_cpu_affinity = 1,
+ .tc_ctx_tags = LCT_DT_THREAD,
+ },
+ .psc_cpt = {
+ .cc_pattern = oss_cpts,
+ },
+ .psc_ops = {
+ .so_req_handler = ost_handle,
+ .so_req_printer = target_print_req,
+ .so_hpreq_handler = ptlrpc_hpreq_handler,
+ },
+ };
+ ost->ost_service = ptlrpc_register_service(&svc_conf,
+ obd->obd_proc_entry);
+ if (IS_ERR(ost->ost_service)) {
+ rc = PTR_ERR(ost->ost_service);
+ CERROR("failed to start service: %d\n", rc);
+ GOTO(out_lprocfs, rc);
+ }
+
+ memset(&svc_conf, 0, sizeof(svc_conf));
+ svc_conf = (typeof(svc_conf)) {
+ .psc_name = "ost_create",
+ .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
+ .psc_buf = {
+ .bc_nbufs = OST_NBUFS,
+ .bc_buf_size = OST_BUFSIZE,
+ .bc_req_max_size = OST_MAXREQSIZE,
+ .bc_rep_max_size = OST_MAXREPSIZE,
+ .bc_req_portal = OST_CREATE_PORTAL,
+ .bc_rep_portal = OSC_REPLY_PORTAL,
+ },
+ .psc_thr = {
+ .tc_thr_name = "ll_ost_create",
+ .tc_thr_factor = OSS_CR_THR_FACTOR,
+ .tc_nthrs_init = OSS_CR_NTHRS_INIT,
+ .tc_nthrs_base = OSS_CR_NTHRS_BASE,
+ .tc_nthrs_max = OSS_CR_NTHRS_MAX,
+ .tc_nthrs_user = oss_num_create_threads,
+ .tc_cpu_affinity = 1,
+ .tc_ctx_tags = LCT_DT_THREAD,
+ },
+ .psc_cpt = {
+ .cc_pattern = oss_cpts,
+ },
+ .psc_ops = {
+ .so_req_handler = ost_handle,
+ .so_req_printer = target_print_req,
+ },
+ };
+ ost->ost_create_service = ptlrpc_register_service(&svc_conf,
+ obd->obd_proc_entry);
+ if (IS_ERR(ost->ost_create_service)) {
+ rc = PTR_ERR(ost->ost_create_service);
+ CERROR("failed to start OST create service: %d\n", rc);
+ GOTO(out_service, rc);
+ }
+
+ mask = cfs_cpt_table->ctb_nodemask;
+ /* event CPT feature is disabled in libcfs level by set partition
+ * number to 1, we still want to set node affinity for io service */
+ if (cfs_cpt_number(cfs_cpt_table) == 1 && nodes_weight(*mask) > 1) {
+ int cpt = 0;
+ int i;
+
+ ost_io_cptable = cfs_cpt_table_alloc(nodes_weight(*mask));
+ for_each_node_mask(i, *mask) {
+ if (ost_io_cptable == NULL) {
+ CWARN("OSS failed to create CPT table\n");
+ break;
+ }
+
+ rc = cfs_cpt_set_node(ost_io_cptable, cpt++, i);
+ if (!rc) {
+ CWARN("OSS Failed to set node %d for"
+ "IO CPT table\n", i);
+ cfs_cpt_table_free(ost_io_cptable);
+ ost_io_cptable = NULL;
+ break;
+ }
+ }
+ }
+
+ memset(&svc_conf, 0, sizeof(svc_conf));
+ svc_conf = (typeof(svc_conf)) {
+ .psc_name = "ost_io",
+ .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
+ .psc_buf = {
+ .bc_nbufs = OST_NBUFS,
+ .bc_buf_size = OST_IO_BUFSIZE,
+ .bc_req_max_size = OST_IO_MAXREQSIZE,
+ .bc_rep_max_size = OST_IO_MAXREPSIZE,
+ .bc_req_portal = OST_IO_PORTAL,
+ .bc_rep_portal = OSC_REPLY_PORTAL,
+ },
+ .psc_thr = {
+ .tc_thr_name = "ll_ost_io",
+ .tc_thr_factor = OSS_THR_FACTOR,
+ .tc_nthrs_init = OSS_NTHRS_INIT,
+ .tc_nthrs_base = OSS_NTHRS_BASE,
+ .tc_nthrs_max = OSS_NTHRS_MAX,
+ .tc_nthrs_user = oss_num_threads,
+ .tc_cpu_affinity = 1,
+ .tc_ctx_tags = LCT_DT_THREAD,
+ },
+ .psc_cpt = {
+ .cc_cptable = ost_io_cptable,
+ .cc_pattern = ost_io_cptable == NULL ?
+ oss_io_cpts : NULL,
+ },
+ .psc_ops = {
+ .so_thr_init = ost_io_thread_init,
+ .so_thr_done = ost_io_thread_done,
+ .so_req_handler = ost_handle,
+ .so_hpreq_handler = ost_io_hpreq_handler,
+ .so_req_printer = target_print_req,
+ },
+ };
+ ost->ost_io_service = ptlrpc_register_service(&svc_conf,
+ obd->obd_proc_entry);
+ if (IS_ERR(ost->ost_io_service)) {
+ rc = PTR_ERR(ost->ost_io_service);
+ CERROR("failed to start OST I/O service: %d\n", rc);
+ ost->ost_io_service = NULL;
+ GOTO(out_create, rc);
+ }
+
+ memset(&svc_conf, 0, sizeof(svc_conf));
+ svc_conf = (typeof(svc_conf)) {
+ .psc_name = "ost_seq",
+ .psc_watchdog_factor = OSS_SERVICE_WATCHDOG_FACTOR,
+ .psc_buf = {
+ .bc_nbufs = OST_NBUFS,
+ .bc_buf_size = OST_BUFSIZE,
+ .bc_req_max_size = OST_MAXREQSIZE,
+ .bc_rep_max_size = OST_MAXREPSIZE,
+ .bc_req_portal = SEQ_DATA_PORTAL,
+ .bc_rep_portal = OSC_REPLY_PORTAL,
+ },
+ .psc_thr = {
+ .tc_thr_name = "ll_ost_seq",
+ .tc_thr_factor = OSS_CR_THR_FACTOR,
+ .tc_nthrs_init = OSS_CR_NTHRS_INIT,
+ .tc_nthrs_base = OSS_CR_NTHRS_BASE,
+ .tc_nthrs_max = OSS_CR_NTHRS_MAX,
+ .tc_nthrs_user = oss_num_create_threads,
+ .tc_cpu_affinity = 1,
+ .tc_ctx_tags = LCT_DT_THREAD,
+ },
+
+ .psc_cpt = {
+ .cc_pattern = oss_cpts,
+ },
+ .psc_ops = {
+ .so_req_handler = ost_handle,
+ .so_req_printer = target_print_req,
+ .so_hpreq_handler = NULL,
+ },
+ };
+ ost->ost_seq_service = ptlrpc_register_service(&svc_conf,
+ obd->obd_proc_entry);
+ if (IS_ERR(ost->ost_seq_service)) {
+ rc = PTR_ERR(ost->ost_seq_service);
+ CERROR("failed to start OST seq service: %d\n", rc);
+ ost->ost_seq_service = NULL;
+ GOTO(out_io, rc);
+ }