1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2001-2004 Cluster File Systems, Inc.
6 * This file is part of Lustre, http://www.sf.net/projects/lustre/
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # define EXPORT_SYMTAB
25 #define DEBUG_SUBSYSTEM S_MDC
28 # include <linux/module.h>
29 # include <linux/pagemap.h>
30 # include <linux/miscdevice.h>
31 # include <linux/init.h>
33 # include <liblustre.h>
36 #include <linux/obd_class.h>
37 #include <linux/lustre_mds.h>
38 #include <linux/lustre_dlm.h>
39 #include <linux/lustre_sec.h>
40 #include <linux/lprocfs_status.h>
41 #include <linux/lustre_acl.h>
42 #include "mdc_internal.h"
44 #define REQUEST_MINOR 244
46 static int mdc_cleanup(struct obd_device *obd, int flags);
48 extern int mds_queue_req(struct ptlrpc_request *);
49 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
50 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
51 static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid,
52 int level, int msg_flags)
54 struct ptlrpc_request *req;
55 struct mds_body *body;
56 int rc, size[2] = {0, sizeof(*body)};
59 //size[0] = lustre_secdesc_size();
61 req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS,
64 GOTO(out, rc = -ENOMEM);
66 //lustre_pack_secdesc(req, size[0]);
68 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
69 req->rq_send_state = level;
70 req->rq_replen = lustre_msg_size(1, &size[1]);
72 req->rq_reqmsg->flags |= msg_flags;
73 rc = ptlrpc_queue_wait(req);
76 body = lustre_swab_repbuf (req, 0, sizeof (*body),
77 lustre_swab_mds_body);
79 CERROR ("Can't extract mds_body\n");
80 GOTO (out, rc = -EPROTO);
83 memcpy(rootid, &body->id1, sizeof(*rootid));
85 CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64
86 ", last_xid="LPU64"\n", rootid->li_stc.u.e3s.l3s_ino,
87 req->rq_repmsg->last_committed, req->rq_repmsg->last_xid);
92 ptlrpc_req_finished(req);
96 /* This should be mdc_get_info("rootid") */
97 int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid)
99 return send_getstatus(class_exp2cliimp(exp), rootid,
103 int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
104 struct ptlrpc_request *req)
106 struct mds_body *body, *reqbody;
109 int repsize[2] = {sizeof(*body)};
113 /* request message already built */
116 repsize[bufcount++] = ea_size;
117 CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n",
121 reqbody = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*reqbody));
122 LASSERT(!(reqbody->valid & OBD_MD_FLACL));
124 req->rq_replen = lustre_msg_size(bufcount, repsize);
126 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
127 rc = ptlrpc_queue_wait(req);
128 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
132 body = lustre_swab_repbuf (req, 0, sizeof (*body),
133 lustre_swab_mds_body);
135 CERROR ("Can't unpack mds_body\n");
139 CDEBUG(D_NET, "mode: %o\n", body->mode);
141 LASSERT_REPSWAB (req, 1);
143 /* Skip the check if getxattr/listxattr are called with no buffers */
144 if ((reqbody->eadatasize != 0) &&
145 !(reqbody->valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST))) {
146 /* reply indicates presence of eadata; check it's there... */
147 eadata = lustre_msg_buf (req->rq_repmsg, 1,
149 if (eadata == NULL) {
150 CERROR ("Missing/short eadata\n");
158 static int mdc_cancel_unused(struct obd_export *exp,
159 struct lov_stripe_md *lsm,
160 int flags, void *opaque)
162 struct obd_device *obd = class_exp2obd(exp);
165 RETURN(ldlm_cli_cancel_unused(obd->obd_namespace,
166 NULL, flags, opaque));
169 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
170 __u64 valid, const char *xattr_name,
171 const void *xattr_data, unsigned int xattr_datalen,
172 unsigned int ea_size, struct ptlrpc_request **request)
174 struct ptlrpc_request *req;
175 struct mds_body *body;
176 int xattr_namelen = xattr_name ? strlen(xattr_name) + 1 : 0;
177 int size[4] = {0, sizeof(*body)};
182 size[0] = lustre_secdesc_size();
184 if (valid & OBD_MD_FLXATTR) {
185 size[bufcount++] = xattr_namelen;
187 if (xattr_datalen > 0) {
189 size[bufcount++] = xattr_datalen;
192 LASSERT(!xattr_data && !xattr_datalen);
194 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
195 MDS_GETATTR, bufcount, size, NULL);
197 GOTO(out, rc = -ENOMEM);
199 lustre_pack_secdesc(req, size[0]);
201 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
202 memcpy(&body->id1, id, sizeof(*id));
204 body->eadatasize = ea_size;
206 if (valid & OBD_MD_FLXATTR) {
207 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, xattr_namelen),
208 xattr_name, xattr_namelen);
210 memcpy(lustre_msg_buf(req->rq_reqmsg, 3, xattr_datalen),
211 xattr_data, xattr_datalen);
214 rc = mdc_getattr_common(exp, ea_size, req);
216 ptlrpc_req_finished (req);
224 int mdc_access_check(struct obd_export *exp, struct lustre_id *id,
225 struct ptlrpc_request **request)
228 struct ptlrpc_request *req;
229 struct mds_body *body;
230 int size[2] = {0, sizeof(*body)};
234 size[0] = lustre_secdesc_size();
235 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
236 MDS_ACCESS_CHECK, 2, size, NULL);
238 GOTO(out, rc = -ENOMEM);
240 lustre_pack_secdesc(req, size[0]);
241 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
242 memcpy(&body->id1, id, sizeof(*id));
244 req->rq_replen = lustre_msg_size(2, size);
245 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
246 rc = ptlrpc_queue_wait(req);
247 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
249 ptlrpc_req_finished (req);
252 body = lustre_swab_repbuf (req, 0, sizeof (*body),
253 lustre_swab_mds_body);
255 CERROR ("Can't unpack mds_body\n");
265 int mdc_getattr_lock(struct obd_export *exp, struct lustre_id *id,
266 char *filename, int namelen, __u64 valid,
267 unsigned int ea_size, struct ptlrpc_request **request)
269 struct ptlrpc_request *req;
270 struct mds_body *body;
271 int rc, size[3] = {0, sizeof(*body), namelen};
274 size[0] = lustre_secdesc_size();
276 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
277 MDS_GETATTR_LOCK, 3, size, NULL);
279 GOTO(out, rc = -ENOMEM);
281 lustre_pack_secdesc(req, size[0]);
283 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
284 memcpy(&body->id1, id, sizeof(*id));
286 body->eadatasize = ea_size;
288 if (filename != NULL) {
289 LASSERT (strnlen (filename, namelen) == namelen - 1);
290 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, namelen),
293 LASSERT(namelen == 1);
296 rc = mdc_getattr_common(exp, ea_size, req);
298 ptlrpc_req_finished (req);
306 /* This should be called with both the request and the reply still packed. */
307 int mdc_store_inode_generation(struct obd_export *exp,
308 struct ptlrpc_request *req,
309 int reqoff, int repoff)
311 struct mds_rec_create *rec =
312 lustre_msg_buf(req->rq_reqmsg, reqoff, sizeof(*rec));
313 struct mds_body *body =
314 lustre_msg_buf(req->rq_repmsg, repoff, sizeof(*body));
316 LASSERT (rec != NULL);
317 LASSERT (body != NULL);
319 memcpy(&rec->cr_replayid, &body->id1, sizeof(rec->cr_replayid));
320 DEBUG_REQ(D_HA, req, "storing generation for ino "DLID4,
321 OLID4(&rec->cr_replayid));
325 int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req,
326 unsigned int offset, struct obd_export *exp_lov,
327 struct lustre_md *md)
329 struct lov_mds_md *lmm;
330 struct posix_acl *acl;
331 struct mds_remote_perm *perm;
338 memset(md, 0, sizeof(*md));
340 md->body = lustre_msg_buf(req->rq_repmsg, offset,
345 LASSERT_REPSWABBED(req, offset);
347 if (!(md->body->valid & OBD_MD_FLEASIZE) &&
348 !(md->body->valid & OBD_MD_FLDIREA))
351 if (S_ISREG(md->body->mode)) {
352 if (md->body->eadatasize == 0) {
353 CERROR("invalid EA size (0) is detected\n");
357 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
358 md->body->eadatasize);
362 LASSERT(exp_lov != NULL);
364 rc = obd_unpackmd(exp_lov, &md->lsm, lmm,
365 md->body->eadatasize);
367 LASSERT(rc >= sizeof(*md->lsm));
370 } else if (S_ISDIR(md->body->mode)) {
371 /* dir can be non-splitted */
372 if (md->body->eadatasize == 0)
375 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
376 md->body->eadatasize);
380 if (md->body->valid & OBD_MD_MEA) {
381 LASSERT(exp_lmv != NULL);
383 rc = obd_unpackmd(exp_lmv, (void *)&md->mea,
384 lmm, md->body->eadatasize);
386 LASSERT(rc >= sizeof(*md->mea));
391 LASSERT(S_ISCHR(md->body->mode) ||
392 S_ISBLK(md->body->mode) ||
393 S_ISFIFO(md->body->mode)||
394 S_ISLNK(md->body->mode) ||
395 S_ISSOCK(md->body->mode));
398 /* if anything wrong when unpacking md, we don't check acl
399 * stuff, for simplicity
404 if (md->body->valid & OBD_MD_FLACL) {
405 acl_off = (md->body->valid & OBD_MD_FLEASIZE) ?
406 (offset + 2) : (offset + 1);
408 if (md->body->valid & OBD_MD_FLRMTACL) {
410 buf = lustre_swab_repbuf(req, acl_off, sizeof(*perm),
411 lustre_swab_remote_perm);
413 CERROR("Can't unpack remote perm\n");
417 OBD_ALLOC(perm, sizeof(*perm));
420 memcpy(perm, buf, sizeof(*perm));
422 md->remote_perm = perm;
424 size = le32_to_cpu(*(__u32 *) lustre_msg_buf(
425 req->rq_repmsg, acl_off, 4));
426 buf = lustre_msg_buf(req->rq_repmsg, acl_off + 1, size);
428 acl = posix_acl_from_xattr(buf, size);
431 CERROR("convert xattr to acl failed: %d\n", rc);
434 rc = posix_acl_valid(acl);
436 CERROR("acl valid error: %d\n", rc);
437 posix_acl_release(acl);
449 static void mdc_commit_open(struct ptlrpc_request *req)
451 struct mdc_open_data *mod = req->rq_cb_data;
455 if (mod->mod_close_req != NULL)
456 mod->mod_close_req->rq_cb_data = NULL;
458 if (mod->mod_och != NULL)
459 mod->mod_och->och_mod = NULL;
461 OBD_FREE(mod, sizeof(*mod));
462 req->rq_cb_data = NULL;
463 LASSERT(atomic_read(&req->rq_refcount) > 1);
464 ptlrpc_req_finished(req);
467 static void mdc_replay_open(struct ptlrpc_request *req)
469 struct mdc_open_data *mod = req->rq_cb_data;
470 struct obd_client_handle *och;
471 struct ptlrpc_request *close_req;
472 struct lustre_handle old;
473 struct mds_body *body;
476 body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body);
477 LASSERT (body != NULL);
480 DEBUG_REQ(D_ERROR, req,
481 "can't properly replay without open data");
488 struct lustre_handle *file_fh;
489 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
490 file_fh = &och->och_fh;
491 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
492 file_fh->cookie, body->handle.cookie);
493 memcpy(&old, file_fh, sizeof(old));
494 memcpy(file_fh, &body->handle, sizeof(*file_fh));
497 close_req = mod->mod_close_req;
498 if (close_req != NULL) {
499 struct mds_body *close_body;
500 LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE);
501 close_body = lustre_msg_buf(close_req->rq_reqmsg,
503 sizeof(*close_body));
505 LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
506 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
507 memcpy(&close_body->handle, &body->handle,
508 sizeof(close_body->handle));
514 int mdc_set_open_replay_data(struct obd_export *exp,
515 struct obd_client_handle *och,
516 struct ptlrpc_request *open_req)
518 struct mdc_open_data *mod;
519 struct mds_rec_create *rec;
520 struct mds_body *body;
522 rec = lustre_msg_buf(open_req->rq_reqmsg, MDS_REQ_INTENT_REC_OFF,
524 body = lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body));
526 LASSERT(rec != NULL);
527 /* outgoing messages always in my byte order */
528 LASSERT(body != NULL);
529 /* incoming message in my byte order (it's been swabbed) */
530 LASSERT_REPSWABBED(open_req, 1);
532 OBD_ALLOC(mod, sizeof(*mod));
534 DEBUG_REQ(D_ERROR, open_req, "can't allocate mdc_open_data");
540 mod->mod_open_req = ptlrpc_request_addref(open_req);
542 memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid);
543 open_req->rq_replay_cb = mdc_replay_open;
544 open_req->rq_commit_cb = mdc_commit_open;
545 open_req->rq_cb_data = mod;
546 DEBUG_REQ(D_HA, open_req, "set up replay data");
550 int mdc_clear_open_replay_data(struct obd_export *exp,
551 struct obd_client_handle *och)
553 struct mdc_open_data *mod = och->och_mod;
555 /* Don't free the structure now (it happens in mdc_commit_open, after
556 * we're sure we won't need to fix up the close request in the future),
557 * but make sure that replay doesn't poke at the och, which is about to
559 LASSERT(mod != LP_POISON);
566 static void mdc_commit_close(struct ptlrpc_request *req)
568 struct mdc_open_data *mod = req->rq_cb_data;
569 struct ptlrpc_request *open_req;
570 struct obd_import *imp = req->rq_import;
572 DEBUG_REQ(D_HA, req, "close req committed");
576 mod->mod_close_req = NULL;
577 req->rq_cb_data = NULL;
578 req->rq_commit_cb = NULL;
580 open_req = mod->mod_open_req;
581 LASSERT(open_req != NULL);
582 LASSERT(open_req != LP_POISON);
583 LASSERT(open_req->rq_type != LI_POISON);
585 DEBUG_REQ(D_HA, open_req, "open req balanced");
586 if (open_req->rq_transno == 0) {
587 DEBUG_REQ(D_ERROR, open_req, "BUG 3892 open");
588 DEBUG_REQ(D_ERROR, req, "BUG 3892 close");
589 LASSERTF(open_req->rq_transno != 0, "BUG 3892\n");
591 LASSERT(open_req->rq_import == imp);
593 /* We no longer want to preserve this for transno-unconditional
595 spin_lock(&open_req->rq_lock);
596 open_req->rq_replay = 0;
597 spin_unlock(&open_req->rq_lock);
600 int mdc_close(struct obd_export *exp, struct obdo *oa,
601 struct obd_client_handle *och,
602 struct ptlrpc_request **request)
604 struct obd_device *obd = class_exp2obd(exp);
605 struct obd_import *imp = class_exp2cliimp(exp);
606 int reqsize[3] = {0, sizeof(struct mds_body),
607 obd->u.cli.cl_max_mds_cookiesize};
608 int rc, repsize[3] = {sizeof(struct mds_body),
609 obd->u.cli.cl_max_mds_easize,
610 obd->u.cli.cl_max_mds_cookiesize};
611 struct ptlrpc_request *req;
612 struct mdc_open_data *mod;
615 if (imp->imp_connection == NULL) {
616 CERROR("request on not connected import %s\n",
617 imp->imp_obd->obd_name);
621 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
622 MDS_CLOSE, 3, reqsize, NULL);
624 GOTO(out, rc = -ENOMEM);
626 //reqsize[0] = lustre_secdesc_size();
627 //lustre_pack_secdesc(req, reqsize[0]);
629 /* Ensure that this close's handle is fixed up during replay. */
630 LASSERT(och != NULL);
632 if (likely(mod != NULL)) {
633 mod->mod_close_req = req;
634 LASSERT(mod->mod_open_req->rq_type != LI_POISON);
635 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
637 CDEBUG(D_HA, "couldn't find open req; "
638 "expecting close error\n");
641 mdc_close_pack(req, 1, oa, oa->o_valid, och);
643 req->rq_replen = lustre_msg_size(3, repsize);
644 req->rq_commit_cb = mdc_commit_close;
645 LASSERT(req->rq_cb_data == NULL);
646 req->rq_cb_data = mod;
648 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
649 rc = ptlrpc_queue_wait(req);
650 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
652 if (req->rq_repmsg == NULL) {
653 CDEBUG(D_HA, "request failed to send: %p, %d\n", req,
656 rc = req->rq_status ? req->rq_status : -EIO;
657 } else if (rc == 0) {
658 rc = req->rq_repmsg->status;
659 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
660 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, "
666 CERROR("Unexpected: can't find mdc_open_data, but "
667 "close succeeded. Please tell CFS.\n");
668 if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body),
669 lustre_swab_mds_body))
671 CERROR("Error unpacking mds_body\n");
683 int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
685 struct ptlrpc_request *req;
686 struct mds_body *body;
687 int rc, size[2] = {0, sizeof(*body)};
690 size[0] = lustre_secdesc_size();
692 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
693 MDS_DONE_WRITING, 2, size, NULL);
697 lustre_pack_secdesc(req, size[0]);
699 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
702 mdc_pack_id(&body->id1, obdo->o_id, 0, obdo->o_mode,
703 obdo->o_mds, obdo->o_fid);
705 body->size = obdo->o_size;
706 body->blocks = obdo->o_blocks;
707 body->flags = obdo->o_flags;
708 body->valid = obdo->o_valid;
710 req->rq_replen = lustre_msg_size(1, &size[1]);
712 rc = ptlrpc_queue_wait(req);
713 ptlrpc_req_finished(req);
717 int mdc_readpage(struct obd_export *exp,
718 struct lustre_id *id,
719 __u64 offset, struct page *page,
720 struct ptlrpc_request **request)
722 struct obd_import *imp = class_exp2cliimp(exp);
723 struct ptlrpc_request *req = NULL;
724 struct ptlrpc_bulk_desc *desc = NULL;
725 struct mds_body *body;
726 int rc, size[2] = {0, sizeof(*body)};
729 CDEBUG(D_INODE, "inode: %ld\n", (long)id->li_stc.u.e3s.l3s_ino);
731 size[0] = lustre_secdesc_size();
733 req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE,
736 GOTO(out, rc = -ENOMEM);
737 /* XXX FIXME bug 249 */
738 req->rq_request_portal = MDS_READPAGE_PORTAL;
740 lustre_pack_secdesc(req, size[0]);
742 desc = ptlrpc_prep_bulk_imp(req, 1, BULK_PUT_SINK, MDS_BULK_PORTAL);
744 GOTO(out, rc = -ENOMEM);
745 /* NB req now owns desc and will free it when it gets freed */
747 ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE);
748 mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, id);
750 req->rq_replen = lustre_msg_size(1, &size[1]);
751 rc = ptlrpc_queue_wait(req);
754 body = lustre_swab_repbuf(req, 0, sizeof (*body),
755 lustre_swab_mds_body);
757 CERROR("Can't unpack mds_body\n");
758 GOTO(out, rc = -EPROTO);
761 if (req->rq_bulk->bd_nob_transferred != PAGE_CACHE_SIZE) {
762 CERROR ("Unexpected # bytes transferred: %d"
764 req->rq_bulk->bd_nob_transferred,
766 GOTO (out, rc = -EPROTO);
776 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
777 void *karg, void *uarg)
779 struct obd_device *obd = exp->exp_obd;
780 struct obd_ioctl_data *data = karg;
781 struct obd_import *imp = obd->u.cli.cl_import;
782 struct llog_ctxt *ctxt;
786 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
789 if (!try_module_get(THIS_MODULE)) {
790 CERROR("Can't get module. Is it alive?");
795 case OBD_IOC_CLIENT_RECOVER:
796 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1);
800 case IOC_OSC_SET_ACTIVE:
801 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
803 case IOC_OSC_CTL_RECOVERY:
804 rc = ptlrpc_import_control_recovery(imp, data->ioc_offset);
806 case OBD_IOC_PARSE: {
807 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,
808 LLOG_CONFIG_REPL_CTXT);
809 rc = class_config_process_llog(ctxt, data->ioc_inlbuf1, NULL);
813 case OBD_IOC_LLOG_INFO:
814 case OBD_IOC_LLOG_PRINT: {
815 ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_REPL_CTXT);
816 rc = llog_ioctl(ctxt, cmd, data);
822 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
823 GOTO(out, rc = -ENOTTY);
826 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
829 module_put(THIS_MODULE);
835 int mdc_set_info(struct obd_export *exp, obd_count keylen,
836 void *key, obd_count vallen, void *val)
840 if (keylen == strlen("initial_recov") &&
841 memcmp(key, "initial_recov", strlen("initial_recov")) == 0) {
842 struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
843 if (vallen != sizeof(int))
845 imp->imp_initial_recov = *(int *)val;
846 CDEBUG(D_HA, "%s: set imp_no_init_recov = %d\n",
847 exp->exp_obd->obd_name,
848 imp->imp_initial_recov);
850 } else if (keylen >= strlen("mds_type") &&
851 strcmp(key, "mds_type") == 0) {
852 struct ptlrpc_request *req;
853 char *bufs[2] = {key, val};
854 int rc, size[2] = {keylen, vallen};
856 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
857 OST_SET_INFO, 2, size, bufs);
861 req->rq_replen = lustre_msg_size(0, NULL);
862 rc = ptlrpc_queue_wait(req);
863 ptlrpc_req_finished(req);
865 } else if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
866 struct obd_import *imp = class_exp2cliimp(exp);
867 imp->imp_server_timeout = 1;
868 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
870 } else if (keylen == strlen("sec") &&
871 memcmp(key, "sec", keylen) == 0) {
872 struct client_obd *cli = &exp->exp_obd->u.cli;
874 cli->cl_sec_flavor = ptlrpcs_name2flavor(val);
875 if (cli->cl_sec_flavor == PTLRPCS_FLVR_INVALID) {
876 CERROR("unrecognized security type %s\n", (char*) val);
881 } else if (keylen == strlen("sec_flags") &&
882 memcmp(key, "sec_flags", keylen) == 0) {
883 struct client_obd *cli = &exp->exp_obd->u.cli;
885 cli->cl_sec_flags = *((unsigned long *) val);
887 } else if (keylen == strlen("flush_cred") &&
888 memcmp(key, "flush_cred", keylen) == 0) {
889 struct client_obd *cli = &exp->exp_obd->u.cli;
892 ptlrpcs_import_flush_current_creds(cli->cl_import);
894 } else if (keylen == strlen("async") && memcmp(key, "async", keylen) == 0) {
895 struct client_obd *cl = &exp->exp_obd->u.cli;
896 if (vallen != sizeof(int))
898 cl->cl_async = *(int *)val;
899 CDEBUG(D_HA, "%s: set async = %d\n",
900 exp->exp_obd->obd_name, cl->cl_async);
906 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
907 unsigned long max_age)
909 struct obd_statfs *msfs;
910 struct ptlrpc_request *req;
911 int rc, size = sizeof(*msfs);
914 /* We could possibly pass max_age in the request (as an absolute
915 * timestamp or a "seconds.usec ago") so the target can avoid doing
916 * extra calls into the filesystem if that isn't necessary (e.g.
917 * during mount that would help a bit). Having relative timestamps
918 * is not so great if request processing is slow, while absolute
919 * timestamps are not ideal because they need time synchronization. */
920 req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_MDS_VERSION,
921 MDS_STATFS, 0, NULL, NULL);
925 req->rq_replen = lustre_msg_size(1, &size);
927 mdc_get_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
928 rc = ptlrpc_queue_wait(req);
929 mdc_put_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
932 /* this can be LMV fake import, whcih is not connected. */
933 if (!req->rq_import->imp_connection)
934 memset(osfs, 0, sizeof(*osfs));
938 msfs = lustre_swab_repbuf(req, 0, sizeof(*msfs),
939 lustre_swab_obd_statfs);
941 CERROR("Can't unpack obd_statfs\n");
942 GOTO(out, rc = -EPROTO);
945 memcpy(osfs, msfs, sizeof (*msfs));
948 ptlrpc_req_finished(req);
952 static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type,
953 struct obd_client_handle *handle, int flag)
955 struct ptlrpc_request *req;
956 struct mds_body *body;
957 int rc, size[2] = {0, sizeof(*body)};
960 //size[0] = lustre_secdesc_size();
962 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
963 MDS_PIN, 2, size, NULL);
967 //lustre_pack_secdesc(req, size[0]);
969 body = lustre_msg_buf(req->rq_reqmsg,
970 MDS_REQ_REC_OFF, sizeof(*body));
972 /* FIXME-UMKA: here should be also mdsnum and fid. */
973 mdc_pack_id(&body->id1, ino, gen, type, 0, 0);
976 req->rq_replen = lustre_msg_size(1, &size[1]);
978 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
979 rc = ptlrpc_queue_wait(req);
980 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
982 CERROR("pin failed: %d\n", rc);
983 ptlrpc_req_finished(req);
987 body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
989 ptlrpc_req_finished(req);
993 memcpy(&handle->och_fh, &body->handle, sizeof(body->handle));
994 handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
996 OBD_ALLOC(handle->och_mod, sizeof(*handle->och_mod));
997 if (handle->och_mod == NULL) {
998 DEBUG_REQ(D_ERROR, req, "can't allocate mdc_open_data");
1001 handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
1006 static int mdc_unpin(struct obd_export *exp,
1007 struct obd_client_handle *handle, int flag)
1009 struct ptlrpc_request *req;
1010 struct mds_body *body;
1011 int rc, size[2] = {0, sizeof(*body)};
1014 if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)
1017 //size[0] = lustre_secdesc_size();
1019 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1020 MDS_CLOSE, 2, size, NULL);
1024 //lustre_pack_secdesc(req, size[0]);
1026 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body));
1027 memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));
1030 req->rq_replen = lustre_msg_size(0, NULL);
1031 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1032 rc = ptlrpc_queue_wait(req);
1033 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1036 CERROR("unpin failed: %d\n", rc);
1038 ptlrpc_req_finished(req);
1039 ptlrpc_req_finished(handle->och_mod->mod_open_req);
1040 OBD_FREE(handle->och_mod, sizeof(*handle->och_mod));
1044 int mdc_sync(struct obd_export *exp, struct lustre_id *id,
1045 struct ptlrpc_request **request)
1047 struct ptlrpc_request *req;
1048 struct mds_body *body;
1049 int size[2] = {0, sizeof(*body)};
1053 //size[0] = lustre_secdesc_size();
1055 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1056 MDS_SYNC, 2, size, NULL);
1058 RETURN(rc = -ENOMEM);
1060 //lustre_pack_secdesc(req, size[0]);
1063 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
1065 memcpy(&body->id1, id, sizeof(*id));
1068 req->rq_replen = lustre_msg_size(1, &size[1]);
1070 rc = ptlrpc_queue_wait(req);
1071 if (rc || request == NULL)
1072 ptlrpc_req_finished(req);
1079 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
1080 enum obd_import_event event)
1084 LASSERT(imp->imp_obd == obd);
1087 case IMP_EVENT_DISCON: {
1090 case IMP_EVENT_INACTIVE: {
1091 if (obd->obd_observer)
1092 rc = obd_notify(obd->obd_observer, obd, 0, 0);
1095 case IMP_EVENT_INVALIDATE: {
1096 struct ldlm_namespace *ns = obd->obd_namespace;
1098 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
1102 case IMP_EVENT_ACTIVE: {
1103 if (obd->obd_observer)
1104 rc = obd_notify(obd->obd_observer, obd, 1, 0);
1108 CERROR("Unknown import event %d\n", event);
1114 static int mdc_attach(struct obd_device *dev, obd_count len, void *data)
1116 struct lprocfs_static_vars lvars;
1118 lprocfs_init_vars(mdc, &lvars);
1119 return lprocfs_obd_attach(dev, lvars.obd_vars);
1122 static int mdc_detach(struct obd_device *dev)
1124 return lprocfs_obd_detach(dev);
1127 static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
1129 struct client_obd *cli = &obd->u.cli;
1133 OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1134 if (!cli->cl_rpc_lock)
1136 mdc_init_rpc_lock(cli->cl_rpc_lock);
1140 OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1141 if (!cli->cl_setattr_lock)
1142 GOTO(err_rpc_lock, rc = -ENOMEM);
1143 mdc_init_rpc_lock(cli->cl_setattr_lock);
1145 OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1146 if (!cli->cl_close_lock)
1147 GOTO(err_setattr_lock, rc = -ENOMEM);
1148 mdc_init_rpc_lock(cli->cl_close_lock);
1150 rc = client_obd_setup(obd, len, buf);
1152 GOTO(err_close_lock, rc);
1154 rc = obd_llog_init(obd, &obd->obd_llogs, obd, 0, NULL);
1156 mdc_cleanup(obd, 0);
1157 CERROR("failed to setup llogging subsystems\n");
1163 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1165 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1167 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1172 static int mdc_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
1174 struct obd_device *obd = exp->exp_obd;
1175 struct client_obd *cli = &obd->u.cli;
1178 if (cli->cl_max_mds_easize < easize)
1179 cli->cl_max_mds_easize = easize;
1180 if (cli->cl_max_mds_cookiesize < cookiesize)
1181 cli->cl_max_mds_cookiesize = cookiesize;
1185 static int mdc_precleanup(struct obd_device *obd, int flags)
1189 rc = obd_llog_finish(obd, &obd->obd_llogs, 0);
1191 CERROR("failed to cleanup llogging subsystems\n");
1196 static int mdc_cleanup(struct obd_device *obd, int flags)
1198 struct client_obd *cli = &obd->u.cli;
1200 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1201 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1202 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1206 return client_obd_cleanup(obd, flags);
1210 static int mdc_llog_init(struct obd_device *obd, struct obd_llogs *llogs,
1211 struct obd_device *tgt, int count,
1212 struct llog_catid *logid)
1214 struct llog_ctxt *ctxt;
1218 rc = obd_llog_setup(obd, llogs, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
1221 ctxt = llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT);
1222 ctxt->loc_imp = obd->u.cli.cl_import;
1228 static int mdc_llog_finish(struct obd_device *obd,
1229 struct obd_llogs *llogs, int count)
1234 rc = obd_llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT));
1237 static struct obd_device *mdc_get_real_obd(struct obd_export *exp,
1238 struct lustre_id *id)
1241 RETURN(exp->exp_obd);
1244 static int mdc_get_info(struct obd_export *exp, __u32 keylen,
1245 void *key, __u32 *valsize, void *val)
1247 struct ptlrpc_request *req;
1248 char *bufs[1] = {key};
1252 if (!valsize || !val)
1255 if (keylen == strlen("remote_flag") && !strcmp(key, "remote_flag")) {
1256 struct obd_import *imp;
1257 struct obd_connect_data *data;
1259 imp = class_exp2cliimp(exp);
1265 if (imp->imp_state != LUSTRE_IMP_FULL) {
1266 CERROR("import state not full\n");
1270 data = &imp->imp_connect_data;
1271 if (data->ocd_connect_flags & OBD_CONNECT_REMOTE) {
1274 } else if (data->ocd_connect_flags & OBD_CONNECT_LOCAL) {
1278 CERROR("no remote flag set?\n");
1282 if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) &&
1283 (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) &&
1284 (keylen < strlen("rootid") || strcmp(key, "rootid") != 0))
1287 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1288 OST_GET_INFO, 1, (int *)&keylen, bufs);
1292 req->rq_replen = lustre_msg_size(1, (int *)valsize);
1293 rc = ptlrpc_queue_wait(req);
1297 if (keylen >= strlen("rootid") && !strcmp(key, "rootid")) {
1298 struct lustre_id *reply;
1300 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1301 lustre_swab_lustre_id);
1302 if (reply == NULL) {
1303 CERROR("Can't unpack %s\n", (char *)key);
1304 GOTO(out_req, rc = -EPROTO);
1307 *(struct lustre_id *)val = *reply;
1308 } else if (keylen >= strlen("lovdesc") && !strcmp(key, "lovdesc")) {
1309 struct lov_desc *reply;
1311 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1312 lustre_swab_lov_desc);
1313 if (reply == NULL) {
1314 CERROR("Can't unpack %s\n", (char *)key);
1315 GOTO(out_req, rc = -EPROTO);
1318 *(struct lov_desc *)val = *reply;
1323 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1324 lustre_swab_generic_32s);
1325 if (reply == NULL) {
1326 CERROR("Can't unpack %s\n", (char *)key);
1327 GOTO(out_req, rc = -EPROTO);
1329 *((__u32 *)val) = *reply;
1332 ptlrpc_req_finished(req);
1336 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
1337 void *acl, int acl_size,
1338 struct lov_stripe_md **ea, struct obd_trans_info *oti)
1340 struct ptlrpc_request *request;
1341 struct ost_body *body;
1343 int rc, size[2] = { sizeof(*body), acl_size };
1348 request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1349 OST_CREATE, 2, size, NULL);
1351 GOTO(out_req, rc = -ENOMEM);
1353 body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1354 memcpy(&body->oa, oa, sizeof(body->oa));
1357 acl_buf = lustre_msg_buf(request->rq_reqmsg, 1, acl_size);
1358 memcpy(acl_buf, acl, acl_size);
1361 request->rq_replen = lustre_msg_size(1, size);
1362 rc = ptlrpc_queue_wait(request);
1366 body = lustre_swab_repbuf(request, 0, sizeof(*body),
1367 lustre_swab_ost_body);
1369 CERROR ("can't unpack ost_body\n");
1370 GOTO (out_req, rc = -EPROTO);
1373 memcpy(oa, &body->oa, sizeof(*oa));
1375 /* store ino/generation for recovery */
1376 body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1377 body->oa.o_id = oa->o_id;
1378 body->oa.o_generation = oa->o_generation;
1379 body->oa.o_fid = oa->o_fid;
1380 body->oa.o_mds = oa->o_mds;
1382 CDEBUG(D_HA, "transno: "LPD64"\n", request->rq_repmsg->transno);
1385 ptlrpc_req_finished(request);
1389 int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa,
1390 struct lov_stripe_md *ea, obd_count oa_bufs,
1391 struct brw_page *pgarr, struct obd_trans_info *oti)
1393 struct ptlrpc_bulk_desc *desc;
1394 struct niobuf_remote *niobuf;
1395 struct ptlrpc_request *req;
1396 struct obd_ioobj *ioobj;
1397 struct ost_body *body;
1401 opc = ((rw & OBD_BRW_WRITE) != 0) ? OST_WRITE : OST_READ;
1403 size[0] = sizeof(*body);
1404 size[1] = sizeof(*ioobj);
1405 size[2] = oa_bufs * sizeof(*niobuf);
1407 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, opc,
1409 LASSERT(req != NULL);
1411 if (opc == OST_WRITE)
1412 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_GET_SOURCE,
1415 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_PUT_SINK,
1417 LASSERT(desc != NULL);
1419 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
1420 ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
1421 niobuf = lustre_msg_buf(req->rq_reqmsg, 2, oa_bufs * sizeof(*niobuf));
1423 memcpy(&body->oa, oa, sizeof(*oa));
1424 obdo_to_ioobj(oa, ioobj);
1425 ioobj->ioo_bufcnt = oa_bufs;
1427 for (i = 0; i < oa_bufs; i++, niobuf++) {
1428 struct brw_page *pg = &pgarr[i];
1430 LASSERT(pg->count > 0);
1431 LASSERT((pg->disk_offset & ~PAGE_MASK) + pg->count <= PAGE_SIZE);
1433 ptlrpc_prep_bulk_page(desc, pg->pg, pg->disk_offset & ~PAGE_MASK,
1436 niobuf->offset = pg->disk_offset;
1437 niobuf->len = pg->count;
1438 niobuf->flags = pg->flag;
1441 /* size[0] still sizeof (*body) */
1442 if (opc == OST_WRITE) {
1443 /* 1 RC per niobuf */
1444 size[1] = sizeof(__u32) * oa_bufs;
1445 req->rq_replen = lustre_msg_size(2, size);
1447 /* 1 RC for the whole I/O */
1448 req->rq_replen = lustre_msg_size(1, size);
1450 err = ptlrpc_queue_wait(req);
1453 ptlrpc_req_finished(req);
1457 static int mdc_valid_attrs(struct obd_export *exp,
1458 struct lustre_id *id)
1460 struct ldlm_res_id res_id = { .name = {0} };
1461 struct obd_device *obd = exp->exp_obd;
1462 struct lustre_handle lockh;
1463 ldlm_policy_data_t policy;
1467 res_id.name[0] = id_fid(id);
1468 res_id.name[1] = id_group(id);
1469 policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
1471 CDEBUG(D_INFO, "trying to match res "LPU64"\n",
1474 /* FIXME use LDLM_FL_TEST_LOCK instead */
1475 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
1476 if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1477 LDLM_IBITS, &policy, LCK_PR, &lockh)) {
1478 ldlm_lock_decref(&lockh, LCK_PR);
1482 if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1483 LDLM_IBITS, &policy, LCK_PW, &lockh)) {
1484 ldlm_lock_decref(&lockh, LCK_PW);
1490 static int mdc_change_cbdata_name(struct obd_export *exp,
1491 struct lustre_id *pid,
1492 char *name, int len,
1493 struct lustre_id *cid,
1494 ldlm_iterator_t it, void *data)
1497 rc = mdc_change_cbdata(exp, cid, it, data);
1501 struct obd_ops mdc_obd_ops = {
1502 .o_owner = THIS_MODULE,
1503 .o_attach = mdc_attach,
1504 .o_detach = mdc_detach,
1505 .o_setup = mdc_setup,
1506 .o_precleanup = mdc_precleanup,
1507 .o_cleanup = mdc_cleanup,
1508 .o_add_conn = client_import_add_conn,
1509 .o_del_conn = client_import_del_conn,
1510 .o_connect = client_connect_import,
1511 .o_disconnect = client_disconnect_export,
1512 .o_iocontrol = mdc_iocontrol,
1513 .o_packmd = mdc_packmd,
1514 .o_unpackmd = mdc_unpackmd,
1515 .o_statfs = mdc_statfs,
1517 .o_unpin = mdc_unpin,
1518 .o_import_event = mdc_import_event,
1519 .o_llog_init = mdc_llog_init,
1520 .o_llog_finish = mdc_llog_finish,
1521 .o_create = mdc_obj_create,
1522 .o_set_info = mdc_set_info,
1523 .o_get_info = mdc_get_info,
1525 .o_cancel_unused = mdc_cancel_unused,
1526 .o_init_ea_size = mdc_init_ea_size,
1529 struct md_ops mdc_md_ops = {
1530 .m_getstatus = mdc_getstatus,
1531 .m_getattr = mdc_getattr,
1532 .m_close = mdc_close,
1533 .m_create = mdc_create,
1534 .m_done_writing = mdc_done_writing,
1535 .m_enqueue = mdc_enqueue,
1536 .m_getattr_lock = mdc_getattr_lock,
1537 .m_intent_lock = mdc_intent_lock,
1539 .m_rename = mdc_rename,
1540 .m_setattr = mdc_setattr,
1542 .m_readpage = mdc_readpage,
1543 .m_unlink = mdc_unlink,
1544 .m_valid_attrs = mdc_valid_attrs,
1545 .m_req2lustre_md = mdc_req2lustre_md,
1546 .m_set_open_replay_data = mdc_set_open_replay_data,
1547 .m_clear_open_replay_data = mdc_clear_open_replay_data,
1548 .m_store_inode_generation = mdc_store_inode_generation,
1549 .m_set_lock_data = mdc_set_lock_data,
1550 .m_get_real_obd = mdc_get_real_obd,
1551 .m_change_cbdata_name = mdc_change_cbdata_name,
1552 .m_change_cbdata = mdc_change_cbdata,
1553 .m_access_check = mdc_access_check,
1556 int __init mdc_init(void)
1558 struct lprocfs_static_vars lvars;
1560 lprocfs_init_vars(mdc, &lvars);
1561 return class_register_type(&mdc_obd_ops, &mdc_md_ops,
1562 lvars.module_vars, OBD_MDC_DEVICENAME);
1566 static void /*__exit*/ mdc_exit(void)
1568 class_unregister_type(OBD_MDC_DEVICENAME);
1571 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1572 MODULE_DESCRIPTION("Lustre Metadata Client");
1573 MODULE_LICENSE("GPL");
1575 EXPORT_SYMBOL(mdc_req2lustre_md);
1576 EXPORT_SYMBOL(mdc_change_cbdata);
1577 EXPORT_SYMBOL(mdc_getstatus);
1578 EXPORT_SYMBOL(mdc_getattr);
1579 EXPORT_SYMBOL(mdc_getattr_lock);
1580 EXPORT_SYMBOL(mdc_create);
1581 EXPORT_SYMBOL(mdc_unlink);
1582 EXPORT_SYMBOL(mdc_rename);
1583 EXPORT_SYMBOL(mdc_link);
1584 EXPORT_SYMBOL(mdc_readpage);
1585 EXPORT_SYMBOL(mdc_setattr);
1586 EXPORT_SYMBOL(mdc_close);
1587 EXPORT_SYMBOL(mdc_done_writing);
1588 EXPORT_SYMBOL(mdc_sync);
1589 EXPORT_SYMBOL(mdc_set_open_replay_data);
1590 EXPORT_SYMBOL(mdc_clear_open_replay_data);
1591 EXPORT_SYMBOL(mdc_store_inode_generation);
1593 module_init(mdc_init);
1594 module_exit(mdc_exit);