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 int mdc_get_secdesc_size(void)
51 int ngroups = current_ngroups;
53 if (ngroups > LUSTRE_MAX_GROUPS)
54 ngroups = LUSTRE_MAX_GROUPS;
56 return sizeof(struct mds_req_sec_desc) +
57 sizeof(__u32) * ngroups;
64 * because group info might have changed since last time we call
65 * get_secdesc_size(), so here we did more sanity check to prevent garbage gids
67 void mdc_pack_secdesc(struct ptlrpc_request *req, int size)
70 struct mds_req_sec_desc *rsd;
72 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
73 struct group_info *ginfo;
76 rsd = lustre_msg_buf(req->rq_reqmsg,
77 MDS_REQ_SECDESC_OFF, size);
79 rsd->rsd_uid = current->uid;
80 rsd->rsd_gid = current->gid;
81 rsd->rsd_fsuid = current->fsuid;
82 rsd->rsd_fsgid = current->fsgid;
83 rsd->rsd_cap = current->cap_effective;
84 rsd->rsd_ngroups = (size - sizeof(*rsd)) / sizeof(__u32);
85 LASSERT(rsd->rsd_ngroups <= LUSTRE_MAX_GROUPS);
87 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
89 get_group_info(current->group_info);
90 ginfo = current->group_info;
92 if (rsd->rsd_ngroups > ginfo->ngroups)
93 rsd->rsd_ngroups = ginfo->ngroups;
94 memcpy(rsd->rsd_groups, ginfo->blocks[0],
95 rsd->rsd_ngroups * sizeof(__u32));
97 LASSERT(rsd->rsd_ngroups <= NGROUPS);
98 if (rsd->rsd_ngroups > current->ngroups)
99 rsd->rsd_ngroups = current->ngroups;
100 memcpy(rsd->rsd_groups, current->groups,
101 rsd->rsd_ngroups * sizeof(__u32));
106 extern int mds_queue_req(struct ptlrpc_request *);
107 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
108 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
109 static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid,
110 int level, int msg_flags)
112 struct ptlrpc_request *req;
113 struct mds_body *body;
114 int rc, size[2] = {0, sizeof(*body)};
117 //size[0] = mdc_get_secdesc_size();
119 req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS,
122 GOTO(out, rc = -ENOMEM);
124 //mdc_pack_secdesc(req, size[0]);
126 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
127 req->rq_send_state = level;
128 req->rq_replen = lustre_msg_size(1, &size[1]);
130 req->rq_reqmsg->flags |= msg_flags;
131 rc = ptlrpc_queue_wait(req);
134 body = lustre_swab_repbuf (req, 0, sizeof (*body),
135 lustre_swab_mds_body);
137 CERROR ("Can't extract mds_body\n");
138 GOTO (out, rc = -EPROTO);
141 memcpy(rootid, &body->id1, sizeof(*rootid));
143 CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64
144 ", last_xid="LPU64"\n", rootid->li_stc.u.e3s.l3s_ino,
145 req->rq_repmsg->last_committed, req->rq_repmsg->last_xid);
150 ptlrpc_req_finished(req);
154 /* This should be mdc_get_info("rootid") */
155 int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid)
157 return send_getstatus(class_exp2cliimp(exp), rootid,
161 int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
162 struct ptlrpc_request *req)
164 struct mds_body *body, *reqbody;
167 int repsize[4] = {sizeof(*body)};
171 /* request message already built */
174 repsize[bufcount++] = ea_size;
175 CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n",
179 reqbody = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*reqbody));
181 if (reqbody->valid & OBD_MD_FLACL_ACCESS) {
182 repsize[bufcount++] = 4;
183 repsize[bufcount++] = xattr_acl_size(LL_ACL_MAX_ENTRIES);
186 req->rq_replen = lustre_msg_size(bufcount, repsize);
188 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
189 rc = ptlrpc_queue_wait(req);
190 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
194 body = lustre_swab_repbuf (req, 0, sizeof (*body),
195 lustre_swab_mds_body);
197 CERROR ("Can't unpack mds_body\n");
201 CDEBUG(D_NET, "mode: %o\n", body->mode);
203 LASSERT_REPSWAB (req, 1);
205 /* Skip the check if getxattr/listxattr are called with no buffers */
206 if ((reqbody->valid & (OBD_MD_FLEA | OBD_MD_FLEALIST)) &&
207 (reqbody->eadatasize != 0)){
208 if (body->eadatasize != 0) {
209 /* reply indicates presence of eadata; check it's there... */
210 eadata = lustre_msg_buf (req->rq_repmsg, 1,
212 if (eadata == NULL) {
213 CERROR ("Missing/short eadata\n");
222 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
223 __u64 valid, const char *ea_name, int ea_namelen,
224 unsigned int ea_size, struct ptlrpc_request **request)
226 struct ptlrpc_request *req;
227 struct mds_body *body;
229 int size[3] = {0, sizeof(*body)};
233 /* XXX do we need to make another request here? We just did a getattr
234 * to do the lookup in the first place.
236 size[0] = mdc_get_secdesc_size();
238 LASSERT((ea_name != NULL) == (ea_namelen != 0));
239 if (valid & (OBD_MD_FLEA | OBD_MD_FLEALIST)) {
240 size[bufcount] = ea_namelen;
244 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
245 MDS_GETATTR, bufcount, size, NULL);
247 GOTO(out, rc = -ENOMEM);
249 mdc_pack_secdesc(req, size[0]);
251 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
252 memcpy(&body->id1, id, sizeof(*id));
254 body->eadatasize = ea_size;
257 if (valid & OBD_MD_FLEA) {
258 LASSERT(strnlen(ea_name, ea_namelen) == (ea_namelen - 1));
259 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, ea_namelen),
260 ea_name, ea_namelen);
263 rc = mdc_getattr_common(exp, ea_size, req);
265 ptlrpc_req_finished (req);
273 int mdc_getattr_lock(struct obd_export *exp, struct lustre_id *id,
274 char *filename, int namelen, __u64 valid,
275 unsigned int ea_size, struct ptlrpc_request **request)
277 struct ptlrpc_request *req;
278 struct mds_body *body;
279 int rc, size[3] = {0, sizeof(*body), namelen};
282 size[0] = mdc_get_secdesc_size();
284 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
285 MDS_GETATTR_LOCK, 3, size, NULL);
287 GOTO(out, rc = -ENOMEM);
289 mdc_pack_secdesc(req, size[0]);
291 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
292 memcpy(&body->id1, id, sizeof(*id));
294 body->eadatasize = ea_size;
296 if (filename != NULL) {
297 LASSERT (strnlen (filename, namelen) == namelen - 1);
298 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, namelen),
301 LASSERT(namelen == 1);
304 rc = mdc_getattr_common(exp, ea_size, req);
306 ptlrpc_req_finished (req);
314 /* This should be called with both the request and the reply still packed. */
315 int mdc_store_inode_generation(struct obd_export *exp,
316 struct ptlrpc_request *req,
317 int reqoff, int repoff)
319 struct mds_rec_create *rec =
320 lustre_msg_buf(req->rq_reqmsg, reqoff, sizeof(*rec));
321 struct mds_body *body =
322 lustre_msg_buf(req->rq_repmsg, repoff, sizeof(*body));
324 LASSERT (rec != NULL);
325 LASSERT (body != NULL);
327 memcpy(&rec->cr_replayid, &body->id1, sizeof(rec->cr_replayid));
328 DEBUG_REQ(D_HA, req, "storing generation for ino "DLID4,
329 OLID4(&rec->cr_replayid));
333 int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req,
334 unsigned int offset, struct obd_export *exp_lov,
335 struct lustre_md *md)
340 struct posix_acl *acl;
341 struct lov_mds_md *lmm;
345 memset(md, 0, sizeof(*md));
347 md->body = lustre_msg_buf(req->rq_repmsg, offset,
352 LASSERT_REPSWABBED(req, offset);
354 if (!(md->body->valid & OBD_MD_FLEASIZE) &&
355 !(md->body->valid & OBD_MD_FLDIREA))
358 if (S_ISREG(md->body->mode)) {
359 if (md->body->eadatasize == 0) {
360 CERROR("invalid EA size (0) is detected\n");
364 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
365 md->body->eadatasize);
369 LASSERT(exp_lov != NULL);
371 rc = obd_unpackmd(exp_lov, &md->lsm, lmm,
372 md->body->eadatasize);
374 LASSERT(rc >= sizeof(*md->lsm));
377 } else if (S_ISDIR(md->body->mode)) {
378 /* dir can be non-splitted */
379 if (md->body->eadatasize == 0)
382 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
383 md->body->eadatasize);
387 if (md->body->valid & OBD_MD_MEA) {
388 LASSERT(exp_lmv != NULL);
390 rc = obd_unpackmd(exp_lmv, (void *)&md->mea,
391 lmm, md->body->eadatasize);
393 LASSERT(rc >= sizeof(*md->mea));
398 LASSERT(S_ISCHR(md->body->mode) ||
399 S_ISBLK(md->body->mode) ||
400 S_ISFIFO(md->body->mode)||
401 S_ISLNK(md->body->mode) ||
402 S_ISSOCK(md->body->mode));
405 acl_off = (md->body->valid & OBD_MD_FLEASIZE) ? (offset + 2) :
408 if (md->body->valid & OBD_MD_FLACL_ACCESS) {
409 size = le32_to_cpu(*(__u32 *) lustre_msg_buf(req->rq_repmsg,
411 buf = lustre_msg_buf(req->rq_repmsg, acl_off + 1, size);
413 acl = posix_acl_from_xattr(buf, size);
416 CERROR("convert xattr to acl failed: %d\n", rc);
419 rc = posix_acl_valid(acl);
421 CERROR("acl valid error: %d\n", rc);
422 posix_acl_release(acl);
427 md->acl_access = acl;
432 static void mdc_commit_open(struct ptlrpc_request *req)
434 struct mdc_open_data *mod = req->rq_cb_data;
438 if (mod->mod_close_req != NULL)
439 mod->mod_close_req->rq_cb_data = NULL;
441 if (mod->mod_och != NULL)
442 mod->mod_och->och_mod = NULL;
444 OBD_FREE(mod, sizeof(*mod));
445 req->rq_cb_data = NULL;
448 static void mdc_replay_open(struct ptlrpc_request *req)
450 struct mdc_open_data *mod = req->rq_cb_data;
451 struct obd_client_handle *och;
452 struct ptlrpc_request *close_req;
453 struct lustre_handle old;
454 struct mds_body *body;
457 body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body);
458 LASSERT (body != NULL);
461 DEBUG_REQ(D_ERROR, req,
462 "can't properly replay without open data");
469 struct lustre_handle *file_fh;
470 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
471 file_fh = &och->och_fh;
472 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
473 file_fh->cookie, body->handle.cookie);
474 memcpy(&old, file_fh, sizeof(old));
475 memcpy(file_fh, &body->handle, sizeof(*file_fh));
478 close_req = mod->mod_close_req;
479 if (close_req != NULL) {
480 struct mds_body *close_body;
481 LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE);
482 close_body = lustre_msg_buf(close_req->rq_reqmsg,
484 sizeof(*close_body));
486 LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
487 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
488 memcpy(&close_body->handle, &body->handle,
489 sizeof(close_body->handle));
495 int mdc_set_open_replay_data(struct obd_export *exp,
496 struct obd_client_handle *och,
497 struct ptlrpc_request *open_req)
499 struct mdc_open_data *mod;
500 struct mds_rec_create *rec;
501 struct mds_body *body;
503 rec = lustre_msg_buf(open_req->rq_reqmsg, MDS_REQ_INTENT_REC_OFF,
505 body = lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body));
507 LASSERT(rec != NULL);
508 /* outgoing messages always in my byte order */
509 LASSERT(body != NULL);
510 /* incoming message in my byte order (it's been swabbed) */
511 LASSERT_REPSWABBED(open_req, 1);
513 OBD_ALLOC(mod, sizeof(*mod));
515 DEBUG_REQ(D_ERROR, open_req, "can't allocate mdc_open_data");
521 mod->mod_open_req = open_req;
523 memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid);
524 open_req->rq_replay_cb = mdc_replay_open;
525 open_req->rq_commit_cb = mdc_commit_open;
526 open_req->rq_cb_data = mod;
527 DEBUG_REQ(D_HA, open_req, "set up replay data");
531 int mdc_clear_open_replay_data(struct obd_export *exp,
532 struct obd_client_handle *och)
534 struct mdc_open_data *mod = och->och_mod;
536 /* Don't free the structure now (it happens in mdc_commit_open, after
537 * we're sure we won't need to fix up the close request in the future),
538 * but make sure that replay doesn't poke at the och, which is about to
540 LASSERT(mod != LP_POISON);
547 static void mdc_commit_close(struct ptlrpc_request *req)
549 struct mdc_open_data *mod = req->rq_cb_data;
550 struct ptlrpc_request *open_req;
551 struct obd_import *imp = req->rq_import;
553 DEBUG_REQ(D_HA, req, "close req committed");
557 mod->mod_close_req = NULL;
558 req->rq_cb_data = NULL;
559 req->rq_commit_cb = NULL;
561 open_req = mod->mod_open_req;
562 LASSERT(open_req != NULL);
563 LASSERT(open_req != LP_POISON);
564 LASSERT(open_req->rq_type != LI_POISON);
566 DEBUG_REQ(D_HA, open_req, "open req balanced");
567 if (open_req->rq_transno == 0) {
568 DEBUG_REQ(D_ERROR, open_req, "BUG 3892 open");
569 DEBUG_REQ(D_ERROR, req, "BUG 3892 close");
570 LASSERTF(open_req->rq_transno != 0, "BUG 3892");
572 LASSERT(open_req->rq_import == imp);
574 /* We no longer want to preserve this for transno-unconditional
576 spin_lock(&open_req->rq_lock);
577 open_req->rq_replay = 0;
578 spin_unlock(&open_req->rq_lock);
581 static int mdc_close_interpret(struct ptlrpc_request *req,
584 union ptlrpc_async_args *aa = data;
585 struct mdc_rpc_lock *close_lock;
586 struct obd_device *obd = aa->pointer_arg[1];
589 spin_lock_irqsave(&req->rq_lock, flags);
590 close_lock = aa->pointer_arg[0];
591 aa->pointer_arg[0] = NULL;
592 spin_unlock_irqrestore (&req->rq_lock, flags);
594 if (close_lock == NULL) {
595 CERROR("called with NULL close_lock\n");
597 mdc_put_rpc_lock(close_lock, NULL);
598 LASSERTF(close_lock == obd->u.cli.cl_close_lock, "%p != %p\n",
599 close_lock, obd->u.cli.cl_close_lock);
601 wake_up(&req->rq_reply_waitq);
605 /* We can't use ptlrpc_check_reply, because we don't want to wake up for
606 * anything but a reply or an error. */
607 static int mdc_close_check_reply(struct ptlrpc_request *req)
612 spin_lock_irqsave(&req->rq_lock, flags);
613 if (req->rq_async_args.pointer_arg[0] == NULL)
615 spin_unlock_irqrestore (&req->rq_lock, flags);
619 int mdc_close(struct obd_export *exp, struct obdo *oa,
620 struct obd_client_handle *och,
621 struct ptlrpc_request **request)
623 struct obd_device *obd = class_exp2obd(exp);
624 struct obd_import *imp = class_exp2cliimp(exp);
625 int reqsize[3] = {0, sizeof(struct mds_body),
626 obd->u.cli.cl_max_mds_cookiesize};
627 int rc, repsize[3] = {sizeof(struct mds_body),
628 obd->u.cli.cl_max_mds_easize,
629 obd->u.cli.cl_max_mds_cookiesize};
630 struct ptlrpc_request *req;
631 struct mdc_open_data *mod;
632 struct l_wait_info lwi;
635 if (imp->imp_connection == NULL) {
636 CERROR("request on not connected import %s\n",
637 imp->imp_obd->obd_name);
641 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
642 MDS_CLOSE, 3, reqsize, NULL);
644 GOTO(out, rc = -ENOMEM);
646 //reqsize[0] = mdc_get_secdesc_size();
647 //mdc_pack_secdesc(req, reqsize[0]);
649 /* Ensure that this close's handle is fixed up during replay. */
650 LASSERT(och != NULL);
652 if (likely(mod != NULL)) {
653 mod->mod_close_req = req;
654 LASSERT(mod->mod_open_req->rq_type != LI_POISON);
655 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
657 CDEBUG(D_HA, "couldn't find open req; "
658 "expecting close error\n");
661 mdc_close_pack(req, 1, oa, oa->o_valid, och);
663 req->rq_replen = lustre_msg_size(3, repsize);
664 req->rq_commit_cb = mdc_commit_close;
665 LASSERT(req->rq_cb_data == NULL);
666 req->rq_cb_data = mod;
668 /* We hand a ref to the rpcd here, so we need another one of our own. */
669 ptlrpc_request_addref(req);
671 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
672 req->rq_interpret_reply = mdc_close_interpret;
673 req->rq_async_args.pointer_arg[0] = obd->u.cli.cl_close_lock;
674 req->rq_async_args.pointer_arg[1] = obd;
675 ptlrpcd_add_req(req);
677 lwi = LWI_TIMEOUT_INTR(MAX(req->rq_timeout * HZ, 1), NULL, NULL, NULL);
678 rc = l_wait_event(req->rq_reply_waitq, mdc_close_check_reply(req),
680 if (req->rq_repmsg == NULL) {
681 CDEBUG(D_HA, "request failed to send: %p, %d\n", req,
684 rc = req->rq_status ? req->rq_status : -EIO;
685 } else if (rc == 0) {
686 rc = req->rq_repmsg->status;
687 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
688 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, "
694 CERROR("Unexpected: can't find mdc_open_data, but "
695 "close succeeded. Please tell CFS.\n");
696 if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body),
697 lustre_swab_mds_body))
699 CERROR("Error unpacking mds_body\n");
704 if (req->rq_async_args.pointer_arg[0] != NULL) {
705 CERROR("returned without dropping close lock: rc %d, "
706 "dropping it now\n", rc);
707 mdc_close_interpret(req, &req->rq_async_args, rc);
716 int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
718 struct ptlrpc_request *req;
719 struct mds_body *body;
720 int rc, size[2] = {0, sizeof(*body)};
723 size[0] = mdc_get_secdesc_size();
725 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
726 MDS_DONE_WRITING, 2, size, NULL);
730 mdc_pack_secdesc(req, size[0]);
732 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
735 mdc_pack_id(&body->id1, obdo->o_id, 0, obdo->o_mode,
736 obdo->o_mds, obdo->o_fid);
738 body->size = obdo->o_size;
739 body->blocks = obdo->o_blocks;
740 body->flags = obdo->o_flags;
741 body->valid = obdo->o_valid;
743 req->rq_replen = lustre_msg_size(1, &size[1]);
745 rc = ptlrpc_queue_wait(req);
746 ptlrpc_req_finished(req);
750 int mdc_readpage(struct obd_export *exp,
751 struct lustre_id *id,
752 __u64 offset, struct page *page,
753 struct ptlrpc_request **request)
755 struct obd_import *imp = class_exp2cliimp(exp);
756 struct ptlrpc_request *req = NULL;
757 struct ptlrpc_bulk_desc *desc = NULL;
758 struct mds_body *body;
759 int rc, size[2] = {0, sizeof(*body)};
762 CDEBUG(D_INODE, "inode: %ld\n", (long)id->li_stc.u.e3s.l3s_ino);
764 size[0] = mdc_get_secdesc_size();
766 req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE,
769 GOTO(out, rc = -ENOMEM);
770 /* XXX FIXME bug 249 */
771 req->rq_request_portal = MDS_READPAGE_PORTAL;
773 mdc_pack_secdesc(req, size[0]);
775 desc = ptlrpc_prep_bulk_imp(req, 1, BULK_PUT_SINK, MDS_BULK_PORTAL);
777 GOTO(out, rc = -ENOMEM);
778 /* NB req now owns desc and will free it when it gets freed */
780 ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE);
781 mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, id);
783 req->rq_replen = lustre_msg_size(1, &size[1]);
784 rc = ptlrpc_queue_wait(req);
787 body = lustre_swab_repbuf(req, 0, sizeof (*body),
788 lustre_swab_mds_body);
790 CERROR("Can't unpack mds_body\n");
791 GOTO(out, rc = -EPROTO);
794 if (req->rq_bulk->bd_nob_transferred != PAGE_CACHE_SIZE) {
795 CERROR ("Unexpected # bytes transferred: %d"
797 req->rq_bulk->bd_nob_transferred,
799 GOTO (out, rc = -EPROTO);
809 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
810 void *karg, void *uarg)
812 struct obd_device *obd = exp->exp_obd;
813 struct obd_ioctl_data *data = karg;
814 struct obd_import *imp = obd->u.cli.cl_import;
815 struct llog_ctxt *ctxt;
819 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
822 if (!try_module_get(THIS_MODULE)) {
823 CERROR("Can't get module. Is it alive?");
828 case OBD_IOC_CLIENT_RECOVER:
829 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1);
833 case IOC_OSC_SET_ACTIVE:
834 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
836 case OBD_IOC_PARSE: {
837 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,
838 LLOG_CONFIG_REPL_CTXT);
839 rc = class_config_process_llog(ctxt, data->ioc_inlbuf1, NULL);
843 case OBD_IOC_LLOG_INFO:
844 case OBD_IOC_LLOG_PRINT: {
845 ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_REPL_CTXT);
846 rc = llog_ioctl(ctxt, cmd, data);
852 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
853 GOTO(out, rc = -ENOTTY);
856 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
859 module_put(THIS_MODULE);
865 int mdc_set_info(struct obd_export *exp, obd_count keylen,
866 void *key, obd_count vallen, void *val)
870 if (keylen == strlen("initial_recov") &&
871 memcmp(key, "initial_recov", strlen("initial_recov")) == 0) {
872 struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
873 if (vallen != sizeof(int))
875 imp->imp_initial_recov = *(int *)val;
876 CDEBUG(D_HA, "%s: set imp_no_init_recov = %d\n",
877 exp->exp_obd->obd_name,
878 imp->imp_initial_recov);
880 } else if (keylen >= strlen("mds_type") && strcmp(key, "mds_type") == 0) {
881 struct ptlrpc_request *req;
882 char *bufs[2] = {key, val};
883 int rc, size[2] = {keylen, vallen};
885 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
886 OST_SET_INFO, 2, size, bufs);
890 req->rq_replen = lustre_msg_size(0, NULL);
891 rc = ptlrpc_queue_wait(req);
892 ptlrpc_req_finished(req);
894 } else if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
895 struct obd_import *imp = class_exp2cliimp(exp);
896 imp->imp_server_timeout = 1;
897 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
899 } else if (keylen == strlen("sec") && memcmp(key, "sec", keylen) == 0) {
900 struct client_obd *cli = &exp->exp_obd->u.cli;
902 if (vallen == strlen("null") &&
903 memcmp(val, "null", vallen) == 0) {
904 cli->cl_sec_flavor = PTLRPC_SEC_NULL;
905 cli->cl_sec_subflavor = 0;
908 if (vallen == strlen("krb5i") &&
909 memcmp(val, "krb5i", vallen) == 0) {
910 cli->cl_sec_flavor = PTLRPC_SEC_GSS;
911 cli->cl_sec_subflavor = PTLRPC_SEC_GSS_KRB5I;
914 if (vallen == strlen("krb5p") &&
915 memcmp(val, "krb5p", vallen) == 0) {
916 cli->cl_sec_flavor = PTLRPC_SEC_GSS;
917 cli->cl_sec_subflavor = PTLRPC_SEC_GSS_KRB5P;
920 CERROR("unrecognized security type %s\n", (char*) val);
922 } else if (keylen == strlen("nllu") && memcmp(key, "nllu", keylen) == 0) {
923 struct client_obd *cli = &exp->exp_obd->u.cli;
925 LASSERT(vallen == sizeof(__u32) * 2);
926 cli->cl_nllu = ((__u32 *) val)[0];
927 cli->cl_nllg = ((__u32 *) val)[1];
929 } else if (keylen == strlen("async") && memcmp(key, "async", keylen) == 0) {
930 struct client_obd *cl = &exp->exp_obd->u.cli;
931 if (vallen != sizeof(int))
933 cl->cl_async = *(int *)val;
934 CDEBUG(D_HA, "%s: set async = %d\n",
935 exp->exp_obd->obd_name, cl->cl_async);
942 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
943 unsigned long max_age)
945 struct obd_statfs *msfs;
946 struct ptlrpc_request *req;
947 int rc, size = sizeof(*msfs);
950 /* We could possibly pass max_age in the request (as an absolute
951 * timestamp or a "seconds.usec ago") so the target can avoid doing
952 * extra calls into the filesystem if that isn't necessary (e.g.
953 * during mount that would help a bit). Having relative timestamps
954 * is not so great if request processing is slow, while absolute
955 * timestamps are not ideal because they need time synchronization. */
956 req = ptlrpc_prep_req(obd->u.cli.cl_import, LUSTRE_MDS_VERSION,
957 MDS_STATFS, 0, NULL, NULL);
961 req->rq_replen = lustre_msg_size(1, &size);
963 mdc_get_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
964 rc = ptlrpc_queue_wait(req);
965 mdc_put_rpc_lock(obd->u.cli.cl_rpc_lock, NULL);
968 /* this can be LMV fake import, whcih is not connected. */
969 if (!req->rq_import->imp_connection)
970 memset(osfs, 0, sizeof(*osfs));
974 msfs = lustre_swab_repbuf(req, 0, sizeof(*msfs),
975 lustre_swab_obd_statfs);
977 CERROR("Can't unpack obd_statfs\n");
978 GOTO(out, rc = -EPROTO);
981 memcpy(osfs, msfs, sizeof (*msfs));
984 ptlrpc_req_finished(req);
988 static int mdc_pin(struct obd_export *exp, obd_id ino, __u32 gen, int type,
989 struct obd_client_handle *handle, int flag)
991 struct ptlrpc_request *req;
992 struct mds_body *body;
993 int rc, size[2] = {0, sizeof(*body)};
996 //size[0] = mdc_get_secdesc_size();
998 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
999 MDS_PIN, 2, size, NULL);
1003 //mdc_pack_secdesc(req, size[0]);
1005 body = lustre_msg_buf(req->rq_reqmsg,
1006 MDS_REQ_REC_OFF, sizeof(*body));
1008 /* FIXME-UMKA: here should be also mdsnum and fid. */
1009 mdc_pack_id(&body->id1, ino, gen, type, 0, 0);
1012 req->rq_replen = lustre_msg_size(1, &size[1]);
1014 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1015 rc = ptlrpc_queue_wait(req);
1016 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1018 CERROR("pin failed: %d\n", rc);
1019 ptlrpc_req_finished(req);
1023 body = lustre_swab_repbuf(req, 0, sizeof(*body), lustre_swab_mds_body);
1025 ptlrpc_req_finished(req);
1029 memcpy(&handle->och_fh, &body->handle, sizeof(body->handle));
1030 handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
1032 OBD_ALLOC(handle->och_mod, sizeof(*handle->och_mod));
1033 if (handle->och_mod == NULL) {
1034 DEBUG_REQ(D_ERROR, req, "can't allocate mdc_open_data");
1037 handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
1042 static int mdc_unpin(struct obd_export *exp,
1043 struct obd_client_handle *handle, int flag)
1045 struct ptlrpc_request *req;
1046 struct mds_body *body;
1047 int rc, size[2] = {0, sizeof(*body)};
1050 if (handle->och_magic != OBD_CLIENT_HANDLE_MAGIC)
1053 //size[0] = mdc_get_secdesc_size();
1055 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1056 MDS_CLOSE, 2, size, NULL);
1060 //mdc_pack_secdesc(req, size[0]);
1062 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof(*body));
1063 memcpy(&body->handle, &handle->och_fh, sizeof(body->handle));
1066 req->rq_replen = lustre_msg_size(0, NULL);
1067 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1068 rc = ptlrpc_queue_wait(req);
1069 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1072 CERROR("unpin failed: %d\n", rc);
1074 ptlrpc_req_finished(req);
1075 ptlrpc_req_finished(handle->och_mod->mod_open_req);
1076 OBD_FREE(handle->och_mod, sizeof(*handle->och_mod));
1080 int mdc_sync(struct obd_export *exp, struct lustre_id *id,
1081 struct ptlrpc_request **request)
1083 struct ptlrpc_request *req;
1084 struct mds_body *body;
1085 int size[2] = {0, sizeof(*body)};
1089 //size[0] = mdc_get_secdesc_size();
1091 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1092 MDS_SYNC, 2, size, NULL);
1094 RETURN(rc = -ENOMEM);
1096 //mdc_pack_secdesc(req, size[0]);
1099 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
1101 memcpy(&body->id1, id, sizeof(*id));
1104 req->rq_replen = lustre_msg_size(1, &size[1]);
1106 rc = ptlrpc_queue_wait(req);
1107 if (rc || request == NULL)
1108 ptlrpc_req_finished(req);
1115 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
1116 enum obd_import_event event)
1120 LASSERT(imp->imp_obd == obd);
1123 case IMP_EVENT_DISCON: {
1126 case IMP_EVENT_INACTIVE: {
1127 if (obd->obd_observer)
1128 rc = obd_notify(obd->obd_observer, obd, 0, 0);
1131 case IMP_EVENT_INVALIDATE: {
1132 struct ldlm_namespace *ns = obd->obd_namespace;
1134 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
1138 case IMP_EVENT_ACTIVE: {
1139 if (obd->obd_observer)
1140 rc = obd_notify(obd->obd_observer, obd, 1, 0);
1144 CERROR("Unknown import event %d\n", event);
1150 static int mdc_attach(struct obd_device *dev, obd_count len, void *data)
1152 struct lprocfs_static_vars lvars;
1154 lprocfs_init_vars(mdc, &lvars);
1155 return lprocfs_obd_attach(dev, lvars.obd_vars);
1158 static int mdc_detach(struct obd_device *dev)
1160 return lprocfs_obd_detach(dev);
1163 static int mdc_setup(struct obd_device *obd, obd_count len, void *buf)
1165 struct client_obd *cli = &obd->u.cli;
1169 OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1170 if (!cli->cl_rpc_lock)
1172 mdc_init_rpc_lock(cli->cl_rpc_lock);
1176 OBD_ALLOC(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1177 if (!cli->cl_setattr_lock)
1178 GOTO(err_rpc_lock, rc = -ENOMEM);
1179 mdc_init_rpc_lock(cli->cl_setattr_lock);
1181 OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1182 if (!cli->cl_close_lock)
1183 GOTO(err_setattr_lock, rc = -ENOMEM);
1184 mdc_init_rpc_lock(cli->cl_close_lock);
1186 rc = client_obd_setup(obd, len, buf);
1188 GOTO(err_close_lock, rc);
1190 rc = obd_llog_init(obd, &obd->obd_llogs, obd, 0, NULL);
1192 mdc_cleanup(obd, 0);
1193 CERROR("failed to setup llogging subsystems\n");
1199 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1201 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1203 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1208 static int mdc_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
1210 struct obd_device *obd = exp->exp_obd;
1211 struct client_obd *cli = &obd->u.cli;
1214 if (cli->cl_max_mds_easize < easize)
1215 cli->cl_max_mds_easize = easize;
1216 if (cli->cl_max_mds_cookiesize < cookiesize)
1217 cli->cl_max_mds_cookiesize = cookiesize;
1221 static int mdc_precleanup(struct obd_device *obd, int flags)
1225 rc = obd_llog_finish(obd, &obd->obd_llogs, 0);
1227 CERROR("failed to cleanup llogging subsystems\n");
1232 static int mdc_cleanup(struct obd_device *obd, int flags)
1234 struct client_obd *cli = &obd->u.cli;
1236 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
1237 OBD_FREE(cli->cl_setattr_lock, sizeof (*cli->cl_setattr_lock));
1238 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
1242 return client_obd_cleanup(obd, flags);
1246 static int mdc_llog_init(struct obd_device *obd, struct obd_llogs *llogs,
1247 struct obd_device *tgt, int count,
1248 struct llog_catid *logid)
1250 struct llog_ctxt *ctxt;
1254 rc = obd_llog_setup(obd, llogs, LLOG_CONFIG_REPL_CTXT, tgt, 0, NULL,
1257 ctxt = llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT);
1258 ctxt->loc_imp = obd->u.cli.cl_import;
1264 static int mdc_llog_finish(struct obd_device *obd,
1265 struct obd_llogs *llogs, int count)
1270 rc = obd_llog_cleanup(llog_get_context(llogs, LLOG_CONFIG_REPL_CTXT));
1273 static struct obd_device *mdc_get_real_obd(struct obd_export *exp,
1274 struct lustre_id *id)
1277 RETURN(exp->exp_obd);
1280 static int mdc_get_info(struct obd_export *exp, obd_count keylen,
1281 void *key, __u32 *valsize, void *val)
1283 struct ptlrpc_request *req;
1284 char *bufs[1] = {key};
1288 if (!valsize || !val)
1291 if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) &&
1292 (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) &&
1293 (keylen < strlen("rootid") || strcmp(key, "rootid") != 0))
1296 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1297 OST_GET_INFO, 1, &keylen, bufs);
1301 req->rq_replen = lustre_msg_size(1, valsize);
1302 rc = ptlrpc_queue_wait(req);
1306 if (keylen >= strlen("rootid") && !strcmp(key, "rootid")) {
1307 struct lustre_id *reply;
1309 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1310 lustre_swab_lustre_id);
1311 if (reply == NULL) {
1312 CERROR("Can't unpack %s\n", (char *)key);
1313 GOTO(out_req, rc = -EPROTO);
1316 *(struct lustre_id *)val = *reply;
1320 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1321 lustre_swab_generic_32s);
1322 if (reply == NULL) {
1323 CERROR("Can't unpack %s\n", (char *)key);
1324 GOTO(out_req, rc = -EPROTO);
1326 *((__u32 *)val) = *reply;
1329 ptlrpc_req_finished(req);
1333 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
1334 struct lov_stripe_md **ea, struct obd_trans_info *oti)
1336 struct ptlrpc_request *request;
1337 struct ost_body *body;
1338 int rc, size = sizeof(*body);
1343 request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1344 OST_CREATE, 1, &size, NULL);
1346 GOTO(out_req, rc = -ENOMEM);
1348 body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1349 memcpy(&body->oa, oa, sizeof(body->oa));
1351 request->rq_replen = lustre_msg_size(1, &size);
1352 rc = ptlrpc_queue_wait(request);
1356 body = lustre_swab_repbuf(request, 0, sizeof(*body),
1357 lustre_swab_ost_body);
1359 CERROR ("can't unpack ost_body\n");
1360 GOTO (out_req, rc = -EPROTO);
1363 memcpy(oa, &body->oa, sizeof(*oa));
1365 /* store ino/generation for recovery */
1366 body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1367 body->oa.o_id = oa->o_id;
1368 body->oa.o_generation = oa->o_generation;
1369 body->oa.o_fid = oa->o_fid;
1370 body->oa.o_mds = oa->o_mds;
1372 CDEBUG(D_HA, "transno: "LPD64"\n", request->rq_repmsg->transno);
1375 ptlrpc_req_finished(request);
1379 int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa,
1380 struct lov_stripe_md *ea, obd_count oa_bufs,
1381 struct brw_page *pgarr, struct obd_trans_info *oti)
1383 struct ptlrpc_bulk_desc *desc;
1384 struct niobuf_remote *niobuf;
1385 struct ptlrpc_request *req;
1386 struct obd_ioobj *ioobj;
1387 struct ost_body *body;
1391 opc = ((rw & OBD_BRW_WRITE) != 0) ? OST_WRITE : OST_READ;
1393 size[0] = sizeof(*body);
1394 size[1] = sizeof(*ioobj);
1395 size[2] = oa_bufs * sizeof(*niobuf);
1397 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, opc,
1399 LASSERT(req != NULL);
1401 if (opc == OST_WRITE)
1402 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_GET_SOURCE,
1405 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_PUT_SINK,
1407 LASSERT(desc != NULL);
1409 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
1410 ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
1411 niobuf = lustre_msg_buf(req->rq_reqmsg, 2, oa_bufs * sizeof(*niobuf));
1413 memcpy(&body->oa, oa, sizeof(*oa));
1414 obdo_to_ioobj(oa, ioobj);
1415 ioobj->ioo_bufcnt = oa_bufs;
1417 for (i = 0; i < oa_bufs; i++, niobuf++) {
1418 struct brw_page *pg = &pgarr[i];
1420 LASSERT(pg->count > 0);
1421 LASSERT((pg->disk_offset & ~PAGE_MASK) + pg->count <= PAGE_SIZE);
1423 ptlrpc_prep_bulk_page(desc, pg->pg, pg->disk_offset & ~PAGE_MASK,
1426 niobuf->offset = pg->disk_offset;
1427 niobuf->len = pg->count;
1428 niobuf->flags = pg->flag;
1431 /* size[0] still sizeof (*body) */
1432 if (opc == OST_WRITE) {
1433 /* 1 RC per niobuf */
1434 size[1] = sizeof(__u32) * oa_bufs;
1435 req->rq_replen = lustre_msg_size(2, size);
1437 /* 1 RC for the whole I/O */
1438 req->rq_replen = lustre_msg_size(1, size);
1440 err = ptlrpc_queue_wait(req);
1443 ptlrpc_req_finished(req);
1447 static int mdc_valid_attrs(struct obd_export *exp,
1448 struct lustre_id *id)
1450 struct ldlm_res_id res_id = { .name = {0} };
1451 struct obd_device *obd = exp->exp_obd;
1452 struct lustre_handle lockh;
1453 ldlm_policy_data_t policy;
1457 res_id.name[0] = id_fid(id);
1458 res_id.name[1] = id_group(id);
1459 policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
1461 CDEBUG(D_INFO, "trying to match res "LPU64"\n",
1464 /* FIXME use LDLM_FL_TEST_LOCK instead */
1465 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
1466 if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1467 LDLM_IBITS, &policy, LCK_PR, &lockh)) {
1468 ldlm_lock_decref(&lockh, LCK_PR);
1472 if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1473 LDLM_IBITS, &policy, LCK_PW, &lockh)) {
1474 ldlm_lock_decref(&lockh, LCK_PW);
1480 static int mdc_change_cbdata_name(struct obd_export *exp,
1481 struct lustre_id *pid,
1482 char *name, int len,
1483 struct lustre_id *cid,
1484 ldlm_iterator_t it, void *data)
1487 rc = mdc_change_cbdata(exp, cid, it, data);
1491 struct obd_ops mdc_obd_ops = {
1492 .o_owner = THIS_MODULE,
1493 .o_attach = mdc_attach,
1494 .o_detach = mdc_detach,
1495 .o_setup = mdc_setup,
1496 .o_precleanup = mdc_precleanup,
1497 .o_cleanup = mdc_cleanup,
1498 .o_add_conn = client_import_add_conn,
1499 .o_del_conn = client_import_del_conn,
1500 .o_connect = client_connect_import,
1501 .o_disconnect = client_disconnect_export,
1502 .o_iocontrol = mdc_iocontrol,
1503 .o_packmd = mdc_packmd,
1504 .o_unpackmd = mdc_unpackmd,
1505 .o_statfs = mdc_statfs,
1507 .o_unpin = mdc_unpin,
1508 .o_import_event = mdc_import_event,
1509 .o_llog_init = mdc_llog_init,
1510 .o_llog_finish = mdc_llog_finish,
1511 .o_create = mdc_obj_create,
1512 .o_set_info = mdc_set_info,
1513 .o_get_info = mdc_get_info,
1515 .o_init_ea_size = mdc_init_ea_size,
1518 struct md_ops mdc_md_ops = {
1519 .m_getstatus = mdc_getstatus,
1520 .m_getattr = mdc_getattr,
1521 .m_close = mdc_close,
1522 .m_create = mdc_create,
1523 .m_done_writing = mdc_done_writing,
1524 .m_enqueue = mdc_enqueue,
1525 .m_getattr_lock = mdc_getattr_lock,
1526 .m_intent_lock = mdc_intent_lock,
1528 .m_rename = mdc_rename,
1529 .m_setattr = mdc_setattr,
1531 .m_readpage = mdc_readpage,
1532 .m_unlink = mdc_unlink,
1533 .m_valid_attrs = mdc_valid_attrs,
1534 .m_req2lustre_md = mdc_req2lustre_md,
1535 .m_set_open_replay_data = mdc_set_open_replay_data,
1536 .m_clear_open_replay_data = mdc_clear_open_replay_data,
1537 .m_store_inode_generation = mdc_store_inode_generation,
1538 .m_set_lock_data = mdc_set_lock_data,
1539 .m_get_real_obd = mdc_get_real_obd,
1540 .m_change_cbdata_name = mdc_change_cbdata_name,
1541 .m_change_cbdata = mdc_change_cbdata,
1544 int __init mdc_init(void)
1546 struct lprocfs_static_vars lvars;
1547 lprocfs_init_vars(mdc, &lvars);
1548 return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
1553 static void /*__exit*/ mdc_exit(void)
1555 class_unregister_type(LUSTRE_MDC_NAME);
1558 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1559 MODULE_DESCRIPTION("Lustre Metadata Client");
1560 MODULE_LICENSE("GPL");
1562 EXPORT_SYMBOL(mdc_req2lustre_md);
1563 EXPORT_SYMBOL(mdc_change_cbdata);
1564 EXPORT_SYMBOL(mdc_getstatus);
1565 EXPORT_SYMBOL(mdc_getattr);
1566 EXPORT_SYMBOL(mdc_getattr_lock);
1567 EXPORT_SYMBOL(mdc_create);
1568 EXPORT_SYMBOL(mdc_unlink);
1569 EXPORT_SYMBOL(mdc_rename);
1570 EXPORT_SYMBOL(mdc_link);
1571 EXPORT_SYMBOL(mdc_readpage);
1572 EXPORT_SYMBOL(mdc_setattr);
1573 EXPORT_SYMBOL(mdc_close);
1574 EXPORT_SYMBOL(mdc_done_writing);
1575 EXPORT_SYMBOL(mdc_sync);
1576 EXPORT_SYMBOL(mdc_set_open_replay_data);
1577 EXPORT_SYMBOL(mdc_clear_open_replay_data);
1578 EXPORT_SYMBOL(mdc_store_inode_generation);
1580 module_init(mdc_init);
1581 module_exit(mdc_exit);