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) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
28 * Use is subject to license terms.
30 * Copyright (c) 2011, 2012, 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_LMV
39 #include <linux/slab.h>
40 #include <linux/module.h>
41 #include <linux/init.h>
42 #include <linux/slab.h>
43 #include <linux/pagemap.h>
45 #include <asm/div64.h>
46 #include <linux/seq_file.h>
47 #include <linux/namei.h>
49 #include <liblustre.h>
52 #include <lustre/lustre_idl.h>
53 #include <obd_support.h>
54 #include <lustre_lib.h>
55 #include <lustre_net.h>
56 #include <obd_class.h>
57 #include <lprocfs_status.h>
58 #include <lustre_lite.h>
59 #include <lustre_fid.h>
60 #include "lmv_internal.h"
62 static void lmv_activate_target(struct lmv_obd *lmv,
63 struct lmv_tgt_desc *tgt,
66 if (tgt->ltd_active == activate)
69 tgt->ltd_active = activate;
70 lmv->desc.ld_active_tgt_count += (activate ? 1 : -1);
76 * -EINVAL : UUID can't be found in the LMV's target list
77 * -ENOTCONN: The UUID is found, but the target connection is bad (!)
78 * -EBADF : The UUID is found, but the OBD of the wrong type (!)
80 static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid,
83 struct lmv_tgt_desc *tgt;
84 struct obd_device *obd;
89 CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n",
90 lmv, uuid->uuid, activate);
92 spin_lock(&lmv->lmv_lock);
93 for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
94 if (tgt->ltd_exp == NULL)
97 CDEBUG(D_INFO, "Target idx %d is %s conn "LPX64"\n",
98 i, tgt->ltd_uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
100 if (obd_uuid_equals(uuid, &tgt->ltd_uuid))
104 if (i == lmv->desc.ld_tgt_count)
105 GOTO(out_lmv_lock, rc = -EINVAL);
107 obd = class_exp2obd(tgt->ltd_exp);
109 GOTO(out_lmv_lock, rc = -ENOTCONN);
111 CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LMV idx %d\n",
112 obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd,
113 obd->obd_type->typ_name, i);
114 LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0);
116 if (tgt->ltd_active == activate) {
117 CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd,
118 activate ? "" : "in");
119 GOTO(out_lmv_lock, rc);
122 CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd,
123 activate ? "" : "in");
124 lmv_activate_target(lmv, tgt, activate);
128 spin_unlock(&lmv->lmv_lock);
132 static int lmv_set_mdc_data(struct lmv_obd *lmv, struct obd_uuid *uuid,
133 struct obd_connect_data *data)
135 struct lmv_tgt_desc *tgt;
139 LASSERT(data != NULL);
141 spin_lock(&lmv->lmv_lock);
142 for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
143 if (tgt->ltd_exp == NULL)
146 if (obd_uuid_equals(uuid, &tgt->ltd_uuid)) {
147 lmv->datas[tgt->ltd_idx] = *data;
151 spin_unlock(&lmv->lmv_lock);
155 struct obd_uuid *lmv_get_uuid(struct obd_export *exp) {
156 struct obd_device *obd = exp->exp_obd;
157 struct lmv_obd *lmv = &obd->u.lmv;
158 return obd_get_uuid(lmv->tgts[0].ltd_exp);
161 static int lmv_notify(struct obd_device *obd, struct obd_device *watched,
162 enum obd_notify_event ev, void *data)
164 struct obd_connect_data *conn_data;
165 struct lmv_obd *lmv = &obd->u.lmv;
166 struct obd_uuid *uuid;
170 if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) {
171 CERROR("unexpected notification of %s %s!\n",
172 watched->obd_type->typ_name,
177 uuid = &watched->u.cli.cl_target_uuid;
178 if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE) {
180 * Set MDC as active before notifying the observer, so the
181 * observer can use the MDC normally.
183 rc = lmv_set_mdc_active(lmv, uuid,
184 ev == OBD_NOTIFY_ACTIVE);
186 CERROR("%sactivation of %s failed: %d\n",
187 ev == OBD_NOTIFY_ACTIVE ? "" : "de",
191 } else if (ev == OBD_NOTIFY_OCD) {
192 conn_data = &watched->u.cli.cl_import->imp_connect_data;
195 * Set connect data to desired target, update exp_connect_flags.
197 rc = lmv_set_mdc_data(lmv, uuid, conn_data);
199 CERROR("can't set connect data to target %s, rc %d\n",
205 * XXX: Make sure that ocd_connect_flags from all targets are
206 * the same. Otherwise one of MDTs runs wrong version or
207 * something like this. --umka
209 obd->obd_self_export->exp_connect_flags =
210 conn_data->ocd_connect_flags;
213 else if (ev == OBD_NOTIFY_DISCON) {
215 * For disconnect event, flush fld cache for failout MDS case.
217 fld_client_flush(&lmv->lmv_fld);
221 * Pass the notification up the chain.
223 if (obd->obd_observer)
224 rc = obd_notify(obd->obd_observer, watched, ev, data);
230 * This is fake connect function. Its purpose is to initialize lmv and say
231 * caller that everything is okay. Real connection will be performed later.
233 static int lmv_connect(const struct lu_env *env,
234 struct obd_export **exp, struct obd_device *obd,
235 struct obd_uuid *cluuid, struct obd_connect_data *data,
239 struct proc_dir_entry *lmv_proc_dir;
241 struct lmv_obd *lmv = &obd->u.lmv;
242 struct lustre_handle conn = { 0 };
247 * We don't want to actually do the underlying connections more than
248 * once, so keep track.
251 if (lmv->refcount > 1) {
256 rc = class_connect(&conn, obd, cluuid);
258 CERROR("class_connection() returned %d\n", rc);
262 *exp = class_conn2export(&conn);
263 class_export_get(*exp);
267 lmv->cluuid = *cluuid;
270 lmv->conn_data = *data;
273 lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
275 if (IS_ERR(lmv_proc_dir)) {
276 CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
277 obd->obd_type->typ_name, obd->obd_name);
283 * All real clients should perform actual connection right away, because
284 * it is possible, that LMV will not have opportunity to connect targets
285 * and MDC stuff will be called directly, for instance while reading
286 * ../mdc/../kbytesfree procfs file, etc.
288 if (data->ocd_connect_flags & OBD_CONNECT_REAL)
289 rc = lmv_check_connect(obd);
294 lprocfs_remove(&lmv_proc_dir);
301 static void lmv_set_timeouts(struct obd_device *obd)
303 struct lmv_tgt_desc *tgts;
308 if (lmv->server_timeout == 0)
311 if (lmv->connected == 0)
314 for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
315 if (tgts->ltd_exp == NULL)
318 obd_set_info_async(NULL, tgts->ltd_exp, sizeof(KEY_INTERMDS),
319 KEY_INTERMDS, 0, NULL, NULL);
323 static int lmv_init_ea_size(struct obd_export *exp, int easize,
324 int def_easize, int cookiesize)
326 struct obd_device *obd = exp->exp_obd;
327 struct lmv_obd *lmv = &obd->u.lmv;
333 if (lmv->max_easize < easize) {
334 lmv->max_easize = easize;
337 if (lmv->max_def_easize < def_easize) {
338 lmv->max_def_easize = def_easize;
341 if (lmv->max_cookiesize < cookiesize) {
342 lmv->max_cookiesize = cookiesize;
348 if (lmv->connected == 0)
351 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
352 if (lmv->tgts[i].ltd_exp == NULL) {
353 CWARN("%s: NULL export for %d\n", obd->obd_name, i);
357 rc = md_init_ea_size(lmv->tgts[i].ltd_exp, easize, def_easize,
360 CERROR("obd_init_ea_size() failed on MDT target %d, "
361 "error %d.\n", i, rc);
368 #define MAX_STRING_SIZE 128
370 int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
373 struct proc_dir_entry *lmv_proc_dir;
375 struct lmv_obd *lmv = &obd->u.lmv;
376 struct obd_uuid *cluuid = &lmv->cluuid;
377 struct obd_connect_data *mdc_data = NULL;
378 struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" };
379 struct obd_device *mdc_obd;
380 struct obd_export *mdc_exp;
381 struct lu_fld_target target;
385 mdc_obd = class_find_client_obd(&tgt->ltd_uuid, LUSTRE_MDC_NAME,
388 CERROR("target %s not attached\n", tgt->ltd_uuid.uuid);
392 CDEBUG(D_CONFIG, "connect to %s(%s) - %s, %s FOR %s\n",
393 mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
394 tgt->ltd_uuid.uuid, obd->obd_uuid.uuid,
397 if (!mdc_obd->obd_set_up) {
398 CERROR("target %s is not set up\n", tgt->ltd_uuid.uuid);
402 rc = obd_connect(NULL, &mdc_exp, mdc_obd, &lmv_mdc_uuid,
403 &lmv->conn_data, NULL);
405 CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc);
410 * Init fid sequence client for this mdc and add new fld target.
412 rc = obd_fid_init(mdc_exp, LUSTRE_SEQ_METADATA);
416 target.ft_srv = NULL;
417 target.ft_exp = mdc_exp;
418 target.ft_idx = tgt->ltd_idx;
420 fld_client_add_target(&lmv->lmv_fld, &target);
422 mdc_data = &class_exp2cliimp(mdc_exp)->imp_connect_data;
424 rc = obd_register_observer(mdc_obd, obd);
426 obd_disconnect(mdc_exp);
427 CERROR("target %s register_observer error %d\n",
428 tgt->ltd_uuid.uuid, rc);
432 if (obd->obd_observer) {
434 * Tell the observer about the new target.
436 rc = obd_notify(obd->obd_observer, mdc_exp->exp_obd,
437 OBD_NOTIFY_ACTIVE, (void *)(tgt - lmv->tgts));
439 obd_disconnect(mdc_exp);
445 tgt->ltd_exp = mdc_exp;
446 lmv->desc.ld_active_tgt_count++;
449 * Copy connect data, it may be used later.
451 lmv->datas[tgt->ltd_idx] = *mdc_data;
453 md_init_ea_size(tgt->ltd_exp, lmv->max_easize,
454 lmv->max_def_easize, lmv->max_cookiesize);
456 CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n",
457 mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
458 cfs_atomic_read(&obd->obd_refcount));
461 lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
463 struct proc_dir_entry *mdc_symlink;
465 LASSERT(mdc_obd->obd_type != NULL);
466 LASSERT(mdc_obd->obd_type->typ_name != NULL);
467 mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
470 mdc_obd->obd_type->typ_name,
472 if (mdc_symlink == NULL) {
473 CERROR("Could not register LMV target "
474 "/proc/fs/lustre/%s/%s/target_obds/%s.",
475 obd->obd_type->typ_name, obd->obd_name,
477 lprocfs_remove(&lmv_proc_dir);
485 int lmv_add_target(struct obd_device *obd, struct obd_uuid *tgt_uuid)
487 struct lmv_obd *lmv = &obd->u.lmv;
488 struct lmv_tgt_desc *tgt;
492 CDEBUG(D_CONFIG, "Target uuid: %s.\n", tgt_uuid->uuid);
496 if (lmv->desc.ld_active_tgt_count >= LMV_MAX_TGT_COUNT) {
497 lmv_init_unlock(lmv);
498 CERROR("Can't add %s, LMV module compiled for %d MDCs. "
499 "That many MDCs already configured.\n",
500 tgt_uuid->uuid, LMV_MAX_TGT_COUNT);
503 if (lmv->desc.ld_tgt_count == 0) {
504 struct obd_device *mdc_obd;
506 mdc_obd = class_find_client_obd(tgt_uuid, LUSTRE_MDC_NAME,
509 lmv_init_unlock(lmv);
510 CERROR("Target %s not attached\n", tgt_uuid->uuid);
514 spin_lock(&lmv->lmv_lock);
515 tgt = lmv->tgts + lmv->desc.ld_tgt_count++;
516 tgt->ltd_uuid = *tgt_uuid;
517 spin_unlock(&lmv->lmv_lock);
519 if (lmv->connected) {
520 rc = lmv_connect_mdc(obd, tgt);
522 spin_lock(&lmv->lmv_lock);
523 lmv->desc.ld_tgt_count--;
524 memset(tgt, 0, sizeof(*tgt));
525 spin_unlock(&lmv->lmv_lock);
527 int easize = sizeof(struct lmv_stripe_md) +
528 lmv->desc.ld_tgt_count *
529 sizeof(struct lu_fid);
530 lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
534 lmv_init_unlock(lmv);
538 int lmv_check_connect(struct obd_device *obd)
540 struct lmv_obd *lmv = &obd->u.lmv;
541 struct lmv_tgt_desc *tgt;
551 if (lmv->connected) {
552 lmv_init_unlock(lmv);
556 if (lmv->desc.ld_tgt_count == 0) {
557 lmv_init_unlock(lmv);
558 CERROR("%s: no targets configured.\n", obd->obd_name);
562 CDEBUG(D_CONFIG, "Time to connect %s to %s\n",
563 lmv->cluuid.uuid, obd->obd_name);
565 LASSERT(lmv->tgts != NULL);
567 for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
568 rc = lmv_connect_mdc(obd, tgt);
573 lmv_set_timeouts(obd);
574 class_export_put(lmv->exp);
576 easize = lmv_get_easize(lmv);
577 lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
578 lmv_init_unlock(lmv);
587 --lmv->desc.ld_active_tgt_count;
588 rc2 = obd_disconnect(tgt->ltd_exp);
590 CERROR("LMV target %s disconnect on "
591 "MDC idx %d: error %d\n",
592 tgt->ltd_uuid.uuid, i, rc2);
596 class_disconnect(lmv->exp);
597 lmv_init_unlock(lmv);
601 static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
604 struct proc_dir_entry *lmv_proc_dir;
606 struct lmv_obd *lmv = &obd->u.lmv;
607 struct obd_device *mdc_obd;
611 LASSERT(tgt != NULL);
612 LASSERT(obd != NULL);
614 mdc_obd = class_exp2obd(tgt->ltd_exp);
617 mdc_obd->obd_force = obd->obd_force;
618 mdc_obd->obd_fail = obd->obd_fail;
619 mdc_obd->obd_no_recov = obd->obd_no_recov;
623 lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
625 struct proc_dir_entry *mdc_symlink;
627 mdc_symlink = lprocfs_srch(lmv_proc_dir, mdc_obd->obd_name);
629 lprocfs_remove(&mdc_symlink);
631 CERROR("/proc/fs/lustre/%s/%s/target_obds/%s missing\n",
632 obd->obd_type->typ_name, obd->obd_name,
637 rc = obd_fid_fini(tgt->ltd_exp);
639 CERROR("Can't finanize fids factory\n");
641 CDEBUG(D_INFO, "Disconnected from %s(%s) successfully\n",
642 tgt->ltd_exp->exp_obd->obd_name,
643 tgt->ltd_exp->exp_obd->obd_uuid.uuid);
645 obd_register_observer(tgt->ltd_exp->exp_obd, NULL);
646 rc = obd_disconnect(tgt->ltd_exp);
648 if (tgt->ltd_active) {
649 CERROR("Target %s disconnect error %d\n",
650 tgt->ltd_uuid.uuid, rc);
654 lmv_activate_target(lmv, tgt, 0);
659 static int lmv_disconnect(struct obd_export *exp)
661 struct obd_device *obd = class_exp2obd(exp);
663 struct proc_dir_entry *lmv_proc_dir;
665 struct lmv_obd *lmv = &obd->u.lmv;
674 * Only disconnect the underlying layers on the final disconnect.
677 if (lmv->refcount != 0)
680 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
681 if (lmv->tgts[i].ltd_exp == NULL)
683 lmv_disconnect_mdc(obd, &lmv->tgts[i]);
687 lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
689 lprocfs_remove(&lmv_proc_dir);
691 CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
692 obd->obd_type->typ_name, obd->obd_name);
698 * This is the case when no real connection is established by
699 * lmv_check_connect().
702 class_export_put(exp);
703 rc = class_disconnect(exp);
704 if (lmv->refcount == 0)
709 static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
710 int len, void *karg, void *uarg)
712 struct obd_device *obddev = class_exp2obd(exp);
713 struct lmv_obd *lmv = &obddev->u.lmv;
717 int count = lmv->desc.ld_tgt_count;
724 case IOC_OBD_STATFS: {
725 struct obd_ioctl_data *data = karg;
726 struct obd_device *mdc_obd;
727 struct obd_statfs stat_buf = {0};
730 memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
731 if ((index >= count))
734 if (!lmv->tgts[index].ltd_active)
737 mdc_obd = class_exp2obd(lmv->tgts[index].ltd_exp);
742 if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd),
743 min((int) data->ioc_plen2,
744 (int) sizeof(struct obd_uuid))))
747 rc = obd_statfs(NULL, lmv->tgts[index].ltd_exp, &stat_buf,
748 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
752 if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf,
753 min((int) data->ioc_plen1,
754 (int) sizeof(stat_buf))))
758 case OBD_IOC_QUOTACTL: {
759 struct if_quotactl *qctl = karg;
760 struct lmv_tgt_desc *tgt = NULL;
761 struct obd_quotactl *oqctl;
763 if (qctl->qc_valid == QC_MDTIDX) {
764 if (qctl->qc_idx < 0 || count <= qctl->qc_idx)
767 tgt = &lmv->tgts[qctl->qc_idx];
770 } else if (qctl->qc_valid == QC_UUID) {
771 for (i = 0; i < count; i++) {
773 if (!obd_uuid_equals(&tgt->ltd_uuid,
777 if (tgt->ltd_exp == NULL)
789 LASSERT(tgt && tgt->ltd_exp);
790 OBD_ALLOC_PTR(oqctl);
794 QCTL_COPY(oqctl, qctl);
795 rc = obd_quotactl(tgt->ltd_exp, oqctl);
797 QCTL_COPY(qctl, oqctl);
798 qctl->qc_valid = QC_MDTIDX;
799 qctl->obd_uuid = tgt->ltd_uuid;
804 case OBD_IOC_CHANGELOG_SEND:
805 case OBD_IOC_CHANGELOG_CLEAR: {
806 struct ioc_changelog *icc = karg;
808 if (icc->icc_mdtindex >= count)
811 rc = obd_iocontrol(cmd, lmv->tgts[icc->icc_mdtindex].ltd_exp,
812 sizeof(*icc), icc, NULL);
815 case LL_IOC_GET_CONNECT_FLAGS: {
816 rc = obd_iocontrol(cmd, lmv->tgts[0].ltd_exp, len, karg, uarg);
821 for (i = 0; i < count; i++) {
823 struct obd_device *mdc_obd;
825 if (lmv->tgts[i].ltd_exp == NULL)
827 /* ll_umount_begin() sets force flag but for lmv, not
828 * mdc. Let's pass it through */
829 mdc_obd = class_exp2obd(lmv->tgts[i].ltd_exp);
830 mdc_obd->obd_force = obddev->obd_force;
831 err = obd_iocontrol(cmd, lmv->tgts[i].ltd_exp, len,
833 if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) {
836 if (lmv->tgts[i].ltd_active) {
837 CERROR("error: iocontrol MDC %s on MDT"
838 "idx %d cmd %x: err = %d\n",
839 lmv->tgts[i].ltd_uuid.uuid,
855 static int lmv_all_chars_policy(int count, const char *name,
866 static int lmv_nid_policy(struct lmv_obd *lmv)
868 struct obd_import *imp;
872 * XXX: To get nid we assume that underlying obd device is mdc.
874 imp = class_exp2cliimp(lmv->tgts[0].ltd_exp);
875 id = imp->imp_connection->c_self ^ (imp->imp_connection->c_self >> 32);
876 return id % lmv->desc.ld_tgt_count;
879 static int lmv_choose_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
880 placement_policy_t placement)
883 case PLACEMENT_CHAR_POLICY:
884 return lmv_all_chars_policy(lmv->desc.ld_tgt_count,
886 op_data->op_namelen);
887 case PLACEMENT_NID_POLICY:
888 return lmv_nid_policy(lmv);
894 CERROR("Unsupported placement policy %x\n", placement);
900 * This is _inode_ placement policy function (not name).
902 static int lmv_placement_policy(struct obd_device *obd,
903 struct md_op_data *op_data,
906 LASSERT(mds != NULL);
908 /* Allocate new fid on target according to to different
909 * QOS policy. In DNE phase I, llite should always tell
910 * which MDT where the dir will be located */
911 *mds = op_data->op_mds;
916 int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
919 struct lmv_tgt_desc *tgt;
923 tgt = lmv_get_target(lmv, mds);
926 * New seq alloc and FLD setup should be atomic. Otherwise we may find
927 * on server that seq in new allocated fid is not yet known.
929 mutex_lock(&tgt->ltd_fid_mutex);
931 if (!tgt->ltd_active)
932 GOTO(out, rc = -ENODEV);
935 * Asking underlaying tgt layer to allocate new fid.
937 rc = obd_fid_alloc(tgt->ltd_exp, fid, NULL);
939 LASSERT(fid_is_sane(fid));
945 mutex_unlock(&tgt->ltd_fid_mutex);
949 int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
950 struct md_op_data *op_data)
952 struct obd_device *obd = class_exp2obd(exp);
953 struct lmv_obd *lmv = &obd->u.lmv;
958 LASSERT(op_data != NULL);
959 LASSERT(fid != NULL);
961 rc = lmv_placement_policy(obd, op_data, &mds);
963 CERROR("Can't get target for allocating fid, "
968 rc = __lmv_fid_alloc(lmv, fid, mds);
970 CERROR("Can't alloc new fid, rc %d\n", rc);
977 static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
979 struct lmv_obd *lmv = &obd->u.lmv;
980 struct lprocfs_static_vars lvars;
981 struct lmv_desc *desc;
986 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
987 CERROR("LMV setup requires a descriptor\n");
991 desc = (struct lmv_desc *)lustre_cfg_buf(lcfg, 1);
992 if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
993 CERROR("Lmv descriptor size wrong: %d > %d\n",
994 (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1));
998 lmv->tgts_size = LMV_MAX_TGT_COUNT * sizeof(struct lmv_tgt_desc);
1000 OBD_ALLOC(lmv->tgts, lmv->tgts_size);
1001 if (lmv->tgts == NULL)
1004 for (i = 0; i < LMV_MAX_TGT_COUNT; i++) {
1005 mutex_init(&lmv->tgts[i].ltd_fid_mutex);
1006 lmv->tgts[i].ltd_idx = i;
1009 lmv->datas_size = LMV_MAX_TGT_COUNT * sizeof(struct obd_connect_data);
1011 OBD_ALLOC(lmv->datas, lmv->datas_size);
1012 if (lmv->datas == NULL)
1013 GOTO(out_free_tgts, rc = -ENOMEM);
1015 obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid);
1016 lmv->desc.ld_tgt_count = 0;
1017 lmv->desc.ld_active_tgt_count = 0;
1018 lmv->max_cookiesize = 0;
1019 lmv->max_def_easize = 0;
1020 lmv->max_easize = 0;
1021 lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
1023 spin_lock_init(&lmv->lmv_lock);
1024 mutex_init(&lmv->init_mutex);
1026 lprocfs_lmv_init_vars(&lvars);
1027 lprocfs_obd_setup(obd, lvars.obd_vars);
1030 rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
1031 0444, &lmv_proc_target_fops, obd);
1033 CWARN("%s: error adding LMV target_obd file: rc = %d\n",
1037 rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
1038 LUSTRE_CLI_FLD_HASH_DHT);
1040 CERROR("Can't init FLD, err %d\n", rc);
1041 GOTO(out_free_datas, rc);
1047 OBD_FREE(lmv->datas, lmv->datas_size);
1050 OBD_FREE(lmv->tgts, lmv->tgts_size);
1055 static int lmv_cleanup(struct obd_device *obd)
1057 struct lmv_obd *lmv = &obd->u.lmv;
1060 fld_client_fini(&lmv->lmv_fld);
1061 OBD_FREE(lmv->datas, lmv->datas_size);
1062 OBD_FREE(lmv->tgts, lmv->tgts_size);
1067 static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf)
1069 struct lustre_cfg *lcfg = buf;
1070 struct obd_uuid tgt_uuid;
1074 switch(lcfg->lcfg_command) {
1076 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(tgt_uuid.uuid))
1077 GOTO(out, rc = -EINVAL);
1079 obd_str2uuid(&tgt_uuid, lustre_cfg_string(lcfg, 1));
1080 rc = lmv_add_target(obd, &tgt_uuid);
1083 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
1084 GOTO(out, rc = -EINVAL);
1091 static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
1092 struct obd_statfs *osfs, __u64 max_age, __u32 flags)
1094 struct obd_device *obd = class_exp2obd(exp);
1095 struct lmv_obd *lmv = &obd->u.lmv;
1096 struct obd_statfs *temp;
1101 rc = lmv_check_connect(obd);
1105 OBD_ALLOC(temp, sizeof(*temp));
1109 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1110 if (lmv->tgts[i].ltd_exp == NULL)
1113 rc = obd_statfs(env, lmv->tgts[i].ltd_exp, temp,
1116 CERROR("can't stat MDS #%d (%s), error %d\n", i,
1117 lmv->tgts[i].ltd_exp->exp_obd->obd_name,
1119 GOTO(out_free_temp, rc);
1124 osfs->os_bavail += temp->os_bavail;
1125 osfs->os_blocks += temp->os_blocks;
1126 osfs->os_ffree += temp->os_ffree;
1127 osfs->os_files += temp->os_files;
1133 OBD_FREE(temp, sizeof(*temp));
1137 static int lmv_getstatus(struct obd_export *exp,
1139 struct obd_capa **pc)
1141 struct obd_device *obd = exp->exp_obd;
1142 struct lmv_obd *lmv = &obd->u.lmv;
1146 rc = lmv_check_connect(obd);
1150 rc = md_getstatus(lmv->tgts[0].ltd_exp, fid, pc);
1154 static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1155 struct obd_capa *oc, obd_valid valid, const char *name,
1156 const char *input, int input_size, int output_size,
1157 int flags, struct ptlrpc_request **request)
1159 struct obd_device *obd = exp->exp_obd;
1160 struct lmv_obd *lmv = &obd->u.lmv;
1161 struct lmv_tgt_desc *tgt;
1165 rc = lmv_check_connect(obd);
1169 tgt = lmv_find_target(lmv, fid);
1171 RETURN(PTR_ERR(tgt));
1173 rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1174 input_size, output_size, flags, request);
1179 static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1180 struct obd_capa *oc, obd_valid valid, const char *name,
1181 const char *input, int input_size, int output_size,
1182 int flags, __u32 suppgid,
1183 struct ptlrpc_request **request)
1185 struct obd_device *obd = exp->exp_obd;
1186 struct lmv_obd *lmv = &obd->u.lmv;
1187 struct lmv_tgt_desc *tgt;
1191 rc = lmv_check_connect(obd);
1195 tgt = lmv_find_target(lmv, fid);
1197 RETURN(PTR_ERR(tgt));
1199 rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1200 input_size, output_size, flags, suppgid,
1206 static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
1207 struct ptlrpc_request **request)
1209 struct obd_device *obd = exp->exp_obd;
1210 struct lmv_obd *lmv = &obd->u.lmv;
1211 struct lmv_tgt_desc *tgt;
1215 rc = lmv_check_connect(obd);
1219 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1221 RETURN(PTR_ERR(tgt));
1223 if (op_data->op_flags & MF_GET_MDT_IDX) {
1224 op_data->op_mds = tgt->ltd_idx;
1228 rc = md_getattr(tgt->ltd_exp, op_data, request);
1233 static int lmv_change_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1234 ldlm_iterator_t it, void *data)
1236 struct obd_device *obd = exp->exp_obd;
1237 struct lmv_obd *lmv = &obd->u.lmv;
1242 rc = lmv_check_connect(obd);
1246 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1249 * With CMD every object can have two locks in different namespaces:
1250 * lookup lock in space of mds storing direntry and update/open lock in
1251 * space of mds storing inode.
1253 for (i = 0; i < lmv->desc.ld_tgt_count; i++)
1254 md_change_cbdata(lmv->tgts[i].ltd_exp, fid, it, data);
1259 static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1260 ldlm_iterator_t it, void *data)
1262 struct obd_device *obd = exp->exp_obd;
1263 struct lmv_obd *lmv = &obd->u.lmv;
1268 rc = lmv_check_connect(obd);
1272 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1275 * With CMD every object can have two locks in different namespaces:
1276 * lookup lock in space of mds storing direntry and update/open lock in
1277 * space of mds storing inode.
1279 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1280 rc = md_find_cbdata(lmv->tgts[i].ltd_exp, fid, it, data);
1289 static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
1290 struct md_open_data *mod, struct ptlrpc_request **request)
1292 struct obd_device *obd = exp->exp_obd;
1293 struct lmv_obd *lmv = &obd->u.lmv;
1294 struct lmv_tgt_desc *tgt;
1298 rc = lmv_check_connect(obd);
1302 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1304 RETURN(PTR_ERR(tgt));
1306 CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1));
1307 rc = md_close(tgt->ltd_exp, op_data, mod, request);
1312 *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
1315 struct lmv_tgt_desc *tgt;
1317 tgt = lmv_find_target(lmv, fid);
1318 op_data->op_mds = tgt->ltd_idx;
1323 int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
1324 const void *data, int datalen, int mode, __u32 uid,
1325 __u32 gid, cfs_cap_t cap_effective, __u64 rdev,
1326 struct ptlrpc_request **request)
1328 struct obd_device *obd = exp->exp_obd;
1329 struct lmv_obd *lmv = &obd->u.lmv;
1330 struct lmv_tgt_desc *tgt;
1334 rc = lmv_check_connect(obd);
1338 if (!lmv->desc.ld_active_tgt_count)
1341 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1343 RETURN(PTR_ERR(tgt));
1345 rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data);
1349 CDEBUG(D_INODE, "CREATE '%*s' on "DFID" -> mds #%x\n",
1350 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1353 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1354 rc = md_create(tgt->ltd_exp, op_data, data, datalen, mode, uid, gid,
1355 cap_effective, rdev, request);
1358 if (*request == NULL)
1360 CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2));
1365 static int lmv_done_writing(struct obd_export *exp,
1366 struct md_op_data *op_data,
1367 struct md_open_data *mod)
1369 struct obd_device *obd = exp->exp_obd;
1370 struct lmv_obd *lmv = &obd->u.lmv;
1371 struct lmv_tgt_desc *tgt;
1375 rc = lmv_check_connect(obd);
1379 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1381 RETURN(PTR_ERR(tgt));
1383 rc = md_done_writing(tgt->ltd_exp, op_data, mod);
1388 lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1389 struct lookup_intent *it, struct md_op_data *op_data,
1390 struct lustre_handle *lockh, void *lmm, int lmmsize,
1391 int extra_lock_flags)
1393 struct ptlrpc_request *req = it->d.lustre.it_data;
1394 struct obd_device *obd = exp->exp_obd;
1395 struct lmv_obd *lmv = &obd->u.lmv;
1396 struct lustre_handle plock;
1397 struct lmv_tgt_desc *tgt;
1398 struct md_op_data *rdata;
1400 struct mdt_body *body;
1405 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1406 LASSERT(body != NULL);
1408 if (!(body->valid & OBD_MD_MDS))
1411 CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n",
1412 LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1));
1415 * We got LOOKUP lock, but we really need attrs.
1417 pmode = it->d.lustre.it_lock_mode;
1418 LASSERT(pmode != 0);
1419 memcpy(&plock, lockh, sizeof(plock));
1420 it->d.lustre.it_lock_mode = 0;
1421 it->d.lustre.it_data = NULL;
1424 it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
1425 ptlrpc_req_finished(req);
1427 tgt = lmv_find_target(lmv, &fid1);
1429 GOTO(out, rc = PTR_ERR(tgt));
1431 OBD_ALLOC_PTR(rdata);
1433 GOTO(out, rc = -ENOMEM);
1435 rdata->op_fid1 = fid1;
1436 rdata->op_bias = MDS_CROSS_REF;
1438 rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
1439 lmm, lmmsize, NULL, extra_lock_flags);
1440 OBD_FREE_PTR(rdata);
1443 ldlm_lock_decref(&plock, pmode);
1448 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1449 struct lookup_intent *it, struct md_op_data *op_data,
1450 struct lustre_handle *lockh, void *lmm, int lmmsize,
1451 struct ptlrpc_request **req, __u64 extra_lock_flags)
1453 struct obd_device *obd = exp->exp_obd;
1454 struct lmv_obd *lmv = &obd->u.lmv;
1455 struct lmv_tgt_desc *tgt;
1459 rc = lmv_check_connect(obd);
1463 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n",
1464 LL_IT2STR(it), PFID(&op_data->op_fid1));
1466 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1468 RETURN(PTR_ERR(tgt));
1470 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n",
1471 LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
1473 rc = md_enqueue(tgt->ltd_exp, einfo, it, op_data, lockh,
1474 lmm, lmmsize, req, extra_lock_flags);
1476 if (rc == 0 && it && it->it_op == IT_OPEN) {
1477 rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh,
1478 lmm, lmmsize, extra_lock_flags);
1484 lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
1485 struct ptlrpc_request **request)
1487 struct ptlrpc_request *req = NULL;
1488 struct obd_device *obd = exp->exp_obd;
1489 struct lmv_obd *lmv = &obd->u.lmv;
1490 struct lmv_tgt_desc *tgt;
1491 struct mdt_body *body;
1495 rc = lmv_check_connect(obd);
1499 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1501 RETURN(PTR_ERR(tgt));
1503 CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" -> mds #%d\n",
1504 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1507 rc = md_getattr_name(tgt->ltd_exp, op_data, request);
1511 body = req_capsule_server_get(&(*request)->rq_pill,
1513 LASSERT(body != NULL);
1515 if (body->valid & OBD_MD_MDS) {
1516 struct lu_fid rid = body->fid1;
1517 CDEBUG(D_INODE, "Request attrs for "DFID"\n",
1520 tgt = lmv_find_target(lmv, &rid);
1522 ptlrpc_req_finished(*request);
1523 RETURN(PTR_ERR(tgt));
1526 op_data->op_fid1 = rid;
1527 op_data->op_valid |= OBD_MD_FLCROSSREF;
1528 op_data->op_namelen = 0;
1529 op_data->op_name = NULL;
1530 rc = md_getattr_name(tgt->ltd_exp, op_data, &req);
1531 ptlrpc_req_finished(*request);
1538 #define md_op_data_fid(op_data, fl) \
1539 (fl == MF_MDC_CANCEL_FID1 ? &op_data->op_fid1 : \
1540 fl == MF_MDC_CANCEL_FID2 ? &op_data->op_fid2 : \
1541 fl == MF_MDC_CANCEL_FID3 ? &op_data->op_fid3 : \
1542 fl == MF_MDC_CANCEL_FID4 ? &op_data->op_fid4 : \
1545 static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data,
1546 int op_tgt, ldlm_mode_t mode, int bits, int flag)
1548 struct lu_fid *fid = md_op_data_fid(op_data, flag);
1549 struct obd_device *obd = exp->exp_obd;
1550 struct lmv_obd *lmv = &obd->u.lmv;
1551 struct lmv_tgt_desc *tgt;
1552 ldlm_policy_data_t policy = {{0}};
1556 if (!fid_is_sane(fid))
1559 tgt = lmv_find_target(lmv, fid);
1561 RETURN(PTR_ERR(tgt));
1563 if (tgt->ltd_idx != op_tgt) {
1564 CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid));
1565 policy.l_inodebits.bits = bits;
1566 rc = md_cancel_unused(tgt->ltd_exp, fid, &policy,
1567 mode, LCF_ASYNC, NULL);
1570 "EARLY_CANCEL skip operation target %d on "DFID"\n",
1572 op_data->op_flags |= flag;
1580 * llite passes fid of an target inode in op_data->op_fid1 and id of directory in
1583 static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
1584 struct ptlrpc_request **request)
1586 struct obd_device *obd = exp->exp_obd;
1587 struct lmv_obd *lmv = &obd->u.lmv;
1588 struct lmv_tgt_desc *tgt;
1592 rc = lmv_check_connect(obd);
1596 LASSERT(op_data->op_namelen != 0);
1598 CDEBUG(D_INODE, "LINK "DFID":%*s to "DFID"\n",
1599 PFID(&op_data->op_fid2), op_data->op_namelen,
1600 op_data->op_name, PFID(&op_data->op_fid1));
1602 op_data->op_fsuid = cfs_curproc_fsuid();
1603 op_data->op_fsgid = cfs_curproc_fsgid();
1604 op_data->op_cap = cfs_curproc_cap_pack();
1605 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1607 RETURN(PTR_ERR(tgt));
1610 * Cancel UPDATE lock on child (fid1).
1612 op_data->op_flags |= MF_MDC_CANCEL_FID2;
1613 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1614 MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1);
1618 rc = md_link(tgt->ltd_exp, op_data, request);
1623 static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
1624 const char *old, int oldlen, const char *new, int newlen,
1625 struct ptlrpc_request **request)
1627 struct obd_device *obd = exp->exp_obd;
1628 struct lmv_obd *lmv = &obd->u.lmv;
1629 struct lmv_tgt_desc *src_tgt;
1630 struct lmv_tgt_desc *tgt_tgt;
1634 LASSERT(oldlen != 0);
1636 CDEBUG(D_INODE, "RENAME %*s in "DFID" to %*s in "DFID"\n",
1637 oldlen, old, PFID(&op_data->op_fid1),
1638 newlen, new, PFID(&op_data->op_fid2));
1640 rc = lmv_check_connect(obd);
1644 op_data->op_fsuid = cfs_curproc_fsuid();
1645 op_data->op_fsgid = cfs_curproc_fsgid();
1646 op_data->op_cap = cfs_curproc_cap_pack();
1647 src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1648 if (IS_ERR(src_tgt))
1649 RETURN(PTR_ERR(src_tgt));
1651 tgt_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1652 if (IS_ERR(tgt_tgt))
1653 RETURN(PTR_ERR(tgt_tgt));
1655 * LOOKUP lock on src child (fid3) should also be cancelled for
1656 * src_tgt in mdc_rename.
1658 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1661 * Cancel UPDATE locks on tgt parent (fid2), tgt_tgt is its
1664 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1665 LCK_EX, MDS_INODELOCK_UPDATE,
1666 MF_MDC_CANCEL_FID2);
1669 * Cancel LOOKUP locks on tgt child (fid4) for parent tgt_tgt.
1672 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1673 LCK_EX, MDS_INODELOCK_LOOKUP,
1674 MF_MDC_CANCEL_FID4);
1678 * Cancel all the locks on tgt child (fid4).
1681 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1682 LCK_EX, MDS_INODELOCK_FULL,
1683 MF_MDC_CANCEL_FID4);
1686 rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen,
1687 new, newlen, request);
1691 static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
1692 void *ea, int ealen, void *ea2, int ea2len,
1693 struct ptlrpc_request **request,
1694 struct md_open_data **mod)
1696 struct obd_device *obd = exp->exp_obd;
1697 struct lmv_obd *lmv = &obd->u.lmv;
1698 struct lmv_tgt_desc *tgt;
1702 rc = lmv_check_connect(obd);
1706 CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n",
1707 PFID(&op_data->op_fid1), op_data->op_attr.ia_valid);
1709 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1710 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1712 RETURN(PTR_ERR(tgt));
1714 rc = md_setattr(tgt->ltd_exp, op_data, ea, ealen, ea2,
1715 ea2len, request, mod);
1720 static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
1721 struct obd_capa *oc, struct ptlrpc_request **request)
1723 struct obd_device *obd = exp->exp_obd;
1724 struct lmv_obd *lmv = &obd->u.lmv;
1725 struct lmv_tgt_desc *tgt;
1729 rc = lmv_check_connect(obd);
1733 tgt = lmv_find_target(lmv, fid);
1735 RETURN(PTR_ERR(tgt));
1737 rc = md_sync(tgt->ltd_exp, fid, oc, request);
1742 static void lmv_hash_adjust(__u64 *hash, __u64 hash_adj)
1746 val = le64_to_cpu(*hash);
1748 val += MAX_HASH_SIZE;
1749 if (val != MDS_DIR_END_OFF)
1750 *hash = cpu_to_le64(val - hash_adj);
1753 static __u32 lmv_node_rank(struct obd_export *exp, const struct lu_fid *fid)
1756 struct obd_import *imp;
1759 * XXX: to get nid we assume that underlying obd device is mdc.
1761 imp = class_exp2cliimp(exp);
1762 id = imp->imp_connection->c_self + fid_flatten(fid);
1764 CDEBUG(D_INODE, "Readpage node rank: "LPX64" "DFID" "LPX64" "LPX64"\n",
1765 imp->imp_connection->c_self, PFID(fid), id, id ^ (id >> 32));
1767 return id ^ (id >> 32);
1771 static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data,
1772 struct page **pages, struct ptlrpc_request **request)
1774 struct obd_device *obd = exp->exp_obd;
1775 struct lmv_obd *lmv = &obd->u.lmv;
1776 __u64 offset = op_data->op_offset;
1779 /* number of pages read, in CFS_PAGE_SIZE */
1781 /* number of pages transferred in LU_PAGE_SIZE */
1783 struct lmv_tgt_desc *tgt;
1784 struct lu_dirpage *dp;
1785 struct lu_dirent *ent;
1788 rc = lmv_check_connect(obd);
1792 CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n",
1793 offset, PFID(&op_data->op_fid1));
1796 * This case handle directory lookup in clustered metadata case (i.e.
1797 * split directory is located on multiple md servers.)
1798 * each server keeps directory entries for certain range of hashes.
1799 * E.g. we have N server and suppose hash range is 0 to MAX_HASH.
1800 * first server will keep records with hashes [ 0 ... MAX_HASH /N - 1],
1801 * second one with hashes [MAX_HASH / N ... 2 * MAX_HASH / N] and
1803 * readdir can simply start reading entries from 0 - N server in
1804 * order but that will not scale well as all client will request dir in
1805 * to server in same order.
1806 * Following algorithm does optimization:
1807 * Instead of doing readdir in 1, 2, ...., N order, client with a
1808 * rank R does readdir in R, R + 1, ..., N, 1, ... R - 1 order.
1809 * (every client has rank R)
1810 * But ll_readdir() expect offset range [0 to MAX_HASH/N) but
1811 * since client ask dir from MDS{R} client has pages with offsets
1812 * [R*MAX_HASH/N ... (R + 1)*MAX_HASH/N] there for we do hash_adj
1813 * on hash values that we get.
1816 seg_size = MAX_HASH_SIZE;
1817 do_div(seg_size, nr);
1818 los = obj->lo_stripes;
1819 tgt = lmv_get_target(lmv, los[0].ls_mds);
1820 rank = lmv_node_rank(tgt->ltd_exp, fid) % nr;
1822 do_div(tgt_tmp, seg_size);
1823 tgt0_idx = do_div(tgt_tmp, nr);
1824 tgt_idx = (tgt0_idx + rank) % nr;
1826 if (tgt_idx < tgt0_idx)
1829 * Last segment has unusual length due to division
1831 hash_adj = MAX_HASH_SIZE - seg_size * nr;
1835 hash_adj += rank * seg_size;
1837 CDEBUG(D_INODE, "Readpage hash adjustment: %x "LPX64" "
1838 LPX64"/%x -> "LPX64"/%x\n", rank, hash_adj,
1839 offset, tgt0_idx, offset + hash_adj, tgt_idx);
1841 offset = (offset + hash_adj) & MAX_HASH_SIZE;
1842 rid = lsm->mea_oinfo[tgt_idx].lmo_fid;
1843 tgt = lmv_get_target(lmv, lsm->mea_oinfo[tgt_idx].lmo_mds);
1845 CDEBUG(D_INODE, "Forward to "DFID" with offset %lu i %d\n",
1846 PFID(&rid), (unsigned long)offset, tgt_idx);
1849 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1851 RETURN(PTR_ERR(tgt));
1853 rc = md_readpage(tgt->ltd_exp, op_data, pages, request);
1857 nrdpgs = ((*request)->rq_bulk->bd_nob_transferred + CFS_PAGE_SIZE - 1)
1859 nlupgs = (*request)->rq_bulk->bd_nob_transferred >> LU_PAGE_SHIFT;
1860 LASSERT(!((*request)->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK));
1861 LASSERT(nrdpgs > 0 && nrdpgs <= op_data->op_npages);
1863 CDEBUG(D_INODE, "read %d(%d)/%d pages\n", nrdpgs, nlupgs,
1864 op_data->op_npages);
1866 for (i = 0; i < nrdpgs; i++) {
1867 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1868 struct lu_dirpage *first;
1872 struct lu_dirent *tmp = NULL;
1874 dp = cfs_kmap(pages[i]);
1875 ent = lu_dirent_start(dp);
1876 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1878 hash_end = dp->ldp_hash_end;
1883 for (tmp = ent; ent != NULL;
1884 tmp = ent, ent = lu_dirent_next(ent));
1885 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1886 dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);
1887 if (((unsigned long)dp & ~CFS_PAGE_MASK) && nlupgs > 0) {
1888 ent = lu_dirent_start(dp);
1891 /* enlarge the end entry lde_reclen from 0 to
1892 * first entry of next lu_dirpage, in this way
1893 * several lu_dirpages can be stored into one
1894 * client page on client. */
1895 tmp = ((void *)tmp) +
1896 le16_to_cpu(tmp->lde_reclen);
1898 cpu_to_le16((char *)(dp->ldp_entries) -
1903 first->ldp_hash_end = hash_end;
1904 first->ldp_flags &= ~cpu_to_le32(LDF_COLLIDE);
1905 first->ldp_flags |= flags & cpu_to_le32(LDF_COLLIDE);
1907 SET_BUT_UNUSED(tmp);
1909 cfs_kunmap(pages[i]);
1914 static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data,
1915 struct ptlrpc_request **request)
1917 struct obd_device *obd = exp->exp_obd;
1918 struct lmv_obd *lmv = &obd->u.lmv;
1919 struct lmv_tgt_desc *tgt = NULL;
1923 rc = lmv_check_connect(obd);
1927 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1929 RETURN(PTR_ERR(tgt));
1931 op_data->op_fsuid = cfs_curproc_fsuid();
1932 op_data->op_fsgid = cfs_curproc_fsgid();
1933 op_data->op_cap = cfs_curproc_cap_pack();
1936 * If child's fid is given, cancel unused locks for it if it is from
1937 * another export than parent.
1939 * LOOKUP lock for child (fid3) should also be cancelled on parent
1940 * tgt_tgt in mdc_unlink().
1942 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1945 * Cancel FULL locks on child (fid3).
1947 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1948 MDS_INODELOCK_FULL, MF_MDC_CANCEL_FID3);
1953 rc = md_unlink(tgt->ltd_exp, op_data, request);
1958 static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
1960 struct lmv_obd *lmv = &obd->u.lmv;
1964 case OBD_CLEANUP_EARLY:
1965 /* XXX: here should be calling obd_precleanup() down to
1968 case OBD_CLEANUP_EXPORTS:
1969 fld_client_proc_fini(&lmv->lmv_fld);
1970 lprocfs_obd_cleanup(obd);
1978 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
1979 __u32 keylen, void *key, __u32 *vallen, void *val,
1980 struct lov_stripe_md *lsm)
1982 struct obd_device *obd;
1983 struct lmv_obd *lmv;
1987 obd = class_exp2obd(exp);
1989 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
1990 exp->exp_handle.h_cookie);
1995 if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
1996 struct lmv_tgt_desc *tgts;
1999 rc = lmv_check_connect(obd);
2003 LASSERT(*vallen == sizeof(__u32));
2004 for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count;
2008 * All tgts should be connected when this gets called.
2010 if (!tgts || !tgts->ltd_exp) {
2011 CERROR("target not setup?\n");
2015 if (!obd_get_info(env, tgts->ltd_exp, keylen, key,
2020 } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) {
2021 rc = lmv_check_connect(obd);
2026 * Forwarding this request to first MDS, it should know LOV
2029 rc = obd_get_info(env, lmv->tgts[0].ltd_exp, keylen, key,
2031 if (!rc && KEY_IS(KEY_CONN_DATA)) {
2032 exp->exp_connect_flags =
2033 ((struct obd_connect_data *)val)->ocd_connect_flags;
2036 } else if (KEY_IS(KEY_TGT_COUNT)) {
2037 *((int *)val) = lmv->desc.ld_tgt_count;
2041 CDEBUG(D_IOCTL, "Invalid key\n");
2045 int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
2046 obd_count keylen, void *key, obd_count vallen,
2047 void *val, struct ptlrpc_request_set *set)
2049 struct lmv_tgt_desc *tgt;
2050 struct obd_device *obd;
2051 struct lmv_obd *lmv;
2055 obd = class_exp2obd(exp);
2057 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2058 exp->exp_handle.h_cookie);
2063 if (KEY_IS(KEY_READ_ONLY) || KEY_IS(KEY_FLUSH_CTX)) {
2066 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2067 tgt = &lmv->tgts[i];
2072 err = obd_set_info_async(env, tgt->ltd_exp,
2073 keylen, key, vallen, val, set);
2084 int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
2085 struct lov_stripe_md *lsm)
2087 struct obd_device *obd = class_exp2obd(exp);
2088 struct lmv_obd *lmv = &obd->u.lmv;
2089 struct lmv_stripe_md *meap;
2090 struct lmv_stripe_md *lsmp;
2095 mea_size = lmv_get_easize(lmv);
2099 if (*lmmp && !lsm) {
2100 OBD_FREE_LARGE(*lmmp, mea_size);
2105 if (*lmmp == NULL) {
2106 OBD_ALLOC_LARGE(*lmmp, mea_size);
2114 lsmp = (struct lmv_stripe_md *)lsm;
2115 meap = (struct lmv_stripe_md *)*lmmp;
2117 if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR &&
2118 lsmp->mea_magic != MEA_MAGIC_ALL_CHARS)
2121 meap->mea_magic = cpu_to_le32(lsmp->mea_magic);
2122 meap->mea_count = cpu_to_le32(lsmp->mea_count);
2123 meap->mea_master = cpu_to_le32(lsmp->mea_master);
2125 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2126 meap->mea_ids[i] = meap->mea_ids[i];
2127 fid_cpu_to_le(&meap->mea_ids[i], &meap->mea_ids[i]);
2133 int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
2134 struct lov_mds_md *lmm, int lmm_size)
2136 struct obd_device *obd = class_exp2obd(exp);
2137 struct lmv_stripe_md **tmea = (struct lmv_stripe_md **)lsmp;
2138 struct lmv_stripe_md *mea = (struct lmv_stripe_md *)lmm;
2139 struct lmv_obd *lmv = &obd->u.lmv;
2145 mea_size = lmv_get_easize(lmv);
2149 if (*lsmp != NULL && lmm == NULL) {
2150 OBD_FREE_LARGE(*tmea, mea_size);
2155 LASSERT(mea_size == lmm_size);
2157 OBD_ALLOC_LARGE(*tmea, mea_size);
2164 if (mea->mea_magic == MEA_MAGIC_LAST_CHAR ||
2165 mea->mea_magic == MEA_MAGIC_ALL_CHARS ||
2166 mea->mea_magic == MEA_MAGIC_HASH_SEGMENT)
2168 magic = le32_to_cpu(mea->mea_magic);
2171 * Old mea is not handled here.
2173 CERROR("Old not supportable EA is found\n");
2177 (*tmea)->mea_magic = magic;
2178 (*tmea)->mea_count = le32_to_cpu(mea->mea_count);
2179 (*tmea)->mea_master = le32_to_cpu(mea->mea_master);
2181 for (i = 0; i < (*tmea)->mea_count; i++) {
2182 (*tmea)->mea_ids[i] = mea->mea_ids[i];
2183 fid_le_to_cpu(&(*tmea)->mea_ids[i], &(*tmea)->mea_ids[i]);
2188 static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
2189 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2190 ldlm_cancel_flags_t flags, void *opaque)
2192 struct obd_device *obd = exp->exp_obd;
2193 struct lmv_obd *lmv = &obd->u.lmv;
2199 LASSERT(fid != NULL);
2201 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2202 if (!lmv->tgts[i].ltd_exp || !lmv->tgts[i].ltd_active)
2205 err = md_cancel_unused(lmv->tgts[i].ltd_exp, fid,
2206 policy, mode, flags, opaque);
2213 int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
2216 struct obd_device *obd = exp->exp_obd;
2217 struct lmv_obd *lmv = &obd->u.lmv;
2221 rc = md_set_lock_data(lmv->tgts[0].ltd_exp, lockh, data, bits);
2225 ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags,
2226 const struct lu_fid *fid, ldlm_type_t type,
2227 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2228 struct lustre_handle *lockh)
2230 struct obd_device *obd = exp->exp_obd;
2231 struct lmv_obd *lmv = &obd->u.lmv;
2236 CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid));
2239 * With CMD every object can have two locks in different namespaces:
2240 * lookup lock in space of mds storing direntry and update/open lock in
2241 * space of mds storing inode. Thus we check all targets, not only that
2242 * one fid was created in.
2244 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2245 rc = md_lock_match(lmv->tgts[i].ltd_exp, flags, fid,
2246 type, policy, mode, lockh);
2254 int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
2255 struct obd_export *dt_exp, struct obd_export *md_exp,
2256 struct lustre_md *md)
2258 struct obd_device *obd = exp->exp_obd;
2259 struct lmv_obd *lmv = &obd->u.lmv;
2262 rc = md_get_lustre_md(lmv->tgts[0].ltd_exp, req, dt_exp, md_exp, md);
2266 int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
2268 struct obd_device *obd = exp->exp_obd;
2269 struct lmv_obd *lmv = &obd->u.lmv;
2273 obd_free_memmd(exp, (void *)&md->mea);
2274 RETURN(md_free_lustre_md(lmv->tgts[0].ltd_exp, md));
2277 int lmv_set_open_replay_data(struct obd_export *exp,
2278 struct obd_client_handle *och,
2279 struct ptlrpc_request *open_req)
2281 struct obd_device *obd = exp->exp_obd;
2282 struct lmv_obd *lmv = &obd->u.lmv;
2283 struct lmv_tgt_desc *tgt;
2286 tgt = lmv_find_target(lmv, &och->och_fid);
2288 RETURN(PTR_ERR(tgt));
2290 RETURN(md_set_open_replay_data(tgt->ltd_exp, och, open_req));
2293 int lmv_clear_open_replay_data(struct obd_export *exp,
2294 struct obd_client_handle *och)
2296 struct obd_device *obd = exp->exp_obd;
2297 struct lmv_obd *lmv = &obd->u.lmv;
2298 struct lmv_tgt_desc *tgt;
2301 tgt = lmv_find_target(lmv, &och->och_fid);
2303 RETURN(PTR_ERR(tgt));
2305 RETURN(md_clear_open_replay_data(tgt->ltd_exp, och));
2308 static int lmv_get_remote_perm(struct obd_export *exp,
2309 const struct lu_fid *fid,
2310 struct obd_capa *oc, __u32 suppgid,
2311 struct ptlrpc_request **request)
2313 struct obd_device *obd = exp->exp_obd;
2314 struct lmv_obd *lmv = &obd->u.lmv;
2315 struct lmv_tgt_desc *tgt;
2319 rc = lmv_check_connect(obd);
2323 tgt = lmv_find_target(lmv, fid);
2325 RETURN(PTR_ERR(tgt));
2327 rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request);
2331 static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2334 struct obd_device *obd = exp->exp_obd;
2335 struct lmv_obd *lmv = &obd->u.lmv;
2336 struct lmv_tgt_desc *tgt;
2340 rc = lmv_check_connect(obd);
2344 tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid);
2346 RETURN(PTR_ERR(tgt));
2348 rc = md_renew_capa(tgt->ltd_exp, oc, cb);
2352 int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
2353 const struct req_msg_field *field, struct obd_capa **oc)
2355 struct obd_device *obd = exp->exp_obd;
2356 struct lmv_obd *lmv = &obd->u.lmv;
2360 rc = md_unpack_capa(lmv->tgts[0].ltd_exp, req, field, oc);
2364 int lmv_intent_getattr_async(struct obd_export *exp,
2365 struct md_enqueue_info *minfo,
2366 struct ldlm_enqueue_info *einfo)
2368 struct md_op_data *op_data = &minfo->mi_data;
2369 struct obd_device *obd = exp->exp_obd;
2370 struct lmv_obd *lmv = &obd->u.lmv;
2371 struct lmv_tgt_desc *tgt = NULL;
2375 rc = lmv_check_connect(obd);
2379 tgt = lmv_find_target(lmv, &op_data->op_fid1);
2381 RETURN(PTR_ERR(tgt));
2383 rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo);
2387 int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
2388 struct lu_fid *fid, __u64 *bits)
2390 struct obd_device *obd = exp->exp_obd;
2391 struct lmv_obd *lmv = &obd->u.lmv;
2392 struct lmv_tgt_desc *tgt;
2396 rc = lmv_check_connect(obd);
2400 tgt = lmv_find_target(lmv, fid);
2402 RETURN(PTR_ERR(tgt));
2404 rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits);
2409 * For lmv, only need to send request to master MDT, and the master MDT will
2410 * process with other slave MDTs. The only exception is Q_GETOQUOTA for which
2411 * we directly fetch data from the slave MDTs.
2413 int lmv_quotactl(struct obd_device *unused, struct obd_export *exp,
2414 struct obd_quotactl *oqctl)
2416 struct obd_device *obd = class_exp2obd(exp);
2417 struct lmv_obd *lmv = &obd->u.lmv;
2418 struct lmv_tgt_desc *tgt = &lmv->tgts[0];
2420 __u64 curspace, curinodes;
2423 if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) {
2424 CERROR("master lmv inactive\n");
2428 if (oqctl->qc_cmd != Q_GETOQUOTA) {
2429 rc = obd_quotactl(tgt->ltd_exp, oqctl);
2433 curspace = curinodes = 0;
2434 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2436 tgt = &lmv->tgts[i];
2438 if (tgt->ltd_exp == NULL)
2440 if (!tgt->ltd_active) {
2441 CDEBUG(D_HA, "mdt %d is inactive.\n", i);
2445 err = obd_quotactl(tgt->ltd_exp, oqctl);
2447 CERROR("getquota on mdt %d failed. %d\n", i, err);
2451 curspace += oqctl->qc_dqblk.dqb_curspace;
2452 curinodes += oqctl->qc_dqblk.dqb_curinodes;
2455 oqctl->qc_dqblk.dqb_curspace = curspace;
2456 oqctl->qc_dqblk.dqb_curinodes = curinodes;
2461 int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
2462 struct obd_quotactl *oqctl)
2464 struct obd_device *obd = class_exp2obd(exp);
2465 struct lmv_obd *lmv = &obd->u.lmv;
2466 struct lmv_tgt_desc *tgt;
2470 for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
2473 if (!tgt->ltd_active) {
2474 CERROR("lmv idx %d inactive\n", i);
2478 err = obd_quotacheck(tgt->ltd_exp, oqctl);
2486 struct obd_ops lmv_obd_ops = {
2487 .o_owner = THIS_MODULE,
2488 .o_setup = lmv_setup,
2489 .o_cleanup = lmv_cleanup,
2490 .o_precleanup = lmv_precleanup,
2491 .o_process_config = lmv_process_config,
2492 .o_connect = lmv_connect,
2493 .o_disconnect = lmv_disconnect,
2494 .o_statfs = lmv_statfs,
2495 .o_get_info = lmv_get_info,
2496 .o_set_info_async = lmv_set_info_async,
2497 .o_packmd = lmv_packmd,
2498 .o_unpackmd = lmv_unpackmd,
2499 .o_notify = lmv_notify,
2500 .o_get_uuid = lmv_get_uuid,
2501 .o_iocontrol = lmv_iocontrol,
2502 .o_quotacheck = lmv_quotacheck,
2503 .o_quotactl = lmv_quotactl
2506 struct md_ops lmv_md_ops = {
2507 .m_getstatus = lmv_getstatus,
2508 .m_change_cbdata = lmv_change_cbdata,
2509 .m_find_cbdata = lmv_find_cbdata,
2510 .m_close = lmv_close,
2511 .m_create = lmv_create,
2512 .m_done_writing = lmv_done_writing,
2513 .m_enqueue = lmv_enqueue,
2514 .m_getattr = lmv_getattr,
2515 .m_getxattr = lmv_getxattr,
2516 .m_getattr_name = lmv_getattr_name,
2517 .m_intent_lock = lmv_intent_lock,
2519 .m_rename = lmv_rename,
2520 .m_setattr = lmv_setattr,
2521 .m_setxattr = lmv_setxattr,
2523 .m_readpage = lmv_readpage,
2524 .m_unlink = lmv_unlink,
2525 .m_init_ea_size = lmv_init_ea_size,
2526 .m_cancel_unused = lmv_cancel_unused,
2527 .m_set_lock_data = lmv_set_lock_data,
2528 .m_lock_match = lmv_lock_match,
2529 .m_get_lustre_md = lmv_get_lustre_md,
2530 .m_free_lustre_md = lmv_free_lustre_md,
2531 .m_set_open_replay_data = lmv_set_open_replay_data,
2532 .m_clear_open_replay_data = lmv_clear_open_replay_data,
2533 .m_renew_capa = lmv_renew_capa,
2534 .m_unpack_capa = lmv_unpack_capa,
2535 .m_get_remote_perm = lmv_get_remote_perm,
2536 .m_intent_getattr_async = lmv_intent_getattr_async,
2537 .m_revalidate_lock = lmv_revalidate_lock
2540 int __init lmv_init(void)
2542 struct lprocfs_static_vars lvars;
2545 lprocfs_lmv_init_vars(&lvars);
2547 rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
2548 lvars.module_vars, LUSTRE_LMV_NAME, NULL);
2553 static void lmv_exit(void)
2555 class_unregister_type(LUSTRE_LMV_NAME);
2558 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2559 MODULE_DESCRIPTION("Lustre Logical Metadata Volume OBD driver");
2560 MODULE_LICENSE("GPL");
2562 module_init(lmv_init);
2563 module_exit(lmv_exit);