4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
27 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, Whamcloud, Inc.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
38 # define EXPORT_SYMTAB
40 #define DEBUG_SUBSYSTEM S_MDC
43 # include <linux/module.h>
44 # include <linux/pagemap.h>
45 # include <linux/miscdevice.h>
46 # include <linux/init.h>
48 # include <liblustre.h>
51 #include <lustre_acl.h>
52 #include <obd_class.h>
53 #include <lustre_dlm.h>
54 #include <lustre_fid.h>
55 #include <md_object.h>
56 #include <lprocfs_status.h>
57 #include <lustre_param.h>
58 #include "mdc_internal.h"
59 #include <lustre/lustre_idl.h>
61 #define REQUEST_MINOR 244
63 struct mdc_renew_capa_args {
64 struct obd_capa *ra_oc;
65 renew_capa_cb_t ra_cb;
68 static int mdc_cleanup(struct obd_device *obd);
70 int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
71 const struct req_msg_field *field, struct obd_capa **oc)
73 struct lustre_capa *capa;
77 /* swabbed already in mdc_enqueue */
78 capa = req_capsule_server_get(&req->rq_pill, field);
82 c = alloc_capa(CAPA_SITE_CLIENT);
84 CDEBUG(D_INFO, "alloc capa failed!\n");
93 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
94 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
95 static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid,
96 struct obd_capa **pc, int level, int msg_flags)
98 struct ptlrpc_request *req;
99 struct mdt_body *body;
103 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS,
104 LUSTRE_MDS_VERSION, MDS_GETSTATUS);
108 mdc_pack_body(req, NULL, NULL, 0, 0, -1, 0);
109 lustre_msg_add_flags(req->rq_reqmsg, msg_flags);
110 req->rq_send_state = level;
112 ptlrpc_request_set_replen(req);
114 rc = ptlrpc_queue_wait(req);
118 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
120 GOTO(out, rc = -EPROTO);
122 if (body->valid & OBD_MD_FLMDSCAPA) {
123 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, pc);
128 *rootfid = body->fid1;
130 "root fid="DFID", last_committed="LPU64"\n",
132 lustre_msg_get_last_committed(req->rq_repmsg));
135 ptlrpc_req_finished(req);
139 /* This should be mdc_get_info("rootfid") */
140 int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid,
141 struct obd_capa **pc)
143 return send_getstatus(class_exp2cliimp(exp), rootfid, pc,
148 * This function now is known to always saying that it will receive 4 buffers
149 * from server. Even for cases when acl_size and md_size is zero, RPC header
150 * will contain 4 fields and RPC itself will contain zero size fields. This is
151 * because mdt_getattr*() _always_ returns 4 fields, but if acl is not needed
152 * and thus zero, it shrinks it, making zero size. The same story about
153 * md_size. And this is course of problem when client waits for smaller number
154 * of fields. This issue will be fixed later when client gets aware of RPC
157 static int mdc_getattr_common(struct obd_export *exp,
158 struct ptlrpc_request *req)
160 struct req_capsule *pill = &req->rq_pill;
161 struct mdt_body *body;
166 /* Request message already built. */
167 rc = ptlrpc_queue_wait(req);
171 /* sanity check for the reply */
172 body = req_capsule_server_get(pill, &RMF_MDT_BODY);
176 CDEBUG(D_NET, "mode: %o\n", body->mode);
178 if (body->eadatasize != 0) {
179 mdc_update_max_ea_from_body(exp, body);
181 eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
187 if (body->valid & OBD_MD_FLRMTPERM) {
188 struct mdt_remote_perm *perm;
190 LASSERT(client_is_remote(exp));
191 perm = req_capsule_server_swab_get(pill, &RMF_ACL,
192 lustre_swab_mdt_remote_perm);
197 if (body->valid & OBD_MD_FLMDSCAPA) {
198 struct lustre_capa *capa;
199 capa = req_capsule_server_get(pill, &RMF_CAPA1);
207 int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
208 struct ptlrpc_request **request)
210 struct ptlrpc_request *req;
215 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
219 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
221 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
223 ptlrpc_request_free(req);
227 mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
228 op_data->op_valid, op_data->op_mode, -1, 0);
230 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
232 if (op_data->op_valid & OBD_MD_FLRMTPERM) {
233 LASSERT(client_is_remote(exp));
234 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
235 sizeof(struct mdt_remote_perm));
237 ptlrpc_request_set_replen(req);
239 rc = mdc_getattr_common(exp, req);
241 ptlrpc_req_finished(req);
247 int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
248 struct ptlrpc_request **request)
250 struct ptlrpc_request *req;
255 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
256 &RQF_MDS_GETATTR_NAME);
260 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
261 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
262 op_data->op_namelen + 1);
264 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME);
266 ptlrpc_request_free(req);
270 mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
271 op_data->op_valid, op_data->op_mode,
272 op_data->op_suppgids[0], 0);
274 if (op_data->op_name) {
275 char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
276 LASSERT(strnlen(op_data->op_name, op_data->op_namelen) ==
277 op_data->op_namelen);
278 memcpy(name, op_data->op_name, op_data->op_namelen);
281 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
283 ptlrpc_request_set_replen(req);
285 rc = mdc_getattr_common(exp, req);
287 ptlrpc_req_finished(req);
293 static int mdc_is_subdir(struct obd_export *exp,
294 const struct lu_fid *pfid,
295 const struct lu_fid *cfid,
296 struct ptlrpc_request **request)
298 struct ptlrpc_request *req;
304 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
305 &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION,
310 mdc_is_subdir_pack(req, pfid, cfid, 0);
311 ptlrpc_request_set_replen(req);
313 rc = ptlrpc_queue_wait(req);
314 if (rc && rc != -EREMOTE)
315 ptlrpc_req_finished(req);
321 static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
322 const struct lu_fid *fid,
323 struct obd_capa *oc, int opcode, obd_valid valid,
324 const char *xattr_name, const char *input,
325 int input_size, int output_size, int flags,
326 __u32 suppgid, struct ptlrpc_request **request)
328 struct ptlrpc_request *req;
329 int xattr_namelen = 0;
335 req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt);
339 mdc_set_capa_size(req, &RMF_CAPA1, oc);
341 xattr_namelen = strlen(xattr_name) + 1;
342 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
347 req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
351 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
353 ptlrpc_request_free(req);
357 if (opcode == MDS_REINT) {
358 struct mdt_rec_setxattr *rec;
360 CLASSERT(sizeof(struct mdt_rec_setxattr) ==
361 sizeof(struct mdt_rec_reint));
362 rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
363 rec->sx_opcode = REINT_SETXATTR;
365 * cfs_curproc_fs{u,g}id() should replace
366 * current->fs{u,g}id for portability.
368 rec->sx_fsuid = cfs_curproc_fsuid();
369 rec->sx_fsgid = cfs_curproc_fsgid();
370 rec->sx_cap = cfs_curproc_cap_pack();
371 rec->sx_suppgid1 = suppgid;
372 rec->sx_suppgid2 = -1;
374 rec->sx_valid = valid | OBD_MD_FLCTIME;
375 rec->sx_time = cfs_time_current_sec();
376 rec->sx_size = output_size;
377 rec->sx_flags = flags;
379 mdc_pack_capa(req, &RMF_CAPA1, oc);
381 mdc_pack_body(req, fid, oc, valid, output_size, suppgid, flags);
385 tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
386 memcpy(tmp, xattr_name, xattr_namelen);
389 tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
390 memcpy(tmp, input, input_size);
393 if (req_capsule_has_field(&req->rq_pill, &RMF_EADATA, RCL_SERVER))
394 req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
395 RCL_SERVER, output_size);
396 ptlrpc_request_set_replen(req);
399 if (opcode == MDS_REINT)
400 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
402 rc = ptlrpc_queue_wait(req);
404 if (opcode == MDS_REINT)
405 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
408 ptlrpc_req_finished(req);
414 int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
415 struct obd_capa *oc, obd_valid valid, const char *xattr_name,
416 const char *input, int input_size, int output_size,
417 int flags, __u32 suppgid, struct ptlrpc_request **request)
419 return mdc_xattr_common(exp, &RQF_MDS_REINT_SETXATTR,
420 fid, oc, MDS_REINT, valid, xattr_name,
421 input, input_size, output_size, flags,
425 int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
426 struct obd_capa *oc, obd_valid valid, const char *xattr_name,
427 const char *input, int input_size, int output_size,
428 int flags, struct ptlrpc_request **request)
430 return mdc_xattr_common(exp, &RQF_MDS_GETXATTR,
431 fid, oc, MDS_GETXATTR, valid, xattr_name,
432 input, input_size, output_size, flags,
436 #ifdef CONFIG_FS_POSIX_ACL
437 static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
439 struct req_capsule *pill = &req->rq_pill;
440 struct mdt_body *body = md->body;
441 struct posix_acl *acl;
449 buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->aclsize);
454 acl = posix_acl_from_xattr(buf, body->aclsize);
457 CERROR("convert xattr to acl: %d\n", rc);
461 rc = posix_acl_valid(acl);
463 CERROR("validate acl: %d\n", rc);
464 posix_acl_release(acl);
472 #define mdc_unpack_acl(req, md) 0
475 int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
476 struct obd_export *dt_exp, struct obd_export *md_exp,
477 struct lustre_md *md)
479 struct req_capsule *pill = &req->rq_pill;
484 memset(md, 0, sizeof(*md));
486 md->body = req_capsule_server_get(pill, &RMF_MDT_BODY);
487 LASSERT(md->body != NULL);
489 if (md->body->valid & OBD_MD_FLEASIZE) {
491 struct lov_mds_md *lmm;
493 if (!S_ISREG(md->body->mode)) {
494 CDEBUG(D_INFO, "OBD_MD_FLEASIZE set, should be a "
495 "regular file, but is not\n");
496 GOTO(out, rc = -EPROTO);
499 if (md->body->eadatasize == 0) {
500 CDEBUG(D_INFO, "OBD_MD_FLEASIZE set, "
501 "but eadatasize 0\n");
502 GOTO(out, rc = -EPROTO);
504 lmmsize = md->body->eadatasize;
505 lmm = req_capsule_server_sized_get(pill, &RMF_MDT_MD, lmmsize);
507 GOTO(out, rc = -EPROTO);
509 rc = obd_unpackmd(dt_exp, &md->lsm, lmm, lmmsize);
513 if (rc < sizeof(*md->lsm)) {
514 CDEBUG(D_INFO, "lsm size too small: "
515 "rc < sizeof (*md->lsm) (%d < %d)\n",
516 rc, (int)sizeof(*md->lsm));
517 GOTO(out, rc = -EPROTO);
520 } else if (md->body->valid & OBD_MD_FLDIREA) {
522 struct lov_mds_md *lmv;
524 if(!S_ISDIR(md->body->mode)) {
525 CDEBUG(D_INFO, "OBD_MD_FLDIREA set, should be a "
526 "directory, but is not\n");
527 GOTO(out, rc = -EPROTO);
530 if (md->body->eadatasize == 0) {
531 CDEBUG(D_INFO, "OBD_MD_FLDIREA is set, "
532 "but eadatasize 0\n");
535 if (md->body->valid & OBD_MD_MEA) {
536 lmvsize = md->body->eadatasize;
537 lmv = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
540 GOTO(out, rc = -EPROTO);
542 rc = obd_unpackmd(md_exp, (void *)&md->mea, lmv,
547 if (rc < sizeof(*md->mea)) {
548 CDEBUG(D_INFO, "size too small: "
549 "rc < sizeof(*md->mea) (%d < %d)\n",
550 rc, (int)sizeof(*md->mea));
551 GOTO(out, rc = -EPROTO);
557 if (md->body->valid & OBD_MD_FLRMTPERM) {
558 /* remote permission */
559 LASSERT(client_is_remote(exp));
560 md->remote_perm = req_capsule_server_swab_get(pill, &RMF_ACL,
561 lustre_swab_mdt_remote_perm);
562 if (!md->remote_perm)
563 GOTO(out, rc = -EPROTO);
565 else if (md->body->valid & OBD_MD_FLACL) {
566 /* for ACL, it's possible that FLACL is set but aclsize is zero.
567 * only when aclsize != 0 there's an actual segment for ACL
570 if (md->body->aclsize) {
571 rc = mdc_unpack_acl(req, md);
574 #ifdef CONFIG_FS_POSIX_ACL
576 md->posix_acl = NULL;
580 if (md->body->valid & OBD_MD_FLMDSCAPA) {
581 struct obd_capa *oc = NULL;
583 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, &oc);
589 if (md->body->valid & OBD_MD_FLOSSCAPA) {
590 struct obd_capa *oc = NULL;
592 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA2, &oc);
602 capa_put(md->oss_capa);
606 capa_put(md->mds_capa);
609 #ifdef CONFIG_FS_POSIX_ACL
610 posix_acl_release(md->posix_acl);
613 obd_free_memmd(dt_exp, &md->lsm);
618 int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
625 * Handles both OPEN and SETATTR RPCs for OPEN-CLOSE and SETATTR-DONE_WRITING
628 void mdc_replay_open(struct ptlrpc_request *req)
630 struct md_open_data *mod = req->rq_cb_data;
631 struct ptlrpc_request *close_req;
632 struct obd_client_handle *och;
633 struct lustre_handle old;
634 struct mdt_body *body;
638 DEBUG_REQ(D_ERROR, req,
639 "Can't properly replay without open data.");
644 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
645 LASSERT(body != NULL);
649 struct lustre_handle *file_fh;
651 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
653 file_fh = &och->och_fh;
654 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
655 file_fh->cookie, body->handle.cookie);
657 *file_fh = body->handle;
659 close_req = mod->mod_close_req;
660 if (close_req != NULL) {
661 __u32 opc = lustre_msg_get_opc(close_req->rq_reqmsg);
662 struct mdt_ioepoch *epoch;
664 LASSERT(opc == MDS_CLOSE || opc == MDS_DONE_WRITING);
665 epoch = req_capsule_client_get(&close_req->rq_pill,
670 LASSERT(!memcmp(&old, &epoch->handle, sizeof(old)));
671 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
672 epoch->handle = body->handle;
677 void mdc_commit_open(struct ptlrpc_request *req)
679 struct md_open_data *mod = req->rq_cb_data;
684 * No need to touch md_open_data::mod_och, it holds a reference on
685 * \var mod and will zero references to each other, \var mod will be
686 * freed after that when md_open_data::mod_och will put the reference.
690 * Do not let open request to disappear as it still may be needed
691 * for close rpc to happen (it may happen on evict only, otherwise
692 * ptlrpc_request::rq_replay does not let mdc_commit_open() to be
693 * called), just mark this rpc as committed to distinguish these 2
694 * cases, see mdc_close() for details. The open request reference will
695 * be put along with freeing \var mod.
697 ptlrpc_request_addref(req);
698 cfs_spin_lock(&req->rq_lock);
699 req->rq_committed = 1;
700 cfs_spin_unlock(&req->rq_lock);
701 req->rq_cb_data = NULL;
705 int mdc_set_open_replay_data(struct obd_export *exp,
706 struct obd_client_handle *och,
707 struct ptlrpc_request *open_req)
709 struct md_open_data *mod;
710 struct mdt_rec_create *rec;
711 struct mdt_body *body;
712 struct obd_import *imp = open_req->rq_import;
715 if (!open_req->rq_replay)
718 rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT);
719 body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY);
720 LASSERT(rec != NULL);
721 /* Incoming message in my byte order (it's been swabbed). */
722 /* Outgoing messages always in my byte order. */
723 LASSERT(body != NULL);
725 /* Only if the import is replayable, we set replay_open data */
726 if (och && imp->imp_replayable) {
727 mod = obd_mod_alloc();
729 DEBUG_REQ(D_ERROR, open_req,
730 "Can't allocate md_open_data");
735 * Take a reference on \var mod, to be freed on mdc_close().
736 * It protects \var mod from being freed on eviction (commit
737 * callback is called despite rq_replay flag).
738 * Another reference for \var och.
743 cfs_spin_lock(&open_req->rq_lock);
746 mod->mod_open_req = open_req;
747 open_req->rq_cb_data = mod;
748 open_req->rq_commit_cb = mdc_commit_open;
749 cfs_spin_unlock(&open_req->rq_lock);
752 rec->cr_fid2 = body->fid1;
753 rec->cr_ioepoch = body->ioepoch;
754 rec->cr_old_handle.cookie = body->handle.cookie;
755 open_req->rq_replay_cb = mdc_replay_open;
756 if (!fid_is_sane(&body->fid1)) {
757 DEBUG_REQ(D_ERROR, open_req, "Saving replay request with "
762 DEBUG_REQ(D_RPCTRACE, open_req, "Set up open replay data");
766 int mdc_clear_open_replay_data(struct obd_export *exp,
767 struct obd_client_handle *och)
769 struct md_open_data *mod = och->och_mod;
773 * It is possible to not have \var mod in a case of eviction between
774 * lookup and ll_file_open().
779 LASSERT(mod != LP_POISON);
788 /* Prepares the request for the replay by the given reply */
789 static void mdc_close_handle_reply(struct ptlrpc_request *req,
790 struct md_op_data *op_data, int rc) {
791 struct mdt_body *repbody;
792 struct mdt_ioepoch *epoch;
794 if (req && rc == -EAGAIN) {
795 repbody = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
796 epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH);
798 epoch->flags |= MF_SOM_AU;
799 if (repbody->valid & OBD_MD_FLGETATTRLOCK)
800 op_data->op_flags |= MF_GETATTR_LOCK;
804 int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
805 struct md_open_data *mod, struct ptlrpc_request **request)
807 struct obd_device *obd = class_exp2obd(exp);
808 struct ptlrpc_request *req;
813 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_CLOSE);
817 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
819 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE);
821 ptlrpc_request_free(req);
825 /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a
826 * portal whose threads are not taking any DLM locks and are therefore
827 * always progressing */
828 req->rq_request_portal = MDS_READPAGE_PORTAL;
829 ptlrpc_at_set_req_timeout(req);
831 /* Ensure that this close's handle is fixed up during replay. */
832 if (likely(mod != NULL)) {
833 LASSERTF(mod->mod_open_req != NULL &&
834 mod->mod_open_req->rq_type != LI_POISON,
835 "POISONED open %p!\n", mod->mod_open_req);
837 mod->mod_close_req = req;
839 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
840 /* We no longer want to preserve this open for replay even
841 * though the open was committed. b=3632, b=3633 */
842 cfs_spin_lock(&mod->mod_open_req->rq_lock);
843 mod->mod_open_req->rq_replay = 0;
844 cfs_spin_unlock(&mod->mod_open_req->rq_lock);
846 CDEBUG(D_HA, "couldn't find open req; expecting close error\n");
849 mdc_close_pack(req, op_data);
851 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
852 obd->u.cli.cl_max_mds_easize);
853 req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
854 obd->u.cli.cl_max_mds_cookiesize);
856 ptlrpc_request_set_replen(req);
858 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
859 rc = ptlrpc_queue_wait(req);
860 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
862 if (req->rq_repmsg == NULL) {
863 CDEBUG(D_RPCTRACE, "request failed to send: %p, %d\n", req,
866 rc = req->rq_status ?: -EIO;
867 } else if (rc == 0 || rc == -EAGAIN) {
868 struct mdt_body *body;
870 rc = lustre_msg_get_status(req->rq_repmsg);
871 if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
872 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err "
877 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
880 } else if (rc == -ESTALE) {
882 * it can be allowed error after 3633 if open was committed and
883 * server failed before close was sent. Let's check if mod
884 * exists and return no error in that case
887 DEBUG_REQ(D_HA, req, "Reset ESTALE = %d", rc);
888 LASSERT(mod->mod_open_req != NULL);
889 if (mod->mod_open_req->rq_committed)
896 mod->mod_close_req = NULL;
897 /* Since now, mod is accessed through open_req only,
898 * thus close req does not keep a reference on mod anymore. */
902 mdc_close_handle_reply(req, op_data, rc);
906 int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data,
907 struct md_open_data *mod)
909 struct obd_device *obd = class_exp2obd(exp);
910 struct ptlrpc_request *req;
914 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
915 &RQF_MDS_DONE_WRITING);
919 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
920 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING);
922 ptlrpc_request_free(req);
927 LASSERTF(mod->mod_open_req != NULL &&
928 mod->mod_open_req->rq_type != LI_POISON,
929 "POISONED setattr %p!\n", mod->mod_open_req);
931 mod->mod_close_req = req;
932 DEBUG_REQ(D_HA, mod->mod_open_req, "matched setattr");
933 /* We no longer want to preserve this setattr for replay even
934 * though the open was committed. b=3632, b=3633 */
935 cfs_spin_lock(&mod->mod_open_req->rq_lock);
936 mod->mod_open_req->rq_replay = 0;
937 cfs_spin_unlock(&mod->mod_open_req->rq_lock);
940 mdc_close_pack(req, op_data);
941 ptlrpc_request_set_replen(req);
943 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
944 rc = ptlrpc_queue_wait(req);
945 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
949 * it can be allowed error after 3633 if open or setattr were
950 * committed and server failed before close was sent.
951 * Let's check if mod exists and return no error in that case
954 LASSERT(mod->mod_open_req != NULL);
955 if (mod->mod_open_req->rq_committed)
962 mod->mod_close_req = NULL;
963 /* Since now, mod is accessed through setattr req only,
964 * thus DW req does not keep a reference on mod anymore. */
968 mdc_close_handle_reply(req, op_data, rc);
969 ptlrpc_req_finished(req);
973 #ifdef HAVE_SPLIT_SUPPORT
974 int mdc_sendpage(struct obd_export *exp, const struct lu_fid *fid,
975 const struct page *page, int offset)
977 struct ptlrpc_request *req;
978 struct ptlrpc_bulk_desc *desc;
982 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_WRITEPAGE);
986 /* FIXME: capa doesn't support split yet */
987 mdc_set_capa_size(req, &RMF_CAPA1, NULL);
989 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_WRITEPAGE);
991 ptlrpc_request_free(req);
995 req->rq_request_portal = MDS_READPAGE_PORTAL;
996 ptlrpc_at_set_req_timeout(req);
998 desc = ptlrpc_prep_bulk_imp(req, 1, BULK_GET_SOURCE, MDS_BULK_PORTAL);
1000 GOTO(out, rc = -ENOMEM);
1002 /* NB req now owns desc and will free it when it gets freed. */
1003 ptlrpc_prep_bulk_page(desc, (struct page *)page, 0, offset);
1004 mdc_readdir_pack(req, 0, offset, fid, NULL);
1006 ptlrpc_request_set_replen(req);
1007 rc = ptlrpc_queue_wait(req);
1011 rc = sptlrpc_cli_unwrap_bulk_write(req, req->rq_bulk);
1013 ptlrpc_req_finished(req);
1016 EXPORT_SYMBOL(mdc_sendpage);
1019 int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data,
1020 struct page **pages, struct ptlrpc_request **request)
1022 struct ptlrpc_request *req;
1023 struct ptlrpc_bulk_desc *desc;
1027 struct l_wait_info lwi;
1032 cfs_waitq_init(&waitq);
1035 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE);
1039 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
1041 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE);
1043 ptlrpc_request_free(req);
1047 req->rq_request_portal = MDS_READPAGE_PORTAL;
1048 ptlrpc_at_set_req_timeout(req);
1050 desc = ptlrpc_prep_bulk_imp(req, op_data->op_npages, BULK_PUT_SINK,
1053 ptlrpc_request_free(req);
1057 /* NB req now owns desc and will free it when it gets freed */
1058 for (i = 0; i < op_data->op_npages; i++)
1059 ptlrpc_prep_bulk_page(desc, pages[i], 0, CFS_PAGE_SIZE);
1061 mdc_readdir_pack(req, op_data->op_offset,
1062 CFS_PAGE_SIZE * op_data->op_npages,
1063 &op_data->op_fid1, op_data->op_capa1);
1065 ptlrpc_request_set_replen(req);
1066 rc = ptlrpc_queue_wait(req);
1068 ptlrpc_req_finished(req);
1069 if (rc != -ETIMEDOUT)
1073 if (!client_should_resend(resends, &exp->exp_obd->u.cli)) {
1074 CERROR("too many resend retries, returning error\n");
1077 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL, NULL);
1078 l_wait_event(waitq, 0, &lwi);
1083 rc = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk,
1084 req->rq_bulk->bd_nob_transferred);
1086 ptlrpc_req_finished(req);
1090 if (req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK) {
1091 CERROR("Unexpected # bytes transferred: %d (%ld expected)\n",
1092 req->rq_bulk->bd_nob_transferred,
1093 CFS_PAGE_SIZE * op_data->op_npages);
1094 ptlrpc_req_finished(req);
1102 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1103 __u64 max_age, __u32 flags)
1105 struct ptlrpc_request *req;
1106 struct obd_statfs *msfs;
1107 struct obd_import *imp = NULL;
1112 * Since the request might also come from lprocfs, so we need
1113 * sync this with client_disconnect_export Bug15684
1115 cfs_down_read(&obd->u.cli.cl_sem);
1116 if (obd->u.cli.cl_import)
1117 imp = class_import_get(obd->u.cli.cl_import);
1118 cfs_up_read(&obd->u.cli.cl_sem);
1122 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS,
1123 LUSTRE_MDS_VERSION, MDS_STATFS);
1125 GOTO(output, rc = -ENOMEM);
1127 ptlrpc_request_set_replen(req);
1129 if (flags & OBD_STATFS_NODELAY) {
1130 /* procfs requests not want stay in wait for avoid deadlock */
1131 req->rq_no_resend = 1;
1132 req->rq_no_delay = 1;
1135 rc = ptlrpc_queue_wait(req);
1137 /* check connection error first */
1138 if (imp->imp_connect_error)
1139 rc = imp->imp_connect_error;
1143 msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
1145 GOTO(out, rc = -EPROTO);
1150 ptlrpc_req_finished(req);
1152 class_import_put(imp);
1156 static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
1158 __u32 keylen, vallen;
1162 if (gf->gf_pathlen > PATH_MAX)
1163 RETURN(-ENAMETOOLONG);
1164 if (gf->gf_pathlen < 2)
1167 /* Key is KEY_FID2PATH + getinfo_fid2path description */
1168 keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
1169 OBD_ALLOC(key, keylen);
1172 memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
1173 memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf));
1175 CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n",
1176 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno);
1178 if (!fid_is_sane(&gf->gf_fid))
1179 GOTO(out, rc = -EINVAL);
1181 /* Val is struct getinfo_fid2path result plus path */
1182 vallen = sizeof(*gf) + gf->gf_pathlen;
1184 rc = obd_get_info(exp, keylen, key, &vallen, gf, NULL);
1188 if (vallen <= sizeof(*gf))
1189 GOTO(out, rc = -EPROTO);
1190 else if (vallen > sizeof(*gf) + gf->gf_pathlen)
1191 GOTO(out, rc = -EOVERFLOW);
1193 CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n%s\n",
1194 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
1197 OBD_FREE(key, keylen);
1201 static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
1203 struct kuc_hdr *lh = (struct kuc_hdr *)buf;
1205 LASSERT(len <= CR_MAXSIZE);
1207 lh->kuc_magic = KUC_MAGIC;
1208 lh->kuc_transport = KUC_TRANSPORT_CHANGELOG;
1209 lh->kuc_flags = flags;
1210 lh->kuc_msgtype = CL_RECORD;
1211 lh->kuc_msglen = len;
1215 #define D_CHANGELOG 0
1217 struct changelog_show {
1222 struct obd_device *cs_obd;
1225 static int changelog_show_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr,
1228 struct changelog_show *cs = data;
1229 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
1234 if ((rec->cr_hdr.lrh_type != CHANGELOG_REC) ||
1235 (rec->cr.cr_type >= CL_LAST)) {
1236 CERROR("Not a changelog rec %d/%d\n", rec->cr_hdr.lrh_type,
1241 if (rec->cr.cr_index < cs->cs_startrec) {
1242 /* Skip entries earlier than what we are interested in */
1243 CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n",
1244 rec->cr.cr_index, cs->cs_startrec);
1248 CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID
1249 " %.*s\n", rec->cr.cr_index, rec->cr.cr_type,
1250 changelog_type2str(rec->cr.cr_type), rec->cr.cr_time,
1251 rec->cr.cr_flags & CLF_FLAGMASK,
1252 PFID(&rec->cr.cr_tfid), PFID(&rec->cr.cr_pfid),
1253 rec->cr.cr_namelen, rec->cr.cr_name);
1255 len = sizeof(*lh) + sizeof(rec->cr) + rec->cr.cr_namelen;
1257 /* Set up the message */
1258 lh = changelog_kuc_hdr(cs->cs_buf, len, cs->cs_flags);
1259 memcpy(lh + 1, &rec->cr, len - sizeof(*lh));
1261 rc = libcfs_kkuc_msg_put(cs->cs_fp, lh);
1262 CDEBUG(D_CHANGELOG, "kucmsg fp %p len %d rc %d\n", cs->cs_fp, len,rc);
1267 static int mdc_changelog_send_thread(void *csdata)
1269 struct changelog_show *cs = csdata;
1270 struct llog_ctxt *ctxt = NULL;
1271 struct llog_handle *llh = NULL;
1272 struct kuc_hdr *kuch;
1275 CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n",
1276 cs->cs_fp, cs->cs_startrec);
1279 * It's important to daemonize here to close unused FDs.
1280 * The write fd from pipe is already opened by the caller,
1281 * so it's fine to clear all files here
1283 cfs_daemonize("mdc_clg_send_thread");
1285 OBD_ALLOC(cs->cs_buf, CR_MAXSIZE);
1286 if (cs->cs_buf == NULL)
1287 GOTO(out, rc = -ENOMEM);
1289 /* Set up the remote catalog handle */
1290 ctxt = llog_get_context(cs->cs_obd, LLOG_CHANGELOG_REPL_CTXT);
1292 GOTO(out, rc = -ENOENT);
1293 rc = llog_create(ctxt, &llh, NULL, CHANGELOG_CATALOG);
1295 CERROR("llog_create() failed %d\n", rc);
1298 rc = llog_init_handle(llh, LLOG_F_IS_CAT, NULL);
1300 CERROR("llog_init_handle failed %d\n", rc);
1304 rc = llog_cat_process_flags(llh, changelog_show_cb, cs, 0, 0, 0);
1306 /* Send EOF no matter what our result */
1307 if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
1309 kuch->kuc_msgtype = CL_EOF;
1310 libcfs_kkuc_msg_put(cs->cs_fp, kuch);
1314 cfs_put_file(cs->cs_fp);
1318 llog_ctxt_put(ctxt);
1320 OBD_FREE(cs->cs_buf, CR_MAXSIZE);
1322 /* detach from parent process so we get cleaned up */
1323 cfs_daemonize("cl_send");
1327 static int mdc_ioc_changelog_send(struct obd_device *obd,
1328 struct ioc_changelog *icc)
1330 struct changelog_show *cs;
1333 /* Freed in mdc_changelog_send_thread */
1339 cs->cs_startrec = icc->icc_recno;
1340 /* matching cfs_put_file in mdc_changelog_send_thread */
1341 cs->cs_fp = cfs_get_fd(icc->icc_id);
1342 cs->cs_flags = icc->icc_flags;
1344 /* New thread because we should return to user app before
1345 writing into our pipe */
1346 rc = cfs_create_thread(mdc_changelog_send_thread, cs, CFS_DAEMON_FLAGS);
1348 CDEBUG(D_CHANGELOG, "start changelog thread: %d\n", rc);
1352 CERROR("Failed to start changelog thread: %d\n", rc);
1357 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1358 struct lustre_kernelcomm *lk);
1360 static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp,
1361 struct obd_quotactl *oqctl)
1363 struct client_obd *cli = &exp->exp_obd->u.cli;
1364 struct ptlrpc_request *req;
1365 struct obd_quotactl *body;
1369 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
1370 &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION,
1375 body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1378 ptlrpc_request_set_replen(req);
1380 /* the next poll will find -ENODATA, that means quotacheck is
1382 cli->cl_qchk_stat = -ENODATA;
1383 rc = ptlrpc_queue_wait(req);
1385 cli->cl_qchk_stat = rc;
1386 ptlrpc_req_finished(req);
1390 static int mdc_quota_poll_check(struct obd_export *exp,
1391 struct if_quotacheck *qchk)
1393 struct client_obd *cli = &exp->exp_obd->u.cli;
1397 qchk->obd_uuid = cli->cl_target_uuid;
1398 memcpy(qchk->obd_type, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME));
1400 rc = cli->cl_qchk_stat;
1401 /* the client is not the previous one */
1402 if (rc == CL_NOT_QUOTACHECKED)
1407 static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp,
1408 struct obd_quotactl *oqctl)
1410 struct ptlrpc_request *req;
1411 struct obd_quotactl *oqc;
1415 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
1416 &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION,
1421 oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1424 ptlrpc_request_set_replen(req);
1425 ptlrpc_at_set_req_timeout(req);
1426 req->rq_no_resend = 1;
1428 rc = ptlrpc_queue_wait(req);
1430 CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc);
1432 if (req->rq_repmsg &&
1433 (oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL))) {
1436 CERROR ("Can't unpack obd_quotactl\n");
1439 ptlrpc_req_finished(req);
1444 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
1445 void *karg, void *uarg)
1447 struct obd_device *obd = exp->exp_obd;
1448 struct obd_ioctl_data *data = karg;
1449 struct obd_import *imp = obd->u.cli.cl_import;
1450 struct llog_ctxt *ctxt;
1454 if (!cfs_try_module_get(THIS_MODULE)) {
1455 CERROR("Can't get module. Is it alive?");
1459 case LL_IOC_HSM_CT_START:
1460 rc = mdc_ioc_hsm_ct_start(exp, karg);
1462 case OBD_IOC_CHANGELOG_SEND:
1463 rc = mdc_ioc_changelog_send(obd, karg);
1465 case OBD_IOC_CHANGELOG_CLEAR: {
1466 struct ioc_changelog *icc = karg;
1467 struct changelog_setinfo cs =
1468 {.cs_recno = icc->icc_recno, .cs_id = icc->icc_id};
1469 rc = obd_set_info_async(exp, strlen(KEY_CHANGELOG_CLEAR),
1470 KEY_CHANGELOG_CLEAR, sizeof(cs), &cs,
1474 case OBD_IOC_FID2PATH: {
1475 rc = mdc_ioc_fid2path(exp, karg);
1478 case OBD_IOC_CLIENT_RECOVER:
1479 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1, 0);
1483 case IOC_OSC_SET_ACTIVE:
1484 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
1486 case OBD_IOC_PARSE: {
1487 ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
1488 rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL);
1489 llog_ctxt_put(ctxt);
1493 case OBD_IOC_LLOG_INFO:
1494 case OBD_IOC_LLOG_PRINT: {
1495 ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
1496 rc = llog_ioctl(ctxt, cmd, data);
1497 llog_ctxt_put(ctxt);
1501 case OBD_IOC_POLL_QUOTACHECK:
1502 rc = mdc_quota_poll_check(exp, (struct if_quotacheck *)karg);
1504 case OBD_IOC_PING_TARGET:
1505 rc = ptlrpc_obd_ping(obd);
1508 * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by
1509 * LMV instead of MDC. But when the cluster is upgraded from 1.8,
1510 * there'd be no LMV layer thus we might be called here. Eventually
1511 * this code should be removed.
1514 case IOC_OBD_STATFS: {
1515 struct obd_statfs stat_buf = {0};
1517 if (*((__u32 *) data->ioc_inlbuf2) != 0)
1518 GOTO(out, rc = -ENODEV);
1521 if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd),
1522 min((int) data->ioc_plen2,
1523 (int) sizeof(struct obd_uuid))))
1524 GOTO(out, rc = -EFAULT);
1526 rc = mdc_statfs(obd, &stat_buf,
1527 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
1532 if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf,
1533 min((int) data->ioc_plen1,
1534 (int) sizeof(stat_buf))))
1535 GOTO(out, rc = -EFAULT);
1539 case OBD_IOC_QUOTACTL: {
1540 struct if_quotactl *qctl = karg;
1541 struct obd_quotactl *oqctl;
1543 OBD_ALLOC_PTR(oqctl);
1547 QCTL_COPY(oqctl, qctl);
1548 rc = obd_quotactl(exp, oqctl);
1550 QCTL_COPY(qctl, oqctl);
1551 qctl->qc_valid = QC_MDTIDX;
1552 qctl->obd_uuid = obd->u.cli.cl_target_uuid;
1554 OBD_FREE_PTR(oqctl);
1557 case LL_IOC_GET_CONNECT_FLAGS: {
1558 if (cfs_copy_to_user(uarg, &exp->exp_connect_flags,
1560 GOTO(out, rc = -EFAULT);
1565 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
1566 GOTO(out, rc = -ENOTTY);
1569 cfs_module_put(THIS_MODULE);
1574 int mdc_get_info_rpc(struct obd_export *exp,
1575 obd_count keylen, void *key,
1576 int vallen, void *val)
1578 struct obd_import *imp = class_exp2cliimp(exp);
1579 struct ptlrpc_request *req;
1584 req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO);
1588 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY,
1589 RCL_CLIENT, keylen);
1590 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VALLEN,
1591 RCL_CLIENT, sizeof(__u32));
1593 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_INFO);
1595 ptlrpc_request_free(req);
1599 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY);
1600 memcpy(tmp, key, keylen);
1601 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_VALLEN);
1602 memcpy(tmp, &vallen, sizeof(__u32));
1604 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VAL,
1605 RCL_SERVER, vallen);
1606 ptlrpc_request_set_replen(req);
1608 rc = ptlrpc_queue_wait(req);
1610 tmp = req_capsule_server_get(&req->rq_pill, &RMF_GETINFO_VAL);
1611 memcpy(val, tmp, vallen);
1612 if (ptlrpc_rep_need_swab(req)) {
1613 if (KEY_IS(KEY_FID2PATH)) {
1614 lustre_swab_fid2path(val);
1618 ptlrpc_req_finished(req);
1623 static void lustre_swab_hai(struct hsm_action_item *h)
1625 __swab32s(&h->hai_len);
1626 __swab32s(&h->hai_action);
1627 lustre_swab_lu_fid(&h->hai_fid);
1628 __swab64s(&h->hai_cookie);
1629 __swab64s(&h->hai_extent.offset);
1630 __swab64s(&h->hai_extent.length);
1631 __swab64s(&h->hai_gid);
1634 static void lustre_swab_hal(struct hsm_action_list *h)
1636 struct hsm_action_item *hai;
1639 __swab32s(&h->hal_version);
1640 __swab32s(&h->hal_count);
1641 __swab32s(&h->hal_archive_num);
1643 for (i = 0; i < h->hal_count; i++) {
1644 lustre_swab_hai(hai);
1645 hai = hai_next(hai);
1649 static void lustre_swab_kuch(struct kuc_hdr *l)
1651 __swab16s(&l->kuc_magic);
1652 /* __u8 l->kuc_transport */
1653 __swab16s(&l->kuc_msgtype);
1654 __swab16s(&l->kuc_msglen);
1657 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1658 struct lustre_kernelcomm *lk)
1662 if (lk->lk_group != KUC_GRP_HSM) {
1663 CERROR("Bad copytool group %d\n", lk->lk_group);
1667 CDEBUG(D_HSM, "CT start r%d w%d u%d g%d f%#x\n", lk->lk_rfd, lk->lk_wfd,
1668 lk->lk_uid, lk->lk_group, lk->lk_flags);
1670 if (lk->lk_flags & LK_FLG_STOP)
1671 rc = libcfs_kkuc_group_rem(lk->lk_uid,lk->lk_group);
1673 cfs_file_t *fp = cfs_get_fd(lk->lk_wfd);
1674 rc = libcfs_kkuc_group_add(fp, lk->lk_uid,lk->lk_group,
1680 /* lk_data is archive number mask */
1681 /* TODO: register archive num with mdt so coordinator can choose
1688 * Send a message to any listening copytools
1689 * @param val KUC message (kuc_hdr + hsm_action_list)
1690 * @param len total length of message
1692 static int mdc_hsm_copytool_send(int len, void *val)
1694 struct kuc_hdr *lh = (struct kuc_hdr *)val;
1695 struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1);
1699 if (len < sizeof(*lh) + sizeof(*hal)) {
1700 CERROR("Short HSM message %d < %d\n", len,
1701 (int) (sizeof(*lh) + sizeof(*hal)));
1704 if (lh->kuc_magic == __swab16(KUC_MAGIC)) {
1705 lustre_swab_kuch(lh);
1706 lustre_swab_hal(hal);
1707 } else if (lh->kuc_magic != KUC_MAGIC) {
1708 CERROR("Bad magic %x!=%x\n", lh->kuc_magic, KUC_MAGIC);
1712 CDEBUG(D_HSM, " Received message mg=%x t=%d m=%d l=%d actions=%d\n",
1713 lh->kuc_magic, lh->kuc_transport, lh->kuc_msgtype,
1714 lh->kuc_msglen, hal->hal_count);
1716 /* Broadcast to HSM listeners */
1717 rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
1722 int mdc_set_info_async(struct obd_export *exp,
1723 obd_count keylen, void *key,
1724 obd_count vallen, void *val,
1725 struct ptlrpc_request_set *set)
1727 struct obd_import *imp = class_exp2cliimp(exp);
1731 if (KEY_IS(KEY_READ_ONLY)) {
1732 if (vallen != sizeof(int))
1735 cfs_spin_lock(&imp->imp_lock);
1736 if (*((int *)val)) {
1737 imp->imp_connect_flags_orig |= OBD_CONNECT_RDONLY;
1738 imp->imp_connect_data.ocd_connect_flags |= OBD_CONNECT_RDONLY;
1740 imp->imp_connect_flags_orig &= ~OBD_CONNECT_RDONLY;
1741 imp->imp_connect_data.ocd_connect_flags &= ~OBD_CONNECT_RDONLY;
1743 cfs_spin_unlock(&imp->imp_lock);
1745 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
1746 keylen, key, vallen, val, set);
1749 if (KEY_IS(KEY_SPTLRPC_CONF)) {
1750 sptlrpc_conf_client_adapt(exp->exp_obd);
1753 if (KEY_IS(KEY_FLUSH_CTX)) {
1754 sptlrpc_import_flush_my_ctx(imp);
1757 if (KEY_IS(KEY_MDS_CONN)) {
1758 /* mds-mds import */
1759 cfs_spin_lock(&imp->imp_lock);
1760 imp->imp_server_timeout = 1;
1761 cfs_spin_unlock(&imp->imp_lock);
1762 imp->imp_client->cli_request_portal = MDS_MDS_PORTAL;
1763 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
1766 if (KEY_IS(KEY_CHANGELOG_CLEAR)) {
1767 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
1768 keylen, key, vallen, val, set);
1771 if (KEY_IS(KEY_HSM_COPYTOOL_SEND)) {
1772 rc = mdc_hsm_copytool_send(vallen, val);
1779 int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key,
1780 __u32 *vallen, void *val, struct lov_stripe_md *lsm)
1784 if (KEY_IS(KEY_MAX_EASIZE)) {
1785 int mdsize, *max_easize;
1787 if (*vallen != sizeof(int))
1789 mdsize = *(int*)val;
1790 if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize)
1791 exp->exp_obd->u.cli.cl_max_mds_easize = mdsize;
1793 *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
1795 } else if (KEY_IS(KEY_CONN_DATA)) {
1796 struct obd_import *imp = class_exp2cliimp(exp);
1797 struct obd_connect_data *data = val;
1799 if (*vallen != sizeof(*data))
1802 *data = imp->imp_connect_data;
1804 } else if (KEY_IS(KEY_TGT_COUNT)) {
1809 rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val);
1814 static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid,
1815 struct obd_capa *oc, struct obd_client_handle *handle,
1818 struct ptlrpc_request *req;
1819 struct mdt_body *body;
1823 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_PIN);
1827 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1829 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_PIN);
1831 ptlrpc_request_free(req);
1835 mdc_pack_body(req, fid, oc, 0, 0, -1, flags);
1837 ptlrpc_request_set_replen(req);
1839 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1840 rc = ptlrpc_queue_wait(req);
1841 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1843 CERROR("Pin failed: %d\n", rc);
1847 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1849 GOTO(err_out, rc = -EPROTO);
1851 handle->och_fh = body->handle;
1852 handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
1854 handle->och_mod = obd_mod_alloc();
1855 if (handle->och_mod == NULL) {
1856 DEBUG_REQ(D_ERROR, req, "can't allocate md_open_data");
1857 GOTO(err_out, rc = -ENOMEM);
1859 handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
1864 ptlrpc_req_finished(req);
1868 static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle,
1871 struct ptlrpc_request *req;
1872 struct mdt_body *body;
1876 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_UNPIN,
1877 LUSTRE_MDS_VERSION, MDS_UNPIN);
1881 body = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY);
1882 body->handle = handle->och_fh;
1885 ptlrpc_request_set_replen(req);
1887 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1888 rc = ptlrpc_queue_wait(req);
1889 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1892 CERROR("Unpin failed: %d\n", rc);
1894 ptlrpc_req_finished(req);
1895 ptlrpc_req_finished(handle->och_mod->mod_open_req);
1897 obd_mod_put(handle->och_mod);
1901 int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
1902 struct obd_capa *oc, struct ptlrpc_request **request)
1904 struct ptlrpc_request *req;
1909 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC);
1913 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1915 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC);
1917 ptlrpc_request_free(req);
1921 mdc_pack_body(req, fid, oc, 0, 0, -1, 0);
1923 ptlrpc_request_set_replen(req);
1925 rc = ptlrpc_queue_wait(req);
1927 ptlrpc_req_finished(req);
1933 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
1934 enum obd_import_event event)
1938 LASSERT(imp->imp_obd == obd);
1941 case IMP_EVENT_DISCON: {
1943 /* XXX Pass event up to OBDs stack. used only for FLD now */
1944 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_DISCON, NULL);
1948 case IMP_EVENT_INACTIVE: {
1949 struct client_obd *cli = &obd->u.cli;
1951 * Flush current sequence to make client obtain new one
1952 * from server in case of disconnect/reconnect.
1954 if (cli->cl_seq != NULL)
1955 seq_client_flush(cli->cl_seq);
1957 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE, NULL);
1960 case IMP_EVENT_INVALIDATE: {
1961 struct ldlm_namespace *ns = obd->obd_namespace;
1963 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
1967 case IMP_EVENT_ACTIVE: {
1968 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL);
1972 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
1974 case IMP_EVENT_DEACTIVATE:
1975 case IMP_EVENT_ACTIVATE:
1978 CERROR("Unknown import event %x\n", event);
1984 static int mdc_fid_init(struct obd_export *exp)
1986 struct client_obd *cli = &exp->exp_obd->u.cli;
1991 OBD_ALLOC_PTR(cli->cl_seq);
1992 if (cli->cl_seq == NULL)
1995 OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
1997 GOTO(out_free_seq, rc = -ENOMEM);
1999 snprintf(prefix, MAX_OBD_NAME + 5, "srv-%s",
2000 exp->exp_obd->obd_name);
2002 /* Init client side sequence-manager */
2003 rc = seq_client_init(cli->cl_seq, exp,
2004 LUSTRE_SEQ_METADATA,
2006 OBD_FREE(prefix, MAX_OBD_NAME + 5);
2008 GOTO(out_free_seq, rc);
2012 OBD_FREE_PTR(cli->cl_seq);
2017 static int mdc_fid_fini(struct obd_export *exp)
2019 struct client_obd *cli = &exp->exp_obd->u.cli;
2022 if (cli->cl_seq != NULL) {
2023 seq_client_fini(cli->cl_seq);
2024 OBD_FREE_PTR(cli->cl_seq);
2031 int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
2032 struct md_op_data *op_data)
2034 struct client_obd *cli = &exp->exp_obd->u.cli;
2035 struct lu_client_seq *seq = cli->cl_seq;
2037 RETURN(seq_client_alloc_fid(NULL, seq, fid));
2040 /* XXX This method is used only to clear current fid seq
2041 * once fld/mds insert failed */
2042 static int mdc_fid_delete(struct obd_export *exp, const struct lu_fid *fid)
2044 struct client_obd *cli = &exp->exp_obd->u.cli;
2046 seq_client_flush(cli->cl_seq);
2050 struct obd_uuid *mdc_get_uuid(struct obd_export *exp) {
2051 struct client_obd *cli = &exp->exp_obd->u.cli;
2052 return &cli->cl_target_uuid;
2056 * Determine whether the lock can be canceled before replaying it during
2057 * recovery, non zero value will be return if the lock can be canceled,
2058 * or zero returned for not
2060 static int mdc_cancel_for_recovery(struct ldlm_lock *lock)
2062 if (lock->l_resource->lr_type != LDLM_IBITS)
2065 /* FIXME: if we ever get into a situation where there are too many
2066 * opened files with open locks on a single node, then we really
2067 * should replay these open locks to reget it */
2068 if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN)
2074 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
2076 struct client_obd *cli = &obd->u.cli;
2077 struct lprocfs_static_vars lvars = { 0 };
2081 OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2082 if (!cli->cl_rpc_lock)
2084 mdc_init_rpc_lock(cli->cl_rpc_lock);
2088 OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2089 if (!cli->cl_close_lock)
2090 GOTO(err_rpc_lock, rc = -ENOMEM);
2091 mdc_init_rpc_lock(cli->cl_close_lock);
2093 rc = client_obd_setup(obd, cfg);
2095 GOTO(err_close_lock, rc);
2096 lprocfs_mdc_init_vars(&lvars);
2097 lprocfs_obd_setup(obd, lvars.obd_vars);
2098 sptlrpc_lprocfs_cliobd_attach(obd);
2099 ptlrpc_lprocfs_register_obd(obd);
2101 ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
2103 rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
2106 CERROR("failed to setup llogging subsystems\n");
2112 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2114 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2119 /* Initialize the default and maximum LOV EA and cookie sizes. This allows
2120 * us to make MDS RPCs with large enough reply buffers to hold the
2121 * maximum-sized (= maximum striped) EA and cookie without having to
2122 * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */
2123 static int mdc_init_ea_size(struct obd_export *exp, int easize,
2124 int def_easize, int cookiesize)
2126 struct obd_device *obd = exp->exp_obd;
2127 struct client_obd *cli = &obd->u.cli;
2130 if (cli->cl_max_mds_easize < easize)
2131 cli->cl_max_mds_easize = easize;
2133 if (cli->cl_default_mds_easize < def_easize)
2134 cli->cl_default_mds_easize = def_easize;
2136 if (cli->cl_max_mds_cookiesize < cookiesize)
2137 cli->cl_max_mds_cookiesize = cookiesize;
2142 static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2148 case OBD_CLEANUP_EARLY:
2150 case OBD_CLEANUP_EXPORTS:
2151 /* Failsafe, ok if racy */
2152 if (obd->obd_type->typ_refcnt <= 1)
2153 libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
2155 obd_cleanup_client_import(obd);
2156 ptlrpc_lprocfs_unregister_obd(obd);
2157 lprocfs_obd_cleanup(obd);
2159 rc = obd_llog_finish(obd, 0);
2161 CERROR("failed to cleanup llogging subsystems\n");
2167 static int mdc_cleanup(struct obd_device *obd)
2169 struct client_obd *cli = &obd->u.cli;
2171 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2172 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2176 return client_obd_cleanup(obd);
2180 static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
2181 struct obd_device *tgt, int *index)
2183 struct llog_ctxt *ctxt;
2187 LASSERT(olg == &obd->obd_olg);
2189 rc = llog_setup(obd, olg, LLOG_LOVEA_REPL_CTXT, tgt, 0, NULL,
2194 ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);
2195 llog_initiator_connect(ctxt);
2196 llog_ctxt_put(ctxt);
2198 rc = llog_setup(obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, 0, NULL,
2201 ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT);
2202 llog_initiator_connect(ctxt);
2203 llog_ctxt_put(ctxt);
2209 static int mdc_llog_finish(struct obd_device *obd, int count)
2211 struct llog_ctxt *ctxt;
2215 ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);
2217 rc = llog_cleanup(ctxt);
2219 ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT);
2221 rc = llog_cleanup(ctxt);
2226 static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
2228 struct lustre_cfg *lcfg = buf;
2229 struct lprocfs_static_vars lvars = { 0 };
2232 lprocfs_mdc_init_vars(&lvars);
2233 switch (lcfg->lcfg_command) {
2235 rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars,
2245 /* get remote permission for current user on fid */
2246 int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
2247 struct obd_capa *oc, __u32 suppgid,
2248 struct ptlrpc_request **request)
2250 struct ptlrpc_request *req;
2254 LASSERT(client_is_remote(exp));
2257 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
2261 mdc_set_capa_size(req, &RMF_CAPA1, oc);
2263 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
2265 ptlrpc_request_free(req);
2269 mdc_pack_body(req, fid, oc, OBD_MD_FLRMTPERM, 0, suppgid, 0);
2271 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
2272 sizeof(struct mdt_remote_perm));
2274 ptlrpc_request_set_replen(req);
2276 rc = ptlrpc_queue_wait(req);
2278 ptlrpc_req_finished(req);
2284 static int mdc_interpret_renew_capa(const struct lu_env *env,
2285 struct ptlrpc_request *req, void *args,
2288 struct mdc_renew_capa_args *ra = args;
2289 struct mdt_body *body = NULL;
2290 struct lustre_capa *capa;
2294 GOTO(out, capa = ERR_PTR(status));
2296 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
2298 GOTO(out, capa = ERR_PTR(-EFAULT));
2300 if ((body->valid & OBD_MD_FLOSSCAPA) == 0)
2301 GOTO(out, capa = ERR_PTR(-ENOENT));
2303 capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA2);
2305 GOTO(out, capa = ERR_PTR(-EFAULT));
2308 ra->ra_cb(ra->ra_oc, capa);
2312 static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2315 struct ptlrpc_request *req;
2316 struct mdc_renew_capa_args *ra;
2319 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR,
2320 LUSTRE_MDS_VERSION, MDS_GETATTR);
2324 /* NB, OBD_MD_FLOSSCAPA is set here, but it doesn't necessarily mean the
2325 * capa to renew is oss capa.
2327 mdc_pack_body(req, &oc->c_capa.lc_fid, oc, OBD_MD_FLOSSCAPA, 0, -1, 0);
2328 ptlrpc_request_set_replen(req);
2330 CLASSERT(sizeof(*ra) <= sizeof(req->rq_async_args));
2331 ra = ptlrpc_req_async_args(req);
2334 req->rq_interpret_reply = mdc_interpret_renew_capa;
2335 ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
2339 static int mdc_connect(const struct lu_env *env,
2340 struct obd_export **exp,
2341 struct obd_device *obd, struct obd_uuid *cluuid,
2342 struct obd_connect_data *data,
2345 struct obd_import *imp = obd->u.cli.cl_import;
2347 /* mds-mds import features */
2348 if (data && (data->ocd_connect_flags & OBD_CONNECT_MDS_MDS)) {
2349 cfs_spin_lock(&imp->imp_lock);
2350 imp->imp_server_timeout = 1;
2351 cfs_spin_unlock(&imp->imp_lock);
2352 imp->imp_client->cli_request_portal = MDS_MDS_PORTAL;
2353 CDEBUG(D_OTHER, "%s: Set 'mds' portal and timeout\n",
2357 return client_connect_import(env, exp, obd, cluuid, data, NULL);
2360 struct obd_ops mdc_obd_ops = {
2361 .o_owner = THIS_MODULE,
2362 .o_setup = mdc_setup,
2363 .o_precleanup = mdc_precleanup,
2364 .o_cleanup = mdc_cleanup,
2365 .o_add_conn = client_import_add_conn,
2366 .o_del_conn = client_import_del_conn,
2367 .o_connect = mdc_connect,
2368 .o_disconnect = client_disconnect_export,
2369 .o_iocontrol = mdc_iocontrol,
2370 .o_set_info_async = mdc_set_info_async,
2371 .o_statfs = mdc_statfs,
2373 .o_unpin = mdc_unpin,
2374 .o_fid_init = mdc_fid_init,
2375 .o_fid_fini = mdc_fid_fini,
2376 .o_fid_alloc = mdc_fid_alloc,
2377 .o_fid_delete = mdc_fid_delete,
2378 .o_import_event = mdc_import_event,
2379 .o_llog_init = mdc_llog_init,
2380 .o_llog_finish = mdc_llog_finish,
2381 .o_get_info = mdc_get_info,
2382 .o_process_config = mdc_process_config,
2383 .o_get_uuid = mdc_get_uuid,
2384 .o_quotactl = mdc_quotactl,
2385 .o_quotacheck = mdc_quotacheck
2388 struct md_ops mdc_md_ops = {
2389 .m_getstatus = mdc_getstatus,
2390 .m_change_cbdata = mdc_change_cbdata,
2391 .m_find_cbdata = mdc_find_cbdata,
2392 .m_close = mdc_close,
2393 .m_create = mdc_create,
2394 .m_done_writing = mdc_done_writing,
2395 .m_enqueue = mdc_enqueue,
2396 .m_getattr = mdc_getattr,
2397 .m_getattr_name = mdc_getattr_name,
2398 .m_intent_lock = mdc_intent_lock,
2400 .m_is_subdir = mdc_is_subdir,
2401 .m_rename = mdc_rename,
2402 .m_setattr = mdc_setattr,
2403 .m_setxattr = mdc_setxattr,
2404 .m_getxattr = mdc_getxattr,
2406 .m_readpage = mdc_readpage,
2407 .m_unlink = mdc_unlink,
2408 .m_cancel_unused = mdc_cancel_unused,
2409 .m_init_ea_size = mdc_init_ea_size,
2410 .m_set_lock_data = mdc_set_lock_data,
2411 .m_lock_match = mdc_lock_match,
2412 .m_get_lustre_md = mdc_get_lustre_md,
2413 .m_free_lustre_md = mdc_free_lustre_md,
2414 .m_set_open_replay_data = mdc_set_open_replay_data,
2415 .m_clear_open_replay_data = mdc_clear_open_replay_data,
2416 .m_renew_capa = mdc_renew_capa,
2417 .m_unpack_capa = mdc_unpack_capa,
2418 .m_get_remote_perm = mdc_get_remote_perm,
2419 .m_intent_getattr_async = mdc_intent_getattr_async,
2420 .m_revalidate_lock = mdc_revalidate_lock
2423 int __init mdc_init(void)
2426 struct lprocfs_static_vars lvars = { 0 };
2427 lprocfs_mdc_init_vars(&lvars);
2429 rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
2430 LUSTRE_MDC_NAME, NULL);
2435 static void /*__exit*/ mdc_exit(void)
2437 class_unregister_type(LUSTRE_MDC_NAME);
2440 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2441 MODULE_DESCRIPTION("Lustre Metadata Client");
2442 MODULE_LICENSE("GPL");
2444 module_init(mdc_init);
2445 module_exit(mdc_exit);