1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * Copyright (c) 2011 Whamcloud, Inc.
36 * This file is part of Lustre, http://www.lustre.org/
37 * Lustre is a trademark of Sun Microsystems, Inc.
41 # define EXPORT_SYMTAB
43 #define DEBUG_SUBSYSTEM S_MDC
46 # include <linux/module.h>
47 # include <linux/pagemap.h>
48 # include <linux/miscdevice.h>
49 # include <linux/init.h>
51 # include <liblustre.h>
54 #include <lustre_acl.h>
55 #include <obd_class.h>
56 #include <lustre_dlm.h>
57 #include <lustre_fid.h>
58 #include <md_object.h>
59 #include <lprocfs_status.h>
60 #include <lustre_param.h>
61 #include "mdc_internal.h"
62 #include <lustre/lustre_idl.h>
64 #define REQUEST_MINOR 244
66 struct mdc_renew_capa_args {
67 struct obd_capa *ra_oc;
68 renew_capa_cb_t ra_cb;
71 static quota_interface_t *quota_interface;
72 extern quota_interface_t mdc_quota_interface;
74 static int mdc_cleanup(struct obd_device *obd);
76 int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
77 const struct req_msg_field *field, struct obd_capa **oc)
79 struct lustre_capa *capa;
83 /* swabbed already in mdc_enqueue */
84 capa = req_capsule_server_get(&req->rq_pill, field);
88 c = alloc_capa(CAPA_SITE_CLIENT);
90 CDEBUG(D_INFO, "alloc capa failed!\n");
99 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
100 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
101 static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid,
102 struct obd_capa **pc, int level, int msg_flags)
104 struct ptlrpc_request *req;
105 struct mdt_body *body;
109 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS,
110 LUSTRE_MDS_VERSION, MDS_GETSTATUS);
114 mdc_pack_body(req, NULL, NULL, 0, 0, -1, 0);
115 lustre_msg_add_flags(req->rq_reqmsg, msg_flags);
116 req->rq_send_state = level;
118 ptlrpc_request_set_replen(req);
120 rc = ptlrpc_queue_wait(req);
124 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
126 GOTO(out, rc = -EPROTO);
128 if (body->valid & OBD_MD_FLMDSCAPA) {
129 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, pc);
134 *rootfid = body->fid1;
136 "root fid="DFID", last_committed="LPU64"\n",
138 lustre_msg_get_last_committed(req->rq_repmsg));
141 ptlrpc_req_finished(req);
145 /* This should be mdc_get_info("rootfid") */
146 int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid,
147 struct obd_capa **pc)
149 return send_getstatus(class_exp2cliimp(exp), rootfid, pc,
154 * This function now is known to always saying that it will receive 4 buffers
155 * from server. Even for cases when acl_size and md_size is zero, RPC header
156 * will contain 4 fields and RPC itself will contain zero size fields. This is
157 * because mdt_getattr*() _always_ returns 4 fields, but if acl is not needed
158 * and thus zero, it shrinks it, making zero size. The same story about
159 * md_size. And this is course of problem when client waits for smaller number
160 * of fields. This issue will be fixed later when client gets aware of RPC
163 static int mdc_getattr_common(struct obd_export *exp,
164 struct ptlrpc_request *req)
166 struct req_capsule *pill = &req->rq_pill;
167 struct mdt_body *body;
172 /* Request message already built. */
173 rc = ptlrpc_queue_wait(req);
177 /* sanity check for the reply */
178 body = req_capsule_server_get(pill, &RMF_MDT_BODY);
182 CDEBUG(D_NET, "mode: %o\n", body->mode);
184 if (body->eadatasize != 0) {
185 mdc_update_max_ea_from_body(exp, body);
187 eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
193 if (body->valid & OBD_MD_FLRMTPERM) {
194 struct mdt_remote_perm *perm;
196 LASSERT(client_is_remote(exp));
197 perm = req_capsule_server_swab_get(pill, &RMF_ACL,
198 lustre_swab_mdt_remote_perm);
203 if (body->valid & OBD_MD_FLMDSCAPA) {
204 struct lustre_capa *capa;
205 capa = req_capsule_server_get(pill, &RMF_CAPA1);
213 int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
214 struct ptlrpc_request **request)
216 struct ptlrpc_request *req;
221 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
225 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
227 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
229 ptlrpc_request_free(req);
233 mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
234 op_data->op_valid, op_data->op_mode, -1, 0);
236 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
238 if (op_data->op_valid & OBD_MD_FLRMTPERM) {
239 LASSERT(client_is_remote(exp));
240 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
241 sizeof(struct mdt_remote_perm));
243 ptlrpc_request_set_replen(req);
245 rc = mdc_getattr_common(exp, req);
247 ptlrpc_req_finished(req);
253 int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
254 struct ptlrpc_request **request)
256 struct ptlrpc_request *req;
261 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
262 &RQF_MDS_GETATTR_NAME);
266 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
267 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
268 op_data->op_namelen + 1);
270 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME);
272 ptlrpc_request_free(req);
276 mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
277 op_data->op_valid, op_data->op_mode,
278 op_data->op_suppgids[0], 0);
280 if (op_data->op_name) {
281 char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
282 LASSERT(strnlen(op_data->op_name, op_data->op_namelen) ==
283 op_data->op_namelen);
284 memcpy(name, op_data->op_name, op_data->op_namelen);
287 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
289 ptlrpc_request_set_replen(req);
291 rc = mdc_getattr_common(exp, req);
293 ptlrpc_req_finished(req);
299 static int mdc_is_subdir(struct obd_export *exp,
300 const struct lu_fid *pfid,
301 const struct lu_fid *cfid,
302 struct ptlrpc_request **request)
304 struct ptlrpc_request *req;
310 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
311 &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION,
316 mdc_is_subdir_pack(req, pfid, cfid, 0);
317 ptlrpc_request_set_replen(req);
319 rc = ptlrpc_queue_wait(req);
320 if (rc && rc != -EREMOTE)
321 ptlrpc_req_finished(req);
327 static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
328 const struct lu_fid *fid,
329 struct obd_capa *oc, int opcode, obd_valid valid,
330 const char *xattr_name, const char *input,
331 int input_size, int output_size, int flags,
332 __u32 suppgid, struct ptlrpc_request **request)
334 struct ptlrpc_request *req;
335 int xattr_namelen = 0;
341 req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt);
345 mdc_set_capa_size(req, &RMF_CAPA1, oc);
347 xattr_namelen = strlen(xattr_name) + 1;
348 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
353 req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
357 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
359 ptlrpc_request_free(req);
363 if (opcode == MDS_REINT) {
364 struct mdt_rec_setxattr *rec;
366 CLASSERT(sizeof(struct mdt_rec_setxattr) ==
367 sizeof(struct mdt_rec_reint));
368 rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
369 rec->sx_opcode = REINT_SETXATTR;
371 * cfs_curproc_fs{u,g}id() should replace
372 * current->fs{u,g}id for portability.
374 rec->sx_fsuid = cfs_curproc_fsuid();
375 rec->sx_fsgid = cfs_curproc_fsgid();
376 rec->sx_cap = cfs_curproc_cap_pack();
377 rec->sx_suppgid1 = suppgid;
378 rec->sx_suppgid2 = -1;
380 rec->sx_valid = valid | OBD_MD_FLCTIME;
381 rec->sx_time = cfs_time_current_sec();
382 rec->sx_size = output_size;
383 rec->sx_flags = flags;
385 mdc_pack_capa(req, &RMF_CAPA1, oc);
387 mdc_pack_body(req, fid, oc, valid, output_size, suppgid, flags);
391 tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
392 memcpy(tmp, xattr_name, xattr_namelen);
395 tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
396 memcpy(tmp, input, input_size);
399 if (req_capsule_has_field(&req->rq_pill, &RMF_EADATA, RCL_SERVER))
400 req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
401 RCL_SERVER, output_size);
402 ptlrpc_request_set_replen(req);
405 if (opcode == MDS_REINT)
406 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
408 rc = ptlrpc_queue_wait(req);
410 if (opcode == MDS_REINT)
411 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
414 ptlrpc_req_finished(req);
420 int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
421 struct obd_capa *oc, obd_valid valid, const char *xattr_name,
422 const char *input, int input_size, int output_size,
423 int flags, __u32 suppgid, struct ptlrpc_request **request)
425 return mdc_xattr_common(exp, &RQF_MDS_REINT_SETXATTR,
426 fid, oc, MDS_REINT, valid, xattr_name,
427 input, input_size, output_size, flags,
431 int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
432 struct obd_capa *oc, obd_valid valid, const char *xattr_name,
433 const char *input, int input_size, int output_size,
434 int flags, struct ptlrpc_request **request)
436 return mdc_xattr_common(exp, &RQF_MDS_GETXATTR,
437 fid, oc, MDS_GETXATTR, valid, xattr_name,
438 input, input_size, output_size, flags,
442 #ifdef CONFIG_FS_POSIX_ACL
443 static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
445 struct req_capsule *pill = &req->rq_pill;
446 struct mdt_body *body = md->body;
447 struct posix_acl *acl;
455 buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->aclsize);
460 acl = posix_acl_from_xattr(buf, body->aclsize);
463 CERROR("convert xattr to acl: %d\n", rc);
467 rc = posix_acl_valid(acl);
469 CERROR("validate acl: %d\n", rc);
470 posix_acl_release(acl);
478 #define mdc_unpack_acl(req, md) 0
481 int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
482 struct obd_export *dt_exp, struct obd_export *md_exp,
483 struct lustre_md *md)
485 struct req_capsule *pill = &req->rq_pill;
490 memset(md, 0, sizeof(*md));
492 md->body = req_capsule_server_get(pill, &RMF_MDT_BODY);
493 LASSERT(md->body != NULL);
495 if (md->body->valid & OBD_MD_FLEASIZE) {
497 struct lov_mds_md *lmm;
499 if (!S_ISREG(md->body->mode)) {
500 CDEBUG(D_INFO, "OBD_MD_FLEASIZE set, should be a "
501 "regular file, but is not\n");
502 GOTO(out, rc = -EPROTO);
505 if (md->body->eadatasize == 0) {
506 CDEBUG(D_INFO, "OBD_MD_FLEASIZE set, "
507 "but eadatasize 0\n");
508 GOTO(out, rc = -EPROTO);
510 lmmsize = md->body->eadatasize;
511 lmm = req_capsule_server_sized_get(pill, &RMF_MDT_MD, lmmsize);
513 GOTO(out, rc = -EPROTO);
515 rc = obd_unpackmd(dt_exp, &md->lsm, lmm, lmmsize);
519 if (rc < sizeof(*md->lsm)) {
520 CDEBUG(D_INFO, "lsm size too small: "
521 "rc < sizeof (*md->lsm) (%d < %d)\n",
522 rc, (int)sizeof(*md->lsm));
523 GOTO(out, rc = -EPROTO);
526 } else if (md->body->valid & OBD_MD_FLDIREA) {
528 struct lov_mds_md *lmv;
530 if(!S_ISDIR(md->body->mode)) {
531 CDEBUG(D_INFO, "OBD_MD_FLDIREA set, should be a "
532 "directory, but is not\n");
533 GOTO(out, rc = -EPROTO);
536 if (md->body->eadatasize == 0) {
537 CDEBUG(D_INFO, "OBD_MD_FLDIREA is set, "
538 "but eadatasize 0\n");
541 if (md->body->valid & OBD_MD_MEA) {
542 lmvsize = md->body->eadatasize;
543 lmv = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
546 GOTO(out, rc = -EPROTO);
548 rc = obd_unpackmd(md_exp, (void *)&md->mea, lmv,
553 if (rc < sizeof(*md->mea)) {
554 CDEBUG(D_INFO, "size too small: "
555 "rc < sizeof(*md->mea) (%d < %d)\n",
556 rc, (int)sizeof(*md->mea));
557 GOTO(out, rc = -EPROTO);
563 if (md->body->valid & OBD_MD_FLRMTPERM) {
564 /* remote permission */
565 LASSERT(client_is_remote(exp));
566 md->remote_perm = req_capsule_server_swab_get(pill, &RMF_ACL,
567 lustre_swab_mdt_remote_perm);
568 if (!md->remote_perm)
569 GOTO(out, rc = -EPROTO);
571 else if (md->body->valid & OBD_MD_FLACL) {
572 /* for ACL, it's possible that FLACL is set but aclsize is zero.
573 * only when aclsize != 0 there's an actual segment for ACL
576 if (md->body->aclsize) {
577 rc = mdc_unpack_acl(req, md);
580 #ifdef CONFIG_FS_POSIX_ACL
582 md->posix_acl = NULL;
586 if (md->body->valid & OBD_MD_FLMDSCAPA) {
587 struct obd_capa *oc = NULL;
589 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, &oc);
595 if (md->body->valid & OBD_MD_FLOSSCAPA) {
596 struct obd_capa *oc = NULL;
598 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA2, &oc);
608 capa_put(md->oss_capa);
612 capa_put(md->mds_capa);
615 #ifdef CONFIG_FS_POSIX_ACL
616 posix_acl_release(md->posix_acl);
619 obd_free_memmd(dt_exp, &md->lsm);
624 int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
631 * Handles both OPEN and SETATTR RPCs for OPEN-CLOSE and SETATTR-DONE_WRITING
634 void mdc_replay_open(struct ptlrpc_request *req)
636 struct md_open_data *mod = req->rq_cb_data;
637 struct ptlrpc_request *close_req;
638 struct obd_client_handle *och;
639 struct lustre_handle old;
640 struct mdt_body *body;
644 DEBUG_REQ(D_ERROR, req,
645 "Can't properly replay without open data.");
650 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
651 LASSERT(body != NULL);
655 struct lustre_handle *file_fh;
657 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
659 file_fh = &och->och_fh;
660 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
661 file_fh->cookie, body->handle.cookie);
663 *file_fh = body->handle;
665 close_req = mod->mod_close_req;
666 if (close_req != NULL) {
667 __u32 opc = lustre_msg_get_opc(close_req->rq_reqmsg);
668 struct mdt_ioepoch *epoch;
670 LASSERT(opc == MDS_CLOSE || opc == MDS_DONE_WRITING);
671 epoch = req_capsule_client_get(&close_req->rq_pill,
676 LASSERT(!memcmp(&old, &epoch->handle, sizeof(old)));
677 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
678 epoch->handle = body->handle;
683 void mdc_commit_open(struct ptlrpc_request *req)
685 struct md_open_data *mod = req->rq_cb_data;
690 * No need to touch md_open_data::mod_och, it holds a reference on
691 * \var mod and will zero references to each other, \var mod will be
692 * freed after that when md_open_data::mod_och will put the reference.
696 * Do not let open request to disappear as it still may be needed
697 * for close rpc to happen (it may happen on evict only, otherwise
698 * ptlrpc_request::rq_replay does not let mdc_commit_open() to be
699 * called), just mark this rpc as committed to distinguish these 2
700 * cases, see mdc_close() for details. The open request reference will
701 * be put along with freeing \var mod.
703 ptlrpc_request_addref(req);
704 cfs_spin_lock(&req->rq_lock);
705 req->rq_committed = 1;
706 cfs_spin_unlock(&req->rq_lock);
707 req->rq_cb_data = NULL;
711 int mdc_set_open_replay_data(struct obd_export *exp,
712 struct obd_client_handle *och,
713 struct ptlrpc_request *open_req)
715 struct md_open_data *mod;
716 struct mdt_rec_create *rec;
717 struct mdt_body *body;
718 struct obd_import *imp = open_req->rq_import;
721 if (!open_req->rq_replay)
724 rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT);
725 body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY);
726 LASSERT(rec != NULL);
727 /* Incoming message in my byte order (it's been swabbed). */
728 /* Outgoing messages always in my byte order. */
729 LASSERT(body != NULL);
731 /* Only if the import is replayable, we set replay_open data */
732 if (och && imp->imp_replayable) {
733 mod = obd_mod_alloc();
735 DEBUG_REQ(D_ERROR, open_req,
736 "Can't allocate md_open_data");
741 * Take a reference on \var mod, to be freed on mdc_close().
742 * It protects \var mod from being freed on eviction (commit
743 * callback is called despite rq_replay flag).
744 * Another reference for \var och.
749 cfs_spin_lock(&open_req->rq_lock);
752 mod->mod_open_req = open_req;
753 open_req->rq_cb_data = mod;
754 open_req->rq_commit_cb = mdc_commit_open;
755 cfs_spin_unlock(&open_req->rq_lock);
758 rec->cr_fid2 = body->fid1;
759 rec->cr_ioepoch = body->ioepoch;
760 rec->cr_old_handle.cookie = body->handle.cookie;
761 open_req->rq_replay_cb = mdc_replay_open;
762 if (!fid_is_sane(&body->fid1)) {
763 DEBUG_REQ(D_ERROR, open_req, "Saving replay request with "
768 DEBUG_REQ(D_RPCTRACE, open_req, "Set up open replay data");
772 int mdc_clear_open_replay_data(struct obd_export *exp,
773 struct obd_client_handle *och)
775 struct md_open_data *mod = och->och_mod;
779 * It is possible to not have \var mod in a case of eviction between
780 * lookup and ll_file_open().
785 LASSERT(mod != LP_POISON);
794 /* Prepares the request for the replay by the given reply */
795 static void mdc_close_handle_reply(struct ptlrpc_request *req,
796 struct md_op_data *op_data, int rc) {
797 struct mdt_body *repbody;
798 struct mdt_ioepoch *epoch;
800 if (req && rc == -EAGAIN) {
801 repbody = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
802 epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH);
804 epoch->flags |= MF_SOM_AU;
805 if (repbody->valid & OBD_MD_FLGETATTRLOCK)
806 op_data->op_flags |= MF_GETATTR_LOCK;
810 int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
811 struct md_open_data *mod, struct ptlrpc_request **request)
813 struct obd_device *obd = class_exp2obd(exp);
814 struct ptlrpc_request *req;
819 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_CLOSE);
823 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
825 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE);
827 ptlrpc_request_free(req);
831 /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a
832 * portal whose threads are not taking any DLM locks and are therefore
833 * always progressing */
834 req->rq_request_portal = MDS_READPAGE_PORTAL;
835 ptlrpc_at_set_req_timeout(req);
837 /* Ensure that this close's handle is fixed up during replay. */
838 if (likely(mod != NULL)) {
839 LASSERTF(mod->mod_open_req != NULL &&
840 mod->mod_open_req->rq_type != LI_POISON,
841 "POISONED open %p!\n", mod->mod_open_req);
843 mod->mod_close_req = req;
845 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
846 /* We no longer want to preserve this open for replay even
847 * though the open was committed. b=3632, b=3633 */
848 cfs_spin_lock(&mod->mod_open_req->rq_lock);
849 mod->mod_open_req->rq_replay = 0;
850 cfs_spin_unlock(&mod->mod_open_req->rq_lock);
852 CDEBUG(D_HA, "couldn't find open req; expecting close error\n");
855 mdc_close_pack(req, op_data);
857 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
858 obd->u.cli.cl_max_mds_easize);
859 req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
860 obd->u.cli.cl_max_mds_cookiesize);
862 ptlrpc_request_set_replen(req);
864 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
865 rc = ptlrpc_queue_wait(req);
866 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
868 if (req->rq_repmsg == NULL) {
869 CDEBUG(D_RPCTRACE, "request failed to send: %p, %d\n", req,
872 rc = req->rq_status ?: -EIO;
873 } else if (rc == 0 || rc == -EAGAIN) {
874 struct mdt_body *body;
876 rc = lustre_msg_get_status(req->rq_repmsg);
877 if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
878 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err "
883 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
886 } else if (rc == -ESTALE) {
888 * it can be allowed error after 3633 if open was committed and
889 * server failed before close was sent. Let's check if mod
890 * exists and return no error in that case
893 DEBUG_REQ(D_HA, req, "Reset ESTALE = %d", rc);
894 LASSERT(mod->mod_open_req != NULL);
895 if (mod->mod_open_req->rq_committed)
902 mod->mod_close_req = NULL;
903 /* Since now, mod is accessed through open_req only,
904 * thus close req does not keep a reference on mod anymore. */
908 mdc_close_handle_reply(req, op_data, rc);
912 int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data,
913 struct md_open_data *mod)
915 struct obd_device *obd = class_exp2obd(exp);
916 struct ptlrpc_request *req;
920 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
921 &RQF_MDS_DONE_WRITING);
925 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
926 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING);
928 ptlrpc_request_free(req);
933 LASSERTF(mod->mod_open_req != NULL &&
934 mod->mod_open_req->rq_type != LI_POISON,
935 "POISONED setattr %p!\n", mod->mod_open_req);
937 mod->mod_close_req = req;
938 DEBUG_REQ(D_HA, mod->mod_open_req, "matched setattr");
939 /* We no longer want to preserve this setattr for replay even
940 * though the open was committed. b=3632, b=3633 */
941 cfs_spin_lock(&mod->mod_open_req->rq_lock);
942 mod->mod_open_req->rq_replay = 0;
943 cfs_spin_unlock(&mod->mod_open_req->rq_lock);
946 mdc_close_pack(req, op_data);
947 ptlrpc_request_set_replen(req);
949 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
950 rc = ptlrpc_queue_wait(req);
951 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
955 * it can be allowed error after 3633 if open or setattr were
956 * committed and server failed before close was sent.
957 * Let's check if mod exists and return no error in that case
960 LASSERT(mod->mod_open_req != NULL);
961 if (mod->mod_open_req->rq_committed)
968 mod->mod_close_req = NULL;
969 /* Since now, mod is accessed through setattr req only,
970 * thus DW req does not keep a reference on mod anymore. */
974 mdc_close_handle_reply(req, op_data, rc);
975 ptlrpc_req_finished(req);
979 #ifdef HAVE_SPLIT_SUPPORT
980 int mdc_sendpage(struct obd_export *exp, const struct lu_fid *fid,
981 const struct page *page, int offset)
983 struct ptlrpc_request *req;
984 struct ptlrpc_bulk_desc *desc;
988 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_WRITEPAGE);
992 /* FIXME: capa doesn't support split yet */
993 mdc_set_capa_size(req, &RMF_CAPA1, NULL);
995 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_WRITEPAGE);
997 ptlrpc_request_free(req);
1001 req->rq_request_portal = MDS_READPAGE_PORTAL;
1002 ptlrpc_at_set_req_timeout(req);
1004 desc = ptlrpc_prep_bulk_imp(req, 1, BULK_GET_SOURCE, MDS_BULK_PORTAL);
1006 GOTO(out, rc = -ENOMEM);
1008 /* NB req now owns desc and will free it when it gets freed. */
1009 ptlrpc_prep_bulk_page(desc, (struct page *)page, 0, offset);
1010 mdc_readdir_pack(req, 0, offset, fid, NULL);
1012 ptlrpc_request_set_replen(req);
1013 rc = ptlrpc_queue_wait(req);
1017 rc = sptlrpc_cli_unwrap_bulk_write(req, req->rq_bulk);
1019 ptlrpc_req_finished(req);
1022 EXPORT_SYMBOL(mdc_sendpage);
1025 int mdc_readpage(struct obd_export *exp, const struct lu_fid *fid,
1026 struct obd_capa *oc, __u64 offset, struct page **pages,
1027 unsigned npages, struct ptlrpc_request **request)
1029 struct ptlrpc_request *req;
1030 struct ptlrpc_bulk_desc *desc;
1034 struct l_wait_info lwi;
1039 cfs_waitq_init(&waitq);
1042 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE);
1046 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1048 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE);
1050 ptlrpc_request_free(req);
1054 req->rq_request_portal = MDS_READPAGE_PORTAL;
1055 ptlrpc_at_set_req_timeout(req);
1057 desc = ptlrpc_prep_bulk_imp(req, npages, BULK_PUT_SINK,
1060 ptlrpc_request_free(req);
1064 /* NB req now owns desc and will free it when it gets freed */
1065 for (i = 0; i < npages; i++)
1066 ptlrpc_prep_bulk_page(desc, pages[i], 0, CFS_PAGE_SIZE);
1068 mdc_readdir_pack(req, offset, CFS_PAGE_SIZE * npages, fid, oc);
1070 ptlrpc_request_set_replen(req);
1071 rc = ptlrpc_queue_wait(req);
1073 ptlrpc_req_finished(req);
1074 if (rc != -ETIMEDOUT)
1078 if (!client_should_resend(resends, &exp->exp_obd->u.cli)) {
1079 CERROR("too many resend retries, returning error\n");
1082 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL, NULL);
1083 l_wait_event(waitq, 0, &lwi);
1088 rc = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk,
1089 req->rq_bulk->bd_nob_transferred);
1091 ptlrpc_req_finished(req);
1095 if (req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK) {
1096 CERROR("Unexpected # bytes transferred: %d (%ld expected)\n",
1097 req->rq_bulk->bd_nob_transferred,
1098 CFS_PAGE_SIZE * npages);
1099 ptlrpc_req_finished(req);
1107 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1108 __u64 max_age, __u32 flags)
1110 struct ptlrpc_request *req;
1111 struct obd_statfs *msfs;
1112 struct obd_import *imp = NULL;
1117 * Since the request might also come from lprocfs, so we need
1118 * sync this with client_disconnect_export Bug15684
1120 cfs_down_read(&obd->u.cli.cl_sem);
1121 if (obd->u.cli.cl_import)
1122 imp = class_import_get(obd->u.cli.cl_import);
1123 cfs_up_read(&obd->u.cli.cl_sem);
1127 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS,
1128 LUSTRE_MDS_VERSION, MDS_STATFS);
1130 GOTO(output, rc = -ENOMEM);
1132 ptlrpc_request_set_replen(req);
1134 if (flags & OBD_STATFS_NODELAY) {
1135 /* procfs requests not want stay in wait for avoid deadlock */
1136 req->rq_no_resend = 1;
1137 req->rq_no_delay = 1;
1140 rc = ptlrpc_queue_wait(req);
1142 /* check connection error first */
1143 if (imp->imp_connect_error)
1144 rc = imp->imp_connect_error;
1148 msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
1150 GOTO(out, rc = -EPROTO);
1155 ptlrpc_req_finished(req);
1157 class_import_put(imp);
1161 static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
1163 __u32 keylen, vallen;
1167 if (gf->gf_pathlen > PATH_MAX)
1168 RETURN(-ENAMETOOLONG);
1169 if (gf->gf_pathlen < 2)
1172 /* Key is KEY_FID2PATH + getinfo_fid2path description */
1173 keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
1174 OBD_ALLOC(key, keylen);
1177 memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
1178 memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf));
1180 CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n",
1181 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno);
1183 if (!fid_is_sane(&gf->gf_fid))
1184 GOTO(out, rc = -EINVAL);
1186 /* Val is struct getinfo_fid2path result plus path */
1187 vallen = sizeof(*gf) + gf->gf_pathlen;
1189 rc = obd_get_info(exp, keylen, key, &vallen, gf, NULL);
1193 if (vallen <= sizeof(*gf))
1194 GOTO(out, rc = -EPROTO);
1195 else if (vallen > sizeof(*gf) + gf->gf_pathlen)
1196 GOTO(out, rc = -EOVERFLOW);
1198 CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n%s\n",
1199 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
1202 OBD_FREE(key, keylen);
1206 static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
1208 struct kuc_hdr *lh = (struct kuc_hdr *)buf;
1210 LASSERT(len <= CR_MAXSIZE);
1212 lh->kuc_magic = KUC_MAGIC;
1213 lh->kuc_transport = KUC_TRANSPORT_CHANGELOG;
1214 lh->kuc_flags = flags;
1215 lh->kuc_msgtype = CL_RECORD;
1216 lh->kuc_msglen = len;
1220 #define D_CHANGELOG 0
1222 struct changelog_show {
1227 struct obd_device *cs_obd;
1230 static int changelog_show_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr,
1233 struct changelog_show *cs = data;
1234 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
1239 if ((rec->cr_hdr.lrh_type != CHANGELOG_REC) ||
1240 (rec->cr.cr_type >= CL_LAST)) {
1241 CERROR("Not a changelog rec %d/%d\n", rec->cr_hdr.lrh_type,
1246 if (rec->cr.cr_index < cs->cs_startrec) {
1247 /* Skip entries earlier than what we are interested in */
1248 CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n",
1249 rec->cr.cr_index, cs->cs_startrec);
1253 CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID
1254 " %.*s\n", rec->cr.cr_index, rec->cr.cr_type,
1255 changelog_type2str(rec->cr.cr_type), rec->cr.cr_time,
1256 rec->cr.cr_flags & CLF_FLAGMASK,
1257 PFID(&rec->cr.cr_tfid), PFID(&rec->cr.cr_pfid),
1258 rec->cr.cr_namelen, rec->cr.cr_name);
1260 len = sizeof(*lh) + sizeof(rec->cr) + rec->cr.cr_namelen;
1262 /* Set up the message */
1263 lh = changelog_kuc_hdr(cs->cs_buf, len, cs->cs_flags);
1264 memcpy(lh + 1, &rec->cr, len - sizeof(*lh));
1266 rc = libcfs_kkuc_msg_put(cs->cs_fp, lh);
1267 CDEBUG(D_CHANGELOG, "kucmsg fp %p len %d rc %d\n", cs->cs_fp, len,rc);
1272 static int mdc_changelog_send_thread(void *csdata)
1274 struct changelog_show *cs = csdata;
1275 struct llog_ctxt *ctxt = NULL;
1276 struct llog_handle *llh = NULL;
1277 struct kuc_hdr *kuch;
1280 CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n",
1281 cs->cs_fp, cs->cs_startrec);
1284 * It's important to daemonize here to close unused FDs.
1285 * The write fd from pipe is already opened by the caller,
1286 * so it's fine to clear all files here
1288 cfs_daemonize("mdc_clg_send_thread");
1290 OBD_ALLOC(cs->cs_buf, CR_MAXSIZE);
1291 if (cs->cs_buf == NULL)
1292 GOTO(out, rc = -ENOMEM);
1294 /* Set up the remote catalog handle */
1295 ctxt = llog_get_context(cs->cs_obd, LLOG_CHANGELOG_REPL_CTXT);
1297 GOTO(out, rc = -ENOENT);
1298 rc = llog_create(ctxt, &llh, NULL, CHANGELOG_CATALOG);
1300 CERROR("llog_create() failed %d\n", rc);
1303 rc = llog_init_handle(llh, LLOG_F_IS_CAT, NULL);
1305 CERROR("llog_init_handle failed %d\n", rc);
1309 rc = llog_cat_process_flags(llh, changelog_show_cb, cs, 0, 0, 0);
1311 /* Send EOF no matter what our result */
1312 if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
1314 kuch->kuc_msgtype = CL_EOF;
1315 libcfs_kkuc_msg_put(cs->cs_fp, kuch);
1319 cfs_put_file(cs->cs_fp);
1323 llog_ctxt_put(ctxt);
1325 OBD_FREE(cs->cs_buf, CR_MAXSIZE);
1327 /* detach from parent process so we get cleaned up */
1328 cfs_daemonize("cl_send");
1332 static int mdc_ioc_changelog_send(struct obd_device *obd,
1333 struct ioc_changelog *icc)
1335 struct changelog_show *cs;
1338 /* Freed in mdc_changelog_send_thread */
1344 cs->cs_startrec = icc->icc_recno;
1345 /* matching cfs_put_file in mdc_changelog_send_thread */
1346 cs->cs_fp = cfs_get_fd(icc->icc_id);
1347 cs->cs_flags = icc->icc_flags;
1349 /* New thread because we should return to user app before
1350 writing into our pipe */
1351 rc = cfs_create_thread(mdc_changelog_send_thread, cs, CFS_DAEMON_FLAGS);
1353 CDEBUG(D_CHANGELOG, "start changelog thread: %d\n", rc);
1357 CERROR("Failed to start changelog thread: %d\n", rc);
1362 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1363 struct lustre_kernelcomm *lk);
1365 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
1366 void *karg, void *uarg)
1368 struct obd_device *obd = exp->exp_obd;
1369 struct obd_ioctl_data *data = karg;
1370 struct obd_import *imp = obd->u.cli.cl_import;
1371 struct llog_ctxt *ctxt;
1375 if (!cfs_try_module_get(THIS_MODULE)) {
1376 CERROR("Can't get module. Is it alive?");
1380 case LL_IOC_HSM_CT_START:
1381 rc = mdc_ioc_hsm_ct_start(exp, karg);
1383 case OBD_IOC_CHANGELOG_SEND:
1384 rc = mdc_ioc_changelog_send(obd, karg);
1386 case OBD_IOC_CHANGELOG_CLEAR: {
1387 struct ioc_changelog *icc = karg;
1388 struct changelog_setinfo cs =
1389 {.cs_recno = icc->icc_recno, .cs_id = icc->icc_id};
1390 rc = obd_set_info_async(exp, strlen(KEY_CHANGELOG_CLEAR),
1391 KEY_CHANGELOG_CLEAR, sizeof(cs), &cs,
1395 case OBD_IOC_FID2PATH: {
1396 rc = mdc_ioc_fid2path(exp, karg);
1399 case OBD_IOC_CLIENT_RECOVER:
1400 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1, 0);
1404 case IOC_OSC_SET_ACTIVE:
1405 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
1407 case OBD_IOC_PARSE: {
1408 ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
1409 rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL);
1410 llog_ctxt_put(ctxt);
1414 case OBD_IOC_LLOG_INFO:
1415 case OBD_IOC_LLOG_PRINT: {
1416 ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
1417 rc = llog_ioctl(ctxt, cmd, data);
1418 llog_ctxt_put(ctxt);
1422 case OBD_IOC_POLL_QUOTACHECK:
1423 rc = lquota_poll_check(quota_interface, exp,
1424 (struct if_quotacheck *)karg);
1426 case OBD_IOC_PING_TARGET:
1427 rc = ptlrpc_obd_ping(obd);
1430 * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by
1431 * LMV instead of MDC. But when the cluster is upgraded from 1.8,
1432 * there'd be no LMV layer thus we might be called here. Eventually
1433 * this code should be removed.
1436 case IOC_OBD_STATFS: {
1437 struct obd_statfs stat_buf = {0};
1439 if (*((__u32 *) data->ioc_inlbuf2) != 0)
1440 GOTO(out, rc = -ENODEV);
1443 if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd),
1444 min((int) data->ioc_plen2,
1445 (int) sizeof(struct obd_uuid))))
1446 GOTO(out, rc = -EFAULT);
1448 rc = mdc_statfs(obd, &stat_buf,
1449 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
1454 if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf,
1455 min((int) data->ioc_plen1,
1456 (int) sizeof(stat_buf))))
1457 GOTO(out, rc = -EFAULT);
1461 case OBD_IOC_QUOTACTL: {
1462 struct if_quotactl *qctl = karg;
1463 struct obd_quotactl *oqctl;
1465 OBD_ALLOC_PTR(oqctl);
1469 QCTL_COPY(oqctl, qctl);
1470 rc = obd_quotactl(exp, oqctl);
1472 QCTL_COPY(qctl, oqctl);
1473 qctl->qc_valid = QC_MDTIDX;
1474 qctl->obd_uuid = obd->u.cli.cl_target_uuid;
1476 OBD_FREE_PTR(oqctl);
1479 case LL_IOC_GET_CONNECT_FLAGS: {
1480 if (cfs_copy_to_user(uarg, &exp->exp_connect_flags,
1482 GOTO(out, rc = -EFAULT);
1487 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
1488 GOTO(out, rc = -ENOTTY);
1491 cfs_module_put(THIS_MODULE);
1496 int mdc_get_info_rpc(struct obd_export *exp,
1497 obd_count keylen, void *key,
1498 int vallen, void *val)
1500 struct obd_import *imp = class_exp2cliimp(exp);
1501 struct ptlrpc_request *req;
1506 req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO);
1510 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY,
1511 RCL_CLIENT, keylen);
1512 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VALLEN,
1513 RCL_CLIENT, sizeof(__u32));
1515 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_INFO);
1517 ptlrpc_request_free(req);
1521 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY);
1522 memcpy(tmp, key, keylen);
1523 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_VALLEN);
1524 memcpy(tmp, &vallen, sizeof(__u32));
1526 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VAL,
1527 RCL_SERVER, vallen);
1528 ptlrpc_request_set_replen(req);
1530 rc = ptlrpc_queue_wait(req);
1532 tmp = req_capsule_server_get(&req->rq_pill, &RMF_GETINFO_VAL);
1533 memcpy(val, tmp, vallen);
1534 if (ptlrpc_rep_need_swab(req)) {
1535 if (KEY_IS(KEY_FID2PATH)) {
1536 lustre_swab_fid2path(val);
1540 ptlrpc_req_finished(req);
1545 static void lustre_swab_hai(struct hsm_action_item *h)
1547 __swab32s(&h->hai_len);
1548 __swab32s(&h->hai_action);
1549 lustre_swab_lu_fid(&h->hai_fid);
1550 __swab64s(&h->hai_cookie);
1551 __swab64s(&h->hai_extent.offset);
1552 __swab64s(&h->hai_extent.length);
1553 __swab64s(&h->hai_gid);
1556 static void lustre_swab_hal(struct hsm_action_list *h)
1558 struct hsm_action_item *hai;
1561 __swab32s(&h->hal_version);
1562 __swab32s(&h->hal_count);
1563 __swab32s(&h->hal_archive_num);
1565 for (i = 0; i < h->hal_count; i++) {
1566 lustre_swab_hai(hai);
1567 hai = hai_next(hai);
1571 static void lustre_swab_kuch(struct kuc_hdr *l)
1573 __swab16s(&l->kuc_magic);
1574 /* __u8 l->kuc_transport */
1575 __swab16s(&l->kuc_msgtype);
1576 __swab16s(&l->kuc_msglen);
1579 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1580 struct lustre_kernelcomm *lk)
1584 if (lk->lk_group != KUC_GRP_HSM) {
1585 CERROR("Bad copytool group %d\n", lk->lk_group);
1589 CDEBUG(D_HSM, "CT start r%d w%d u%d g%d f%#x\n", lk->lk_rfd, lk->lk_wfd,
1590 lk->lk_uid, lk->lk_group, lk->lk_flags);
1592 if (lk->lk_flags & LK_FLG_STOP)
1593 rc = libcfs_kkuc_group_rem(lk->lk_uid,lk->lk_group);
1595 cfs_file_t *fp = cfs_get_fd(lk->lk_wfd);
1596 rc = libcfs_kkuc_group_add(fp, lk->lk_uid,lk->lk_group,
1602 /* lk_data is archive number mask */
1603 /* TODO: register archive num with mdt so coordinator can choose
1610 * Send a message to any listening copytools
1611 * @param val KUC message (kuc_hdr + hsm_action_list)
1612 * @param len total length of message
1614 static int mdc_hsm_copytool_send(int len, void *val)
1616 struct kuc_hdr *lh = (struct kuc_hdr *)val;
1617 struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1);
1621 if (len < sizeof(*lh) + sizeof(*hal)) {
1622 CERROR("Short HSM message %d < %d\n", len,
1623 (int) (sizeof(*lh) + sizeof(*hal)));
1626 if (lh->kuc_magic == __swab16(KUC_MAGIC)) {
1627 lustre_swab_kuch(lh);
1628 lustre_swab_hal(hal);
1629 } else if (lh->kuc_magic != KUC_MAGIC) {
1630 CERROR("Bad magic %x!=%x\n", lh->kuc_magic, KUC_MAGIC);
1634 CDEBUG(D_HSM, " Received message mg=%x t=%d m=%d l=%d actions=%d\n",
1635 lh->kuc_magic, lh->kuc_transport, lh->kuc_msgtype,
1636 lh->kuc_msglen, hal->hal_count);
1638 /* Broadcast to HSM listeners */
1639 rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
1644 int mdc_set_info_async(struct obd_export *exp,
1645 obd_count keylen, void *key,
1646 obd_count vallen, void *val,
1647 struct ptlrpc_request_set *set)
1649 struct obd_import *imp = class_exp2cliimp(exp);
1653 if (KEY_IS(KEY_READ_ONLY)) {
1654 if (vallen != sizeof(int))
1657 cfs_spin_lock(&imp->imp_lock);
1658 if (*((int *)val)) {
1659 imp->imp_connect_flags_orig |= OBD_CONNECT_RDONLY;
1660 imp->imp_connect_data.ocd_connect_flags |= OBD_CONNECT_RDONLY;
1662 imp->imp_connect_flags_orig &= ~OBD_CONNECT_RDONLY;
1663 imp->imp_connect_data.ocd_connect_flags &= ~OBD_CONNECT_RDONLY;
1665 cfs_spin_unlock(&imp->imp_lock);
1667 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
1668 keylen, key, vallen, val, set);
1671 if (KEY_IS(KEY_SPTLRPC_CONF)) {
1672 sptlrpc_conf_client_adapt(exp->exp_obd);
1675 if (KEY_IS(KEY_FLUSH_CTX)) {
1676 sptlrpc_import_flush_my_ctx(imp);
1679 if (KEY_IS(KEY_MDS_CONN)) {
1680 /* mds-mds import */
1681 cfs_spin_lock(&imp->imp_lock);
1682 imp->imp_server_timeout = 1;
1683 cfs_spin_unlock(&imp->imp_lock);
1684 imp->imp_client->cli_request_portal = MDS_MDS_PORTAL;
1685 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
1688 if (KEY_IS(KEY_CHANGELOG_CLEAR)) {
1689 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
1690 keylen, key, vallen, val, set);
1693 if (KEY_IS(KEY_HSM_COPYTOOL_SEND)) {
1694 rc = mdc_hsm_copytool_send(vallen, val);
1701 int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key,
1702 __u32 *vallen, void *val, struct lov_stripe_md *lsm)
1706 if (KEY_IS(KEY_MAX_EASIZE)) {
1707 int mdsize, *max_easize;
1709 if (*vallen != sizeof(int))
1711 mdsize = *(int*)val;
1712 if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize)
1713 exp->exp_obd->u.cli.cl_max_mds_easize = mdsize;
1715 *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
1717 } else if (KEY_IS(KEY_CONN_DATA)) {
1718 struct obd_import *imp = class_exp2cliimp(exp);
1719 struct obd_connect_data *data = val;
1721 if (*vallen != sizeof(*data))
1724 *data = imp->imp_connect_data;
1726 } else if (KEY_IS(KEY_TGT_COUNT)) {
1731 rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val);
1736 static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid,
1737 struct obd_capa *oc, struct obd_client_handle *handle,
1740 struct ptlrpc_request *req;
1741 struct mdt_body *body;
1745 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_PIN);
1749 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1751 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_PIN);
1753 ptlrpc_request_free(req);
1757 mdc_pack_body(req, fid, oc, 0, 0, -1, flags);
1759 ptlrpc_request_set_replen(req);
1761 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1762 rc = ptlrpc_queue_wait(req);
1763 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1765 CERROR("Pin failed: %d\n", rc);
1769 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1771 GOTO(err_out, rc = -EPROTO);
1773 handle->och_fh = body->handle;
1774 handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
1776 handle->och_mod = obd_mod_alloc();
1777 if (handle->och_mod == NULL) {
1778 DEBUG_REQ(D_ERROR, req, "can't allocate md_open_data");
1779 GOTO(err_out, rc = -ENOMEM);
1781 handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
1786 ptlrpc_req_finished(req);
1790 static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle,
1793 struct ptlrpc_request *req;
1794 struct mdt_body *body;
1798 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_UNPIN,
1799 LUSTRE_MDS_VERSION, MDS_UNPIN);
1803 body = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY);
1804 body->handle = handle->och_fh;
1807 ptlrpc_request_set_replen(req);
1809 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1810 rc = ptlrpc_queue_wait(req);
1811 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1814 CERROR("Unpin failed: %d\n", rc);
1816 ptlrpc_req_finished(req);
1817 ptlrpc_req_finished(handle->och_mod->mod_open_req);
1819 obd_mod_put(handle->och_mod);
1823 int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
1824 struct obd_capa *oc, struct ptlrpc_request **request)
1826 struct ptlrpc_request *req;
1831 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC);
1835 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1837 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC);
1839 ptlrpc_request_free(req);
1843 mdc_pack_body(req, fid, oc, 0, 0, -1, 0);
1845 ptlrpc_request_set_replen(req);
1847 rc = ptlrpc_queue_wait(req);
1849 ptlrpc_req_finished(req);
1855 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
1856 enum obd_import_event event)
1860 LASSERT(imp->imp_obd == obd);
1863 case IMP_EVENT_DISCON: {
1865 /* XXX Pass event up to OBDs stack. used only for FLD now */
1866 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_DISCON, NULL);
1870 case IMP_EVENT_INACTIVE: {
1871 struct client_obd *cli = &obd->u.cli;
1873 * Flush current sequence to make client obtain new one
1874 * from server in case of disconnect/reconnect.
1876 if (cli->cl_seq != NULL)
1877 seq_client_flush(cli->cl_seq);
1879 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE, NULL);
1882 case IMP_EVENT_INVALIDATE: {
1883 struct ldlm_namespace *ns = obd->obd_namespace;
1885 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
1889 case IMP_EVENT_ACTIVE: {
1890 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL);
1894 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
1896 case IMP_EVENT_DEACTIVATE:
1897 case IMP_EVENT_ACTIVATE:
1900 CERROR("Unknown import event %x\n", event);
1906 static int mdc_fid_init(struct obd_export *exp)
1908 struct client_obd *cli = &exp->exp_obd->u.cli;
1913 OBD_ALLOC_PTR(cli->cl_seq);
1914 if (cli->cl_seq == NULL)
1917 OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
1919 GOTO(out_free_seq, rc = -ENOMEM);
1921 snprintf(prefix, MAX_OBD_NAME + 5, "srv-%s",
1922 exp->exp_obd->obd_name);
1924 /* Init client side sequence-manager */
1925 rc = seq_client_init(cli->cl_seq, exp,
1926 LUSTRE_SEQ_METADATA,
1928 OBD_FREE(prefix, MAX_OBD_NAME + 5);
1930 GOTO(out_free_seq, rc);
1934 OBD_FREE_PTR(cli->cl_seq);
1939 static int mdc_fid_fini(struct obd_export *exp)
1941 struct client_obd *cli = &exp->exp_obd->u.cli;
1944 if (cli->cl_seq != NULL) {
1945 seq_client_fini(cli->cl_seq);
1946 OBD_FREE_PTR(cli->cl_seq);
1953 int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
1954 struct md_op_data *op_data)
1956 struct client_obd *cli = &exp->exp_obd->u.cli;
1957 struct lu_client_seq *seq = cli->cl_seq;
1959 RETURN(seq_client_alloc_fid(seq, fid));
1962 /* XXX This method is used only to clear current fid seq
1963 * once fld/mds insert failed */
1964 static int mdc_fid_delete(struct obd_export *exp, const struct lu_fid *fid)
1966 struct client_obd *cli = &exp->exp_obd->u.cli;
1968 seq_client_flush(cli->cl_seq);
1972 struct obd_uuid *mdc_get_uuid(struct obd_export *exp) {
1973 struct client_obd *cli = &exp->exp_obd->u.cli;
1974 return &cli->cl_target_uuid;
1978 * Determine whether the lock can be canceled before replaying it during
1979 * recovery, non zero value will be return if the lock can be canceled,
1980 * or zero returned for not
1982 static int mdc_cancel_for_recovery(struct ldlm_lock *lock)
1984 if (lock->l_resource->lr_type != LDLM_IBITS)
1987 /* FIXME: if we ever get into a situation where there are too many
1988 * opened files with open locks on a single node, then we really
1989 * should replay these open locks to reget it */
1990 if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN)
1996 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
1998 struct client_obd *cli = &obd->u.cli;
1999 struct lprocfs_static_vars lvars = { 0 };
2003 OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2004 if (!cli->cl_rpc_lock)
2006 mdc_init_rpc_lock(cli->cl_rpc_lock);
2010 OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
2011 if (!cli->cl_setattr_lock)
2012 GOTO(err_rpc_lock, rc = -ENOMEM);
2013 mdc_init_rpc_lock(cli->cl_setattr_lock);
2015 OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2016 if (!cli->cl_close_lock)
2017 GOTO(err_setattr_lock, rc = -ENOMEM);
2018 mdc_init_rpc_lock(cli->cl_close_lock);
2020 rc = client_obd_setup(obd, cfg);
2022 GOTO(err_close_lock, rc);
2023 lprocfs_mdc_init_vars(&lvars);
2024 lprocfs_obd_setup(obd, lvars.obd_vars);
2025 sptlrpc_lprocfs_cliobd_attach(obd);
2026 ptlrpc_lprocfs_register_obd(obd);
2028 ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
2030 rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
2033 CERROR("failed to setup llogging subsystems\n");
2039 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2041 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
2043 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2048 /* Initialize the default and maximum LOV EA and cookie sizes. This allows
2049 * us to make MDS RPCs with large enough reply buffers to hold the
2050 * maximum-sized (= maximum striped) EA and cookie without having to
2051 * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */
2052 static int mdc_init_ea_size(struct obd_export *exp, int easize,
2053 int def_easize, int cookiesize)
2055 struct obd_device *obd = exp->exp_obd;
2056 struct client_obd *cli = &obd->u.cli;
2059 if (cli->cl_max_mds_easize < easize)
2060 cli->cl_max_mds_easize = easize;
2062 if (cli->cl_default_mds_easize < def_easize)
2063 cli->cl_default_mds_easize = def_easize;
2065 if (cli->cl_max_mds_cookiesize < cookiesize)
2066 cli->cl_max_mds_cookiesize = cookiesize;
2071 static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2077 case OBD_CLEANUP_EARLY:
2079 case OBD_CLEANUP_EXPORTS:
2080 /* Failsafe, ok if racy */
2081 if (obd->obd_type->typ_refcnt <= 1)
2082 libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
2084 obd_cleanup_client_import(obd);
2086 rc = obd_llog_finish(obd, 0);
2088 CERROR("failed to cleanup llogging subsystems\n");
2094 static int mdc_cleanup(struct obd_device *obd)
2096 struct client_obd *cli = &obd->u.cli;
2098 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2099 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
2100 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2102 ptlrpc_lprocfs_unregister_obd(obd);
2103 lprocfs_obd_cleanup(obd);
2106 return client_obd_cleanup(obd);
2110 static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
2111 struct obd_device *tgt, int *index)
2113 struct llog_ctxt *ctxt;
2117 LASSERT(olg == &obd->obd_olg);
2119 rc = llog_setup(obd, olg, LLOG_LOVEA_REPL_CTXT, tgt, 0, NULL,
2124 ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);
2125 llog_initiator_connect(ctxt);
2126 llog_ctxt_put(ctxt);
2128 rc = llog_setup(obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, 0, NULL,
2131 ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT);
2132 llog_initiator_connect(ctxt);
2133 llog_ctxt_put(ctxt);
2139 static int mdc_llog_finish(struct obd_device *obd, int count)
2141 struct llog_ctxt *ctxt;
2145 ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);
2147 rc = llog_cleanup(ctxt);
2149 ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT);
2151 rc = llog_cleanup(ctxt);
2156 static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
2158 struct lustre_cfg *lcfg = buf;
2159 struct lprocfs_static_vars lvars = { 0 };
2162 lprocfs_mdc_init_vars(&lvars);
2163 switch (lcfg->lcfg_command) {
2165 rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars,
2175 /* get remote permission for current user on fid */
2176 int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
2177 struct obd_capa *oc, __u32 suppgid,
2178 struct ptlrpc_request **request)
2180 struct ptlrpc_request *req;
2184 LASSERT(client_is_remote(exp));
2187 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
2191 mdc_set_capa_size(req, &RMF_CAPA1, oc);
2193 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
2195 ptlrpc_request_free(req);
2199 mdc_pack_body(req, fid, oc, OBD_MD_FLRMTPERM, 0, suppgid, 0);
2201 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
2202 sizeof(struct mdt_remote_perm));
2204 ptlrpc_request_set_replen(req);
2206 rc = ptlrpc_queue_wait(req);
2208 ptlrpc_req_finished(req);
2214 static int mdc_interpret_renew_capa(const struct lu_env *env,
2215 struct ptlrpc_request *req, void *args,
2218 struct mdc_renew_capa_args *ra = args;
2219 struct mdt_body *body = NULL;
2220 struct lustre_capa *capa;
2224 GOTO(out, capa = ERR_PTR(status));
2226 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
2228 GOTO(out, capa = ERR_PTR(-EFAULT));
2230 if ((body->valid & OBD_MD_FLOSSCAPA) == 0)
2231 GOTO(out, capa = ERR_PTR(-ENOENT));
2233 capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA2);
2235 GOTO(out, capa = ERR_PTR(-EFAULT));
2238 ra->ra_cb(ra->ra_oc, capa);
2242 static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2245 struct ptlrpc_request *req;
2246 struct mdc_renew_capa_args *ra;
2249 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR,
2250 LUSTRE_MDS_VERSION, MDS_GETATTR);
2254 /* NB, OBD_MD_FLOSSCAPA is set here, but it doesn't necessarily mean the
2255 * capa to renew is oss capa.
2257 mdc_pack_body(req, &oc->c_capa.lc_fid, oc, OBD_MD_FLOSSCAPA, 0, -1, 0);
2258 ptlrpc_request_set_replen(req);
2260 CLASSERT(sizeof(*ra) <= sizeof(req->rq_async_args));
2261 ra = ptlrpc_req_async_args(req);
2264 req->rq_interpret_reply = mdc_interpret_renew_capa;
2265 ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
2269 static int mdc_connect(const struct lu_env *env,
2270 struct obd_export **exp,
2271 struct obd_device *obd, struct obd_uuid *cluuid,
2272 struct obd_connect_data *data,
2275 struct obd_import *imp = obd->u.cli.cl_import;
2277 /* mds-mds import features */
2278 if (data && (data->ocd_connect_flags & OBD_CONNECT_MDS_MDS)) {
2279 cfs_spin_lock(&imp->imp_lock);
2280 imp->imp_server_timeout = 1;
2281 cfs_spin_unlock(&imp->imp_lock);
2282 imp->imp_client->cli_request_portal = MDS_MDS_PORTAL;
2283 CDEBUG(D_OTHER, "%s: Set 'mds' portal and timeout\n",
2287 return client_connect_import(env, exp, obd, cluuid, data, NULL);
2290 struct obd_ops mdc_obd_ops = {
2291 .o_owner = THIS_MODULE,
2292 .o_setup = mdc_setup,
2293 .o_precleanup = mdc_precleanup,
2294 .o_cleanup = mdc_cleanup,
2295 .o_add_conn = client_import_add_conn,
2296 .o_del_conn = client_import_del_conn,
2297 .o_connect = mdc_connect,
2298 .o_disconnect = client_disconnect_export,
2299 .o_iocontrol = mdc_iocontrol,
2300 .o_set_info_async = mdc_set_info_async,
2301 .o_statfs = mdc_statfs,
2303 .o_unpin = mdc_unpin,
2304 .o_fid_init = mdc_fid_init,
2305 .o_fid_fini = mdc_fid_fini,
2306 .o_fid_alloc = mdc_fid_alloc,
2307 .o_fid_delete = mdc_fid_delete,
2308 .o_import_event = mdc_import_event,
2309 .o_llog_init = mdc_llog_init,
2310 .o_llog_finish = mdc_llog_finish,
2311 .o_get_info = mdc_get_info,
2312 .o_process_config = mdc_process_config,
2313 .o_get_uuid = mdc_get_uuid,
2316 struct md_ops mdc_md_ops = {
2317 .m_getstatus = mdc_getstatus,
2318 .m_change_cbdata = mdc_change_cbdata,
2319 .m_find_cbdata = mdc_find_cbdata,
2320 .m_close = mdc_close,
2321 .m_create = mdc_create,
2322 .m_done_writing = mdc_done_writing,
2323 .m_enqueue = mdc_enqueue,
2324 .m_getattr = mdc_getattr,
2325 .m_getattr_name = mdc_getattr_name,
2326 .m_intent_lock = mdc_intent_lock,
2328 .m_is_subdir = mdc_is_subdir,
2329 .m_rename = mdc_rename,
2330 .m_setattr = mdc_setattr,
2331 .m_setxattr = mdc_setxattr,
2332 .m_getxattr = mdc_getxattr,
2334 .m_readpage = mdc_readpage,
2335 .m_unlink = mdc_unlink,
2336 .m_cancel_unused = mdc_cancel_unused,
2337 .m_init_ea_size = mdc_init_ea_size,
2338 .m_set_lock_data = mdc_set_lock_data,
2339 .m_lock_match = mdc_lock_match,
2340 .m_get_lustre_md = mdc_get_lustre_md,
2341 .m_free_lustre_md = mdc_free_lustre_md,
2342 .m_set_open_replay_data = mdc_set_open_replay_data,
2343 .m_clear_open_replay_data = mdc_clear_open_replay_data,
2344 .m_renew_capa = mdc_renew_capa,
2345 .m_unpack_capa = mdc_unpack_capa,
2346 .m_get_remote_perm = mdc_get_remote_perm,
2347 .m_intent_getattr_async = mdc_intent_getattr_async,
2348 .m_revalidate_lock = mdc_revalidate_lock
2351 int __init mdc_init(void)
2354 struct lprocfs_static_vars lvars = { 0 };
2355 lprocfs_mdc_init_vars(&lvars);
2357 cfs_request_module("lquota");
2358 quota_interface = PORTAL_SYMBOL_GET(mdc_quota_interface);
2359 init_obd_quota_ops(quota_interface, &mdc_obd_ops);
2361 rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
2362 LUSTRE_MDC_NAME, NULL);
2363 if (rc && quota_interface)
2364 PORTAL_SYMBOL_PUT(mdc_quota_interface);
2370 static void /*__exit*/ mdc_exit(void)
2372 if (quota_interface)
2373 PORTAL_SYMBOL_PUT(mdc_quota_interface);
2375 class_unregister_type(LUSTRE_MDC_NAME);
2378 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2379 MODULE_DESCRIPTION("Lustre Metadata Client");
2380 MODULE_LICENSE("GPL");
2382 module_init(mdc_init);
2383 module_exit(mdc_exit);