1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 only,
10 * as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License version 2 for more details (a copy is included
16 * in the LICENSE file that accompanied this code).
18 * You should have received a copy of the GNU General Public License
19 * version 2 along with this program; If not, see
20 * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
29 * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
30 * Use is subject to license terms.
33 * Copyright (c) 2011 Whamcloud, Inc.
36 * This file is part of Lustre, http://www.lustre.org/
37 * Lustre is a trademark of Sun Microsystems, Inc.
41 # define EXPORT_SYMTAB
43 #define DEBUG_SUBSYSTEM S_MDC
46 # include <linux/module.h>
47 # include <linux/pagemap.h>
48 # include <linux/miscdevice.h>
49 # include <linux/init.h>
51 # include <liblustre.h>
54 #include <lustre_acl.h>
55 #include <obd_class.h>
56 #include <lustre_dlm.h>
57 #include <lustre_fid.h>
58 #include <md_object.h>
59 #include <lprocfs_status.h>
60 #include <lustre_param.h>
61 #include "mdc_internal.h"
62 #include <lustre/lustre_idl.h>
64 #define REQUEST_MINOR 244
66 struct mdc_renew_capa_args {
67 struct obd_capa *ra_oc;
68 renew_capa_cb_t ra_cb;
71 static int mdc_cleanup(struct obd_device *obd);
73 int mdc_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
74 const struct req_msg_field *field, struct obd_capa **oc)
76 struct lustre_capa *capa;
80 /* swabbed already in mdc_enqueue */
81 capa = req_capsule_server_get(&req->rq_pill, field);
85 c = alloc_capa(CAPA_SITE_CLIENT);
87 CDEBUG(D_INFO, "alloc capa failed!\n");
96 /* Helper that implements most of mdc_getstatus and signal_completed_replay. */
97 /* XXX this should become mdc_get_info("key"), sending MDS_GET_INFO RPC */
98 static int send_getstatus(struct obd_import *imp, struct lu_fid *rootfid,
99 struct obd_capa **pc, int level, int msg_flags)
101 struct ptlrpc_request *req;
102 struct mdt_body *body;
106 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_GETSTATUS,
107 LUSTRE_MDS_VERSION, MDS_GETSTATUS);
111 mdc_pack_body(req, NULL, NULL, 0, 0, -1, 0);
112 lustre_msg_add_flags(req->rq_reqmsg, msg_flags);
113 req->rq_send_state = level;
115 ptlrpc_request_set_replen(req);
117 rc = ptlrpc_queue_wait(req);
121 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
123 GOTO(out, rc = -EPROTO);
125 if (body->valid & OBD_MD_FLMDSCAPA) {
126 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, pc);
131 *rootfid = body->fid1;
133 "root fid="DFID", last_committed="LPU64"\n",
135 lustre_msg_get_last_committed(req->rq_repmsg));
138 ptlrpc_req_finished(req);
142 /* This should be mdc_get_info("rootfid") */
143 int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid,
144 struct obd_capa **pc)
146 return send_getstatus(class_exp2cliimp(exp), rootfid, pc,
151 * This function now is known to always saying that it will receive 4 buffers
152 * from server. Even for cases when acl_size and md_size is zero, RPC header
153 * will contain 4 fields and RPC itself will contain zero size fields. This is
154 * because mdt_getattr*() _always_ returns 4 fields, but if acl is not needed
155 * and thus zero, it shrinks it, making zero size. The same story about
156 * md_size. And this is course of problem when client waits for smaller number
157 * of fields. This issue will be fixed later when client gets aware of RPC
160 static int mdc_getattr_common(struct obd_export *exp,
161 struct ptlrpc_request *req)
163 struct req_capsule *pill = &req->rq_pill;
164 struct mdt_body *body;
169 /* Request message already built. */
170 rc = ptlrpc_queue_wait(req);
174 /* sanity check for the reply */
175 body = req_capsule_server_get(pill, &RMF_MDT_BODY);
179 CDEBUG(D_NET, "mode: %o\n", body->mode);
181 if (body->eadatasize != 0) {
182 mdc_update_max_ea_from_body(exp, body);
184 eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
190 if (body->valid & OBD_MD_FLRMTPERM) {
191 struct mdt_remote_perm *perm;
193 LASSERT(client_is_remote(exp));
194 perm = req_capsule_server_swab_get(pill, &RMF_ACL,
195 lustre_swab_mdt_remote_perm);
200 if (body->valid & OBD_MD_FLMDSCAPA) {
201 struct lustre_capa *capa;
202 capa = req_capsule_server_get(pill, &RMF_CAPA1);
210 int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
211 struct ptlrpc_request **request)
213 struct ptlrpc_request *req;
218 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
222 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
224 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
226 ptlrpc_request_free(req);
230 mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
231 op_data->op_valid, op_data->op_mode, -1, 0);
233 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
235 if (op_data->op_valid & OBD_MD_FLRMTPERM) {
236 LASSERT(client_is_remote(exp));
237 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
238 sizeof(struct mdt_remote_perm));
240 ptlrpc_request_set_replen(req);
242 rc = mdc_getattr_common(exp, req);
244 ptlrpc_req_finished(req);
250 int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
251 struct ptlrpc_request **request)
253 struct ptlrpc_request *req;
258 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
259 &RQF_MDS_GETATTR_NAME);
263 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
264 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
265 op_data->op_namelen + 1);
267 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME);
269 ptlrpc_request_free(req);
273 mdc_pack_body(req, &op_data->op_fid1, op_data->op_capa1,
274 op_data->op_valid, op_data->op_mode,
275 op_data->op_suppgids[0], 0);
277 if (op_data->op_name) {
278 char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
279 LASSERT(strnlen(op_data->op_name, op_data->op_namelen) ==
280 op_data->op_namelen);
281 memcpy(name, op_data->op_name, op_data->op_namelen);
284 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
286 ptlrpc_request_set_replen(req);
288 rc = mdc_getattr_common(exp, req);
290 ptlrpc_req_finished(req);
296 static int mdc_is_subdir(struct obd_export *exp,
297 const struct lu_fid *pfid,
298 const struct lu_fid *cfid,
299 struct ptlrpc_request **request)
301 struct ptlrpc_request *req;
307 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
308 &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION,
313 mdc_is_subdir_pack(req, pfid, cfid, 0);
314 ptlrpc_request_set_replen(req);
316 rc = ptlrpc_queue_wait(req);
317 if (rc && rc != -EREMOTE)
318 ptlrpc_req_finished(req);
324 static int mdc_xattr_common(struct obd_export *exp,const struct req_format *fmt,
325 const struct lu_fid *fid,
326 struct obd_capa *oc, int opcode, obd_valid valid,
327 const char *xattr_name, const char *input,
328 int input_size, int output_size, int flags,
329 __u32 suppgid, struct ptlrpc_request **request)
331 struct ptlrpc_request *req;
332 int xattr_namelen = 0;
338 req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt);
342 mdc_set_capa_size(req, &RMF_CAPA1, oc);
344 xattr_namelen = strlen(xattr_name) + 1;
345 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
350 req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
354 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
356 ptlrpc_request_free(req);
360 if (opcode == MDS_REINT) {
361 struct mdt_rec_setxattr *rec;
363 CLASSERT(sizeof(struct mdt_rec_setxattr) ==
364 sizeof(struct mdt_rec_reint));
365 rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
366 rec->sx_opcode = REINT_SETXATTR;
368 * cfs_curproc_fs{u,g}id() should replace
369 * current->fs{u,g}id for portability.
371 rec->sx_fsuid = cfs_curproc_fsuid();
372 rec->sx_fsgid = cfs_curproc_fsgid();
373 rec->sx_cap = cfs_curproc_cap_pack();
374 rec->sx_suppgid1 = suppgid;
375 rec->sx_suppgid2 = -1;
377 rec->sx_valid = valid | OBD_MD_FLCTIME;
378 rec->sx_time = cfs_time_current_sec();
379 rec->sx_size = output_size;
380 rec->sx_flags = flags;
382 mdc_pack_capa(req, &RMF_CAPA1, oc);
384 mdc_pack_body(req, fid, oc, valid, output_size, suppgid, flags);
388 tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
389 memcpy(tmp, xattr_name, xattr_namelen);
392 tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
393 memcpy(tmp, input, input_size);
396 if (req_capsule_has_field(&req->rq_pill, &RMF_EADATA, RCL_SERVER))
397 req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
398 RCL_SERVER, output_size);
399 ptlrpc_request_set_replen(req);
402 if (opcode == MDS_REINT)
403 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
405 rc = ptlrpc_queue_wait(req);
407 if (opcode == MDS_REINT)
408 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
411 ptlrpc_req_finished(req);
417 int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
418 struct obd_capa *oc, obd_valid valid, const char *xattr_name,
419 const char *input, int input_size, int output_size,
420 int flags, __u32 suppgid, struct ptlrpc_request **request)
422 return mdc_xattr_common(exp, &RQF_MDS_REINT_SETXATTR,
423 fid, oc, MDS_REINT, valid, xattr_name,
424 input, input_size, output_size, flags,
428 int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
429 struct obd_capa *oc, obd_valid valid, const char *xattr_name,
430 const char *input, int input_size, int output_size,
431 int flags, struct ptlrpc_request **request)
433 return mdc_xattr_common(exp, &RQF_MDS_GETXATTR,
434 fid, oc, MDS_GETXATTR, valid, xattr_name,
435 input, input_size, output_size, flags,
439 #ifdef CONFIG_FS_POSIX_ACL
440 static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
442 struct req_capsule *pill = &req->rq_pill;
443 struct mdt_body *body = md->body;
444 struct posix_acl *acl;
452 buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->aclsize);
457 acl = posix_acl_from_xattr(buf, body->aclsize);
460 CERROR("convert xattr to acl: %d\n", rc);
464 rc = posix_acl_valid(acl);
466 CERROR("validate acl: %d\n", rc);
467 posix_acl_release(acl);
475 #define mdc_unpack_acl(req, md) 0
478 int mdc_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
479 struct obd_export *dt_exp, struct obd_export *md_exp,
480 struct lustre_md *md)
482 struct req_capsule *pill = &req->rq_pill;
487 memset(md, 0, sizeof(*md));
489 md->body = req_capsule_server_get(pill, &RMF_MDT_BODY);
490 LASSERT(md->body != NULL);
492 if (md->body->valid & OBD_MD_FLEASIZE) {
494 struct lov_mds_md *lmm;
496 if (!S_ISREG(md->body->mode)) {
497 CDEBUG(D_INFO, "OBD_MD_FLEASIZE set, should be a "
498 "regular file, but is not\n");
499 GOTO(out, rc = -EPROTO);
502 if (md->body->eadatasize == 0) {
503 CDEBUG(D_INFO, "OBD_MD_FLEASIZE set, "
504 "but eadatasize 0\n");
505 GOTO(out, rc = -EPROTO);
507 lmmsize = md->body->eadatasize;
508 lmm = req_capsule_server_sized_get(pill, &RMF_MDT_MD, lmmsize);
510 GOTO(out, rc = -EPROTO);
512 rc = obd_unpackmd(dt_exp, &md->lsm, lmm, lmmsize);
516 if (rc < sizeof(*md->lsm)) {
517 CDEBUG(D_INFO, "lsm size too small: "
518 "rc < sizeof (*md->lsm) (%d < %d)\n",
519 rc, (int)sizeof(*md->lsm));
520 GOTO(out, rc = -EPROTO);
523 } else if (md->body->valid & OBD_MD_FLDIREA) {
525 struct lov_mds_md *lmv;
527 if(!S_ISDIR(md->body->mode)) {
528 CDEBUG(D_INFO, "OBD_MD_FLDIREA set, should be a "
529 "directory, but is not\n");
530 GOTO(out, rc = -EPROTO);
533 if (md->body->eadatasize == 0) {
534 CDEBUG(D_INFO, "OBD_MD_FLDIREA is set, "
535 "but eadatasize 0\n");
538 if (md->body->valid & OBD_MD_MEA) {
539 lmvsize = md->body->eadatasize;
540 lmv = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
543 GOTO(out, rc = -EPROTO);
545 rc = obd_unpackmd(md_exp, (void *)&md->mea, lmv,
550 if (rc < sizeof(*md->mea)) {
551 CDEBUG(D_INFO, "size too small: "
552 "rc < sizeof(*md->mea) (%d < %d)\n",
553 rc, (int)sizeof(*md->mea));
554 GOTO(out, rc = -EPROTO);
560 if (md->body->valid & OBD_MD_FLRMTPERM) {
561 /* remote permission */
562 LASSERT(client_is_remote(exp));
563 md->remote_perm = req_capsule_server_swab_get(pill, &RMF_ACL,
564 lustre_swab_mdt_remote_perm);
565 if (!md->remote_perm)
566 GOTO(out, rc = -EPROTO);
568 else if (md->body->valid & OBD_MD_FLACL) {
569 /* for ACL, it's possible that FLACL is set but aclsize is zero.
570 * only when aclsize != 0 there's an actual segment for ACL
573 if (md->body->aclsize) {
574 rc = mdc_unpack_acl(req, md);
577 #ifdef CONFIG_FS_POSIX_ACL
579 md->posix_acl = NULL;
583 if (md->body->valid & OBD_MD_FLMDSCAPA) {
584 struct obd_capa *oc = NULL;
586 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA1, &oc);
592 if (md->body->valid & OBD_MD_FLOSSCAPA) {
593 struct obd_capa *oc = NULL;
595 rc = mdc_unpack_capa(NULL, req, &RMF_CAPA2, &oc);
605 capa_put(md->oss_capa);
609 capa_put(md->mds_capa);
612 #ifdef CONFIG_FS_POSIX_ACL
613 posix_acl_release(md->posix_acl);
616 obd_free_memmd(dt_exp, &md->lsm);
621 int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
628 * Handles both OPEN and SETATTR RPCs for OPEN-CLOSE and SETATTR-DONE_WRITING
631 void mdc_replay_open(struct ptlrpc_request *req)
633 struct md_open_data *mod = req->rq_cb_data;
634 struct ptlrpc_request *close_req;
635 struct obd_client_handle *och;
636 struct lustre_handle old;
637 struct mdt_body *body;
641 DEBUG_REQ(D_ERROR, req,
642 "Can't properly replay without open data.");
647 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
648 LASSERT(body != NULL);
652 struct lustre_handle *file_fh;
654 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
656 file_fh = &och->och_fh;
657 CDEBUG(D_HA, "updating handle from "LPX64" to "LPX64"\n",
658 file_fh->cookie, body->handle.cookie);
660 *file_fh = body->handle;
662 close_req = mod->mod_close_req;
663 if (close_req != NULL) {
664 __u32 opc = lustre_msg_get_opc(close_req->rq_reqmsg);
665 struct mdt_ioepoch *epoch;
667 LASSERT(opc == MDS_CLOSE || opc == MDS_DONE_WRITING);
668 epoch = req_capsule_client_get(&close_req->rq_pill,
673 LASSERT(!memcmp(&old, &epoch->handle, sizeof(old)));
674 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
675 epoch->handle = body->handle;
680 void mdc_commit_open(struct ptlrpc_request *req)
682 struct md_open_data *mod = req->rq_cb_data;
687 * No need to touch md_open_data::mod_och, it holds a reference on
688 * \var mod and will zero references to each other, \var mod will be
689 * freed after that when md_open_data::mod_och will put the reference.
693 * Do not let open request to disappear as it still may be needed
694 * for close rpc to happen (it may happen on evict only, otherwise
695 * ptlrpc_request::rq_replay does not let mdc_commit_open() to be
696 * called), just mark this rpc as committed to distinguish these 2
697 * cases, see mdc_close() for details. The open request reference will
698 * be put along with freeing \var mod.
700 ptlrpc_request_addref(req);
701 cfs_spin_lock(&req->rq_lock);
702 req->rq_committed = 1;
703 cfs_spin_unlock(&req->rq_lock);
704 req->rq_cb_data = NULL;
708 int mdc_set_open_replay_data(struct obd_export *exp,
709 struct obd_client_handle *och,
710 struct ptlrpc_request *open_req)
712 struct md_open_data *mod;
713 struct mdt_rec_create *rec;
714 struct mdt_body *body;
715 struct obd_import *imp = open_req->rq_import;
718 if (!open_req->rq_replay)
721 rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT);
722 body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY);
723 LASSERT(rec != NULL);
724 /* Incoming message in my byte order (it's been swabbed). */
725 /* Outgoing messages always in my byte order. */
726 LASSERT(body != NULL);
728 /* Only if the import is replayable, we set replay_open data */
729 if (och && imp->imp_replayable) {
730 mod = obd_mod_alloc();
732 DEBUG_REQ(D_ERROR, open_req,
733 "Can't allocate md_open_data");
738 * Take a reference on \var mod, to be freed on mdc_close().
739 * It protects \var mod from being freed on eviction (commit
740 * callback is called despite rq_replay flag).
741 * Another reference for \var och.
746 cfs_spin_lock(&open_req->rq_lock);
749 mod->mod_open_req = open_req;
750 open_req->rq_cb_data = mod;
751 open_req->rq_commit_cb = mdc_commit_open;
752 cfs_spin_unlock(&open_req->rq_lock);
755 rec->cr_fid2 = body->fid1;
756 rec->cr_ioepoch = body->ioepoch;
757 rec->cr_old_handle.cookie = body->handle.cookie;
758 open_req->rq_replay_cb = mdc_replay_open;
759 if (!fid_is_sane(&body->fid1)) {
760 DEBUG_REQ(D_ERROR, open_req, "Saving replay request with "
765 DEBUG_REQ(D_RPCTRACE, open_req, "Set up open replay data");
769 int mdc_clear_open_replay_data(struct obd_export *exp,
770 struct obd_client_handle *och)
772 struct md_open_data *mod = och->och_mod;
776 * It is possible to not have \var mod in a case of eviction between
777 * lookup and ll_file_open().
782 LASSERT(mod != LP_POISON);
791 /* Prepares the request for the replay by the given reply */
792 static void mdc_close_handle_reply(struct ptlrpc_request *req,
793 struct md_op_data *op_data, int rc) {
794 struct mdt_body *repbody;
795 struct mdt_ioepoch *epoch;
797 if (req && rc == -EAGAIN) {
798 repbody = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
799 epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH);
801 epoch->flags |= MF_SOM_AU;
802 if (repbody->valid & OBD_MD_FLGETATTRLOCK)
803 op_data->op_flags |= MF_GETATTR_LOCK;
807 int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
808 struct md_open_data *mod, struct ptlrpc_request **request)
810 struct obd_device *obd = class_exp2obd(exp);
811 struct ptlrpc_request *req;
816 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_CLOSE);
820 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
822 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE);
824 ptlrpc_request_free(req);
828 /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a
829 * portal whose threads are not taking any DLM locks and are therefore
830 * always progressing */
831 req->rq_request_portal = MDS_READPAGE_PORTAL;
832 ptlrpc_at_set_req_timeout(req);
834 /* Ensure that this close's handle is fixed up during replay. */
835 if (likely(mod != NULL)) {
836 LASSERTF(mod->mod_open_req != NULL &&
837 mod->mod_open_req->rq_type != LI_POISON,
838 "POISONED open %p!\n", mod->mod_open_req);
840 mod->mod_close_req = req;
842 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
843 /* We no longer want to preserve this open for replay even
844 * though the open was committed. b=3632, b=3633 */
845 cfs_spin_lock(&mod->mod_open_req->rq_lock);
846 mod->mod_open_req->rq_replay = 0;
847 cfs_spin_unlock(&mod->mod_open_req->rq_lock);
849 CDEBUG(D_HA, "couldn't find open req; expecting close error\n");
852 mdc_close_pack(req, op_data);
854 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
855 obd->u.cli.cl_max_mds_easize);
856 req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
857 obd->u.cli.cl_max_mds_cookiesize);
859 ptlrpc_request_set_replen(req);
861 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
862 rc = ptlrpc_queue_wait(req);
863 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
865 if (req->rq_repmsg == NULL) {
866 CDEBUG(D_RPCTRACE, "request failed to send: %p, %d\n", req,
869 rc = req->rq_status ?: -EIO;
870 } else if (rc == 0 || rc == -EAGAIN) {
871 struct mdt_body *body;
873 rc = lustre_msg_get_status(req->rq_repmsg);
874 if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
875 DEBUG_REQ(D_ERROR, req, "type == PTL_RPC_MSG_ERR, err "
880 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
883 } else if (rc == -ESTALE) {
885 * it can be allowed error after 3633 if open was committed and
886 * server failed before close was sent. Let's check if mod
887 * exists and return no error in that case
890 DEBUG_REQ(D_HA, req, "Reset ESTALE = %d", rc);
891 LASSERT(mod->mod_open_req != NULL);
892 if (mod->mod_open_req->rq_committed)
899 mod->mod_close_req = NULL;
900 /* Since now, mod is accessed through open_req only,
901 * thus close req does not keep a reference on mod anymore. */
905 mdc_close_handle_reply(req, op_data, rc);
909 int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data,
910 struct md_open_data *mod)
912 struct obd_device *obd = class_exp2obd(exp);
913 struct ptlrpc_request *req;
917 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
918 &RQF_MDS_DONE_WRITING);
922 mdc_set_capa_size(req, &RMF_CAPA1, op_data->op_capa1);
923 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING);
925 ptlrpc_request_free(req);
930 LASSERTF(mod->mod_open_req != NULL &&
931 mod->mod_open_req->rq_type != LI_POISON,
932 "POISONED setattr %p!\n", mod->mod_open_req);
934 mod->mod_close_req = req;
935 DEBUG_REQ(D_HA, mod->mod_open_req, "matched setattr");
936 /* We no longer want to preserve this setattr for replay even
937 * though the open was committed. b=3632, b=3633 */
938 cfs_spin_lock(&mod->mod_open_req->rq_lock);
939 mod->mod_open_req->rq_replay = 0;
940 cfs_spin_unlock(&mod->mod_open_req->rq_lock);
943 mdc_close_pack(req, op_data);
944 ptlrpc_request_set_replen(req);
946 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
947 rc = ptlrpc_queue_wait(req);
948 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
952 * it can be allowed error after 3633 if open or setattr were
953 * committed and server failed before close was sent.
954 * Let's check if mod exists and return no error in that case
957 LASSERT(mod->mod_open_req != NULL);
958 if (mod->mod_open_req->rq_committed)
965 mod->mod_close_req = NULL;
966 /* Since now, mod is accessed through setattr req only,
967 * thus DW req does not keep a reference on mod anymore. */
971 mdc_close_handle_reply(req, op_data, rc);
972 ptlrpc_req_finished(req);
976 #ifdef HAVE_SPLIT_SUPPORT
977 int mdc_sendpage(struct obd_export *exp, const struct lu_fid *fid,
978 const struct page *page, int offset)
980 struct ptlrpc_request *req;
981 struct ptlrpc_bulk_desc *desc;
985 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_WRITEPAGE);
989 /* FIXME: capa doesn't support split yet */
990 mdc_set_capa_size(req, &RMF_CAPA1, NULL);
992 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_WRITEPAGE);
994 ptlrpc_request_free(req);
998 req->rq_request_portal = MDS_READPAGE_PORTAL;
999 ptlrpc_at_set_req_timeout(req);
1001 desc = ptlrpc_prep_bulk_imp(req, 1, BULK_GET_SOURCE, MDS_BULK_PORTAL);
1003 GOTO(out, rc = -ENOMEM);
1005 /* NB req now owns desc and will free it when it gets freed. */
1006 ptlrpc_prep_bulk_page(desc, (struct page *)page, 0, offset);
1007 mdc_readdir_pack(req, 0, offset, fid, NULL);
1009 ptlrpc_request_set_replen(req);
1010 rc = ptlrpc_queue_wait(req);
1014 rc = sptlrpc_cli_unwrap_bulk_write(req, req->rq_bulk);
1016 ptlrpc_req_finished(req);
1019 EXPORT_SYMBOL(mdc_sendpage);
1022 int mdc_readpage(struct obd_export *exp, const struct lu_fid *fid,
1023 struct obd_capa *oc, __u64 offset, struct page **pages,
1024 unsigned npages, struct ptlrpc_request **request)
1026 struct ptlrpc_request *req;
1027 struct ptlrpc_bulk_desc *desc;
1031 struct l_wait_info lwi;
1036 cfs_waitq_init(&waitq);
1039 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE);
1043 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1045 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE);
1047 ptlrpc_request_free(req);
1051 req->rq_request_portal = MDS_READPAGE_PORTAL;
1052 ptlrpc_at_set_req_timeout(req);
1054 desc = ptlrpc_prep_bulk_imp(req, npages, BULK_PUT_SINK,
1057 ptlrpc_request_free(req);
1061 /* NB req now owns desc and will free it when it gets freed */
1062 for (i = 0; i < npages; i++)
1063 ptlrpc_prep_bulk_page(desc, pages[i], 0, CFS_PAGE_SIZE);
1065 mdc_readdir_pack(req, offset, CFS_PAGE_SIZE * npages, fid, oc);
1067 ptlrpc_request_set_replen(req);
1068 rc = ptlrpc_queue_wait(req);
1070 ptlrpc_req_finished(req);
1071 if (rc != -ETIMEDOUT)
1075 if (!client_should_resend(resends, &exp->exp_obd->u.cli)) {
1076 CERROR("too many resend retries, returning error\n");
1079 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends), NULL, NULL, NULL);
1080 l_wait_event(waitq, 0, &lwi);
1085 rc = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk,
1086 req->rq_bulk->bd_nob_transferred);
1088 ptlrpc_req_finished(req);
1092 if (req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK) {
1093 CERROR("Unexpected # bytes transferred: %d (%ld expected)\n",
1094 req->rq_bulk->bd_nob_transferred,
1095 CFS_PAGE_SIZE * npages);
1096 ptlrpc_req_finished(req);
1104 static int mdc_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1105 __u64 max_age, __u32 flags)
1107 struct ptlrpc_request *req;
1108 struct obd_statfs *msfs;
1109 struct obd_import *imp = NULL;
1114 * Since the request might also come from lprocfs, so we need
1115 * sync this with client_disconnect_export Bug15684
1117 cfs_down_read(&obd->u.cli.cl_sem);
1118 if (obd->u.cli.cl_import)
1119 imp = class_import_get(obd->u.cli.cl_import);
1120 cfs_up_read(&obd->u.cli.cl_sem);
1124 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS,
1125 LUSTRE_MDS_VERSION, MDS_STATFS);
1127 GOTO(output, rc = -ENOMEM);
1129 ptlrpc_request_set_replen(req);
1131 if (flags & OBD_STATFS_NODELAY) {
1132 /* procfs requests not want stay in wait for avoid deadlock */
1133 req->rq_no_resend = 1;
1134 req->rq_no_delay = 1;
1137 rc = ptlrpc_queue_wait(req);
1139 /* check connection error first */
1140 if (imp->imp_connect_error)
1141 rc = imp->imp_connect_error;
1145 msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
1147 GOTO(out, rc = -EPROTO);
1152 ptlrpc_req_finished(req);
1154 class_import_put(imp);
1158 static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
1160 __u32 keylen, vallen;
1164 if (gf->gf_pathlen > PATH_MAX)
1165 RETURN(-ENAMETOOLONG);
1166 if (gf->gf_pathlen < 2)
1169 /* Key is KEY_FID2PATH + getinfo_fid2path description */
1170 keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
1171 OBD_ALLOC(key, keylen);
1174 memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
1175 memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf));
1177 CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n",
1178 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno);
1180 if (!fid_is_sane(&gf->gf_fid))
1181 GOTO(out, rc = -EINVAL);
1183 /* Val is struct getinfo_fid2path result plus path */
1184 vallen = sizeof(*gf) + gf->gf_pathlen;
1186 rc = obd_get_info(exp, keylen, key, &vallen, gf, NULL);
1190 if (vallen <= sizeof(*gf))
1191 GOTO(out, rc = -EPROTO);
1192 else if (vallen > sizeof(*gf) + gf->gf_pathlen)
1193 GOTO(out, rc = -EOVERFLOW);
1195 CDEBUG(D_IOCTL, "path get "DFID" from "LPU64" #%d\n%s\n",
1196 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
1199 OBD_FREE(key, keylen);
1203 static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
1205 struct kuc_hdr *lh = (struct kuc_hdr *)buf;
1207 LASSERT(len <= CR_MAXSIZE);
1209 lh->kuc_magic = KUC_MAGIC;
1210 lh->kuc_transport = KUC_TRANSPORT_CHANGELOG;
1211 lh->kuc_flags = flags;
1212 lh->kuc_msgtype = CL_RECORD;
1213 lh->kuc_msglen = len;
1217 #define D_CHANGELOG 0
1219 struct changelog_show {
1224 struct obd_device *cs_obd;
1227 static int changelog_show_cb(struct llog_handle *llh, struct llog_rec_hdr *hdr,
1230 struct changelog_show *cs = data;
1231 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
1236 if ((rec->cr_hdr.lrh_type != CHANGELOG_REC) ||
1237 (rec->cr.cr_type >= CL_LAST)) {
1238 CERROR("Not a changelog rec %d/%d\n", rec->cr_hdr.lrh_type,
1243 if (rec->cr.cr_index < cs->cs_startrec) {
1244 /* Skip entries earlier than what we are interested in */
1245 CDEBUG(D_CHANGELOG, "rec="LPU64" start="LPU64"\n",
1246 rec->cr.cr_index, cs->cs_startrec);
1250 CDEBUG(D_CHANGELOG, LPU64" %02d%-5s "LPU64" 0x%x t="DFID" p="DFID
1251 " %.*s\n", rec->cr.cr_index, rec->cr.cr_type,
1252 changelog_type2str(rec->cr.cr_type), rec->cr.cr_time,
1253 rec->cr.cr_flags & CLF_FLAGMASK,
1254 PFID(&rec->cr.cr_tfid), PFID(&rec->cr.cr_pfid),
1255 rec->cr.cr_namelen, rec->cr.cr_name);
1257 len = sizeof(*lh) + sizeof(rec->cr) + rec->cr.cr_namelen;
1259 /* Set up the message */
1260 lh = changelog_kuc_hdr(cs->cs_buf, len, cs->cs_flags);
1261 memcpy(lh + 1, &rec->cr, len - sizeof(*lh));
1263 rc = libcfs_kkuc_msg_put(cs->cs_fp, lh);
1264 CDEBUG(D_CHANGELOG, "kucmsg fp %p len %d rc %d\n", cs->cs_fp, len,rc);
1269 static int mdc_changelog_send_thread(void *csdata)
1271 struct changelog_show *cs = csdata;
1272 struct llog_ctxt *ctxt = NULL;
1273 struct llog_handle *llh = NULL;
1274 struct kuc_hdr *kuch;
1277 CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n",
1278 cs->cs_fp, cs->cs_startrec);
1281 * It's important to daemonize here to close unused FDs.
1282 * The write fd from pipe is already opened by the caller,
1283 * so it's fine to clear all files here
1285 cfs_daemonize("mdc_clg_send_thread");
1287 OBD_ALLOC(cs->cs_buf, CR_MAXSIZE);
1288 if (cs->cs_buf == NULL)
1289 GOTO(out, rc = -ENOMEM);
1291 /* Set up the remote catalog handle */
1292 ctxt = llog_get_context(cs->cs_obd, LLOG_CHANGELOG_REPL_CTXT);
1294 GOTO(out, rc = -ENOENT);
1295 rc = llog_create(ctxt, &llh, NULL, CHANGELOG_CATALOG);
1297 CERROR("llog_create() failed %d\n", rc);
1300 rc = llog_init_handle(llh, LLOG_F_IS_CAT, NULL);
1302 CERROR("llog_init_handle failed %d\n", rc);
1306 rc = llog_cat_process_flags(llh, changelog_show_cb, cs, 0, 0, 0);
1308 /* Send EOF no matter what our result */
1309 if ((kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch),
1311 kuch->kuc_msgtype = CL_EOF;
1312 libcfs_kkuc_msg_put(cs->cs_fp, kuch);
1316 cfs_put_file(cs->cs_fp);
1320 llog_ctxt_put(ctxt);
1322 OBD_FREE(cs->cs_buf, CR_MAXSIZE);
1324 /* detach from parent process so we get cleaned up */
1325 cfs_daemonize("cl_send");
1329 static int mdc_ioc_changelog_send(struct obd_device *obd,
1330 struct ioc_changelog *icc)
1332 struct changelog_show *cs;
1335 /* Freed in mdc_changelog_send_thread */
1341 cs->cs_startrec = icc->icc_recno;
1342 /* matching cfs_put_file in mdc_changelog_send_thread */
1343 cs->cs_fp = cfs_get_fd(icc->icc_id);
1344 cs->cs_flags = icc->icc_flags;
1346 /* New thread because we should return to user app before
1347 writing into our pipe */
1348 rc = cfs_create_thread(mdc_changelog_send_thread, cs, CFS_DAEMON_FLAGS);
1350 CDEBUG(D_CHANGELOG, "start changelog thread: %d\n", rc);
1354 CERROR("Failed to start changelog thread: %d\n", rc);
1359 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1360 struct lustre_kernelcomm *lk);
1362 static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp,
1363 struct obd_quotactl *oqctl)
1365 struct client_obd *cli = &exp->exp_obd->u.cli;
1366 struct ptlrpc_request *req;
1367 struct obd_quotactl *body;
1371 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
1372 &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION,
1377 body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1380 ptlrpc_request_set_replen(req);
1382 /* the next poll will find -ENODATA, that means quotacheck is
1384 cli->cl_qchk_stat = -ENODATA;
1385 rc = ptlrpc_queue_wait(req);
1387 cli->cl_qchk_stat = rc;
1388 ptlrpc_req_finished(req);
1392 static int mdc_quota_poll_check(struct obd_export *exp,
1393 struct if_quotacheck *qchk)
1395 struct client_obd *cli = &exp->exp_obd->u.cli;
1399 qchk->obd_uuid = cli->cl_target_uuid;
1400 memcpy(qchk->obd_type, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME));
1402 rc = cli->cl_qchk_stat;
1403 /* the client is not the previous one */
1404 if (rc == CL_NOT_QUOTACHECKED)
1409 static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp,
1410 struct obd_quotactl *oqctl)
1412 struct ptlrpc_request *req;
1413 struct obd_quotactl *oqc;
1417 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
1418 &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION,
1423 oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1426 ptlrpc_request_set_replen(req);
1427 ptlrpc_at_set_req_timeout(req);
1428 req->rq_no_resend = 1;
1430 rc = ptlrpc_queue_wait(req);
1432 CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc);
1434 if (req->rq_repmsg &&
1435 (oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL))) {
1438 CERROR ("Can't unpack obd_quotactl\n");
1441 ptlrpc_req_finished(req);
1446 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
1447 void *karg, void *uarg)
1449 struct obd_device *obd = exp->exp_obd;
1450 struct obd_ioctl_data *data = karg;
1451 struct obd_import *imp = obd->u.cli.cl_import;
1452 struct llog_ctxt *ctxt;
1456 if (!cfs_try_module_get(THIS_MODULE)) {
1457 CERROR("Can't get module. Is it alive?");
1461 case LL_IOC_HSM_CT_START:
1462 rc = mdc_ioc_hsm_ct_start(exp, karg);
1464 case OBD_IOC_CHANGELOG_SEND:
1465 rc = mdc_ioc_changelog_send(obd, karg);
1467 case OBD_IOC_CHANGELOG_CLEAR: {
1468 struct ioc_changelog *icc = karg;
1469 struct changelog_setinfo cs =
1470 {.cs_recno = icc->icc_recno, .cs_id = icc->icc_id};
1471 rc = obd_set_info_async(exp, strlen(KEY_CHANGELOG_CLEAR),
1472 KEY_CHANGELOG_CLEAR, sizeof(cs), &cs,
1476 case OBD_IOC_FID2PATH: {
1477 rc = mdc_ioc_fid2path(exp, karg);
1480 case OBD_IOC_CLIENT_RECOVER:
1481 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1, 0);
1485 case IOC_OSC_SET_ACTIVE:
1486 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
1488 case OBD_IOC_PARSE: {
1489 ctxt = llog_get_context(exp->exp_obd, LLOG_CONFIG_REPL_CTXT);
1490 rc = class_config_parse_llog(ctxt, data->ioc_inlbuf1, NULL);
1491 llog_ctxt_put(ctxt);
1495 case OBD_IOC_LLOG_INFO:
1496 case OBD_IOC_LLOG_PRINT: {
1497 ctxt = llog_get_context(obd, LLOG_CONFIG_REPL_CTXT);
1498 rc = llog_ioctl(ctxt, cmd, data);
1499 llog_ctxt_put(ctxt);
1503 case OBD_IOC_POLL_QUOTACHECK:
1504 rc = mdc_quota_poll_check(exp, (struct if_quotacheck *)karg);
1506 case OBD_IOC_PING_TARGET:
1507 rc = ptlrpc_obd_ping(obd);
1510 * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by
1511 * LMV instead of MDC. But when the cluster is upgraded from 1.8,
1512 * there'd be no LMV layer thus we might be called here. Eventually
1513 * this code should be removed.
1516 case IOC_OBD_STATFS: {
1517 struct obd_statfs stat_buf = {0};
1519 if (*((__u32 *) data->ioc_inlbuf2) != 0)
1520 GOTO(out, rc = -ENODEV);
1523 if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd),
1524 min((int) data->ioc_plen2,
1525 (int) sizeof(struct obd_uuid))))
1526 GOTO(out, rc = -EFAULT);
1528 rc = mdc_statfs(obd, &stat_buf,
1529 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
1534 if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf,
1535 min((int) data->ioc_plen1,
1536 (int) sizeof(stat_buf))))
1537 GOTO(out, rc = -EFAULT);
1541 case OBD_IOC_QUOTACTL: {
1542 struct if_quotactl *qctl = karg;
1543 struct obd_quotactl *oqctl;
1545 OBD_ALLOC_PTR(oqctl);
1549 QCTL_COPY(oqctl, qctl);
1550 rc = obd_quotactl(exp, oqctl);
1552 QCTL_COPY(qctl, oqctl);
1553 qctl->qc_valid = QC_MDTIDX;
1554 qctl->obd_uuid = obd->u.cli.cl_target_uuid;
1556 OBD_FREE_PTR(oqctl);
1559 case LL_IOC_GET_CONNECT_FLAGS: {
1560 if (cfs_copy_to_user(uarg, &exp->exp_connect_flags,
1562 GOTO(out, rc = -EFAULT);
1567 CERROR("mdc_ioctl(): unrecognised ioctl %#x\n", cmd);
1568 GOTO(out, rc = -ENOTTY);
1571 cfs_module_put(THIS_MODULE);
1576 int mdc_get_info_rpc(struct obd_export *exp,
1577 obd_count keylen, void *key,
1578 int vallen, void *val)
1580 struct obd_import *imp = class_exp2cliimp(exp);
1581 struct ptlrpc_request *req;
1586 req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO);
1590 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY,
1591 RCL_CLIENT, keylen);
1592 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VALLEN,
1593 RCL_CLIENT, sizeof(__u32));
1595 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_INFO);
1597 ptlrpc_request_free(req);
1601 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY);
1602 memcpy(tmp, key, keylen);
1603 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_VALLEN);
1604 memcpy(tmp, &vallen, sizeof(__u32));
1606 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VAL,
1607 RCL_SERVER, vallen);
1608 ptlrpc_request_set_replen(req);
1610 rc = ptlrpc_queue_wait(req);
1612 tmp = req_capsule_server_get(&req->rq_pill, &RMF_GETINFO_VAL);
1613 memcpy(val, tmp, vallen);
1614 if (ptlrpc_rep_need_swab(req)) {
1615 if (KEY_IS(KEY_FID2PATH)) {
1616 lustre_swab_fid2path(val);
1620 ptlrpc_req_finished(req);
1625 static void lustre_swab_hai(struct hsm_action_item *h)
1627 __swab32s(&h->hai_len);
1628 __swab32s(&h->hai_action);
1629 lustre_swab_lu_fid(&h->hai_fid);
1630 __swab64s(&h->hai_cookie);
1631 __swab64s(&h->hai_extent.offset);
1632 __swab64s(&h->hai_extent.length);
1633 __swab64s(&h->hai_gid);
1636 static void lustre_swab_hal(struct hsm_action_list *h)
1638 struct hsm_action_item *hai;
1641 __swab32s(&h->hal_version);
1642 __swab32s(&h->hal_count);
1643 __swab32s(&h->hal_archive_num);
1645 for (i = 0; i < h->hal_count; i++) {
1646 lustre_swab_hai(hai);
1647 hai = hai_next(hai);
1651 static void lustre_swab_kuch(struct kuc_hdr *l)
1653 __swab16s(&l->kuc_magic);
1654 /* __u8 l->kuc_transport */
1655 __swab16s(&l->kuc_msgtype);
1656 __swab16s(&l->kuc_msglen);
1659 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1660 struct lustre_kernelcomm *lk)
1664 if (lk->lk_group != KUC_GRP_HSM) {
1665 CERROR("Bad copytool group %d\n", lk->lk_group);
1669 CDEBUG(D_HSM, "CT start r%d w%d u%d g%d f%#x\n", lk->lk_rfd, lk->lk_wfd,
1670 lk->lk_uid, lk->lk_group, lk->lk_flags);
1672 if (lk->lk_flags & LK_FLG_STOP)
1673 rc = libcfs_kkuc_group_rem(lk->lk_uid,lk->lk_group);
1675 cfs_file_t *fp = cfs_get_fd(lk->lk_wfd);
1676 rc = libcfs_kkuc_group_add(fp, lk->lk_uid,lk->lk_group,
1682 /* lk_data is archive number mask */
1683 /* TODO: register archive num with mdt so coordinator can choose
1690 * Send a message to any listening copytools
1691 * @param val KUC message (kuc_hdr + hsm_action_list)
1692 * @param len total length of message
1694 static int mdc_hsm_copytool_send(int len, void *val)
1696 struct kuc_hdr *lh = (struct kuc_hdr *)val;
1697 struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1);
1701 if (len < sizeof(*lh) + sizeof(*hal)) {
1702 CERROR("Short HSM message %d < %d\n", len,
1703 (int) (sizeof(*lh) + sizeof(*hal)));
1706 if (lh->kuc_magic == __swab16(KUC_MAGIC)) {
1707 lustre_swab_kuch(lh);
1708 lustre_swab_hal(hal);
1709 } else if (lh->kuc_magic != KUC_MAGIC) {
1710 CERROR("Bad magic %x!=%x\n", lh->kuc_magic, KUC_MAGIC);
1714 CDEBUG(D_HSM, " Received message mg=%x t=%d m=%d l=%d actions=%d\n",
1715 lh->kuc_magic, lh->kuc_transport, lh->kuc_msgtype,
1716 lh->kuc_msglen, hal->hal_count);
1718 /* Broadcast to HSM listeners */
1719 rc = libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
1724 int mdc_set_info_async(struct obd_export *exp,
1725 obd_count keylen, void *key,
1726 obd_count vallen, void *val,
1727 struct ptlrpc_request_set *set)
1729 struct obd_import *imp = class_exp2cliimp(exp);
1733 if (KEY_IS(KEY_READ_ONLY)) {
1734 if (vallen != sizeof(int))
1737 cfs_spin_lock(&imp->imp_lock);
1738 if (*((int *)val)) {
1739 imp->imp_connect_flags_orig |= OBD_CONNECT_RDONLY;
1740 imp->imp_connect_data.ocd_connect_flags |= OBD_CONNECT_RDONLY;
1742 imp->imp_connect_flags_orig &= ~OBD_CONNECT_RDONLY;
1743 imp->imp_connect_data.ocd_connect_flags &= ~OBD_CONNECT_RDONLY;
1745 cfs_spin_unlock(&imp->imp_lock);
1747 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
1748 keylen, key, vallen, val, set);
1751 if (KEY_IS(KEY_SPTLRPC_CONF)) {
1752 sptlrpc_conf_client_adapt(exp->exp_obd);
1755 if (KEY_IS(KEY_FLUSH_CTX)) {
1756 sptlrpc_import_flush_my_ctx(imp);
1759 if (KEY_IS(KEY_MDS_CONN)) {
1760 /* mds-mds import */
1761 cfs_spin_lock(&imp->imp_lock);
1762 imp->imp_server_timeout = 1;
1763 cfs_spin_unlock(&imp->imp_lock);
1764 imp->imp_client->cli_request_portal = MDS_MDS_PORTAL;
1765 CDEBUG(D_OTHER, "%s: timeout / 2\n", exp->exp_obd->obd_name);
1768 if (KEY_IS(KEY_CHANGELOG_CLEAR)) {
1769 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
1770 keylen, key, vallen, val, set);
1773 if (KEY_IS(KEY_HSM_COPYTOOL_SEND)) {
1774 rc = mdc_hsm_copytool_send(vallen, val);
1781 int mdc_get_info(struct obd_export *exp, __u32 keylen, void *key,
1782 __u32 *vallen, void *val, struct lov_stripe_md *lsm)
1786 if (KEY_IS(KEY_MAX_EASIZE)) {
1787 int mdsize, *max_easize;
1789 if (*vallen != sizeof(int))
1791 mdsize = *(int*)val;
1792 if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize)
1793 exp->exp_obd->u.cli.cl_max_mds_easize = mdsize;
1795 *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
1797 } else if (KEY_IS(KEY_CONN_DATA)) {
1798 struct obd_import *imp = class_exp2cliimp(exp);
1799 struct obd_connect_data *data = val;
1801 if (*vallen != sizeof(*data))
1804 *data = imp->imp_connect_data;
1806 } else if (KEY_IS(KEY_TGT_COUNT)) {
1811 rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val);
1816 static int mdc_pin(struct obd_export *exp, const struct lu_fid *fid,
1817 struct obd_capa *oc, struct obd_client_handle *handle,
1820 struct ptlrpc_request *req;
1821 struct mdt_body *body;
1825 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_PIN);
1829 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1831 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_PIN);
1833 ptlrpc_request_free(req);
1837 mdc_pack_body(req, fid, oc, 0, 0, -1, flags);
1839 ptlrpc_request_set_replen(req);
1841 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1842 rc = ptlrpc_queue_wait(req);
1843 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1845 CERROR("Pin failed: %d\n", rc);
1849 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1851 GOTO(err_out, rc = -EPROTO);
1853 handle->och_fh = body->handle;
1854 handle->och_magic = OBD_CLIENT_HANDLE_MAGIC;
1856 handle->och_mod = obd_mod_alloc();
1857 if (handle->och_mod == NULL) {
1858 DEBUG_REQ(D_ERROR, req, "can't allocate md_open_data");
1859 GOTO(err_out, rc = -ENOMEM);
1861 handle->och_mod->mod_open_req = req; /* will be dropped by unpin */
1866 ptlrpc_req_finished(req);
1870 static int mdc_unpin(struct obd_export *exp, struct obd_client_handle *handle,
1873 struct ptlrpc_request *req;
1874 struct mdt_body *body;
1878 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_UNPIN,
1879 LUSTRE_MDS_VERSION, MDS_UNPIN);
1883 body = req_capsule_client_get(&req->rq_pill, &RMF_MDT_BODY);
1884 body->handle = handle->och_fh;
1887 ptlrpc_request_set_replen(req);
1889 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1890 rc = ptlrpc_queue_wait(req);
1891 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
1894 CERROR("Unpin failed: %d\n", rc);
1896 ptlrpc_req_finished(req);
1897 ptlrpc_req_finished(handle->och_mod->mod_open_req);
1899 obd_mod_put(handle->och_mod);
1903 int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
1904 struct obd_capa *oc, struct ptlrpc_request **request)
1906 struct ptlrpc_request *req;
1911 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC);
1915 mdc_set_capa_size(req, &RMF_CAPA1, oc);
1917 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC);
1919 ptlrpc_request_free(req);
1923 mdc_pack_body(req, fid, oc, 0, 0, -1, 0);
1925 ptlrpc_request_set_replen(req);
1927 rc = ptlrpc_queue_wait(req);
1929 ptlrpc_req_finished(req);
1935 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
1936 enum obd_import_event event)
1940 LASSERT(imp->imp_obd == obd);
1943 case IMP_EVENT_DISCON: {
1945 /* XXX Pass event up to OBDs stack. used only for FLD now */
1946 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_DISCON, NULL);
1950 case IMP_EVENT_INACTIVE: {
1951 struct client_obd *cli = &obd->u.cli;
1953 * Flush current sequence to make client obtain new one
1954 * from server in case of disconnect/reconnect.
1956 if (cli->cl_seq != NULL)
1957 seq_client_flush(cli->cl_seq);
1959 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE, NULL);
1962 case IMP_EVENT_INVALIDATE: {
1963 struct ldlm_namespace *ns = obd->obd_namespace;
1965 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
1969 case IMP_EVENT_ACTIVE: {
1970 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL);
1974 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
1976 case IMP_EVENT_DEACTIVATE:
1977 case IMP_EVENT_ACTIVATE:
1980 CERROR("Unknown import event %x\n", event);
1986 static int mdc_fid_init(struct obd_export *exp)
1988 struct client_obd *cli = &exp->exp_obd->u.cli;
1993 OBD_ALLOC_PTR(cli->cl_seq);
1994 if (cli->cl_seq == NULL)
1997 OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
1999 GOTO(out_free_seq, rc = -ENOMEM);
2001 snprintf(prefix, MAX_OBD_NAME + 5, "srv-%s",
2002 exp->exp_obd->obd_name);
2004 /* Init client side sequence-manager */
2005 rc = seq_client_init(cli->cl_seq, exp,
2006 LUSTRE_SEQ_METADATA,
2008 OBD_FREE(prefix, MAX_OBD_NAME + 5);
2010 GOTO(out_free_seq, rc);
2014 OBD_FREE_PTR(cli->cl_seq);
2019 static int mdc_fid_fini(struct obd_export *exp)
2021 struct client_obd *cli = &exp->exp_obd->u.cli;
2024 if (cli->cl_seq != NULL) {
2025 seq_client_fini(cli->cl_seq);
2026 OBD_FREE_PTR(cli->cl_seq);
2033 int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
2034 struct md_op_data *op_data)
2036 struct client_obd *cli = &exp->exp_obd->u.cli;
2037 struct lu_client_seq *seq = cli->cl_seq;
2039 RETURN(seq_client_alloc_fid(NULL, seq, fid));
2042 /* XXX This method is used only to clear current fid seq
2043 * once fld/mds insert failed */
2044 static int mdc_fid_delete(struct obd_export *exp, const struct lu_fid *fid)
2046 struct client_obd *cli = &exp->exp_obd->u.cli;
2048 seq_client_flush(cli->cl_seq);
2052 struct obd_uuid *mdc_get_uuid(struct obd_export *exp) {
2053 struct client_obd *cli = &exp->exp_obd->u.cli;
2054 return &cli->cl_target_uuid;
2058 * Determine whether the lock can be canceled before replaying it during
2059 * recovery, non zero value will be return if the lock can be canceled,
2060 * or zero returned for not
2062 static int mdc_cancel_for_recovery(struct ldlm_lock *lock)
2064 if (lock->l_resource->lr_type != LDLM_IBITS)
2067 /* FIXME: if we ever get into a situation where there are too many
2068 * opened files with open locks on a single node, then we really
2069 * should replay these open locks to reget it */
2070 if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN)
2076 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
2078 struct client_obd *cli = &obd->u.cli;
2079 struct lprocfs_static_vars lvars = { 0 };
2083 OBD_ALLOC(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2084 if (!cli->cl_rpc_lock)
2086 mdc_init_rpc_lock(cli->cl_rpc_lock);
2090 OBD_ALLOC(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2091 if (!cli->cl_close_lock)
2092 GOTO(err_rpc_lock, rc = -ENOMEM);
2093 mdc_init_rpc_lock(cli->cl_close_lock);
2095 rc = client_obd_setup(obd, cfg);
2097 GOTO(err_close_lock, rc);
2098 lprocfs_mdc_init_vars(&lvars);
2099 lprocfs_obd_setup(obd, lvars.obd_vars);
2100 sptlrpc_lprocfs_cliobd_attach(obd);
2101 ptlrpc_lprocfs_register_obd(obd);
2103 ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
2105 rc = obd_llog_init(obd, &obd->obd_olg, obd, NULL);
2108 CERROR("failed to setup llogging subsystems\n");
2114 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2116 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2121 /* Initialize the default and maximum LOV EA and cookie sizes. This allows
2122 * us to make MDS RPCs with large enough reply buffers to hold the
2123 * maximum-sized (= maximum striped) EA and cookie without having to
2124 * calculate this (via a call into the LOV + OSCs) each time we make an RPC. */
2125 static int mdc_init_ea_size(struct obd_export *exp, int easize,
2126 int def_easize, int cookiesize)
2128 struct obd_device *obd = exp->exp_obd;
2129 struct client_obd *cli = &obd->u.cli;
2132 if (cli->cl_max_mds_easize < easize)
2133 cli->cl_max_mds_easize = easize;
2135 if (cli->cl_default_mds_easize < def_easize)
2136 cli->cl_default_mds_easize = def_easize;
2138 if (cli->cl_max_mds_cookiesize < cookiesize)
2139 cli->cl_max_mds_cookiesize = cookiesize;
2144 static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2150 case OBD_CLEANUP_EARLY:
2152 case OBD_CLEANUP_EXPORTS:
2153 /* Failsafe, ok if racy */
2154 if (obd->obd_type->typ_refcnt <= 1)
2155 libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
2157 obd_cleanup_client_import(obd);
2158 ptlrpc_lprocfs_unregister_obd(obd);
2159 lprocfs_obd_cleanup(obd);
2161 rc = obd_llog_finish(obd, 0);
2163 CERROR("failed to cleanup llogging subsystems\n");
2169 static int mdc_cleanup(struct obd_device *obd)
2171 struct client_obd *cli = &obd->u.cli;
2173 OBD_FREE(cli->cl_rpc_lock, sizeof (*cli->cl_rpc_lock));
2174 OBD_FREE(cli->cl_close_lock, sizeof (*cli->cl_close_lock));
2178 return client_obd_cleanup(obd);
2182 static int mdc_llog_init(struct obd_device *obd, struct obd_llog_group *olg,
2183 struct obd_device *tgt, int *index)
2185 struct llog_ctxt *ctxt;
2189 LASSERT(olg == &obd->obd_olg);
2191 rc = llog_setup(obd, olg, LLOG_LOVEA_REPL_CTXT, tgt, 0, NULL,
2196 ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);
2197 llog_initiator_connect(ctxt);
2198 llog_ctxt_put(ctxt);
2200 rc = llog_setup(obd, olg, LLOG_CHANGELOG_REPL_CTXT, tgt, 0, NULL,
2203 ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT);
2204 llog_initiator_connect(ctxt);
2205 llog_ctxt_put(ctxt);
2211 static int mdc_llog_finish(struct obd_device *obd, int count)
2213 struct llog_ctxt *ctxt;
2217 ctxt = llog_get_context(obd, LLOG_LOVEA_REPL_CTXT);
2219 rc = llog_cleanup(ctxt);
2221 ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT);
2223 rc = llog_cleanup(ctxt);
2228 static int mdc_process_config(struct obd_device *obd, obd_count len, void *buf)
2230 struct lustre_cfg *lcfg = buf;
2231 struct lprocfs_static_vars lvars = { 0 };
2234 lprocfs_mdc_init_vars(&lvars);
2235 switch (lcfg->lcfg_command) {
2237 rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars,
2247 /* get remote permission for current user on fid */
2248 int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
2249 struct obd_capa *oc, __u32 suppgid,
2250 struct ptlrpc_request **request)
2252 struct ptlrpc_request *req;
2256 LASSERT(client_is_remote(exp));
2259 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
2263 mdc_set_capa_size(req, &RMF_CAPA1, oc);
2265 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
2267 ptlrpc_request_free(req);
2271 mdc_pack_body(req, fid, oc, OBD_MD_FLRMTPERM, 0, suppgid, 0);
2273 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
2274 sizeof(struct mdt_remote_perm));
2276 ptlrpc_request_set_replen(req);
2278 rc = ptlrpc_queue_wait(req);
2280 ptlrpc_req_finished(req);
2286 static int mdc_interpret_renew_capa(const struct lu_env *env,
2287 struct ptlrpc_request *req, void *args,
2290 struct mdc_renew_capa_args *ra = args;
2291 struct mdt_body *body = NULL;
2292 struct lustre_capa *capa;
2296 GOTO(out, capa = ERR_PTR(status));
2298 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
2300 GOTO(out, capa = ERR_PTR(-EFAULT));
2302 if ((body->valid & OBD_MD_FLOSSCAPA) == 0)
2303 GOTO(out, capa = ERR_PTR(-ENOENT));
2305 capa = req_capsule_server_get(&req->rq_pill, &RMF_CAPA2);
2307 GOTO(out, capa = ERR_PTR(-EFAULT));
2310 ra->ra_cb(ra->ra_oc, capa);
2314 static int mdc_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2317 struct ptlrpc_request *req;
2318 struct mdc_renew_capa_args *ra;
2321 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp), &RQF_MDS_GETATTR,
2322 LUSTRE_MDS_VERSION, MDS_GETATTR);
2326 /* NB, OBD_MD_FLOSSCAPA is set here, but it doesn't necessarily mean the
2327 * capa to renew is oss capa.
2329 mdc_pack_body(req, &oc->c_capa.lc_fid, oc, OBD_MD_FLOSSCAPA, 0, -1, 0);
2330 ptlrpc_request_set_replen(req);
2332 CLASSERT(sizeof(*ra) <= sizeof(req->rq_async_args));
2333 ra = ptlrpc_req_async_args(req);
2336 req->rq_interpret_reply = mdc_interpret_renew_capa;
2337 ptlrpcd_add_req(req, PDL_POLICY_LOCAL, -1);
2341 static int mdc_connect(const struct lu_env *env,
2342 struct obd_export **exp,
2343 struct obd_device *obd, struct obd_uuid *cluuid,
2344 struct obd_connect_data *data,
2347 struct obd_import *imp = obd->u.cli.cl_import;
2349 /* mds-mds import features */
2350 if (data && (data->ocd_connect_flags & OBD_CONNECT_MDS_MDS)) {
2351 cfs_spin_lock(&imp->imp_lock);
2352 imp->imp_server_timeout = 1;
2353 cfs_spin_unlock(&imp->imp_lock);
2354 imp->imp_client->cli_request_portal = MDS_MDS_PORTAL;
2355 CDEBUG(D_OTHER, "%s: Set 'mds' portal and timeout\n",
2359 return client_connect_import(env, exp, obd, cluuid, data, NULL);
2362 struct obd_ops mdc_obd_ops = {
2363 .o_owner = THIS_MODULE,
2364 .o_setup = mdc_setup,
2365 .o_precleanup = mdc_precleanup,
2366 .o_cleanup = mdc_cleanup,
2367 .o_add_conn = client_import_add_conn,
2368 .o_del_conn = client_import_del_conn,
2369 .o_connect = mdc_connect,
2370 .o_disconnect = client_disconnect_export,
2371 .o_iocontrol = mdc_iocontrol,
2372 .o_set_info_async = mdc_set_info_async,
2373 .o_statfs = mdc_statfs,
2375 .o_unpin = mdc_unpin,
2376 .o_fid_init = mdc_fid_init,
2377 .o_fid_fini = mdc_fid_fini,
2378 .o_fid_alloc = mdc_fid_alloc,
2379 .o_fid_delete = mdc_fid_delete,
2380 .o_import_event = mdc_import_event,
2381 .o_llog_init = mdc_llog_init,
2382 .o_llog_finish = mdc_llog_finish,
2383 .o_get_info = mdc_get_info,
2384 .o_process_config = mdc_process_config,
2385 .o_get_uuid = mdc_get_uuid,
2386 .o_quotactl = mdc_quotactl,
2387 .o_quotacheck = mdc_quotacheck
2390 struct md_ops mdc_md_ops = {
2391 .m_getstatus = mdc_getstatus,
2392 .m_change_cbdata = mdc_change_cbdata,
2393 .m_find_cbdata = mdc_find_cbdata,
2394 .m_close = mdc_close,
2395 .m_create = mdc_create,
2396 .m_done_writing = mdc_done_writing,
2397 .m_enqueue = mdc_enqueue,
2398 .m_getattr = mdc_getattr,
2399 .m_getattr_name = mdc_getattr_name,
2400 .m_intent_lock = mdc_intent_lock,
2402 .m_is_subdir = mdc_is_subdir,
2403 .m_rename = mdc_rename,
2404 .m_setattr = mdc_setattr,
2405 .m_setxattr = mdc_setxattr,
2406 .m_getxattr = mdc_getxattr,
2408 .m_readpage = mdc_readpage,
2409 .m_unlink = mdc_unlink,
2410 .m_cancel_unused = mdc_cancel_unused,
2411 .m_init_ea_size = mdc_init_ea_size,
2412 .m_set_lock_data = mdc_set_lock_data,
2413 .m_lock_match = mdc_lock_match,
2414 .m_get_lustre_md = mdc_get_lustre_md,
2415 .m_free_lustre_md = mdc_free_lustre_md,
2416 .m_set_open_replay_data = mdc_set_open_replay_data,
2417 .m_clear_open_replay_data = mdc_clear_open_replay_data,
2418 .m_renew_capa = mdc_renew_capa,
2419 .m_unpack_capa = mdc_unpack_capa,
2420 .m_get_remote_perm = mdc_get_remote_perm,
2421 .m_intent_getattr_async = mdc_intent_getattr_async,
2422 .m_revalidate_lock = mdc_revalidate_lock
2425 int __init mdc_init(void)
2428 struct lprocfs_static_vars lvars = { 0 };
2429 lprocfs_mdc_init_vars(&lvars);
2431 rc = class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
2432 LUSTRE_MDC_NAME, NULL);
2437 static void /*__exit*/ mdc_exit(void)
2439 class_unregister_type(LUSTRE_MDC_NAME);
2442 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2443 MODULE_DESCRIPTION("Lustre Metadata Client");
2444 MODULE_LICENSE("GPL");
2446 module_init(mdc_init);
2447 module_exit(mdc_exit);