Whamcloud - gitweb
LU-13326 mds: remove MDS_SETATTR_PORTAL and service
[fs/lustre-release.git] / lustre / mdt / mdt_mds.c
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 only,
8  * as published by the Free Software Foundation.
9
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License version 2 for more details.  A copy is
14  * included in the COPYING file that accompanied this code.
15
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * GPL HEADER END
21  */
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Use is subject to license terms.
25  *
26  * Copyright (c) 2013, 2017, Intel Corporation.
27  */
28 /*
29  * This file is part of Lustre, http://www.lustre.org/
30  *
31  * lustre/mdt/mdt_mds.c
32  *
33  * Lustre Metadata Service Layer
34  *
35  * Author: Di Wang <di.wang@whamcloud.com>
36  **/
37
38 #define DEBUG_SUBSYSTEM S_MDS
39
40 #include <linux/module.h>
41
42 #include <obd_support.h>
43 /* struct ptlrpc_request */
44 #include <lustre_net.h>
45 /* struct obd_export */
46 #include <lustre_export.h>
47 /* struct obd_device */
48 #include <obd.h>
49 /* lu2dt_dev() */
50 #include <dt_object.h>
51 #include <lustre_mds.h>
52 #include "mdt_internal.h"
53 #include <lustre_quota.h>
54 #include <lustre_acl.h>
55 #include <uapi/linux/lustre/lustre_param.h>
56
57 struct mds_device {
58         /* super-class */
59         struct md_device         mds_md_dev;
60         struct ptlrpc_service   *mds_regular_service;
61         struct ptlrpc_service   *mds_readpage_service;
62         struct ptlrpc_service   *mds_out_service;
63         struct ptlrpc_service   *mds_mdsc_service;
64         struct ptlrpc_service   *mds_mdss_service;
65         struct ptlrpc_service   *mds_fld_service;
66         struct ptlrpc_service   *mds_io_service;
67         struct mutex             mds_health_mutex;
68 };
69
70 /*
71  *  * Initialized in mds_mod_init().
72  *   */
73 static unsigned long mds_num_threads;
74 module_param(mds_num_threads, ulong, 0444);
75 MODULE_PARM_DESC(mds_num_threads, "number of MDS service threads to start");
76
77 static unsigned int mds_cpu_bind = 1;
78 module_param(mds_cpu_bind, uint, 0444);
79 MODULE_PARM_DESC(mds_cpu_bind,
80                  "bind MDS threads to particular CPU partitions");
81
82 int mds_max_io_threads = 512;
83 module_param(mds_max_io_threads, int, 0444);
84 MODULE_PARM_DESC(mds_max_io_threads,
85                  "maximum number of MDS IO service threads");
86
87 static unsigned int mds_io_cpu_bind = 1;
88 module_param(mds_io_cpu_bind, uint, 0444);
89 MODULE_PARM_DESC(mds_io_cpu_bind,
90                  "bind MDS IO threads to particular CPU partitions");
91
92 static char *mds_io_num_cpts;
93 module_param(mds_io_num_cpts, charp, 0444);
94 MODULE_PARM_DESC(mds_io_num_cpts,
95                  "CPU partitions MDS IO threads should run on");
96
97 static struct cfs_cpt_table *mdt_io_cptable;
98
99 static char *mds_num_cpts;
100 module_param(mds_num_cpts, charp, 0444);
101 MODULE_PARM_DESC(mds_num_cpts, "CPU partitions MDS threads should run on");
102
103 static unsigned long mds_rdpg_num_threads;
104 module_param(mds_rdpg_num_threads, ulong, 0444);
105 MODULE_PARM_DESC(mds_rdpg_num_threads,
106                  "number of MDS readpage service threads to start");
107
108 static unsigned int mds_rdpg_cpu_bind = 1;
109 module_param(mds_rdpg_cpu_bind, uint, 0444);
110 MODULE_PARM_DESC(mds_rdpg_cpu_bind,
111                  "bind MDS readpage threads to particular CPU partitions");
112
113 static char *mds_rdpg_num_cpts;
114 module_param(mds_rdpg_num_cpts, charp, 0444);
115 MODULE_PARM_DESC(mds_rdpg_num_cpts,
116                  "CPU partitions MDS readpage threads should run on");
117
118 /* device init/fini methods */
119 static void mds_stop_ptlrpc_service(struct mds_device *m)
120 {
121         ENTRY;
122
123         mutex_lock(&m->mds_health_mutex);
124         if (m->mds_regular_service != NULL) {
125                 ptlrpc_unregister_service(m->mds_regular_service);
126                 m->mds_regular_service = NULL;
127         }
128         if (m->mds_readpage_service != NULL) {
129                 ptlrpc_unregister_service(m->mds_readpage_service);
130                 m->mds_readpage_service = NULL;
131         }
132         if (m->mds_out_service != NULL) {
133                 ptlrpc_unregister_service(m->mds_out_service);
134                 m->mds_out_service = NULL;
135         }
136         if (m->mds_mdsc_service != NULL) {
137                 ptlrpc_unregister_service(m->mds_mdsc_service);
138                 m->mds_mdsc_service = NULL;
139         }
140         if (m->mds_mdss_service != NULL) {
141                 ptlrpc_unregister_service(m->mds_mdss_service);
142                 m->mds_mdss_service = NULL;
143         }
144         if (m->mds_fld_service != NULL) {
145                 ptlrpc_unregister_service(m->mds_fld_service);
146                 m->mds_fld_service = NULL;
147         }
148         if (m->mds_io_service != NULL) {
149                 ptlrpc_unregister_service(m->mds_io_service);
150                 m->mds_io_service = NULL;
151         }
152         mutex_unlock(&m->mds_health_mutex);
153
154         if (mdt_io_cptable != NULL) {
155                 cfs_cpt_table_free(mdt_io_cptable);
156                 mdt_io_cptable = NULL;
157         }
158
159         EXIT;
160 }
161
162 static int mds_start_ptlrpc_service(struct mds_device *m)
163 {
164         static struct ptlrpc_service_conf conf;
165         struct obd_device *obd = m->mds_md_dev.md_lu_dev.ld_obd;
166         nodemask_t *mask;
167         int rc = 0;
168
169         ENTRY;
170
171         conf = (typeof(conf)) {
172                 .psc_name               = LUSTRE_MDT_NAME,
173                 .psc_watchdog_factor    = MDT_SERVICE_WATCHDOG_FACTOR,
174                 .psc_buf                = {
175                         .bc_nbufs               = MDS_NBUFS,
176                         .bc_buf_size            = MDS_REG_BUFSIZE,
177                         .bc_req_max_size        = MDS_REG_MAXREQSIZE,
178                         .bc_rep_max_size        = MDS_REG_MAXREPSIZE,
179                         .bc_req_portal          = MDS_REQUEST_PORTAL,
180                         .bc_rep_portal          = MDC_REPLY_PORTAL,
181                 },
182                 /*
183                  * We'd like to have a mechanism to set this on a per-device
184                  * basis, but alas...
185                  */
186                 .psc_thr                = {
187                         .tc_thr_name            = LUSTRE_MDT_NAME,
188                         .tc_thr_factor          = MDS_THR_FACTOR,
189                         .tc_nthrs_init          = MDS_NTHRS_INIT,
190                         .tc_nthrs_base          = MDS_NTHRS_BASE,
191                         .tc_nthrs_max           = MDS_NTHRS_MAX,
192                         .tc_nthrs_user          = mds_num_threads,
193                         .tc_cpu_bind            = mds_cpu_bind,
194                         /* LCT_DT_THREAD is required as MDT threads may scan
195                          * all LDLM namespaces (including OFD-originated) to
196                          * cancel LDLM locks */
197                         .tc_ctx_tags            = LCT_MD_THREAD | LCT_DT_THREAD,
198                 },
199                 .psc_cpt                = {
200                         .cc_pattern             = mds_num_cpts,
201                         .cc_affinity            = true,
202                 },
203                 .psc_ops                = {
204                         .so_req_handler         = tgt_request_handle,
205                         .so_req_printer         = target_print_req,
206                         .so_hpreq_handler       = ptlrpc_hpreq_handler,
207                 },
208         };
209         m->mds_regular_service = ptlrpc_register_service(&conf, &obd->obd_kset,
210                                                          obd->obd_debugfs_entry);
211         if (IS_ERR(m->mds_regular_service)) {
212                 rc = PTR_ERR(m->mds_regular_service);
213                 CERROR("failed to start regular mdt service: %d\n", rc);
214                 m->mds_regular_service = NULL;
215
216                 RETURN(rc);
217         }
218
219         /*
220          * readpage service configuration. Parameters have to be adjusted,
221          * ideally.
222          */
223         memset(&conf, 0, sizeof(conf));
224         conf = (typeof(conf)) {
225                 .psc_name               = LUSTRE_MDT_NAME "_readpage",
226                 .psc_watchdog_factor    = MDT_SERVICE_WATCHDOG_FACTOR,
227                 .psc_buf                = {
228                         .bc_nbufs               = MDS_NBUFS,
229                         .bc_buf_size            = MDS_BUFSIZE,
230                         .bc_req_max_size        = MDS_MAXREQSIZE,
231                         .bc_rep_max_size        = MDS_MAXREPSIZE,
232                         .bc_req_portal          = MDS_READPAGE_PORTAL,
233                         .bc_rep_portal          = MDC_REPLY_PORTAL,
234                 },
235                 .psc_thr                = {
236                         .tc_thr_name            = LUSTRE_MDT_NAME "_rdpg",
237                         .tc_thr_factor          = MDS_RDPG_THR_FACTOR,
238                         .tc_nthrs_init          = MDS_RDPG_NTHRS_INIT,
239                         .tc_nthrs_base          = MDS_RDPG_NTHRS_BASE,
240                         .tc_nthrs_max           = MDS_RDPG_NTHRS_MAX,
241                         .tc_nthrs_user          = mds_rdpg_num_threads,
242                         .tc_cpu_bind            = mds_rdpg_cpu_bind,
243                         .tc_ctx_tags            = LCT_MD_THREAD,
244                 },
245                 .psc_cpt                = {
246                         .cc_pattern             = mds_rdpg_num_cpts,
247                         .cc_affinity            = true,
248                 },
249                 .psc_ops                = {
250                         .so_req_handler         = tgt_request_handle,
251                         .so_req_printer         = target_print_req,
252                 },
253         };
254         m->mds_readpage_service = ptlrpc_register_service(&conf, &obd->obd_kset,
255                                                           obd->obd_debugfs_entry);
256         if (IS_ERR(m->mds_readpage_service)) {
257                 rc = PTR_ERR(m->mds_readpage_service);
258                 CERROR("failed to start readpage service: %d\n", rc);
259                 m->mds_readpage_service = NULL;
260
261                 GOTO(err_mds_svc, rc);
262         }
263
264         /* Object update service */
265         conf = (typeof(conf)) {
266                 .psc_name               = LUSTRE_MDT_NAME "_out",
267                 .psc_watchdog_factor    = MDT_SERVICE_WATCHDOG_FACTOR,
268                 .psc_buf                = {
269                         .bc_nbufs               = MDS_NBUFS,
270                         .bc_buf_size            = OUT_BUFSIZE,
271                         .bc_req_max_size        = OUT_MAXREQSIZE,
272                         .bc_rep_max_size        = OUT_MAXREPSIZE,
273                         .bc_req_portal          = OUT_PORTAL,
274                         .bc_rep_portal          = OSC_REPLY_PORTAL,
275                 },
276                 /*
277                  * We'd like to have a mechanism to set this on a per-device
278                  * basis, but alas...
279                  */
280                 .psc_thr                = {
281                         .tc_thr_name            = LUSTRE_MDT_NAME "_out",
282                         .tc_thr_factor          = MDS_THR_FACTOR,
283                         .tc_nthrs_init          = MDS_NTHRS_INIT,
284                         .tc_nthrs_base          = MDS_NTHRS_BASE,
285                         .tc_nthrs_max           = MDS_NTHRS_MAX,
286                         .tc_nthrs_user          = mds_num_threads,
287                         .tc_cpu_bind            = mds_cpu_bind,
288                         .tc_ctx_tags            = LCT_MD_THREAD |
289                                                   LCT_DT_THREAD,
290                 },
291                 .psc_cpt                = {
292                         .cc_pattern             = mds_num_cpts,
293                         .cc_affinity            = true,
294                 },
295                 .psc_ops                = {
296                         .so_req_handler         = tgt_request_handle,
297                         .so_req_printer         = target_print_req,
298                         .so_hpreq_handler       = NULL,
299                 },
300         };
301         m->mds_out_service = ptlrpc_register_service(&conf, &obd->obd_kset,
302                                                      obd->obd_debugfs_entry);
303         if (IS_ERR(m->mds_out_service)) {
304                 rc = PTR_ERR(m->mds_out_service);
305                 CERROR("failed to start out service: %d\n", rc);
306                 m->mds_out_service = NULL;
307                 GOTO(err_mds_svc, rc);
308         }
309
310         /*
311          * sequence controller service configuration
312          */
313         memset(&conf, 0, sizeof(conf));
314         conf = (typeof(conf)) {
315                 .psc_name               = LUSTRE_MDT_NAME "_seqs",
316                 .psc_watchdog_factor    = MDT_SERVICE_WATCHDOG_FACTOR,
317                 .psc_buf                = {
318                         .bc_nbufs               = MDS_NBUFS,
319                         .bc_buf_size            = SEQ_BUFSIZE,
320                         .bc_req_max_size        = SEQ_MAXREQSIZE,
321                         .bc_rep_max_size        = SEQ_MAXREPSIZE,
322                         .bc_req_portal          = SEQ_CONTROLLER_PORTAL,
323                         .bc_rep_portal          = MDC_REPLY_PORTAL,
324                 },
325                 .psc_thr                = {
326                         .tc_thr_name            = LUSTRE_MDT_NAME "_seqs",
327                         .tc_nthrs_init          = MDS_OTHR_NTHRS_INIT,
328                         .tc_nthrs_max           = MDS_OTHR_NTHRS_MAX,
329                         .tc_ctx_tags            = LCT_MD_THREAD,
330                 },
331                 .psc_ops                = {
332                         .so_req_handler         = tgt_request_handle,
333                         .so_req_printer         = target_print_req,
334                         .so_hpreq_handler       = NULL,
335                 },
336         };
337         m->mds_mdsc_service = ptlrpc_register_service(&conf, &obd->obd_kset,
338                                                       obd->obd_debugfs_entry);
339         if (IS_ERR(m->mds_mdsc_service)) {
340                 rc = PTR_ERR(m->mds_mdsc_service);
341                 CERROR("failed to start seq controller service: %d\n", rc);
342                 m->mds_mdsc_service = NULL;
343
344                 GOTO(err_mds_svc, rc);
345         }
346
347         /*
348          * metadata sequence server service configuration
349          */
350         memset(&conf, 0, sizeof(conf));
351         conf = (typeof(conf)) {
352                 .psc_name               = LUSTRE_MDT_NAME "_seqm",
353                 .psc_watchdog_factor    = MDT_SERVICE_WATCHDOG_FACTOR,
354                 .psc_buf                = {
355                         .bc_nbufs               = MDS_NBUFS,
356                         .bc_buf_size            = SEQ_BUFSIZE,
357                         .bc_req_max_size        = SEQ_MAXREQSIZE,
358                         .bc_rep_max_size        = SEQ_MAXREPSIZE,
359                         .bc_req_portal          = SEQ_METADATA_PORTAL,
360                         .bc_rep_portal          = MDC_REPLY_PORTAL,
361                 },
362                 .psc_thr                = {
363                         .tc_thr_name            = LUSTRE_MDT_NAME "_seqm",
364                         .tc_nthrs_init          = MDS_OTHR_NTHRS_INIT,
365                         .tc_nthrs_max           = MDS_OTHR_NTHRS_MAX,
366                         .tc_ctx_tags            = LCT_MD_THREAD | LCT_DT_THREAD
367                 },
368                 .psc_ops                = {
369                         .so_req_handler         = tgt_request_handle,
370                         .so_req_printer         = target_print_req,
371                         .so_hpreq_handler       = NULL,
372                 },
373         };
374         m->mds_mdss_service = ptlrpc_register_service(&conf, &obd->obd_kset,
375                                                       obd->obd_debugfs_entry);
376         if (IS_ERR(m->mds_mdss_service)) {
377                 rc = PTR_ERR(m->mds_mdss_service);
378                 CERROR("failed to start metadata seq server service: %d\n", rc);
379                 m->mds_mdss_service = NULL;
380
381                 GOTO(err_mds_svc, rc);
382         }
383
384         /* FLD service start */
385         memset(&conf, 0, sizeof(conf));
386         conf = (typeof(conf)) {
387                 .psc_name            = LUSTRE_MDT_NAME "_fld",
388                 .psc_watchdog_factor = MDT_SERVICE_WATCHDOG_FACTOR,
389                 .psc_buf                = {
390                         .bc_nbufs               = MDS_NBUFS,
391                         .bc_buf_size            = FLD_BUFSIZE,
392                         .bc_req_max_size        = FLD_MAXREQSIZE,
393                         .bc_rep_max_size        = FLD_MAXREPSIZE,
394                         .bc_req_portal          = FLD_REQUEST_PORTAL,
395                         .bc_rep_portal          = MDC_REPLY_PORTAL,
396                 },
397                 .psc_thr                = {
398                         .tc_thr_name            = LUSTRE_MDT_NAME "_fld",
399                         .tc_nthrs_init          = MDS_OTHR_NTHRS_INIT,
400                         .tc_nthrs_max           = MDS_OTHR_NTHRS_MAX,
401                         .tc_ctx_tags            = LCT_DT_THREAD | LCT_MD_THREAD,
402                 },
403                 .psc_ops                = {
404                         .so_req_handler         = tgt_request_handle,
405                         .so_req_printer         = target_print_req,
406                         .so_hpreq_handler       = NULL,
407                 },
408         };
409         m->mds_fld_service = ptlrpc_register_service(&conf, &obd->obd_kset,
410                                                      obd->obd_debugfs_entry);
411         if (IS_ERR(m->mds_fld_service)) {
412                 rc = PTR_ERR(m->mds_fld_service);
413                 CERROR("failed to start fld service: %d\n", rc);
414                 m->mds_fld_service = NULL;
415
416                 GOTO(err_mds_svc, rc);
417         }
418
419
420         mask = cfs_cpt_nodemask(cfs_cpt_tab, CFS_CPT_ANY);
421         /* event CPT feature is disabled in libcfs level by set partition
422          * number to 1, we still want to set node affinity for io service */
423         if (cfs_cpt_number(cfs_cpt_tab) == 1 && nodes_weight(*mask) > 1) {
424                 int cpt = 0;
425                 int i;
426
427                 mdt_io_cptable = cfs_cpt_table_alloc(nodes_weight(*mask));
428                 for_each_node_mask(i, *mask) {
429                         if (mdt_io_cptable == NULL) {
430                                 CWARN("MDS failed to create CPT table\n");
431                                 break;
432                         }
433
434                         rc = cfs_cpt_set_node(mdt_io_cptable, cpt++, i);
435                         if (!rc) {
436                                 CWARN("MDS Failed to set node %d for IO CPT table\n",
437                                       i);
438                                 cfs_cpt_table_free(mdt_io_cptable);
439                                 mdt_io_cptable = NULL;
440                                 break;
441                         }
442                 }
443         }
444
445         memset(&conf, 0, sizeof(conf));
446         conf = (typeof(conf)) {
447                 .psc_name               = LUSTRE_MDT_NAME "_io",
448                 .psc_watchdog_factor    = MDT_SERVICE_WATCHDOG_FACTOR,
449                 .psc_buf                = {
450                         .bc_nbufs               = OST_NBUFS,
451                         .bc_buf_size            = OST_IO_BUFSIZE,
452                         .bc_req_max_size        = OST_IO_MAXREQSIZE,
453                         .bc_rep_max_size        = OST_IO_MAXREPSIZE,
454                         .bc_req_portal          = MDS_IO_PORTAL,
455                         .bc_rep_portal          = MDC_REPLY_PORTAL,
456                 },
457                 .psc_thr                = {
458                         .tc_thr_name            = LUSTRE_MDT_NAME "_io",
459                         .tc_thr_factor          = OSS_THR_FACTOR,
460                         .tc_nthrs_init          = OSS_NTHRS_INIT,
461                         .tc_nthrs_base          = OSS_NTHRS_BASE,
462                         .tc_nthrs_max           = mds_max_io_threads,
463                         .tc_nthrs_user          = mds_num_threads,
464                         .tc_cpu_bind            = mds_io_cpu_bind,
465                         .tc_ctx_tags            = LCT_DT_THREAD | LCT_MD_THREAD,
466                 },
467                 .psc_cpt                = {
468                         .cc_cptable             = mdt_io_cptable,
469                         .cc_pattern             = mdt_io_cptable == NULL ?
470                                                   mds_io_num_cpts : NULL,
471                         .cc_affinity            = true,
472                 },
473                 .psc_ops                = {
474                         .so_thr_init            = tgt_io_thread_init,
475                         .so_thr_done            = tgt_io_thread_done,
476                         .so_req_handler         = tgt_request_handle,
477                         .so_req_printer         = target_print_req,
478                         .so_hpreq_handler       = tgt_hpreq_handler,
479                 },
480         };
481         m->mds_io_service = ptlrpc_register_service(&conf, &obd->obd_kset,
482                                                     obd->obd_debugfs_entry);
483         if (IS_ERR(m->mds_io_service)) {
484                 rc = PTR_ERR(m->mds_io_service);
485                 CERROR("failed to start MDT I/O service: %d\n", rc);
486                 m->mds_io_service = NULL;
487                 GOTO(err_mds_svc, rc);
488         }
489
490         EXIT;
491 err_mds_svc:
492         if (rc)
493                 mds_stop_ptlrpc_service(m);
494
495         return rc;
496 }
497
498 static inline struct mds_device *mds_dev(struct lu_device *d)
499 {
500         return container_of_safe(d, struct mds_device, mds_md_dev.md_lu_dev);
501 }
502
503 static struct lu_device *mds_device_fini(const struct lu_env *env,
504                                          struct lu_device *d)
505 {
506         struct mds_device *m = mds_dev(d);
507         struct obd_device *obd = d->ld_obd;
508         ENTRY;
509
510         mds_stop_ptlrpc_service(m);
511         lprocfs_obd_cleanup(obd);
512         RETURN(NULL);
513 }
514
515 static struct lu_device *mds_device_free(const struct lu_env *env,
516                                          struct lu_device *d)
517 {
518         struct mds_device *m = mds_dev(d);
519         ENTRY;
520
521         md_device_fini(&m->mds_md_dev);
522         OBD_FREE_PTR(m);
523         RETURN(NULL);
524 }
525
526 static struct lu_device *mds_device_alloc(const struct lu_env *env,
527                                           struct lu_device_type *t,
528                                           struct lustre_cfg *cfg)
529 {
530         struct mds_device        *m;
531         struct obd_device        *obd;
532         struct lu_device          *l;
533         int rc;
534
535         OBD_ALLOC_PTR(m);
536         if (m == NULL)
537                 return ERR_PTR(-ENOMEM);
538
539         md_device_init(&m->mds_md_dev, t);
540         l = &m->mds_md_dev.md_lu_dev;
541
542         obd = class_name2obd(lustre_cfg_string(cfg, 0));
543         LASSERT(obd != NULL);
544
545         l->ld_obd = obd;
546         /* set this lu_device to obd, because error handling need it */
547         obd->obd_lu_dev = l;
548
549         rc = lprocfs_obd_setup(obd, true);
550         if (rc != 0) {
551                 mds_device_free(env, l);
552                 l = ERR_PTR(rc);
553                 return l;
554         }
555
556         mutex_init(&m->mds_health_mutex);
557
558         rc = mds_start_ptlrpc_service(m);
559         if (rc != 0) {
560                 lprocfs_obd_cleanup(obd);
561                 mds_device_free(env, l);
562                 l = ERR_PTR(rc);
563                 return l;
564         }
565         return l;
566 }
567
568 /* type constructor/destructor: mdt_type_init, mdt_type_fini */
569 LU_TYPE_INIT_FINI(mds, &mdt_thread_key);
570
571 static const struct lu_device_type_operations mds_device_type_ops = {
572         .ldto_init = mds_type_init,
573         .ldto_fini = mds_type_fini,
574
575         .ldto_start = mds_type_start,
576         .ldto_stop  = mds_type_stop,
577
578         .ldto_device_alloc = mds_device_alloc,
579         .ldto_device_free  = mds_device_free,
580         .ldto_device_fini  = mds_device_fini
581 };
582
583 static struct lu_device_type mds_device_type = {
584         .ldt_tags     = LU_DEVICE_MD,
585         .ldt_name     = LUSTRE_MDS_NAME,
586         .ldt_ops      = &mds_device_type_ops,
587         .ldt_ctx_tags = LCT_MD_THREAD
588 };
589
590 static int mds_health_check(const struct lu_env *env, struct obd_device *obd)
591 {
592         struct mds_device *mds = mds_dev(obd->obd_lu_dev);
593         int rc = 0;
594
595
596         mutex_lock(&mds->mds_health_mutex);
597         rc |= ptlrpc_service_health_check(mds->mds_regular_service);
598         rc |= ptlrpc_service_health_check(mds->mds_readpage_service);
599         rc |= ptlrpc_service_health_check(mds->mds_out_service);
600         rc |= ptlrpc_service_health_check(mds->mds_mdsc_service);
601         rc |= ptlrpc_service_health_check(mds->mds_mdss_service);
602         rc |= ptlrpc_service_health_check(mds->mds_fld_service);
603         rc |= ptlrpc_service_health_check(mds->mds_io_service);
604         mutex_unlock(&mds->mds_health_mutex);
605
606         return rc != 0 ? 1 : 0;
607 }
608
609 static const struct obd_ops mds_obd_device_ops = {
610         .o_owner           = THIS_MODULE,
611         .o_health_check    = mds_health_check,
612 };
613
614 int mds_mod_init(void)
615 {
616         return class_register_type(&mds_obd_device_ops, NULL, false,
617                                    LUSTRE_MDS_NAME, &mds_device_type);
618 }
619
620 void mds_mod_exit(void)
621 {
622         class_unregister_type(LUSTRE_MDS_NAME);
623 }