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, 2015, Intel Corporation.
33 * This file is part of Lustre, http://www.lustre.org/
34 * Lustre is a trademark of Sun Microsystems, Inc.
37 #define DEBUG_SUBSYSTEM S_MDC
39 # include <linux/module.h>
40 # include <linux/pagemap.h>
41 # include <linux/miscdevice.h>
42 # include <linux/init.h>
43 # include <linux/utsname.h>
45 #include "../include/lustre_acl.h"
46 #include "../include/obd_class.h"
47 #include "../include/lustre_fid.h"
48 #include "../include/lprocfs_status.h"
49 #include "../include/lustre_param.h"
50 #include "../include/lustre_log.h"
52 #include "mdc_internal.h"
54 #define REQUEST_MINOR 244
56 static int mdc_cleanup(struct obd_device *obd);
58 static inline int mdc_queue_wait(struct ptlrpc_request *req)
60 struct client_obd *cli = &req->rq_import->imp_obd->u.cli;
63 /* mdc_enter_request() ensures that this client has no more
64 * than cl_max_rpcs_in_flight RPCs simultaneously inf light
66 rc = mdc_enter_request(cli);
70 rc = ptlrpc_queue_wait(req);
71 mdc_exit_request(cli);
76 static int mdc_getstatus(struct obd_export *exp, struct lu_fid *rootfid)
78 struct ptlrpc_request *req;
79 struct mdt_body *body;
82 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
84 LUSTRE_MDS_VERSION, MDS_GETSTATUS);
88 mdc_pack_body(req, NULL, 0, 0, -1, 0);
89 req->rq_send_state = LUSTRE_IMP_FULL;
91 ptlrpc_request_set_replen(req);
93 rc = ptlrpc_queue_wait(req);
97 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
103 *rootfid = body->fid1;
105 "root fid="DFID", last_committed=%llu\n",
107 lustre_msg_get_last_committed(req->rq_repmsg));
109 ptlrpc_req_finished(req);
114 * This function now is known to always saying that it will receive 4 buffers
115 * from server. Even for cases when acl_size and md_size is zero, RPC header
116 * will contain 4 fields and RPC itself will contain zero size fields. This is
117 * because mdt_getattr*() _always_ returns 4 fields, but if acl is not needed
118 * and thus zero, it shrinks it, making zero size. The same story about
119 * md_size. And this is course of problem when client waits for smaller number
120 * of fields. This issue will be fixed later when client gets aware of RPC
123 static int mdc_getattr_common(struct obd_export *exp,
124 struct ptlrpc_request *req)
126 struct req_capsule *pill = &req->rq_pill;
127 struct mdt_body *body;
131 /* Request message already built. */
132 rc = ptlrpc_queue_wait(req);
136 /* sanity check for the reply */
137 body = req_capsule_server_get(pill, &RMF_MDT_BODY);
141 CDEBUG(D_NET, "mode: %o\n", body->mode);
143 if (body->eadatasize != 0) {
144 mdc_update_max_ea_from_body(exp, body);
146 eadata = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
152 if (body->valid & OBD_MD_FLRMTPERM) {
153 struct mdt_remote_perm *perm;
155 LASSERT(client_is_remote(exp));
156 perm = req_capsule_server_swab_get(pill, &RMF_ACL,
157 lustre_swab_mdt_remote_perm);
165 static int mdc_getattr(struct obd_export *exp, struct md_op_data *op_data,
166 struct ptlrpc_request **request)
168 struct ptlrpc_request *req;
171 /* Single MDS without an LMV case */
172 if (op_data->op_flags & MF_GET_MDT_IDX) {
177 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
181 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
183 ptlrpc_request_free(req);
187 mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid,
188 op_data->op_mode, -1, 0);
190 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
192 if (op_data->op_valid & OBD_MD_FLRMTPERM) {
193 LASSERT(client_is_remote(exp));
194 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
195 sizeof(struct mdt_remote_perm));
197 ptlrpc_request_set_replen(req);
199 rc = mdc_getattr_common(exp, req);
201 ptlrpc_req_finished(req);
207 static int mdc_getattr_name(struct obd_export *exp, struct md_op_data *op_data,
208 struct ptlrpc_request **request)
210 struct ptlrpc_request *req;
214 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
215 &RQF_MDS_GETATTR_NAME);
219 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
220 op_data->op_namelen + 1);
222 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR_NAME);
224 ptlrpc_request_free(req);
228 mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid,
229 op_data->op_mode, op_data->op_suppgids[0], 0);
231 if (op_data->op_name) {
232 char *name = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
234 LASSERT(strnlen(op_data->op_name, op_data->op_namelen) ==
235 op_data->op_namelen);
236 memcpy(name, op_data->op_name, op_data->op_namelen);
239 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
241 ptlrpc_request_set_replen(req);
243 rc = mdc_getattr_common(exp, req);
245 ptlrpc_req_finished(req);
251 static int mdc_is_subdir(struct obd_export *exp,
252 const struct lu_fid *pfid,
253 const struct lu_fid *cfid,
254 struct ptlrpc_request **request)
256 struct ptlrpc_request *req;
260 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
261 &RQF_MDS_IS_SUBDIR, LUSTRE_MDS_VERSION,
266 mdc_is_subdir_pack(req, pfid, cfid, 0);
267 ptlrpc_request_set_replen(req);
269 rc = ptlrpc_queue_wait(req);
270 if (rc && rc != -EREMOTE)
271 ptlrpc_req_finished(req);
277 static int mdc_xattr_common(struct obd_export *exp,
278 const struct req_format *fmt,
279 const struct lu_fid *fid,
280 int opcode, u64 valid,
281 const char *xattr_name, const char *input,
282 int input_size, int output_size, int flags,
283 __u32 suppgid, struct ptlrpc_request **request)
285 struct ptlrpc_request *req;
286 int xattr_namelen = 0;
291 req = ptlrpc_request_alloc(class_exp2cliimp(exp), fmt);
296 xattr_namelen = strlen(xattr_name) + 1;
297 req_capsule_set_size(&req->rq_pill, &RMF_NAME, RCL_CLIENT,
302 req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_CLIENT,
306 /* Flush local XATTR locks to get rid of a possible cancel RPC */
307 if (opcode == MDS_REINT && fid_is_sane(fid) &&
308 exp->exp_connect_data.ocd_ibits_known & MDS_INODELOCK_XATTR) {
312 /* Without that packing would fail */
314 req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
317 count = mdc_resource_get_unused(exp, fid,
319 MDS_INODELOCK_XATTR);
321 rc = mdc_prep_elc_req(exp, req, MDS_REINT, &cancels, count);
323 ptlrpc_request_free(req);
327 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, opcode);
329 ptlrpc_request_free(req);
334 if (opcode == MDS_REINT) {
335 struct mdt_rec_setxattr *rec;
337 CLASSERT(sizeof(struct mdt_rec_setxattr) ==
338 sizeof(struct mdt_rec_reint));
339 rec = req_capsule_client_get(&req->rq_pill, &RMF_REC_REINT);
340 rec->sx_opcode = REINT_SETXATTR;
341 rec->sx_fsuid = from_kuid(&init_user_ns, current_fsuid());
342 rec->sx_fsgid = from_kgid(&init_user_ns, current_fsgid());
343 rec->sx_cap = cfs_curproc_cap_pack();
344 rec->sx_suppgid1 = suppgid;
345 rec->sx_suppgid2 = -1;
347 rec->sx_valid = valid | OBD_MD_FLCTIME;
348 rec->sx_time = ktime_get_real_seconds();
349 rec->sx_size = output_size;
350 rec->sx_flags = flags;
353 mdc_pack_body(req, fid, valid, output_size, suppgid, flags);
357 tmp = req_capsule_client_get(&req->rq_pill, &RMF_NAME);
358 memcpy(tmp, xattr_name, xattr_namelen);
361 tmp = req_capsule_client_get(&req->rq_pill, &RMF_EADATA);
362 memcpy(tmp, input, input_size);
365 if (req_capsule_has_field(&req->rq_pill, &RMF_EADATA, RCL_SERVER))
366 req_capsule_set_size(&req->rq_pill, &RMF_EADATA,
367 RCL_SERVER, output_size);
368 ptlrpc_request_set_replen(req);
371 if (opcode == MDS_REINT)
372 mdc_get_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
374 rc = ptlrpc_queue_wait(req);
376 if (opcode == MDS_REINT)
377 mdc_put_rpc_lock(exp->exp_obd->u.cli.cl_rpc_lock, NULL);
380 ptlrpc_req_finished(req);
386 static int mdc_setxattr(struct obd_export *exp, const struct lu_fid *fid,
387 u64 valid, const char *xattr_name,
388 const char *input, int input_size, int output_size,
389 int flags, __u32 suppgid,
390 struct ptlrpc_request **request)
392 return mdc_xattr_common(exp, &RQF_MDS_REINT_SETXATTR,
393 fid, MDS_REINT, valid, xattr_name,
394 input, input_size, output_size, flags,
398 static int mdc_getxattr(struct obd_export *exp, const struct lu_fid *fid,
399 u64 valid, const char *xattr_name,
400 const char *input, int input_size, int output_size,
401 int flags, struct ptlrpc_request **request)
403 return mdc_xattr_common(exp, &RQF_MDS_GETXATTR,
404 fid, MDS_GETXATTR, valid, xattr_name,
405 input, input_size, output_size, flags,
409 #ifdef CONFIG_FS_POSIX_ACL
410 static int mdc_unpack_acl(struct ptlrpc_request *req, struct lustre_md *md)
412 struct req_capsule *pill = &req->rq_pill;
413 struct mdt_body *body = md->body;
414 struct posix_acl *acl;
421 buf = req_capsule_server_sized_get(pill, &RMF_ACL, body->aclsize);
426 acl = posix_acl_from_xattr(&init_user_ns, buf, body->aclsize);
432 CERROR("convert xattr to acl: %d\n", rc);
436 rc = posix_acl_valid(acl);
438 CERROR("validate acl: %d\n", rc);
439 posix_acl_release(acl);
447 #define mdc_unpack_acl(req, md) 0
450 static int mdc_get_lustre_md(struct obd_export *exp,
451 struct ptlrpc_request *req,
452 struct obd_export *dt_exp,
453 struct obd_export *md_exp,
454 struct lustre_md *md)
456 struct req_capsule *pill = &req->rq_pill;
460 memset(md, 0, sizeof(*md));
462 md->body = req_capsule_server_get(pill, &RMF_MDT_BODY);
463 LASSERT(md->body != NULL);
465 if (md->body->valid & OBD_MD_FLEASIZE) {
467 struct lov_mds_md *lmm;
469 if (!S_ISREG(md->body->mode)) {
471 "OBD_MD_FLEASIZE set, should be a regular file, but is not\n");
476 if (md->body->eadatasize == 0) {
478 "OBD_MD_FLEASIZE set, but eadatasize 0\n");
482 lmmsize = md->body->eadatasize;
483 lmm = req_capsule_server_sized_get(pill, &RMF_MDT_MD, lmmsize);
489 rc = obd_unpackmd(dt_exp, &md->lsm, lmm, lmmsize);
493 if (rc < sizeof(*md->lsm)) {
495 "lsm size too small: rc < sizeof (*md->lsm) (%d < %d)\n",
496 rc, (int)sizeof(*md->lsm));
501 } else if (md->body->valid & OBD_MD_FLDIREA) {
503 struct lov_mds_md *lmv;
505 if (!S_ISDIR(md->body->mode)) {
507 "OBD_MD_FLDIREA set, should be a directory, but is not\n");
512 if (md->body->eadatasize == 0) {
514 "OBD_MD_FLDIREA is set, but eadatasize 0\n");
517 if (md->body->valid & OBD_MD_MEA) {
518 lmvsize = md->body->eadatasize;
519 lmv = req_capsule_server_sized_get(pill, &RMF_MDT_MD,
526 rc = obd_unpackmd(md_exp, (void *)&md->mea, lmv,
531 if (rc < sizeof(*md->mea)) {
533 "size too small: rc < sizeof(*md->mea) (%d < %d)\n",
534 rc, (int)sizeof(*md->mea));
542 if (md->body->valid & OBD_MD_FLRMTPERM) {
543 /* remote permission */
544 LASSERT(client_is_remote(exp));
545 md->remote_perm = req_capsule_server_swab_get(pill, &RMF_ACL,
546 lustre_swab_mdt_remote_perm);
547 if (!md->remote_perm) {
551 } else if (md->body->valid & OBD_MD_FLACL) {
552 /* for ACL, it's possible that FLACL is set but aclsize is zero.
553 * only when aclsize != 0 there's an actual segment for ACL
556 if (md->body->aclsize) {
557 rc = mdc_unpack_acl(req, md);
560 #ifdef CONFIG_FS_POSIX_ACL
562 md->posix_acl = NULL;
569 #ifdef CONFIG_FS_POSIX_ACL
570 posix_acl_release(md->posix_acl);
573 obd_free_memmd(dt_exp, &md->lsm);
578 static int mdc_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
584 * Handles both OPEN and SETATTR RPCs for OPEN-CLOSE and SETATTR-DONE_WRITING
587 void mdc_replay_open(struct ptlrpc_request *req)
589 struct md_open_data *mod = req->rq_cb_data;
590 struct ptlrpc_request *close_req;
591 struct obd_client_handle *och;
592 struct lustre_handle old;
593 struct mdt_body *body;
596 DEBUG_REQ(D_ERROR, req,
597 "Can't properly replay without open data.");
601 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
602 LASSERT(body != NULL);
606 struct lustre_handle *file_fh;
608 LASSERT(och->och_magic == OBD_CLIENT_HANDLE_MAGIC);
610 file_fh = &och->och_fh;
611 CDEBUG(D_HA, "updating handle from %#llx to %#llx\n",
612 file_fh->cookie, body->handle.cookie);
614 *file_fh = body->handle;
616 close_req = mod->mod_close_req;
617 if (close_req != NULL) {
618 __u32 opc = lustre_msg_get_opc(close_req->rq_reqmsg);
619 struct mdt_ioepoch *epoch;
621 LASSERT(opc == MDS_CLOSE || opc == MDS_DONE_WRITING);
622 epoch = req_capsule_client_get(&close_req->rq_pill,
627 LASSERT(!memcmp(&old, &epoch->handle, sizeof(old)));
628 DEBUG_REQ(D_HA, close_req, "updating close body with new fh");
629 epoch->handle = body->handle;
633 void mdc_commit_open(struct ptlrpc_request *req)
635 struct md_open_data *mod = req->rq_cb_data;
641 * No need to touch md_open_data::mod_och, it holds a reference on
642 * \var mod and will zero references to each other, \var mod will be
643 * freed after that when md_open_data::mod_och will put the reference.
647 * Do not let open request to disappear as it still may be needed
648 * for close rpc to happen (it may happen on evict only, otherwise
649 * ptlrpc_request::rq_replay does not let mdc_commit_open() to be
650 * called), just mark this rpc as committed to distinguish these 2
651 * cases, see mdc_close() for details. The open request reference will
652 * be put along with freeing \var mod.
654 ptlrpc_request_addref(req);
655 spin_lock(&req->rq_lock);
656 req->rq_committed = 1;
657 spin_unlock(&req->rq_lock);
658 req->rq_cb_data = NULL;
662 int mdc_set_open_replay_data(struct obd_export *exp,
663 struct obd_client_handle *och,
664 struct lookup_intent *it)
666 struct md_open_data *mod;
667 struct mdt_rec_create *rec;
668 struct mdt_body *body;
669 struct ptlrpc_request *open_req = it->d.lustre.it_data;
670 struct obd_import *imp = open_req->rq_import;
672 if (!open_req->rq_replay)
675 rec = req_capsule_client_get(&open_req->rq_pill, &RMF_REC_REINT);
676 body = req_capsule_server_get(&open_req->rq_pill, &RMF_MDT_BODY);
677 LASSERT(rec != NULL);
678 /* Incoming message in my byte order (it's been swabbed). */
679 /* Outgoing messages always in my byte order. */
680 LASSERT(body != NULL);
682 /* Only if the import is replayable, we set replay_open data */
683 if (och && imp->imp_replayable) {
684 mod = obd_mod_alloc();
686 DEBUG_REQ(D_ERROR, open_req,
687 "Can't allocate md_open_data");
692 * Take a reference on \var mod, to be freed on mdc_close().
693 * It protects \var mod from being freed on eviction (commit
694 * callback is called despite rq_replay flag).
695 * Another reference for \var och.
700 spin_lock(&open_req->rq_lock);
703 mod->mod_is_create = it_disposition(it, DISP_OPEN_CREATE) ||
704 it_disposition(it, DISP_OPEN_STRIPE);
705 mod->mod_open_req = open_req;
706 open_req->rq_cb_data = mod;
707 open_req->rq_commit_cb = mdc_commit_open;
708 spin_unlock(&open_req->rq_lock);
711 rec->cr_fid2 = body->fid1;
712 rec->cr_ioepoch = body->ioepoch;
713 rec->cr_old_handle.cookie = body->handle.cookie;
714 open_req->rq_replay_cb = mdc_replay_open;
715 if (!fid_is_sane(&body->fid1)) {
716 DEBUG_REQ(D_ERROR, open_req,
717 "Saving replay request with insane fid");
721 DEBUG_REQ(D_RPCTRACE, open_req, "Set up open replay data");
725 static void mdc_free_open(struct md_open_data *mod)
729 if (mod->mod_is_create == 0 &&
730 imp_connect_disp_stripe(mod->mod_open_req->rq_import))
733 LASSERT(mod->mod_open_req->rq_replay == 0);
735 DEBUG_REQ(D_RPCTRACE, mod->mod_open_req, "free open request\n");
737 ptlrpc_request_committed(mod->mod_open_req, committed);
738 if (mod->mod_close_req)
739 ptlrpc_request_committed(mod->mod_close_req, committed);
742 static int mdc_clear_open_replay_data(struct obd_export *exp,
743 struct obd_client_handle *och)
745 struct md_open_data *mod = och->och_mod;
748 * It is possible to not have \var mod in a case of eviction between
749 * lookup and ll_file_open().
754 LASSERT(mod != LP_POISON);
755 LASSERT(mod->mod_open_req != NULL);
765 /* Prepares the request for the replay by the given reply */
766 static void mdc_close_handle_reply(struct ptlrpc_request *req,
767 struct md_op_data *op_data, int rc) {
768 struct mdt_body *repbody;
769 struct mdt_ioepoch *epoch;
771 if (req && rc == -EAGAIN) {
772 repbody = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
773 epoch = req_capsule_client_get(&req->rq_pill, &RMF_MDT_EPOCH);
775 epoch->flags |= MF_SOM_AU;
776 if (repbody->valid & OBD_MD_FLGETATTRLOCK)
777 op_data->op_flags |= MF_GETATTR_LOCK;
781 static int mdc_close(struct obd_export *exp, struct md_op_data *op_data,
782 struct md_open_data *mod, struct ptlrpc_request **request)
784 struct obd_device *obd = class_exp2obd(exp);
785 struct ptlrpc_request *req;
786 struct req_format *req_fmt;
790 req_fmt = &RQF_MDS_CLOSE;
791 if (op_data->op_bias & MDS_HSM_RELEASE) {
792 req_fmt = &RQF_MDS_RELEASE_CLOSE;
794 /* allocate a FID for volatile file */
795 rc = mdc_fid_alloc(exp, &op_data->op_fid2, op_data);
797 CERROR("%s: "DFID" failed to allocate FID: %d\n",
798 obd->obd_name, PFID(&op_data->op_fid1), rc);
799 /* save the errcode and proceed to close */
805 req = ptlrpc_request_alloc(class_exp2cliimp(exp), req_fmt);
809 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_CLOSE);
811 ptlrpc_request_free(req);
815 /* To avoid a livelock (bug 7034), we need to send CLOSE RPCs to a
816 * portal whose threads are not taking any DLM locks and are therefore
817 * always progressing */
818 req->rq_request_portal = MDS_READPAGE_PORTAL;
819 ptlrpc_at_set_req_timeout(req);
821 /* Ensure that this close's handle is fixed up during replay. */
822 if (likely(mod != NULL)) {
823 LASSERTF(mod->mod_open_req != NULL &&
824 mod->mod_open_req->rq_type != LI_POISON,
825 "POISONED open %p!\n", mod->mod_open_req);
827 mod->mod_close_req = req;
829 DEBUG_REQ(D_HA, mod->mod_open_req, "matched open");
830 /* We no longer want to preserve this open for replay even
831 * though the open was committed. b=3632, b=3633 */
832 spin_lock(&mod->mod_open_req->rq_lock);
833 mod->mod_open_req->rq_replay = 0;
834 spin_unlock(&mod->mod_open_req->rq_lock);
837 "couldn't find open req; expecting close error\n");
840 mdc_close_pack(req, op_data);
842 req_capsule_set_size(&req->rq_pill, &RMF_MDT_MD, RCL_SERVER,
843 obd->u.cli.cl_default_mds_easize);
844 req_capsule_set_size(&req->rq_pill, &RMF_LOGCOOKIES, RCL_SERVER,
845 obd->u.cli.cl_default_mds_cookiesize);
847 ptlrpc_request_set_replen(req);
849 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
850 rc = ptlrpc_queue_wait(req);
851 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
853 if (req->rq_repmsg == NULL) {
854 CDEBUG(D_RPCTRACE, "request failed to send: %p, %d\n", req,
857 rc = req->rq_status ?: -EIO;
858 } else if (rc == 0 || rc == -EAGAIN) {
859 struct mdt_body *body;
861 rc = lustre_msg_get_status(req->rq_repmsg);
862 if (lustre_msg_get_type(req->rq_repmsg) == PTL_RPC_MSG_ERR) {
863 DEBUG_REQ(D_ERROR, req,
864 "type == PTL_RPC_MSG_ERR, err = %d", rc);
868 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
871 } else if (rc == -ESTALE) {
873 * it can be allowed error after 3633 if open was committed and
874 * server failed before close was sent. Let's check if mod
875 * exists and return no error in that case
878 DEBUG_REQ(D_HA, req, "Reset ESTALE = %d", rc);
879 LASSERT(mod->mod_open_req != NULL);
880 if (mod->mod_open_req->rq_committed)
887 mod->mod_close_req = NULL;
888 /* Since now, mod is accessed through open_req only,
889 * thus close req does not keep a reference on mod anymore. */
893 mdc_close_handle_reply(req, op_data, rc);
894 return rc < 0 ? rc : saved_rc;
897 static int mdc_done_writing(struct obd_export *exp, struct md_op_data *op_data,
898 struct md_open_data *mod)
900 struct obd_device *obd = class_exp2obd(exp);
901 struct ptlrpc_request *req;
904 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
905 &RQF_MDS_DONE_WRITING);
909 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_DONE_WRITING);
911 ptlrpc_request_free(req);
916 LASSERTF(mod->mod_open_req != NULL &&
917 mod->mod_open_req->rq_type != LI_POISON,
918 "POISONED setattr %p!\n", mod->mod_open_req);
920 mod->mod_close_req = req;
921 DEBUG_REQ(D_HA, mod->mod_open_req, "matched setattr");
922 /* We no longer want to preserve this setattr for replay even
923 * though the open was committed. b=3632, b=3633 */
924 spin_lock(&mod->mod_open_req->rq_lock);
925 mod->mod_open_req->rq_replay = 0;
926 spin_unlock(&mod->mod_open_req->rq_lock);
929 mdc_close_pack(req, op_data);
930 ptlrpc_request_set_replen(req);
932 mdc_get_rpc_lock(obd->u.cli.cl_close_lock, NULL);
933 rc = ptlrpc_queue_wait(req);
934 mdc_put_rpc_lock(obd->u.cli.cl_close_lock, NULL);
938 * it can be allowed error after 3633 if open or setattr were
939 * committed and server failed before close was sent.
940 * Let's check if mod exists and return no error in that case
943 LASSERT(mod->mod_open_req != NULL);
944 if (mod->mod_open_req->rq_committed)
951 mod->mod_close_req = NULL;
952 LASSERT(mod->mod_open_req != NULL);
955 /* Since now, mod is accessed through setattr req only,
956 * thus DW req does not keep a reference on mod anymore. */
960 mdc_close_handle_reply(req, op_data, rc);
961 ptlrpc_req_finished(req);
965 static int mdc_readpage(struct obd_export *exp, struct md_op_data *op_data,
966 struct page **pages, struct ptlrpc_request **request)
968 struct ptlrpc_request *req;
969 struct ptlrpc_bulk_desc *desc;
971 wait_queue_head_t waitq;
973 struct l_wait_info lwi;
977 init_waitqueue_head(&waitq);
980 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_READPAGE);
984 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_READPAGE);
986 ptlrpc_request_free(req);
990 req->rq_request_portal = MDS_READPAGE_PORTAL;
991 ptlrpc_at_set_req_timeout(req);
993 desc = ptlrpc_prep_bulk_imp(req, op_data->op_npages, 1, BULK_PUT_SINK,
996 ptlrpc_request_free(req);
1000 /* NB req now owns desc and will free it when it gets freed */
1001 for (i = 0; i < op_data->op_npages; i++)
1002 ptlrpc_prep_bulk_page_pin(desc, pages[i], 0, PAGE_CACHE_SIZE);
1004 mdc_readdir_pack(req, op_data->op_offset,
1005 PAGE_CACHE_SIZE * op_data->op_npages,
1008 ptlrpc_request_set_replen(req);
1009 rc = ptlrpc_queue_wait(req);
1011 ptlrpc_req_finished(req);
1012 if (rc != -ETIMEDOUT)
1016 if (!client_should_resend(resends, &exp->exp_obd->u.cli)) {
1017 CERROR("too many resend retries, returning error\n");
1020 lwi = LWI_TIMEOUT_INTR(cfs_time_seconds(resends),
1022 l_wait_event(waitq, 0, &lwi);
1027 rc = sptlrpc_cli_unwrap_bulk_read(req, req->rq_bulk,
1028 req->rq_bulk->bd_nob_transferred);
1030 ptlrpc_req_finished(req);
1034 if (req->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK) {
1035 CERROR("Unexpected # bytes transferred: %d (%ld expected)\n",
1036 req->rq_bulk->bd_nob_transferred,
1037 PAGE_CACHE_SIZE * op_data->op_npages);
1038 ptlrpc_req_finished(req);
1046 static int mdc_statfs(const struct lu_env *env,
1047 struct obd_export *exp, struct obd_statfs *osfs,
1048 __u64 max_age, __u32 flags)
1050 struct obd_device *obd = class_exp2obd(exp);
1051 struct ptlrpc_request *req;
1052 struct obd_statfs *msfs;
1053 struct obd_import *imp = NULL;
1057 * Since the request might also come from lprocfs, so we need
1058 * sync this with client_disconnect_export Bug15684
1060 down_read(&obd->u.cli.cl_sem);
1061 if (obd->u.cli.cl_import)
1062 imp = class_import_get(obd->u.cli.cl_import);
1063 up_read(&obd->u.cli.cl_sem);
1067 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_STATFS,
1068 LUSTRE_MDS_VERSION, MDS_STATFS);
1074 ptlrpc_request_set_replen(req);
1076 if (flags & OBD_STATFS_NODELAY) {
1077 /* procfs requests not want stay in wait for avoid deadlock */
1078 req->rq_no_resend = 1;
1079 req->rq_no_delay = 1;
1082 rc = ptlrpc_queue_wait(req);
1084 /* check connection error first */
1085 if (imp->imp_connect_error)
1086 rc = imp->imp_connect_error;
1090 msfs = req_capsule_server_get(&req->rq_pill, &RMF_OBD_STATFS);
1098 ptlrpc_req_finished(req);
1100 class_import_put(imp);
1104 static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
1106 __u32 keylen, vallen;
1110 if (gf->gf_pathlen > PATH_MAX)
1111 return -ENAMETOOLONG;
1112 if (gf->gf_pathlen < 2)
1115 /* Key is KEY_FID2PATH + getinfo_fid2path description */
1116 keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
1117 key = kzalloc(keylen, GFP_NOFS);
1120 memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
1121 memcpy(key + cfs_size_round(sizeof(KEY_FID2PATH)), gf, sizeof(*gf));
1123 CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n",
1124 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno);
1126 if (!fid_is_sane(&gf->gf_fid)) {
1131 /* Val is struct getinfo_fid2path result plus path */
1132 vallen = sizeof(*gf) + gf->gf_pathlen;
1134 rc = obd_get_info(NULL, exp, keylen, key, &vallen, gf, NULL);
1135 if (rc != 0 && rc != -EREMOTE)
1138 if (vallen <= sizeof(*gf)) {
1141 } else if (vallen > sizeof(*gf) + gf->gf_pathlen) {
1146 CDEBUG(D_IOCTL, "path get "DFID" from %llu #%d\n%s\n",
1147 PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
1154 static int mdc_ioc_hsm_progress(struct obd_export *exp,
1155 struct hsm_progress_kernel *hpk)
1157 struct obd_import *imp = class_exp2cliimp(exp);
1158 struct hsm_progress_kernel *req_hpk;
1159 struct ptlrpc_request *req;
1162 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_PROGRESS,
1163 LUSTRE_MDS_VERSION, MDS_HSM_PROGRESS);
1169 mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
1171 /* Copy hsm_progress struct */
1172 req_hpk = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_PROGRESS);
1173 if (req_hpk == NULL) {
1179 req_hpk->hpk_errval = lustre_errno_hton(hpk->hpk_errval);
1181 ptlrpc_request_set_replen(req);
1183 rc = mdc_queue_wait(req);
1185 ptlrpc_req_finished(req);
1189 static int mdc_ioc_hsm_ct_register(struct obd_import *imp, __u32 archives)
1191 __u32 *archive_mask;
1192 struct ptlrpc_request *req;
1195 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_REGISTER,
1197 MDS_HSM_CT_REGISTER);
1203 mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
1205 /* Copy hsm_progress struct */
1206 archive_mask = req_capsule_client_get(&req->rq_pill,
1207 &RMF_MDS_HSM_ARCHIVE);
1208 if (archive_mask == NULL) {
1213 *archive_mask = archives;
1215 ptlrpc_request_set_replen(req);
1217 rc = mdc_queue_wait(req);
1219 ptlrpc_req_finished(req);
1223 static int mdc_ioc_hsm_current_action(struct obd_export *exp,
1224 struct md_op_data *op_data)
1226 struct hsm_current_action *hca = op_data->op_data;
1227 struct hsm_current_action *req_hca;
1228 struct ptlrpc_request *req;
1231 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
1232 &RQF_MDS_HSM_ACTION);
1236 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_ACTION);
1238 ptlrpc_request_free(req);
1242 mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0,
1243 op_data->op_suppgids[0], 0);
1245 ptlrpc_request_set_replen(req);
1247 rc = mdc_queue_wait(req);
1251 req_hca = req_capsule_server_get(&req->rq_pill,
1252 &RMF_MDS_HSM_CURRENT_ACTION);
1253 if (req_hca == NULL) {
1261 ptlrpc_req_finished(req);
1265 static int mdc_ioc_hsm_ct_unregister(struct obd_import *imp)
1267 struct ptlrpc_request *req;
1270 req = ptlrpc_request_alloc_pack(imp, &RQF_MDS_HSM_CT_UNREGISTER,
1272 MDS_HSM_CT_UNREGISTER);
1278 mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
1280 ptlrpc_request_set_replen(req);
1282 rc = mdc_queue_wait(req);
1284 ptlrpc_req_finished(req);
1288 static int mdc_ioc_hsm_state_get(struct obd_export *exp,
1289 struct md_op_data *op_data)
1291 struct hsm_user_state *hus = op_data->op_data;
1292 struct hsm_user_state *req_hus;
1293 struct ptlrpc_request *req;
1296 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
1297 &RQF_MDS_HSM_STATE_GET);
1301 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_GET);
1303 ptlrpc_request_free(req);
1307 mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0,
1308 op_data->op_suppgids[0], 0);
1310 ptlrpc_request_set_replen(req);
1312 rc = mdc_queue_wait(req);
1316 req_hus = req_capsule_server_get(&req->rq_pill, &RMF_HSM_USER_STATE);
1317 if (req_hus == NULL) {
1325 ptlrpc_req_finished(req);
1329 static int mdc_ioc_hsm_state_set(struct obd_export *exp,
1330 struct md_op_data *op_data)
1332 struct hsm_state_set *hss = op_data->op_data;
1333 struct hsm_state_set *req_hss;
1334 struct ptlrpc_request *req;
1337 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
1338 &RQF_MDS_HSM_STATE_SET);
1342 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_STATE_SET);
1344 ptlrpc_request_free(req);
1348 mdc_pack_body(req, &op_data->op_fid1, OBD_MD_FLRMTPERM, 0,
1349 op_data->op_suppgids[0], 0);
1352 req_hss = req_capsule_client_get(&req->rq_pill, &RMF_HSM_STATE_SET);
1353 if (req_hss == NULL) {
1359 ptlrpc_request_set_replen(req);
1361 rc = mdc_queue_wait(req);
1363 ptlrpc_req_finished(req);
1367 static int mdc_ioc_hsm_request(struct obd_export *exp,
1368 struct hsm_user_request *hur)
1370 struct obd_import *imp = class_exp2cliimp(exp);
1371 struct ptlrpc_request *req;
1372 struct hsm_request *req_hr;
1373 struct hsm_user_item *req_hui;
1377 req = ptlrpc_request_alloc(imp, &RQF_MDS_HSM_REQUEST);
1383 req_capsule_set_size(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM, RCL_CLIENT,
1384 hur->hur_request.hr_itemcount
1385 * sizeof(struct hsm_user_item));
1386 req_capsule_set_size(&req->rq_pill, &RMF_GENERIC_DATA, RCL_CLIENT,
1387 hur->hur_request.hr_data_len);
1389 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_HSM_REQUEST);
1391 ptlrpc_request_free(req);
1395 mdc_pack_body(req, NULL, OBD_MD_FLRMTPERM, 0, 0, 0);
1397 /* Copy hsm_request struct */
1398 req_hr = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_REQUEST);
1399 if (req_hr == NULL) {
1403 *req_hr = hur->hur_request;
1405 /* Copy hsm_user_item structs */
1406 req_hui = req_capsule_client_get(&req->rq_pill, &RMF_MDS_HSM_USER_ITEM);
1407 if (req_hui == NULL) {
1411 memcpy(req_hui, hur->hur_user_item,
1412 hur->hur_request.hr_itemcount * sizeof(struct hsm_user_item));
1414 /* Copy opaque field */
1415 req_opaque = req_capsule_client_get(&req->rq_pill, &RMF_GENERIC_DATA);
1416 if (req_opaque == NULL) {
1420 memcpy(req_opaque, hur_data(hur), hur->hur_request.hr_data_len);
1422 ptlrpc_request_set_replen(req);
1424 rc = mdc_queue_wait(req);
1426 ptlrpc_req_finished(req);
1430 static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags)
1432 struct kuc_hdr *lh = (struct kuc_hdr *)buf;
1434 LASSERT(len <= KUC_CHANGELOG_MSG_MAXSIZE);
1436 lh->kuc_magic = KUC_MAGIC;
1437 lh->kuc_transport = KUC_TRANSPORT_CHANGELOG;
1438 lh->kuc_flags = flags;
1439 lh->kuc_msgtype = CL_RECORD;
1440 lh->kuc_msglen = len;
1444 #define D_CHANGELOG 0
1446 struct changelog_show {
1451 struct obd_device *cs_obd;
1454 static int changelog_kkuc_cb(const struct lu_env *env, struct llog_handle *llh,
1455 struct llog_rec_hdr *hdr, void *data)
1457 struct changelog_show *cs = data;
1458 struct llog_changelog_rec *rec = (struct llog_changelog_rec *)hdr;
1462 if (rec->cr_hdr.lrh_type != CHANGELOG_REC) {
1464 CERROR("%s: not a changelog rec %x/%d: rc = %d\n",
1465 cs->cs_obd->obd_name, rec->cr_hdr.lrh_type,
1466 rec->cr.cr_type, rc);
1470 if (rec->cr.cr_index < cs->cs_startrec) {
1471 /* Skip entries earlier than what we are interested in */
1472 CDEBUG(D_CHANGELOG, "rec=%llu start=%llu\n",
1473 rec->cr.cr_index, cs->cs_startrec);
1477 CDEBUG(D_CHANGELOG, "%llu %02d%-5s %llu 0x%x t="DFID" p="DFID
1478 " %.*s\n", rec->cr.cr_index, rec->cr.cr_type,
1479 changelog_type2str(rec->cr.cr_type), rec->cr.cr_time,
1480 rec->cr.cr_flags & CLF_FLAGMASK,
1481 PFID(&rec->cr.cr_tfid), PFID(&rec->cr.cr_pfid),
1482 rec->cr.cr_namelen, changelog_rec_name(&rec->cr));
1484 len = sizeof(*lh) + changelog_rec_size(&rec->cr) + rec->cr.cr_namelen;
1486 /* Set up the message */
1487 lh = changelog_kuc_hdr(cs->cs_buf, len, cs->cs_flags);
1488 memcpy(lh + 1, &rec->cr, len - sizeof(*lh));
1490 rc = libcfs_kkuc_msg_put(cs->cs_fp, lh);
1491 CDEBUG(D_CHANGELOG, "kucmsg fp %p len %d rc %d\n", cs->cs_fp, len, rc);
1496 static int mdc_changelog_send_thread(void *csdata)
1498 struct changelog_show *cs = csdata;
1499 struct llog_ctxt *ctxt = NULL;
1500 struct llog_handle *llh = NULL;
1501 struct kuc_hdr *kuch;
1504 CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n",
1505 cs->cs_fp, cs->cs_startrec);
1507 cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS);
1513 /* Set up the remote catalog handle */
1514 ctxt = llog_get_context(cs->cs_obd, LLOG_CHANGELOG_REPL_CTXT);
1519 rc = llog_open(NULL, ctxt, &llh, NULL, CHANGELOG_CATALOG,
1522 CERROR("%s: fail to open changelog catalog: rc = %d\n",
1523 cs->cs_obd->obd_name, rc);
1526 rc = llog_init_handle(NULL, llh, LLOG_F_IS_CAT, NULL);
1528 CERROR("llog_init_handle failed %d\n", rc);
1532 rc = llog_cat_process(NULL, llh, changelog_kkuc_cb, cs, 0, 0);
1534 /* Send EOF no matter what our result */
1535 kuch = changelog_kuc_hdr(cs->cs_buf, sizeof(*kuch), cs->cs_flags);
1537 kuch->kuc_msgtype = CL_EOF;
1538 libcfs_kkuc_msg_put(cs->cs_fp, kuch);
1544 llog_cat_close(NULL, llh);
1546 llog_ctxt_put(ctxt);
1552 static int mdc_ioc_changelog_send(struct obd_device *obd,
1553 struct ioc_changelog *icc)
1555 struct changelog_show *cs;
1558 /* Freed in mdc_changelog_send_thread */
1559 cs = kzalloc(sizeof(*cs), GFP_NOFS);
1564 cs->cs_startrec = icc->icc_recno;
1565 /* matching fput in mdc_changelog_send_thread */
1566 cs->cs_fp = fget(icc->icc_id);
1567 cs->cs_flags = icc->icc_flags;
1570 * New thread because we should return to user app before
1571 * writing into our pipe
1573 rc = PTR_ERR(kthread_run(mdc_changelog_send_thread, cs,
1574 "mdc_clg_send_thread"));
1575 if (!IS_ERR_VALUE(rc)) {
1576 CDEBUG(D_CHANGELOG, "start changelog thread\n");
1580 CERROR("Failed to start changelog thread: %d\n", rc);
1585 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1586 struct lustre_kernelcomm *lk);
1588 static int mdc_quotacheck(struct obd_device *unused, struct obd_export *exp,
1589 struct obd_quotactl *oqctl)
1591 struct client_obd *cli = &exp->exp_obd->u.cli;
1592 struct ptlrpc_request *req;
1593 struct obd_quotactl *body;
1596 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
1597 &RQF_MDS_QUOTACHECK, LUSTRE_MDS_VERSION,
1602 body = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1605 ptlrpc_request_set_replen(req);
1607 /* the next poll will find -ENODATA, that means quotacheck is
1609 cli->cl_qchk_stat = -ENODATA;
1610 rc = ptlrpc_queue_wait(req);
1612 cli->cl_qchk_stat = rc;
1613 ptlrpc_req_finished(req);
1617 static int mdc_quota_poll_check(struct obd_export *exp,
1618 struct if_quotacheck *qchk)
1620 struct client_obd *cli = &exp->exp_obd->u.cli;
1623 qchk->obd_uuid = cli->cl_target_uuid;
1624 memcpy(qchk->obd_type, LUSTRE_MDS_NAME, strlen(LUSTRE_MDS_NAME));
1626 rc = cli->cl_qchk_stat;
1627 /* the client is not the previous one */
1628 if (rc == CL_NOT_QUOTACHECKED)
1633 static int mdc_quotactl(struct obd_device *unused, struct obd_export *exp,
1634 struct obd_quotactl *oqctl)
1636 struct ptlrpc_request *req;
1637 struct obd_quotactl *oqc;
1640 req = ptlrpc_request_alloc_pack(class_exp2cliimp(exp),
1641 &RQF_MDS_QUOTACTL, LUSTRE_MDS_VERSION,
1646 oqc = req_capsule_client_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1649 ptlrpc_request_set_replen(req);
1650 ptlrpc_at_set_req_timeout(req);
1651 req->rq_no_resend = 1;
1653 rc = ptlrpc_queue_wait(req);
1655 CERROR("ptlrpc_queue_wait failed, rc: %d\n", rc);
1657 if (req->rq_repmsg) {
1658 oqc = req_capsule_server_get(&req->rq_pill, &RMF_OBD_QUOTACTL);
1662 CERROR("Can't unpack obd_quotactl\n");
1666 CERROR("Can't unpack obd_quotactl\n");
1669 ptlrpc_req_finished(req);
1674 static int mdc_ioc_swap_layouts(struct obd_export *exp,
1675 struct md_op_data *op_data)
1678 struct ptlrpc_request *req;
1680 struct mdc_swap_layouts *msl, *payload;
1682 msl = op_data->op_data;
1684 /* When the MDT will get the MDS_SWAP_LAYOUTS RPC the
1685 * first thing it will do is to cancel the 2 layout
1686 * locks hold by this client.
1687 * So the client must cancel its layout locks on the 2 fids
1688 * with the request RPC to avoid extra RPC round trips
1690 count = mdc_resource_get_unused(exp, &op_data->op_fid1, &cancels,
1691 LCK_CR, MDS_INODELOCK_LAYOUT);
1692 count += mdc_resource_get_unused(exp, &op_data->op_fid2, &cancels,
1693 LCK_CR, MDS_INODELOCK_LAYOUT);
1695 req = ptlrpc_request_alloc(class_exp2cliimp(exp),
1696 &RQF_MDS_SWAP_LAYOUTS);
1698 ldlm_lock_list_put(&cancels, l_bl_ast, count);
1702 rc = mdc_prep_elc_req(exp, req, MDS_SWAP_LAYOUTS, &cancels, count);
1704 ptlrpc_request_free(req);
1708 mdc_swap_layouts_pack(req, op_data);
1710 payload = req_capsule_client_get(&req->rq_pill, &RMF_SWAP_LAYOUTS);
1715 ptlrpc_request_set_replen(req);
1717 rc = ptlrpc_queue_wait(req);
1719 ptlrpc_req_finished(req);
1723 static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
1724 void *karg, void *uarg)
1726 struct obd_device *obd = exp->exp_obd;
1727 struct obd_ioctl_data *data = karg;
1728 struct obd_import *imp = obd->u.cli.cl_import;
1731 if (!try_module_get(THIS_MODULE)) {
1732 CERROR("Can't get module. Is it alive?");
1736 case OBD_IOC_CHANGELOG_SEND:
1737 rc = mdc_ioc_changelog_send(obd, karg);
1739 case OBD_IOC_CHANGELOG_CLEAR: {
1740 struct ioc_changelog *icc = karg;
1741 struct changelog_setinfo cs = {
1742 .cs_recno = icc->icc_recno,
1743 .cs_id = icc->icc_id
1746 rc = obd_set_info_async(NULL, exp, strlen(KEY_CHANGELOG_CLEAR),
1747 KEY_CHANGELOG_CLEAR, sizeof(cs), &cs,
1751 case OBD_IOC_FID2PATH:
1752 rc = mdc_ioc_fid2path(exp, karg);
1754 case LL_IOC_HSM_CT_START:
1755 rc = mdc_ioc_hsm_ct_start(exp, karg);
1756 /* ignore if it was already registered on this MDS. */
1760 case LL_IOC_HSM_PROGRESS:
1761 rc = mdc_ioc_hsm_progress(exp, karg);
1763 case LL_IOC_HSM_STATE_GET:
1764 rc = mdc_ioc_hsm_state_get(exp, karg);
1766 case LL_IOC_HSM_STATE_SET:
1767 rc = mdc_ioc_hsm_state_set(exp, karg);
1769 case LL_IOC_HSM_ACTION:
1770 rc = mdc_ioc_hsm_current_action(exp, karg);
1772 case LL_IOC_HSM_REQUEST:
1773 rc = mdc_ioc_hsm_request(exp, karg);
1775 case OBD_IOC_CLIENT_RECOVER:
1776 rc = ptlrpc_recover_import(imp, data->ioc_inlbuf1, 0);
1781 case IOC_OSC_SET_ACTIVE:
1782 rc = ptlrpc_set_import_active(imp, data->ioc_offset);
1784 case OBD_IOC_POLL_QUOTACHECK:
1785 rc = mdc_quota_poll_check(exp, (struct if_quotacheck *)karg);
1787 case OBD_IOC_PING_TARGET:
1788 rc = ptlrpc_obd_ping(obd);
1791 * Normally IOC_OBD_STATFS, OBD_IOC_QUOTACTL iocontrol are handled by
1792 * LMV instead of MDC. But when the cluster is upgraded from 1.8,
1793 * there'd be no LMV layer thus we might be called here. Eventually
1794 * this code should be removed.
1797 case IOC_OBD_STATFS: {
1798 struct obd_statfs stat_buf = {0};
1800 if (*((__u32 *) data->ioc_inlbuf2) != 0) {
1806 if (copy_to_user(data->ioc_pbuf2, obd2cli_tgt(obd),
1807 min_t(size_t, data->ioc_plen2,
1808 sizeof(struct obd_uuid)))) {
1813 rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf,
1814 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
1819 if (copy_to_user(data->ioc_pbuf1, &stat_buf,
1820 min_t(size_t, data->ioc_plen1,
1821 sizeof(stat_buf)))) {
1829 case OBD_IOC_QUOTACTL: {
1830 struct if_quotactl *qctl = karg;
1831 struct obd_quotactl *oqctl;
1833 oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
1839 QCTL_COPY(oqctl, qctl);
1840 rc = obd_quotactl(exp, oqctl);
1842 QCTL_COPY(qctl, oqctl);
1843 qctl->qc_valid = QC_MDTIDX;
1844 qctl->obd_uuid = obd->u.cli.cl_target_uuid;
1850 case LL_IOC_GET_CONNECT_FLAGS:
1851 if (copy_to_user(uarg, exp_connect_flags_ptr(exp),
1852 sizeof(*exp_connect_flags_ptr(exp)))) {
1859 case LL_IOC_LOV_SWAP_LAYOUTS:
1860 rc = mdc_ioc_swap_layouts(exp, karg);
1863 CERROR("unrecognised ioctl: cmd = %#x\n", cmd);
1868 module_put(THIS_MODULE);
1873 static int mdc_get_info_rpc(struct obd_export *exp,
1874 u32 keylen, void *key,
1875 int vallen, void *val)
1877 struct obd_import *imp = class_exp2cliimp(exp);
1878 struct ptlrpc_request *req;
1882 req = ptlrpc_request_alloc(imp, &RQF_MDS_GET_INFO);
1886 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_KEY,
1887 RCL_CLIENT, keylen);
1888 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VALLEN,
1889 RCL_CLIENT, sizeof(__u32));
1891 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GET_INFO);
1893 ptlrpc_request_free(req);
1897 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_KEY);
1898 memcpy(tmp, key, keylen);
1899 tmp = req_capsule_client_get(&req->rq_pill, &RMF_GETINFO_VALLEN);
1900 memcpy(tmp, &vallen, sizeof(__u32));
1902 req_capsule_set_size(&req->rq_pill, &RMF_GETINFO_VAL,
1903 RCL_SERVER, vallen);
1904 ptlrpc_request_set_replen(req);
1906 rc = ptlrpc_queue_wait(req);
1907 /* -EREMOTE means the get_info result is partial, and it needs to
1908 * continue on another MDT, see fid2path part in lmv_iocontrol */
1909 if (rc == 0 || rc == -EREMOTE) {
1910 tmp = req_capsule_server_get(&req->rq_pill, &RMF_GETINFO_VAL);
1911 memcpy(val, tmp, vallen);
1912 if (ptlrpc_rep_need_swab(req)) {
1913 if (KEY_IS(KEY_FID2PATH))
1914 lustre_swab_fid2path(val);
1917 ptlrpc_req_finished(req);
1922 static void lustre_swab_hai(struct hsm_action_item *h)
1924 __swab32s(&h->hai_len);
1925 __swab32s(&h->hai_action);
1926 lustre_swab_lu_fid(&h->hai_fid);
1927 lustre_swab_lu_fid(&h->hai_dfid);
1928 __swab64s(&h->hai_cookie);
1929 __swab64s(&h->hai_extent.offset);
1930 __swab64s(&h->hai_extent.length);
1931 __swab64s(&h->hai_gid);
1934 static void lustre_swab_hal(struct hsm_action_list *h)
1936 struct hsm_action_item *hai;
1939 __swab32s(&h->hal_version);
1940 __swab32s(&h->hal_count);
1941 __swab32s(&h->hal_archive_id);
1942 __swab64s(&h->hal_flags);
1944 for (i = 0; i < h->hal_count; i++, hai = hai_next(hai))
1945 lustre_swab_hai(hai);
1948 static void lustre_swab_kuch(struct kuc_hdr *l)
1950 __swab16s(&l->kuc_magic);
1951 /* __u8 l->kuc_transport */
1952 __swab16s(&l->kuc_msgtype);
1953 __swab16s(&l->kuc_msglen);
1956 static int mdc_ioc_hsm_ct_start(struct obd_export *exp,
1957 struct lustre_kernelcomm *lk)
1959 struct obd_import *imp = class_exp2cliimp(exp);
1960 __u32 archive = lk->lk_data;
1963 if (lk->lk_group != KUC_GRP_HSM) {
1964 CERROR("Bad copytool group %d\n", lk->lk_group);
1968 CDEBUG(D_HSM, "CT start r%d w%d u%d g%d f%#x\n", lk->lk_rfd, lk->lk_wfd,
1969 lk->lk_uid, lk->lk_group, lk->lk_flags);
1971 if (lk->lk_flags & LK_FLG_STOP) {
1972 /* Unregister with the coordinator */
1973 rc = mdc_ioc_hsm_ct_unregister(imp);
1975 rc = mdc_ioc_hsm_ct_register(imp, archive);
1982 * Send a message to any listening copytools
1983 * @param val KUC message (kuc_hdr + hsm_action_list)
1984 * @param len total length of message
1986 static int mdc_hsm_copytool_send(int len, void *val)
1988 struct kuc_hdr *lh = (struct kuc_hdr *)val;
1989 struct hsm_action_list *hal = (struct hsm_action_list *)(lh + 1);
1991 if (len < sizeof(*lh) + sizeof(*hal)) {
1992 CERROR("Short HSM message %d < %d\n", len,
1993 (int) (sizeof(*lh) + sizeof(*hal)));
1996 if (lh->kuc_magic == __swab16(KUC_MAGIC)) {
1997 lustre_swab_kuch(lh);
1998 lustre_swab_hal(hal);
1999 } else if (lh->kuc_magic != KUC_MAGIC) {
2000 CERROR("Bad magic %x!=%x\n", lh->kuc_magic, KUC_MAGIC);
2005 "Received message mg=%x t=%d m=%d l=%d actions=%d on %s\n",
2006 lh->kuc_magic, lh->kuc_transport, lh->kuc_msgtype,
2007 lh->kuc_msglen, hal->hal_count, hal->hal_fsname);
2009 /* Broadcast to HSM listeners */
2010 return libcfs_kkuc_group_put(KUC_GRP_HSM, lh);
2014 * callback function passed to kuc for re-registering each HSM copytool
2015 * running on MDC, after MDT shutdown/recovery.
2016 * @param data archive id served by the copytool
2017 * @param cb_arg callback argument (obd_import)
2019 static int mdc_hsm_ct_reregister(__u32 data, void *cb_arg)
2021 struct obd_import *imp = (struct obd_import *)cb_arg;
2022 __u32 archive = data;
2025 CDEBUG(D_HA, "recover copytool registration to MDT (archive=%#x)\n",
2027 rc = mdc_ioc_hsm_ct_register(imp, archive);
2029 /* ignore error if the copytool is already registered */
2030 return ((rc != 0) && (rc != -EEXIST)) ? rc : 0;
2033 static int mdc_set_info_async(const struct lu_env *env,
2034 struct obd_export *exp,
2035 u32 keylen, void *key,
2036 u32 vallen, void *val,
2037 struct ptlrpc_request_set *set)
2039 struct obd_import *imp = class_exp2cliimp(exp);
2042 if (KEY_IS(KEY_READ_ONLY)) {
2043 if (vallen != sizeof(int))
2046 spin_lock(&imp->imp_lock);
2047 if (*((int *)val)) {
2048 imp->imp_connect_flags_orig |= OBD_CONNECT_RDONLY;
2049 imp->imp_connect_data.ocd_connect_flags |=
2052 imp->imp_connect_flags_orig &= ~OBD_CONNECT_RDONLY;
2053 imp->imp_connect_data.ocd_connect_flags &=
2054 ~OBD_CONNECT_RDONLY;
2056 spin_unlock(&imp->imp_lock);
2058 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
2059 keylen, key, vallen, val, set);
2062 if (KEY_IS(KEY_SPTLRPC_CONF)) {
2063 sptlrpc_conf_client_adapt(exp->exp_obd);
2066 if (KEY_IS(KEY_FLUSH_CTX)) {
2067 sptlrpc_import_flush_my_ctx(imp);
2070 if (KEY_IS(KEY_CHANGELOG_CLEAR)) {
2071 rc = do_set_info_async(imp, MDS_SET_INFO, LUSTRE_MDS_VERSION,
2072 keylen, key, vallen, val, set);
2075 if (KEY_IS(KEY_HSM_COPYTOOL_SEND)) {
2076 rc = mdc_hsm_copytool_send(vallen, val);
2080 CERROR("Unknown key %s\n", (char *)key);
2084 static int mdc_get_info(const struct lu_env *env, struct obd_export *exp,
2085 __u32 keylen, void *key, __u32 *vallen, void *val,
2086 struct lov_stripe_md *lsm)
2090 if (KEY_IS(KEY_MAX_EASIZE)) {
2091 int mdsize, *max_easize;
2093 if (*vallen != sizeof(int))
2095 mdsize = *(int *)val;
2096 if (mdsize > exp->exp_obd->u.cli.cl_max_mds_easize)
2097 exp->exp_obd->u.cli.cl_max_mds_easize = mdsize;
2099 *max_easize = exp->exp_obd->u.cli.cl_max_mds_easize;
2101 } else if (KEY_IS(KEY_DEFAULT_EASIZE)) {
2102 int *default_easize;
2104 if (*vallen != sizeof(int))
2106 default_easize = val;
2107 *default_easize = exp->exp_obd->u.cli.cl_default_mds_easize;
2109 } else if (KEY_IS(KEY_CONN_DATA)) {
2110 struct obd_import *imp = class_exp2cliimp(exp);
2111 struct obd_connect_data *data = val;
2113 if (*vallen != sizeof(*data))
2116 *data = imp->imp_connect_data;
2118 } else if (KEY_IS(KEY_TGT_COUNT)) {
2123 rc = mdc_get_info_rpc(exp, keylen, key, *vallen, val);
2128 static int mdc_sync(struct obd_export *exp, const struct lu_fid *fid,
2129 struct ptlrpc_request **request)
2131 struct ptlrpc_request *req;
2135 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_SYNC);
2139 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_SYNC);
2141 ptlrpc_request_free(req);
2145 mdc_pack_body(req, fid, 0, 0, -1, 0);
2147 ptlrpc_request_set_replen(req);
2149 rc = ptlrpc_queue_wait(req);
2151 ptlrpc_req_finished(req);
2157 static int mdc_import_event(struct obd_device *obd, struct obd_import *imp,
2158 enum obd_import_event event)
2162 LASSERT(imp->imp_obd == obd);
2165 case IMP_EVENT_DISCON: {
2167 /* XXX Pass event up to OBDs stack. used only for FLD now */
2168 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_DISCON, NULL);
2172 case IMP_EVENT_INACTIVE: {
2173 struct client_obd *cli = &obd->u.cli;
2175 * Flush current sequence to make client obtain new one
2176 * from server in case of disconnect/reconnect.
2178 if (cli->cl_seq != NULL)
2179 seq_client_flush(cli->cl_seq);
2181 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_INACTIVE, NULL);
2184 case IMP_EVENT_INVALIDATE: {
2185 struct ldlm_namespace *ns = obd->obd_namespace;
2187 ldlm_namespace_cleanup(ns, LDLM_FL_LOCAL_ONLY);
2191 case IMP_EVENT_ACTIVE:
2192 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_ACTIVE, NULL);
2193 /* redo the kuc registration after reconnecting */
2195 /* re-register HSM agents */
2196 rc = libcfs_kkuc_group_foreach(KUC_GRP_HSM,
2197 mdc_hsm_ct_reregister,
2201 rc = obd_notify_observer(obd, obd, OBD_NOTIFY_OCD, NULL);
2203 case IMP_EVENT_DEACTIVATE:
2204 case IMP_EVENT_ACTIVATE:
2207 CERROR("Unknown import event %x\n", event);
2213 int mdc_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
2214 struct md_op_data *op_data)
2216 struct client_obd *cli = &exp->exp_obd->u.cli;
2217 struct lu_client_seq *seq = cli->cl_seq;
2219 return seq_client_alloc_fid(NULL, seq, fid);
2222 static struct obd_uuid *mdc_get_uuid(struct obd_export *exp)
2224 struct client_obd *cli = &exp->exp_obd->u.cli;
2226 return &cli->cl_target_uuid;
2230 * Determine whether the lock can be canceled before replaying it during
2231 * recovery, non zero value will be return if the lock can be canceled,
2232 * or zero returned for not
2234 static int mdc_cancel_for_recovery(struct ldlm_lock *lock)
2236 if (lock->l_resource->lr_type != LDLM_IBITS)
2239 /* FIXME: if we ever get into a situation where there are too many
2240 * opened files with open locks on a single node, then we really
2241 * should replay these open locks to reget it */
2242 if (lock->l_policy_data.l_inodebits.bits & MDS_INODELOCK_OPEN)
2248 static int mdc_resource_inode_free(struct ldlm_resource *res)
2250 if (res->lr_lvb_inode)
2251 res->lr_lvb_inode = NULL;
2256 static struct ldlm_valblock_ops inode_lvbo = {
2257 .lvbo_free = mdc_resource_inode_free,
2260 static int mdc_llog_init(struct obd_device *obd)
2262 struct obd_llog_group *olg = &obd->obd_olg;
2263 struct llog_ctxt *ctxt;
2266 rc = llog_setup(NULL, obd, olg, LLOG_CHANGELOG_REPL_CTXT, obd,
2271 ctxt = llog_group_get_ctxt(olg, LLOG_CHANGELOG_REPL_CTXT);
2272 llog_initiator_connect(ctxt);
2273 llog_ctxt_put(ctxt);
2278 static void mdc_llog_finish(struct obd_device *obd)
2280 struct llog_ctxt *ctxt;
2282 ctxt = llog_get_context(obd, LLOG_CHANGELOG_REPL_CTXT);
2284 llog_cleanup(NULL, ctxt);
2287 static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
2289 struct client_obd *cli = &obd->u.cli;
2290 struct lprocfs_static_vars lvars = { NULL };
2293 cli->cl_rpc_lock = kzalloc(sizeof(*cli->cl_rpc_lock), GFP_NOFS);
2294 if (!cli->cl_rpc_lock)
2296 mdc_init_rpc_lock(cli->cl_rpc_lock);
2300 cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS);
2301 if (!cli->cl_close_lock) {
2305 mdc_init_rpc_lock(cli->cl_close_lock);
2307 rc = client_obd_setup(obd, cfg);
2309 goto err_close_lock;
2310 lprocfs_mdc_init_vars(&lvars);
2311 lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
2312 sptlrpc_lprocfs_cliobd_attach(obd);
2313 ptlrpc_lprocfs_register_obd(obd);
2315 ns_register_cancel(obd->obd_namespace, mdc_cancel_for_recovery);
2317 obd->obd_namespace->ns_lvbo = &inode_lvbo;
2319 rc = mdc_llog_init(obd);
2322 CERROR("failed to setup llogging subsystems\n");
2328 kfree(cli->cl_close_lock);
2330 kfree(cli->cl_rpc_lock);
2335 /* Initialize the default and maximum LOV EA and cookie sizes. This allows
2336 * us to make MDS RPCs with large enough reply buffers to hold a default
2337 * sized EA and cookie without having to calculate this (via a call into the
2338 * LOV + OSCs) each time we make an RPC. The maximum size is also tracked
2339 * but not used to avoid wastefully vmalloc()'ing large reply buffers when
2340 * a large number of stripes is possible. If a larger reply buffer is
2341 * required it will be reallocated in the ptlrpc layer due to overflow.
2343 static int mdc_init_ea_size(struct obd_export *exp, int easize,
2344 int def_easize, int cookiesize, int def_cookiesize)
2346 struct obd_device *obd = exp->exp_obd;
2347 struct client_obd *cli = &obd->u.cli;
2349 if (cli->cl_max_mds_easize < easize)
2350 cli->cl_max_mds_easize = easize;
2352 if (cli->cl_default_mds_easize < def_easize)
2353 cli->cl_default_mds_easize = def_easize;
2355 if (cli->cl_max_mds_cookiesize < cookiesize)
2356 cli->cl_max_mds_cookiesize = cookiesize;
2358 if (cli->cl_default_mds_cookiesize < def_cookiesize)
2359 cli->cl_default_mds_cookiesize = def_cookiesize;
2364 static int mdc_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2367 case OBD_CLEANUP_EARLY:
2369 case OBD_CLEANUP_EXPORTS:
2370 /* Failsafe, ok if racy */
2371 if (obd->obd_type->typ_refcnt <= 1)
2372 libcfs_kkuc_group_rem(0, KUC_GRP_HSM);
2374 obd_cleanup_client_import(obd);
2375 ptlrpc_lprocfs_unregister_obd(obd);
2376 lprocfs_obd_cleanup(obd);
2378 mdc_llog_finish(obd);
2384 static int mdc_cleanup(struct obd_device *obd)
2386 struct client_obd *cli = &obd->u.cli;
2388 kfree(cli->cl_rpc_lock);
2389 kfree(cli->cl_close_lock);
2393 return client_obd_cleanup(obd);
2396 static int mdc_process_config(struct obd_device *obd, u32 len, void *buf)
2398 struct lustre_cfg *lcfg = buf;
2399 struct lprocfs_static_vars lvars = { NULL };
2402 lprocfs_mdc_init_vars(&lvars);
2403 switch (lcfg->lcfg_command) {
2405 rc = class_process_proc_param(PARAM_MDC, lvars.obd_vars,
2414 /* get remote permission for current user on fid */
2415 static int mdc_get_remote_perm(struct obd_export *exp, const struct lu_fid *fid,
2416 __u32 suppgid, struct ptlrpc_request **request)
2418 struct ptlrpc_request *req;
2421 LASSERT(client_is_remote(exp));
2424 req = ptlrpc_request_alloc(class_exp2cliimp(exp), &RQF_MDS_GETATTR);
2428 rc = ptlrpc_request_pack(req, LUSTRE_MDS_VERSION, MDS_GETATTR);
2430 ptlrpc_request_free(req);
2434 mdc_pack_body(req, fid, OBD_MD_FLRMTPERM, 0, suppgid, 0);
2436 req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER,
2437 sizeof(struct mdt_remote_perm));
2439 ptlrpc_request_set_replen(req);
2441 rc = ptlrpc_queue_wait(req);
2443 ptlrpc_req_finished(req);
2449 static struct obd_ops mdc_obd_ops = {
2450 .owner = THIS_MODULE,
2452 .precleanup = mdc_precleanup,
2453 .cleanup = mdc_cleanup,
2454 .add_conn = client_import_add_conn,
2455 .del_conn = client_import_del_conn,
2456 .connect = client_connect_import,
2457 .disconnect = client_disconnect_export,
2458 .iocontrol = mdc_iocontrol,
2459 .set_info_async = mdc_set_info_async,
2460 .statfs = mdc_statfs,
2461 .fid_init = client_fid_init,
2462 .fid_fini = client_fid_fini,
2463 .fid_alloc = mdc_fid_alloc,
2464 .import_event = mdc_import_event,
2465 .get_info = mdc_get_info,
2466 .process_config = mdc_process_config,
2467 .get_uuid = mdc_get_uuid,
2468 .quotactl = mdc_quotactl,
2469 .quotacheck = mdc_quotacheck
2472 static struct md_ops mdc_md_ops = {
2473 .getstatus = mdc_getstatus,
2474 .null_inode = mdc_null_inode,
2475 .find_cbdata = mdc_find_cbdata,
2477 .create = mdc_create,
2478 .done_writing = mdc_done_writing,
2479 .enqueue = mdc_enqueue,
2480 .getattr = mdc_getattr,
2481 .getattr_name = mdc_getattr_name,
2482 .intent_lock = mdc_intent_lock,
2484 .is_subdir = mdc_is_subdir,
2485 .rename = mdc_rename,
2486 .setattr = mdc_setattr,
2487 .setxattr = mdc_setxattr,
2488 .getxattr = mdc_getxattr,
2490 .readpage = mdc_readpage,
2491 .unlink = mdc_unlink,
2492 .cancel_unused = mdc_cancel_unused,
2493 .init_ea_size = mdc_init_ea_size,
2494 .set_lock_data = mdc_set_lock_data,
2495 .lock_match = mdc_lock_match,
2496 .get_lustre_md = mdc_get_lustre_md,
2497 .free_lustre_md = mdc_free_lustre_md,
2498 .set_open_replay_data = mdc_set_open_replay_data,
2499 .clear_open_replay_data = mdc_clear_open_replay_data,
2500 .get_remote_perm = mdc_get_remote_perm,
2501 .intent_getattr_async = mdc_intent_getattr_async,
2502 .revalidate_lock = mdc_revalidate_lock
2505 static int __init mdc_init(void)
2507 struct lprocfs_static_vars lvars = { NULL };
2509 lprocfs_mdc_init_vars(&lvars);
2511 return class_register_type(&mdc_obd_ops, &mdc_md_ops,
2512 LUSTRE_MDC_NAME, NULL);
2515 static void /*__exit*/ mdc_exit(void)
2517 class_unregister_type(LUSTRE_MDC_NAME);
2520 MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
2521 MODULE_DESCRIPTION("Lustre Metadata Client");
2522 MODULE_LICENSE("GPL");
2524 module_init(mdc_init);
2525 module_exit(mdc_exit);