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 <linux/lustre_gs.h>
43 #include "mdc_internal.h"
45 #define REQUEST_MINOR 244
47 static int mdc_cleanup(struct obd_device *obd, int flags);
49 extern int mds_queue_req(struct ptlrpc_request *);
50 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
51 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
52 static int send_getstatus(struct obd_import *imp, struct lustre_id *rootid,
53 int level, int msg_flags)
55 struct ptlrpc_request *req;
56 struct mds_body *body;
57 int rc, size[2] = {0, sizeof(*body)};
60 //size[0] = lustre_secdesc_size();
62 req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_GETSTATUS,
65 GOTO(out, rc = -ENOMEM);
67 //lustre_pack_secdesc(req, size[0]);
69 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
70 req->rq_send_state = level;
71 req->rq_replen = lustre_msg_size(1, &size[1]);
73 req->rq_reqmsg->flags |= msg_flags;
74 rc = ptlrpc_queue_wait(req);
77 body = lustre_swab_repbuf (req, 0, sizeof (*body),
78 lustre_swab_mds_body);
80 CERROR ("Can't extract mds_body\n");
81 GOTO (out, rc = -EPROTO);
84 memcpy(rootid, &body->id1, sizeof(*rootid));
86 CDEBUG(D_NET, "root ino="LPU64", last_committed="LPU64
87 ", last_xid="LPU64"\n", rootid->li_stc.u.e3s.l3s_ino,
88 req->rq_repmsg->last_committed, req->rq_repmsg->last_xid);
93 ptlrpc_req_finished(req);
97 /* This should be mdc_get_info("rootid") */
98 int mdc_getstatus(struct obd_export *exp, struct lustre_id *rootid)
100 return send_getstatus(class_exp2cliimp(exp), rootid,
104 int mdc_getattr_common(struct obd_export *exp, unsigned int ea_size,
105 struct ptlrpc_request *req)
107 struct mds_body *body, *reqbody;
110 int repsize[2] = {sizeof(*body)};
114 /* request message already built */
117 repsize[bufcount++] = ea_size;
118 CDEBUG(D_INODE, "reserved %u bytes for MD/symlink in packet\n",
122 reqbody = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*reqbody));
123 LASSERT(!(reqbody->valid & OBD_MD_FLACL));
125 if (reqbody->valid & OBD_MD_FLKEY) {
126 repsize[bufcount++] = 5;
127 repsize[bufcount++] = sizeof(struct lustre_key);
130 req->rq_replen = lustre_msg_size(bufcount, repsize);
132 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
133 rc = ptlrpc_queue_wait(req);
134 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
138 body = lustre_swab_repbuf (req, 0, sizeof (*body),
139 lustre_swab_mds_body);
141 CERROR ("Can't unpack mds_body\n");
145 CDEBUG(D_NET, "mode: %o\n", body->mode);
147 LASSERT_REPSWAB (req, 1);
149 /* Skip the check if getxattr/listxattr are called with no buffers */
150 if ((reqbody->eadatasize != 0) &&
151 !(reqbody->valid & (OBD_MD_FLXATTR | OBD_MD_FLXATTRLIST))) {
152 /* reply indicates presence of eadata; check it's there... */
153 eadata = lustre_msg_buf (req->rq_repmsg, 1,
155 if (eadata == NULL) {
156 CERROR ("Missing/short eadata\n");
164 static int mdc_cancel_unused(struct obd_export *exp,
165 struct lov_stripe_md *lsm,
166 int flags, void *opaque)
168 struct obd_device *obd = class_exp2obd(exp);
171 RETURN(ldlm_cli_cancel_unused(obd->obd_namespace,
172 NULL, flags, opaque));
175 int mdc_getattr(struct obd_export *exp, struct lustre_id *id,
176 __u64 valid, const char *xattr_name,
177 const void *xattr_data, unsigned int xattr_datalen,
178 unsigned int ea_size, struct ptlrpc_request **request)
180 struct ptlrpc_request *req;
181 struct mds_body *body;
182 int xattr_namelen = xattr_name ? strlen(xattr_name) + 1 : 0;
183 int size[4] = {0, sizeof(*body)};
188 size[0] = lustre_secdesc_size();
190 if (valid & OBD_MD_FLXATTR) {
191 size[bufcount++] = xattr_namelen;
193 if (xattr_datalen > 0) {
195 size[bufcount++] = xattr_datalen;
198 LASSERT(!xattr_data && !xattr_datalen);
200 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
201 MDS_GETATTR, bufcount, size, NULL);
203 GOTO(out, rc = -ENOMEM);
205 lustre_pack_secdesc(req, size[0]);
207 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
208 memcpy(&body->id1, id, sizeof(*id));
210 body->eadatasize = ea_size;
212 if (valid & OBD_MD_FLXATTR) {
213 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, xattr_namelen),
214 xattr_name, xattr_namelen);
216 memcpy(lustre_msg_buf(req->rq_reqmsg, 3, xattr_datalen),
217 xattr_data, xattr_datalen);
220 rc = mdc_getattr_common(exp, ea_size, req);
222 ptlrpc_req_finished (req);
230 int mdc_access_check(struct obd_export *exp, struct lustre_id *id,
231 struct ptlrpc_request **request)
234 struct ptlrpc_request *req;
235 struct mds_body *body;
236 int size[2] = {0, sizeof(*body)};
240 size[0] = lustre_secdesc_size();
241 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
242 MDS_ACCESS_CHECK, 2, size, NULL);
244 GOTO(out, rc = -ENOMEM);
246 lustre_pack_secdesc(req, size[0]);
247 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
248 memcpy(&body->id1, id, sizeof(*id));
250 req->rq_replen = lustre_msg_size(2, size);
251 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
252 rc = ptlrpc_queue_wait(req);
253 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
255 ptlrpc_req_finished (req);
258 body = lustre_swab_repbuf (req, 0, sizeof (*body),
259 lustre_swab_mds_body);
261 CERROR ("Can't unpack mds_body\n");
271 int mdc_getattr_lock(struct obd_export *exp, struct lustre_id *id,
272 char *filename, int namelen, __u64 valid,
273 unsigned int ea_size, struct ptlrpc_request **request)
275 struct ptlrpc_request *req;
276 struct mds_body *body;
277 int rc, size[3] = {0, sizeof(*body), namelen};
280 size[0] = lustre_secdesc_size();
282 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
283 MDS_GETATTR_LOCK, 3, size, NULL);
285 GOTO(out, rc = -ENOMEM);
287 lustre_pack_secdesc(req, size[0]);
289 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF, sizeof (*body));
290 memcpy(&body->id1, id, sizeof(*id));
292 body->eadatasize = ea_size;
294 if (filename != NULL) {
295 LASSERT (strnlen (filename, namelen) == namelen - 1);
296 memcpy(lustre_msg_buf(req->rq_reqmsg, 2, namelen),
299 LASSERT(namelen == 1);
302 rc = mdc_getattr_common(exp, ea_size, req);
304 ptlrpc_req_finished (req);
312 /* This should be called with both the request and the reply still packed. */
313 int mdc_store_inode_generation(struct obd_export *exp,
314 struct ptlrpc_request *req,
315 int reqoff, int repoff)
317 struct mds_rec_create *rec =
318 lustre_msg_buf(req->rq_reqmsg, reqoff, sizeof(*rec));
319 struct mds_body *body =
320 lustre_msg_buf(req->rq_repmsg, repoff, sizeof(*body));
322 LASSERT (rec != NULL);
323 LASSERT (body != NULL);
325 memcpy(&rec->cr_replayid, &body->id1, sizeof(rec->cr_replayid));
326 DEBUG_REQ(D_HA, req, "storing generation for ino "DLID4,
327 OLID4(&rec->cr_replayid));
331 static int mdc_unpack_acl(struct obd_export *exp_lmv, struct ptlrpc_request *req,
332 unsigned int *offset, struct lustre_md *md)
334 struct posix_acl *acl;
335 struct mds_remote_perm *perm;
336 int size, acl_off = 0, rc = 0;
339 /* if anything wrong when unpacking md, we don't check acl
340 * stuff, for simplicity
342 if (md->body->valid & OBD_MD_FLACL) {
344 if (md->body->valid & OBD_MD_FLRMTACL) {
346 buf = lustre_swab_repbuf(req, acl_off++, sizeof(*perm),
347 lustre_swab_remote_perm);
349 CERROR("Can't unpack remote perm\n");
352 OBD_ALLOC(perm, sizeof(*perm));
355 memcpy(perm, buf, sizeof(*perm));
356 md->remote_perm = perm;
359 size = le32_to_cpu(*(__u32 *) lustre_msg_buf(
360 req->rq_repmsg, acl_off++, 4));
361 buf = lustre_msg_buf(req->rq_repmsg, acl_off++, size);
363 acl = posix_acl_from_xattr(buf, size);
367 CERROR("convert xattr to acl failed: %d\n", rc);
370 rc = posix_acl_valid(acl);
372 CERROR("acl valid error: %d\n", rc);
373 posix_acl_release(acl);
382 static int mdc_unpack_gskey(struct obd_export *exp_lmv, struct ptlrpc_request *req,
383 unsigned int *offset, struct lustre_md *md)
385 int key_off = 0, rc = 0, size = 0;
389 if (md->body->valid & OBD_MD_FLKEY) {
390 size = le32_to_cpu(*(__u32 *) lustre_msg_buf(req->rq_repmsg,
392 buf = lustre_msg_buf(req->rq_repmsg, key_off++, size);
394 CDEBUG(D_INFO, "buf %p key_off %d size %d \n",
396 md->key = (struct lustre_key *)buf;
401 int mdc_req2lustre_md(struct obd_export *exp_lmv, struct ptlrpc_request *req,
402 unsigned int offset, struct obd_export *exp_lov,
403 struct lustre_md *md)
405 struct lov_mds_md *lmm;
406 int rc = 0, reply_off;
410 memset(md, 0, sizeof(*md));
412 md->body = lustre_msg_buf(req->rq_repmsg, offset,
417 LASSERT_REPSWABBED(req, offset);
419 if (!(md->body->valid & OBD_MD_FLEASIZE) &&
420 !(md->body->valid & OBD_MD_FLDIREA))
423 if (S_ISREG(md->body->mode)) {
424 if (md->body->eadatasize == 0) {
425 CERROR("invalid EA size (0) is detected\n");
429 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
430 md->body->eadatasize);
434 LASSERT(exp_lov != NULL);
436 rc = obd_unpackmd(exp_lov, &md->lsm, lmm,
437 md->body->eadatasize);
439 LASSERT(rc >= sizeof(*md->lsm));
442 } else if (S_ISDIR(md->body->mode)) {
443 /* dir can be non-splitted */
444 if (md->body->eadatasize == 0)
447 lmm = lustre_msg_buf(req->rq_repmsg, offset + 1,
448 md->body->eadatasize);
452 if (md->body->valid & OBD_MD_MEA) {
453 LASSERT(exp_lmv != NULL);
455 rc = obd_unpackmd(exp_lmv, (void *)&md->mea,
456 lmm, md->body->eadatasize);
458 LASSERT(rc >= sizeof(*md->mea));
463 LASSERT(S_ISCHR(md->body->mode) ||
464 S_ISBLK(md->body->mode) ||
465 S_ISFIFO(md->body->mode)||
466 S_ISLNK(md->body->mode) ||
467 S_ISSOCK(md->body->mode));
470 reply_off = (md->body->valid & OBD_MD_FLEASIZE) ?
471 (offset + 2) : (offset + 1);
472 rc = mdc_unpack_acl(exp_lmv, req, &reply_off, md);
474 CERROR("upack acl error %d \n", rc);
478 rc = mdc_unpack_gskey(exp_lmv, req, &reply_off, md);
485 static void mdc_commit_open(struct ptlrpc_request *req)
487 struct mdc_open_data *mod = req->rq_cb_data;
491 if (mod->mod_close_req != NULL)
492 mod->mod_close_req->rq_cb_data = NULL;
494 if (mod->mod_och != NULL)
495 mod->mod_och->och_mod = NULL;
497 OBD_FREE(mod, sizeof(*mod));
498 req->rq_cb_data = NULL;
499 LASSERT(atomic_read(&req->rq_refcount) > 1);
500 ptlrpc_req_finished(req);
503 static void mdc_replay_open(struct ptlrpc_request *req)
505 struct mdc_open_data *mod = req->rq_cb_data;
506 struct obd_client_handle *och;
507 struct ptlrpc_request *close_req;
508 struct lustre_handle old;
509 struct mds_body *body;
512 body = lustre_swab_repbuf(req, 1, sizeof(*body), lustre_swab_mds_body);
513 LASSERT (body != NULL);
516 DEBUG_REQ(D_ERROR, req,
517 "can't properly replay without open data");
524 struct lustre_handle *file_fh;
525 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
526 file_fh = &och->och_fh;
527 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
528 file_fh->cookie, body->handle.cookie);
529 memcpy(&old, file_fh, sizeof(old));
530 memcpy(file_fh, &body->handle, sizeof(*file_fh));
533 close_req = mod->mod_close_req;
534 if (close_req != NULL) {
535 struct mds_body *close_body;
536 LASSERT(close_req->rq_reqmsg->opc == MDS_CLOSE);
537 close_body = lustre_msg_buf(close_req->rq_reqmsg,
539 sizeof(*close_body));
541 LASSERT(!memcmp(&old, &close_body->handle, sizeof old));
542 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
543 memcpy(&close_body->handle, &body->handle,
544 sizeof(close_body->handle));
550 int mdc_set_open_replay_data(struct obd_export *exp,
551 struct obd_client_handle *och,
552 struct ptlrpc_request *open_req)
554 struct mdc_open_data *mod;
555 struct mds_rec_create *rec;
556 struct mds_body *body;
558 rec = lustre_msg_buf(open_req->rq_reqmsg, MDS_REQ_INTENT_REC_OFF,
560 body = lustre_msg_buf(open_req->rq_repmsg, 1, sizeof(*body));
562 LASSERT(rec != NULL);
563 /* outgoing messages always in my byte order */
564 LASSERT(body != NULL);
565 /* incoming message in my byte order (it's been swabbed) */
566 LASSERT_REPSWABBED(open_req, 1);
568 OBD_ALLOC(mod, sizeof(*mod));
570 DEBUG_REQ(D_ERROR, open_req, "can't allocate mdc_open_data");
576 mod->mod_open_req = ptlrpc_request_addref(open_req);
578 memcpy(&rec->cr_replayid, &body->id1, sizeof rec->cr_replayid);
579 open_req->rq_replay_cb = mdc_replay_open;
580 open_req->rq_commit_cb = mdc_commit_open;
581 open_req->rq_cb_data = mod;
582 DEBUG_REQ(D_HA, open_req, "set up replay data");
586 int mdc_clear_open_replay_data(struct obd_export *exp,
587 struct obd_client_handle *och)
589 struct mdc_open_data *mod = och->och_mod;
591 /* Don't free the structure now (it happens in mdc_commit_open, after
592 * we're sure we won't need to fix up the close request in the future),
593 * but make sure that replay doesn't poke at the och, which is about to
595 LASSERT(mod != LP_POISON);
602 static void mdc_commit_close(struct ptlrpc_request *req)
604 struct mdc_open_data *mod = req->rq_cb_data;
605 struct ptlrpc_request *open_req;
606 struct obd_import *imp = req->rq_import;
608 DEBUG_REQ(D_HA, req, "close req committed");
612 mod->mod_close_req = NULL;
613 req->rq_cb_data = NULL;
614 req->rq_commit_cb = NULL;
616 open_req = mod->mod_open_req;
617 LASSERT(open_req != NULL);
618 LASSERT(open_req != LP_POISON);
619 LASSERT(open_req->rq_type != LI_POISON);
621 DEBUG_REQ(D_HA, open_req, "open req balanced");
622 if (open_req->rq_transno == 0) {
623 DEBUG_REQ(D_ERROR, open_req, "BUG 3892 open");
624 DEBUG_REQ(D_ERROR, req, "BUG 3892 close");
625 LASSERTF(open_req->rq_transno != 0, "BUG 3892\n");
627 LASSERT(open_req->rq_import == imp);
629 /* We no longer want to preserve this for transno-unconditional
631 spin_lock(&open_req->rq_lock);
632 open_req->rq_replay = 0;
633 spin_unlock(&open_req->rq_lock);
636 int mdc_close(struct obd_export *exp, struct obdo *oa,
637 struct obd_client_handle *och,
638 struct ptlrpc_request **request)
640 struct obd_device *obd = class_exp2obd(exp);
641 struct obd_import *imp = class_exp2cliimp(exp);
642 int reqsize[3] = {0, sizeof(struct mds_body),
643 obd->u.cli.cl_max_mds_cookiesize};
644 int rc, repsize[3] = {sizeof(struct mds_body),
645 obd->u.cli.cl_max_mds_easize,
646 obd->u.cli.cl_max_mds_cookiesize};
647 struct ptlrpc_request *req;
648 struct mdc_open_data *mod;
651 if (imp->imp_connection == NULL) {
652 CERROR("request on not connected import %s\n",
653 imp->imp_obd->obd_name);
657 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
658 MDS_CLOSE, 3, reqsize, NULL);
660 GOTO(out, rc = -ENOMEM);
662 //reqsize[0] = lustre_secdesc_size();
663 //lustre_pack_secdesc(req, reqsize[0]);
665 /* Ensure that this close's handle is fixed up during replay. */
666 LASSERT(och != NULL);
668 if (likely(mod != NULL)) {
669 mod->mod_close_req = req;
670 LASSERT(mod->mod_open_req->rq_type != LI_POISON);
671 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
673 CDEBUG(D_HA, "couldn't find open req; "
674 "expecting close error\n");
677 mdc_close_pack(req, 1, oa, oa->o_valid, och);
679 req->rq_replen = lustre_msg_size(3, repsize);
680 req->rq_commit_cb = mdc_commit_close;
681 LASSERT(req->rq_cb_data == NULL);
682 req->rq_cb_data = mod;
684 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
685 rc = ptlrpc_queue_wait(req);
686 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
688 if (req->rq_repmsg == NULL) {
689 CDEBUG(D_HA, "request failed to send: %p, %d\n", req,
692 rc = req->rq_status ? req->rq_status : -EIO;
693 } else if (rc == 0) {
694 rc = req->rq_repmsg->status;
695 if (req->rq_repmsg->type == PTL_RPC_MSG_ERR) {
696 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, "
702 CERROR("Unexpected: can't find mdc_open_data, but "
703 "close succeeded. Please tell CFS.\n");
704 if (!lustre_swab_repbuf(req, 0, sizeof(struct mds_body),
705 lustre_swab_mds_body))
707 CERROR("Error unpacking mds_body\n");
719 int mdc_done_writing(struct obd_export *exp, struct obdo *obdo)
721 struct ptlrpc_request *req;
722 struct mds_body *body;
723 int rc, size[2] = {0, sizeof(*body)};
726 size[0] = lustre_secdesc_size();
728 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
729 MDS_DONE_WRITING, 2, size, NULL);
733 lustre_pack_secdesc(req, size[0]);
735 body = lustre_msg_buf(req->rq_reqmsg, MDS_REQ_REC_OFF,
738 mdc_pack_id(&body->id1, obdo->o_id, 0, obdo->o_mode,
739 obdo->o_mds, obdo->o_fid);
741 body->size = obdo->o_size;
742 body->blocks = obdo->o_blocks;
743 body->flags = obdo->o_flags;
744 body->valid = obdo->o_valid;
746 req->rq_replen = lustre_msg_size(1, &size[1]);
748 rc = ptlrpc_queue_wait(req);
749 ptlrpc_req_finished(req);
753 int mdc_readpage(struct obd_export *exp,
754 struct lustre_id *id,
755 __u64 offset, struct page *page,
756 struct ptlrpc_request **request)
758 struct obd_import *imp = class_exp2cliimp(exp);
759 struct ptlrpc_request *req = NULL;
760 struct ptlrpc_bulk_desc *desc = NULL;
761 struct mds_body *body;
762 int rc, size[2] = {0, sizeof(*body)};
765 CDEBUG(D_INODE, "inode: %ld\n", (long)id->li_stc.u.e3s.l3s_ino);
767 size[0] = lustre_secdesc_size();
769 req = ptlrpc_prep_req(imp, LUSTRE_MDS_VERSION, MDS_READPAGE,
772 GOTO(out, rc = -ENOMEM);
773 /* XXX FIXME bug 249 */
774 req->rq_request_portal = MDS_READPAGE_PORTAL;
776 lustre_pack_secdesc(req, size[0]);
778 desc = ptlrpc_prep_bulk_imp(req, 1, BULK_PUT_SINK, MDS_BULK_PORTAL);
780 GOTO(out, rc = -ENOMEM);
781 /* NB req now owns desc and will free it when it gets freed */
783 ptlrpc_prep_bulk_page(desc, page, 0, PAGE_CACHE_SIZE);
784 mdc_readdir_pack(req, 1, offset, PAGE_CACHE_SIZE, id);
786 req->rq_replen = lustre_msg_size(1, &size[1]);
787 rc = ptlrpc_queue_wait(req);
790 body = lustre_swab_repbuf(req, 0, sizeof (*body),
791 lustre_swab_mds_body);
793 CERROR("Can't unpack mds_body\n");
794 GOTO(out, rc = -EPROTO);
797 if (req->rq_bulk->bd_nob_transferred != PAGE_CACHE_SIZE) {
798 CERROR ("Unexpected # bytes transferred: %d"
800 req->rq_bulk->bd_nob_transferred,
802 GOTO (out, rc = -EPROTO);
812 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
813 void *karg, void *uarg)
815 struct obd_device *obd = exp->exp_obd;
816 struct obd_ioctl_data *data = karg;
817 struct obd_import *imp = obd->u.cli.cl_import;
818 struct llog_ctxt *ctxt;
822 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
825 if (!try_module_get(THIS_MODULE)) {
826 CERROR("Can't get module. Is it alive?");
831 case OBD_IOC_CLIENT_RECOVER:
832 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1);
836 case IOC_OSC_SET_ACTIVE:
837 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
839 case IOC_OSC_CTL_RECOVERY:
840 rc = ptlrpc_import_control_recovery(imp, data->ioc_offset);
842 case OBD_IOC_PARSE: {
843 ctxt = llog_get_context(&exp->exp_obd->obd_llogs,
844 LLOG_CONFIG_REPL_CTXT);
845 rc = class_config_process_llog(ctxt, data->ioc_inlbuf1, NULL);
849 case OBD_IOC_LLOG_INFO:
850 case OBD_IOC_LLOG_PRINT: {
851 ctxt = llog_get_context(&obd->obd_llogs, LLOG_CONFIG_REPL_CTXT);
852 rc = llog_ioctl(ctxt, cmd, data);
858 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
859 GOTO(out, rc = -ENOTTY);
862 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
865 module_put(THIS_MODULE);
871 int mdc_set_info(struct obd_export *exp, obd_count keylen,
872 void *key, obd_count vallen, void *val)
876 if (keylen == strlen("initial_recov") &&
877 memcmp(key, "initial_recov", strlen("initial_recov")) == 0) {
878 struct obd_import *imp = exp->exp_obd->u.cli.cl_import;
879 if (vallen != sizeof(int))
881 imp->imp_initial_recov = *(int *)val;
882 CDEBUG(D_HA, "%s: set imp_no_init_recov = %d\n",
883 exp->exp_obd->obd_name,
884 imp->imp_initial_recov);
886 } else if ((keylen >= strlen("crypto_type")) &&
887 strcmp(key, "crypto_type") == 0) {
888 struct ptlrpc_request *req;
889 char *bufs[2] = {key, val};
890 int rc, size[2] = {keylen, vallen};
892 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
893 OST_SET_INFO, 2, size, bufs);
897 req->rq_replen = lustre_msg_size(0, NULL);
898 rc = ptlrpc_queue_wait(req);
899 ptlrpc_req_finished(req);
901 } else if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
902 struct obd_import *imp = class_exp2cliimp(exp);
903 imp->imp_server_timeout = 1;
904 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
906 } else if (keylen == strlen("sec") &&
907 memcmp(key, "sec", keylen) == 0) {
908 struct client_obd *cli = &exp->exp_obd->u.cli;
910 cli->cl_sec_flavor = ptlrpcs_name2flavor(val);
911 if (cli->cl_sec_flavor == PTLRPCS_FLVR_INVALID) {
912 CERROR("unrecognized security type %s\n", (char*) val);
917 } else if (keylen == strlen("sec_flags") &&
918 memcmp(key, "sec_flags", keylen) == 0) {
919 struct client_obd *cli = &exp->exp_obd->u.cli;
921 cli->cl_sec_flags = *((unsigned long *) val);
923 } else if (keylen == strlen("flush_cred") &&
924 memcmp(key, "flush_cred", keylen) == 0) {
925 struct client_obd *cli = &exp->exp_obd->u.cli;
928 ptlrpcs_import_flush_current_creds(cli->cl_import);
930 } else if (keylen == strlen("async") && memcmp(key, "async", keylen) == 0) {
931 struct client_obd *cl = &exp->exp_obd->u.cli;
932 if (vallen != sizeof(int))
934 cl->cl_async = *(int *)val;
935 CDEBUG(D_HA, "%s: set async = %d\n",
936 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] = lustre_secdesc_size();
998 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
999 MDS_PIN, 2, size, NULL);
1003 //lustre_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] = lustre_secdesc_size();
1055 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1056 MDS_CLOSE, 2, size, NULL);
1060 //lustre_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] = lustre_secdesc_size();
1091 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_MDS_VERSION,
1092 MDS_SYNC, 2, size, NULL);
1094 RETURN(rc = -ENOMEM);
1096 //lustre_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, __u32 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("remote_flag") && !strcmp(key, "remote_flag")) {
1292 struct obd_import *imp;
1293 struct obd_connect_data *data;
1295 imp = class_exp2cliimp(exp);
1301 if (imp->imp_state != LUSTRE_IMP_FULL) {
1302 CERROR("import state not full\n");
1306 data = &imp->imp_connect_data;
1307 if (data->ocd_connect_flags & OBD_CONNECT_REMOTE) {
1310 } else if (data->ocd_connect_flags & OBD_CONNECT_LOCAL) {
1314 CERROR("no remote flag set?\n");
1318 if ((keylen < strlen("mdsize") || strcmp(key, "mdsize") != 0) &&
1319 (keylen < strlen("mdsnum") || strcmp(key, "mdsnum") != 0) &&
1320 (keylen < strlen("rootid") || strcmp(key, "rootid") != 0))
1323 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1324 OST_GET_INFO, 1, (int *)&keylen, bufs);
1328 req->rq_replen = lustre_msg_size(1, (int *)valsize);
1329 rc = ptlrpc_queue_wait(req);
1333 if (keylen >= strlen("rootid") && !strcmp(key, "rootid")) {
1334 struct lustre_id *reply;
1336 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1337 lustre_swab_lustre_id);
1338 if (reply == NULL) {
1339 CERROR("Can't unpack %s\n", (char *)key);
1340 GOTO(out_req, rc = -EPROTO);
1343 *(struct lustre_id *)val = *reply;
1344 } else if (keylen >= strlen("lovdesc") && !strcmp(key, "lovdesc")) {
1345 struct lov_desc *reply;
1347 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1348 lustre_swab_lov_desc);
1349 if (reply == NULL) {
1350 CERROR("Can't unpack %s\n", (char *)key);
1351 GOTO(out_req, rc = -EPROTO);
1354 *(struct lov_desc *)val = *reply;
1359 reply = lustre_swab_repbuf(req, 0, sizeof(*reply),
1360 lustre_swab_generic_32s);
1361 if (reply == NULL) {
1362 CERROR("Can't unpack %s\n", (char *)key);
1363 GOTO(out_req, rc = -EPROTO);
1365 *((__u32 *)val) = *reply;
1368 ptlrpc_req_finished(req);
1372 int mdc_obj_create(struct obd_export *exp, struct obdo *oa,
1373 void *acl, int acl_size,
1374 struct lov_stripe_md **ea, struct obd_trans_info *oti)
1376 struct ptlrpc_request *request;
1377 struct ost_body *body;
1379 int rc, size[2] = { sizeof(*body), acl_size };
1384 request = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION,
1385 OST_CREATE, 2, size, NULL);
1387 GOTO(out_req, rc = -ENOMEM);
1389 body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1390 memcpy(&body->oa, oa, sizeof(body->oa));
1393 acl_buf = lustre_msg_buf(request->rq_reqmsg, 1, acl_size);
1394 memcpy(acl_buf, acl, acl_size);
1397 request->rq_replen = lustre_msg_size(1, size);
1398 rc = ptlrpc_queue_wait(request);
1402 body = lustre_swab_repbuf(request, 0, sizeof(*body),
1403 lustre_swab_ost_body);
1405 CERROR ("can't unpack ost_body\n");
1406 GOTO (out_req, rc = -EPROTO);
1409 memcpy(oa, &body->oa, sizeof(*oa));
1411 /* store ino/generation for recovery */
1412 body = lustre_msg_buf(request->rq_reqmsg, 0, sizeof (*body));
1413 body->oa.o_id = oa->o_id;
1414 body->oa.o_generation = oa->o_generation;
1415 body->oa.o_fid = oa->o_fid;
1416 body->oa.o_mds = oa->o_mds;
1418 CDEBUG(D_HA, "transno: "LPD64"\n", request->rq_repmsg->transno);
1421 ptlrpc_req_finished(request);
1425 int mdc_brw(int rw, struct obd_export *exp, struct obdo *oa,
1426 struct lov_stripe_md *ea, obd_count oa_bufs,
1427 struct brw_page *pgarr, struct obd_trans_info *oti)
1429 struct ptlrpc_bulk_desc *desc;
1430 struct niobuf_remote *niobuf;
1431 struct ptlrpc_request *req;
1432 struct obd_ioobj *ioobj;
1433 struct ost_body *body;
1437 opc = ((rw & OBD_BRW_WRITE) != 0) ? OST_WRITE : OST_READ;
1439 size[0] = sizeof(*body);
1440 size[1] = sizeof(*ioobj);
1441 size[2] = oa_bufs * sizeof(*niobuf);
1443 req = ptlrpc_prep_req(class_exp2cliimp(exp), LUSTRE_OBD_VERSION, opc,
1445 LASSERT(req != NULL);
1447 if (opc == OST_WRITE)
1448 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_GET_SOURCE,
1451 desc = ptlrpc_prep_bulk_imp(req, oa_bufs, BULK_PUT_SINK,
1453 LASSERT(desc != NULL);
1455 body = lustre_msg_buf(req->rq_reqmsg, 0, sizeof(*body));
1456 ioobj = lustre_msg_buf(req->rq_reqmsg, 1, sizeof(*ioobj));
1457 niobuf = lustre_msg_buf(req->rq_reqmsg, 2, oa_bufs * sizeof(*niobuf));
1459 memcpy(&body->oa, oa, sizeof(*oa));
1460 obdo_to_ioobj(oa, ioobj);
1461 ioobj->ioo_bufcnt = oa_bufs;
1463 for (i = 0; i < oa_bufs; i++, niobuf++) {
1464 struct brw_page *pg = &pgarr[i];
1466 LASSERT(pg->count > 0);
1467 LASSERT((pg->disk_offset & ~PAGE_MASK) + pg->count <= PAGE_SIZE);
1469 ptlrpc_prep_bulk_page(desc, pg->pg, pg->disk_offset & ~PAGE_MASK,
1472 niobuf->offset = pg->disk_offset;
1473 niobuf->len = pg->count;
1474 niobuf->flags = pg->flag;
1477 /* size[0] still sizeof (*body) */
1478 if (opc == OST_WRITE) {
1479 /* 1 RC per niobuf */
1480 size[1] = sizeof(__u32) * oa_bufs;
1481 req->rq_replen = lustre_msg_size(2, size);
1483 /* 1 RC for the whole I/O */
1484 req->rq_replen = lustre_msg_size(1, size);
1486 err = ptlrpc_queue_wait(req);
1489 ptlrpc_req_finished(req);
1493 static int mdc_valid_attrs(struct obd_export *exp,
1494 struct lustre_id *id)
1496 struct ldlm_res_id res_id = { .name = {0} };
1497 struct obd_device *obd = exp->exp_obd;
1498 struct lustre_handle lockh;
1499 ldlm_policy_data_t policy;
1503 res_id.name[0] = id_fid(id);
1504 res_id.name[1] = id_group(id);
1505 policy.l_inodebits.bits = MDS_INODELOCK_UPDATE;
1507 CDEBUG(D_INFO, "trying to match res "LPU64"\n",
1510 /* FIXME use LDLM_FL_TEST_LOCK instead */
1511 flags = LDLM_FL_BLOCK_GRANTED | LDLM_FL_CBPENDING;
1512 if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1513 LDLM_IBITS, &policy, LCK_PR, &lockh)) {
1514 ldlm_lock_decref(&lockh, LCK_PR);
1518 if (ldlm_lock_match(obd->obd_namespace, flags, &res_id,
1519 LDLM_IBITS, &policy, LCK_PW, &lockh)) {
1520 ldlm_lock_decref(&lockh, LCK_PW);
1526 static int mdc_change_cbdata_name(struct obd_export *exp,
1527 struct lustre_id *pid,
1528 char *name, int len,
1529 struct lustre_id *cid,
1530 ldlm_iterator_t it, void *data)
1533 rc = mdc_change_cbdata(exp, cid, it, data);
1537 struct obd_ops mdc_obd_ops = {
1538 .o_owner = THIS_MODULE,
1539 .o_attach = mdc_attach,
1540 .o_detach = mdc_detach,
1541 .o_setup = mdc_setup,
1542 .o_precleanup = mdc_precleanup,
1543 .o_cleanup = mdc_cleanup,
1544 .o_add_conn = client_import_add_conn,
1545 .o_del_conn = client_import_del_conn,
1546 .o_connect = client_connect_import,
1547 .o_disconnect = client_disconnect_export,
1548 .o_iocontrol = mdc_iocontrol,
1549 .o_packmd = mdc_packmd,
1550 .o_unpackmd = mdc_unpackmd,
1551 .o_statfs = mdc_statfs,
1553 .o_unpin = mdc_unpin,
1554 .o_import_event = mdc_import_event,
1555 .o_llog_init = mdc_llog_init,
1556 .o_llog_finish = mdc_llog_finish,
1557 .o_create = mdc_obj_create,
1558 .o_set_info = mdc_set_info,
1559 .o_get_info = mdc_get_info,
1561 .o_cancel_unused = mdc_cancel_unused,
1562 .o_init_ea_size = mdc_init_ea_size,
1565 struct md_ops mdc_md_ops = {
1566 .m_getstatus = mdc_getstatus,
1567 .m_getattr = mdc_getattr,
1568 .m_close = mdc_close,
1569 .m_create = mdc_create,
1570 .m_done_writing = mdc_done_writing,
1571 .m_enqueue = mdc_enqueue,
1572 .m_getattr_lock = mdc_getattr_lock,
1573 .m_intent_lock = mdc_intent_lock,
1575 .m_rename = mdc_rename,
1576 .m_setattr = mdc_setattr,
1578 .m_readpage = mdc_readpage,
1579 .m_unlink = mdc_unlink,
1580 .m_valid_attrs = mdc_valid_attrs,
1581 .m_req2lustre_md = mdc_req2lustre_md,
1582 .m_set_open_replay_data = mdc_set_open_replay_data,
1583 .m_clear_open_replay_data = mdc_clear_open_replay_data,
1584 .m_store_inode_generation = mdc_store_inode_generation,
1585 .m_set_lock_data = mdc_set_lock_data,
1586 .m_get_real_obd = mdc_get_real_obd,
1587 .m_change_cbdata_name = mdc_change_cbdata_name,
1588 .m_change_cbdata = mdc_change_cbdata,
1589 .m_access_check = mdc_access_check,
1592 int __init mdc_init(void)
1594 struct lprocfs_static_vars lvars;
1596 lprocfs_init_vars(mdc, &lvars);
1597 return class_register_type(&mdc_obd_ops, &mdc_md_ops,
1598 lvars.module_vars, OBD_MDC_DEVICENAME);
1602 static void /*__exit*/ mdc_exit(void)
1604 class_unregister_type(OBD_MDC_DEVICENAME);
1607 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1608 MODULE_DESCRIPTION("Lustre Metadata Client");
1609 MODULE_LICENSE("GPL");
1611 EXPORT_SYMBOL(mdc_req2lustre_md);
1612 EXPORT_SYMBOL(mdc_change_cbdata);
1613 EXPORT_SYMBOL(mdc_getstatus);
1614 EXPORT_SYMBOL(mdc_getattr);
1615 EXPORT_SYMBOL(mdc_getattr_lock);
1616 EXPORT_SYMBOL(mdc_create);
1617 EXPORT_SYMBOL(mdc_unlink);
1618 EXPORT_SYMBOL(mdc_rename);
1619 EXPORT_SYMBOL(mdc_link);
1620 EXPORT_SYMBOL(mdc_readpage);
1621 EXPORT_SYMBOL(mdc_setattr);
1622 EXPORT_SYMBOL(mdc_close);
1623 EXPORT_SYMBOL(mdc_done_writing);
1624 EXPORT_SYMBOL(mdc_sync);
1625 EXPORT_SYMBOL(mdc_set_open_replay_data);
1626 EXPORT_SYMBOL(mdc_clear_open_replay_data);
1627 EXPORT_SYMBOL(mdc_store_inode_generation);
1629 module_init(mdc_init);
1630 module_exit(mdc_exit);