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; i < lmv->desc.ld_tgt_count; i++) {
95 if (tgt == NULL || tgt->ltd_exp == NULL)
98 CDEBUG(D_INFO, "Target idx %d is %s conn "LPX64"\n", i,
99 tgt->ltd_uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
101 if (obd_uuid_equals(uuid, &tgt->ltd_uuid))
105 if (i == lmv->desc.ld_tgt_count)
106 GOTO(out_lmv_lock, rc = -EINVAL);
108 obd = class_exp2obd(tgt->ltd_exp);
110 GOTO(out_lmv_lock, rc = -ENOTCONN);
112 CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LMV idx %d\n",
113 obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd,
114 obd->obd_type->typ_name, i);
115 LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0);
117 if (tgt->ltd_active == activate) {
118 CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd,
119 activate ? "" : "in");
120 GOTO(out_lmv_lock, rc);
123 CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd,
124 activate ? "" : "in");
125 lmv_activate_target(lmv, tgt, activate);
129 spin_unlock(&lmv->lmv_lock);
133 struct obd_uuid *lmv_get_uuid(struct obd_export *exp)
135 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
137 return obd_get_uuid(lmv->tgts[0]->ltd_exp);
140 static int lmv_notify(struct obd_device *obd, struct obd_device *watched,
141 enum obd_notify_event ev, void *data)
143 struct obd_connect_data *conn_data;
144 struct lmv_obd *lmv = &obd->u.lmv;
145 struct obd_uuid *uuid;
149 if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) {
150 CERROR("unexpected notification of %s %s!\n",
151 watched->obd_type->typ_name,
156 uuid = &watched->u.cli.cl_target_uuid;
157 if (ev == OBD_NOTIFY_ACTIVE || ev == OBD_NOTIFY_INACTIVE) {
159 * Set MDC as active before notifying the observer, so the
160 * observer can use the MDC normally.
162 rc = lmv_set_mdc_active(lmv, uuid,
163 ev == OBD_NOTIFY_ACTIVE);
165 CERROR("%sactivation of %s failed: %d\n",
166 ev == OBD_NOTIFY_ACTIVE ? "" : "de",
170 } else if (ev == OBD_NOTIFY_OCD) {
171 conn_data = &watched->u.cli.cl_import->imp_connect_data;
173 * XXX: Make sure that ocd_connect_flags from all targets are
174 * the same. Otherwise one of MDTs runs wrong version or
175 * something like this. --umka
177 obd->obd_self_export->exp_connect_flags =
178 conn_data->ocd_connect_flags;
181 else if (ev == OBD_NOTIFY_DISCON) {
183 * For disconnect event, flush fld cache for failout MDS case.
185 fld_client_flush(&lmv->lmv_fld);
189 * Pass the notification up the chain.
191 if (obd->obd_observer)
192 rc = obd_notify(obd->obd_observer, watched, ev, data);
198 * This is fake connect function. Its purpose is to initialize lmv and say
199 * caller that everything is okay. Real connection will be performed later.
201 static int lmv_connect(const struct lu_env *env,
202 struct obd_export **exp, struct obd_device *obd,
203 struct obd_uuid *cluuid, struct obd_connect_data *data,
207 struct proc_dir_entry *lmv_proc_dir;
209 struct lmv_obd *lmv = &obd->u.lmv;
210 struct lustre_handle conn = { 0 };
215 * We don't want to actually do the underlying connections more than
216 * once, so keep track.
219 if (lmv->refcount > 1) {
224 rc = class_connect(&conn, obd, cluuid);
226 CERROR("class_connection() returned %d\n", rc);
230 *exp = class_conn2export(&conn);
231 class_export_get(*exp);
235 lmv->cluuid = *cluuid;
238 lmv->conn_data = *data;
241 lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
243 if (IS_ERR(lmv_proc_dir)) {
244 CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
245 obd->obd_type->typ_name, obd->obd_name);
251 * All real clients should perform actual connection right away, because
252 * it is possible, that LMV will not have opportunity to connect targets
253 * and MDC stuff will be called directly, for instance while reading
254 * ../mdc/../kbytesfree procfs file, etc.
256 if (data->ocd_connect_flags & OBD_CONNECT_REAL)
257 rc = lmv_check_connect(obd);
262 lprocfs_remove(&lmv_proc_dir);
269 static void lmv_set_timeouts(struct obd_device *obd)
271 struct lmv_tgt_desc *tgt;
276 if (lmv->server_timeout == 0)
279 if (lmv->connected == 0)
282 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
284 if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0)
287 obd_set_info_async(NULL, tgt->ltd_exp, sizeof(KEY_INTERMDS),
288 KEY_INTERMDS, 0, NULL, NULL);
292 static int lmv_init_ea_size(struct obd_export *exp, int easize,
293 int def_easize, int cookiesize)
295 struct obd_device *obd = exp->exp_obd;
296 struct lmv_obd *lmv = &obd->u.lmv;
302 if (lmv->max_easize < easize) {
303 lmv->max_easize = easize;
306 if (lmv->max_def_easize < def_easize) {
307 lmv->max_def_easize = def_easize;
310 if (lmv->max_cookiesize < cookiesize) {
311 lmv->max_cookiesize = cookiesize;
317 if (lmv->connected == 0)
320 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
321 if (lmv->tgts[i] == NULL ||
322 lmv->tgts[i]->ltd_exp == NULL ||
323 lmv->tgts[i]->ltd_active == 0) {
324 CWARN("%s: NULL export for %d\n", obd->obd_name, i);
328 rc = md_init_ea_size(lmv->tgts[i]->ltd_exp, easize, def_easize,
331 CERROR("%s: obd_init_ea_size() failed on MDT target %d:"
332 " rc = %d.\n", obd->obd_name, i, rc);
339 #define MAX_STRING_SIZE 128
341 int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
344 struct proc_dir_entry *lmv_proc_dir;
346 struct lmv_obd *lmv = &obd->u.lmv;
347 struct obd_uuid *cluuid = &lmv->cluuid;
348 struct obd_connect_data *mdc_data = NULL;
349 struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" };
350 struct obd_device *mdc_obd;
351 struct obd_export *mdc_exp;
352 struct lu_fld_target target;
356 mdc_obd = class_find_client_obd(&tgt->ltd_uuid, LUSTRE_MDC_NAME,
359 CERROR("target %s not attached\n", tgt->ltd_uuid.uuid);
363 CDEBUG(D_CONFIG, "connect to %s(%s) - %s, %s FOR %s\n",
364 mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
365 tgt->ltd_uuid.uuid, obd->obd_uuid.uuid,
368 if (!mdc_obd->obd_set_up) {
369 CERROR("target %s is not set up\n", tgt->ltd_uuid.uuid);
373 rc = obd_connect(NULL, &mdc_exp, mdc_obd, &lmv_mdc_uuid,
374 &lmv->conn_data, NULL);
376 CERROR("target %s connect error %d\n", tgt->ltd_uuid.uuid, rc);
381 * Init fid sequence client for this mdc and add new fld target.
383 rc = obd_fid_init(mdc_obd, mdc_exp, LUSTRE_SEQ_METADATA);
387 target.ft_srv = NULL;
388 target.ft_exp = mdc_exp;
389 target.ft_idx = tgt->ltd_idx;
391 fld_client_add_target(&lmv->lmv_fld, &target);
393 mdc_data = &class_exp2cliimp(mdc_exp)->imp_connect_data;
395 rc = obd_register_observer(mdc_obd, obd);
397 obd_disconnect(mdc_exp);
398 CERROR("target %s register_observer error %d\n",
399 tgt->ltd_uuid.uuid, rc);
403 if (obd->obd_observer) {
405 * Tell the observer about the new target.
407 rc = obd_notify(obd->obd_observer, mdc_exp->exp_obd,
409 (void *)(tgt - lmv->tgts[0]));
411 obd_disconnect(mdc_exp);
417 tgt->ltd_exp = mdc_exp;
418 lmv->desc.ld_active_tgt_count++;
420 md_init_ea_size(tgt->ltd_exp, lmv->max_easize,
421 lmv->max_def_easize, lmv->max_cookiesize);
423 CDEBUG(D_CONFIG, "Connected to %s(%s) successfully (%d)\n",
424 mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
425 cfs_atomic_read(&obd->obd_refcount));
428 lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
430 struct proc_dir_entry *mdc_symlink;
432 LASSERT(mdc_obd->obd_type != NULL);
433 LASSERT(mdc_obd->obd_type->typ_name != NULL);
434 mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
437 mdc_obd->obd_type->typ_name,
439 if (mdc_symlink == NULL) {
440 CERROR("Could not register LMV target "
441 "/proc/fs/lustre/%s/%s/target_obds/%s.",
442 obd->obd_type->typ_name, obd->obd_name,
444 lprocfs_remove(&lmv_proc_dir);
452 static void lmv_del_target(struct lmv_obd *lmv, int index)
454 if (lmv->tgts[index] == NULL)
457 OBD_FREE_PTR(lmv->tgts[index]);
458 lmv->tgts[index] = NULL;
462 static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
463 __u32 index, int gen)
465 struct lmv_obd *lmv = &obd->u.lmv;
466 struct lmv_tgt_desc *tgt;
470 CDEBUG(D_CONFIG, "Target uuid: %s. index %d\n", uuidp->uuid, index);
474 if (lmv->desc.ld_tgt_count == 0) {
475 struct obd_device *mdc_obd;
477 mdc_obd = class_find_client_obd(uuidp, LUSTRE_MDC_NAME,
480 lmv_init_unlock(lmv);
481 CERROR("%s: Target %s not attached: rc = %d\n",
482 obd->obd_name, uuidp->uuid, -EINVAL);
487 if ((index < lmv->tgts_size) && (lmv->tgts[index] != NULL)) {
488 tgt = lmv->tgts[index];
489 CERROR("%s: UUID %s already assigned at LOV target index %d:"
490 " rc = %d\n", obd->obd_name,
491 obd_uuid2str(&tgt->ltd_uuid), index, -EEXIST);
492 lmv_init_unlock(lmv);
496 if (index >= lmv->tgts_size) {
497 /* We need to reallocate the lmv target array. */
498 struct lmv_tgt_desc **newtgts, **old = NULL;
502 while (newsize < index + 1)
503 newsize = newsize << 1;
504 OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
505 if (newtgts == NULL) {
506 lmv_init_unlock(lmv);
510 if (lmv->tgts_size) {
511 memcpy(newtgts, lmv->tgts,
512 sizeof(*newtgts) * lmv->tgts_size);
514 oldsize = lmv->tgts_size;
518 lmv->tgts_size = newsize;
521 OBD_FREE(old, sizeof(*old) * oldsize);
523 CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts,
529 lmv_init_unlock(lmv);
533 mutex_init(&tgt->ltd_fid_mutex);
534 tgt->ltd_idx = index;
535 tgt->ltd_uuid = *uuidp;
537 lmv->tgts[index] = tgt;
538 if (index >= lmv->desc.ld_tgt_count)
539 lmv->desc.ld_tgt_count = index + 1;
541 if (lmv->connected) {
542 rc = lmv_connect_mdc(obd, tgt);
544 spin_lock(&lmv->lmv_lock);
545 lmv->desc.ld_tgt_count--;
546 memset(tgt, 0, sizeof(*tgt));
547 spin_unlock(&lmv->lmv_lock);
549 int easize = sizeof(struct lmv_stripe_md) +
550 lmv->desc.ld_tgt_count *
551 sizeof(struct lu_fid);
552 lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
556 lmv_init_unlock(lmv);
560 int lmv_check_connect(struct obd_device *obd)
562 struct lmv_obd *lmv = &obd->u.lmv;
563 struct lmv_tgt_desc *tgt;
573 if (lmv->connected) {
574 lmv_init_unlock(lmv);
578 if (lmv->desc.ld_tgt_count == 0) {
579 lmv_init_unlock(lmv);
580 CERROR("%s: no targets configured.\n", obd->obd_name);
584 CDEBUG(D_CONFIG, "Time to connect %s to %s\n",
585 lmv->cluuid.uuid, obd->obd_name);
587 LASSERT(lmv->tgts != NULL);
589 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
593 rc = lmv_connect_mdc(obd, tgt);
598 lmv_set_timeouts(obd);
599 class_export_put(lmv->exp);
601 easize = lmv_get_easize(lmv);
602 lmv_init_ea_size(obd->obd_self_export, easize, 0, 0);
603 lmv_init_unlock(lmv);
614 --lmv->desc.ld_active_tgt_count;
615 rc2 = obd_disconnect(tgt->ltd_exp);
617 CERROR("LMV target %s disconnect on "
618 "MDC idx %d: error %d\n",
619 tgt->ltd_uuid.uuid, i, rc2);
623 class_disconnect(lmv->exp);
624 lmv_init_unlock(lmv);
628 static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
631 struct proc_dir_entry *lmv_proc_dir;
633 struct lmv_obd *lmv = &obd->u.lmv;
634 struct obd_device *mdc_obd;
638 LASSERT(tgt != NULL);
639 LASSERT(obd != NULL);
641 mdc_obd = class_exp2obd(tgt->ltd_exp);
644 mdc_obd->obd_force = obd->obd_force;
645 mdc_obd->obd_fail = obd->obd_fail;
646 mdc_obd->obd_no_recov = obd->obd_no_recov;
650 lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
652 struct proc_dir_entry *mdc_symlink;
654 mdc_symlink = lprocfs_srch(lmv_proc_dir, mdc_obd->obd_name);
656 lprocfs_remove(&mdc_symlink);
658 CERROR("/proc/fs/lustre/%s/%s/target_obds/%s missing\n",
659 obd->obd_type->typ_name, obd->obd_name,
664 rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
666 CERROR("Can't finanize fids factory\n");
668 CDEBUG(D_INFO, "Disconnected from %s(%s) successfully\n",
669 tgt->ltd_exp->exp_obd->obd_name,
670 tgt->ltd_exp->exp_obd->obd_uuid.uuid);
672 obd_register_observer(tgt->ltd_exp->exp_obd, NULL);
673 rc = obd_disconnect(tgt->ltd_exp);
675 if (tgt->ltd_active) {
676 CERROR("Target %s disconnect error %d\n",
677 tgt->ltd_uuid.uuid, rc);
681 lmv_activate_target(lmv, tgt, 0);
686 static int lmv_disconnect(struct obd_export *exp)
688 struct obd_device *obd = class_exp2obd(exp);
690 struct proc_dir_entry *lmv_proc_dir;
692 struct lmv_obd *lmv = &obd->u.lmv;
701 * Only disconnect the underlying layers on the final disconnect.
704 if (lmv->refcount != 0)
707 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
708 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
711 lmv_disconnect_mdc(obd, lmv->tgts[i]);
715 lmv_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
717 lprocfs_remove(&lmv_proc_dir);
719 CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
720 obd->obd_type->typ_name, obd->obd_name);
726 * This is the case when no real connection is established by
727 * lmv_check_connect().
730 class_export_put(exp);
731 rc = class_disconnect(exp);
732 if (lmv->refcount == 0)
737 static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
738 int len, void *karg, void *uarg)
740 struct obd_device *obddev = class_exp2obd(exp);
741 struct lmv_obd *lmv = &obddev->u.lmv;
745 int count = lmv->desc.ld_tgt_count;
752 case IOC_OBD_STATFS: {
753 struct obd_ioctl_data *data = karg;
754 struct obd_device *mdc_obd;
755 struct obd_statfs stat_buf = {0};
758 memcpy(&index, data->ioc_inlbuf2, sizeof(__u32));
759 if ((index >= count))
762 if (lmv->tgts[index] == NULL ||
763 lmv->tgts[index]->ltd_active == 0)
766 mdc_obd = class_exp2obd(lmv->tgts[index]->ltd_exp);
771 if (cfs_copy_to_user(data->ioc_pbuf2, obd2cli_tgt(mdc_obd),
772 min((int) data->ioc_plen2,
773 (int) sizeof(struct obd_uuid))))
776 rc = obd_statfs(NULL, lmv->tgts[index]->ltd_exp, &stat_buf,
777 cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
781 if (cfs_copy_to_user(data->ioc_pbuf1, &stat_buf,
782 min((int) data->ioc_plen1,
783 (int) sizeof(stat_buf))))
787 case OBD_IOC_QUOTACTL: {
788 struct if_quotactl *qctl = karg;
789 struct lmv_tgt_desc *tgt = NULL;
790 struct obd_quotactl *oqctl;
792 if (qctl->qc_valid == QC_MDTIDX) {
793 if (qctl->qc_idx < 0 || count <= qctl->qc_idx)
796 tgt = lmv->tgts[qctl->qc_idx];
797 if (tgt == NULL || tgt->ltd_exp == NULL)
799 } else if (qctl->qc_valid == QC_UUID) {
800 for (i = 0; i < count; i++) {
804 if (!obd_uuid_equals(&tgt->ltd_uuid,
808 if (tgt->ltd_exp == NULL)
820 LASSERT(tgt && tgt->ltd_exp);
821 OBD_ALLOC_PTR(oqctl);
825 QCTL_COPY(oqctl, qctl);
826 rc = obd_quotactl(tgt->ltd_exp, oqctl);
828 QCTL_COPY(qctl, oqctl);
829 qctl->qc_valid = QC_MDTIDX;
830 qctl->obd_uuid = tgt->ltd_uuid;
835 case OBD_IOC_CHANGELOG_SEND:
836 case OBD_IOC_CHANGELOG_CLEAR: {
837 struct ioc_changelog *icc = karg;
839 if (icc->icc_mdtindex >= count)
842 if (lmv->tgts[icc->icc_mdtindex] == NULL ||
843 lmv->tgts[icc->icc_mdtindex]->ltd_exp == NULL ||
844 lmv->tgts[icc->icc_mdtindex]->ltd_active == 0)
846 rc = obd_iocontrol(cmd, lmv->tgts[icc->icc_mdtindex]->ltd_exp,
847 sizeof(*icc), icc, NULL);
850 case LL_IOC_GET_CONNECT_FLAGS: {
851 if (lmv->tgts[0] == NULL)
853 rc = obd_iocontrol(cmd, lmv->tgts[0]->ltd_exp, len, karg, uarg);
856 case OBD_IOC_FID2PATH: {
857 struct getinfo_fid2path *gf;
858 struct lmv_tgt_desc *tgt;
860 gf = (struct getinfo_fid2path *)karg;
861 tgt = lmv_find_target(lmv, &gf->gf_fid);
863 RETURN(PTR_ERR(tgt));
864 rc = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
867 case LL_IOC_HSM_STATE_GET:
868 case LL_IOC_HSM_STATE_SET: {
869 struct md_op_data *op_data = karg;
870 struct lmv_tgt_desc *tgt;
872 tgt = lmv_find_target(lmv, &op_data->op_fid1);
876 rc = obd_iocontrol(cmd, lmv->tgts[0]->ltd_exp, len, karg, uarg);
880 for (i = 0; i < count; i++) {
881 struct obd_device *mdc_obd;
884 if (lmv->tgts[i] == NULL ||
885 lmv->tgts[i]->ltd_exp == NULL)
887 /* ll_umount_begin() sets force flag but for lmv, not
888 * mdc. Let's pass it through */
889 mdc_obd = class_exp2obd(lmv->tgts[i]->ltd_exp);
890 mdc_obd->obd_force = obddev->obd_force;
891 err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len,
893 if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) {
896 if (lmv->tgts[i]->ltd_active) {
897 CERROR("error: iocontrol MDC %s on MDT"
898 "idx %d cmd %x: err = %d\n",
899 lmv->tgts[i]->ltd_uuid.uuid,
914 static int lmv_all_chars_policy(int count, const char *name,
925 static int lmv_nid_policy(struct lmv_obd *lmv)
927 struct obd_import *imp;
931 * XXX: To get nid we assume that underlying obd device is mdc.
933 imp = class_exp2cliimp(lmv->tgts[0].ltd_exp);
934 id = imp->imp_connection->c_self ^ (imp->imp_connection->c_self >> 32);
935 return id % lmv->desc.ld_tgt_count;
938 static int lmv_choose_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
939 placement_policy_t placement)
942 case PLACEMENT_CHAR_POLICY:
943 return lmv_all_chars_policy(lmv->desc.ld_tgt_count,
945 op_data->op_namelen);
946 case PLACEMENT_NID_POLICY:
947 return lmv_nid_policy(lmv);
953 CERROR("Unsupported placement policy %x\n", placement);
959 * This is _inode_ placement policy function (not name).
961 static int lmv_placement_policy(struct obd_device *obd,
962 struct md_op_data *op_data,
965 LASSERT(mds != NULL);
967 /* Allocate new fid on target according to to different
968 * QOS policy. In DNE phase I, llite should always tell
969 * which MDT where the dir will be located */
970 *mds = op_data->op_mds;
975 int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
978 struct lmv_tgt_desc *tgt;
982 tgt = lmv_get_target(lmv, mds);
985 * New seq alloc and FLD setup should be atomic. Otherwise we may find
986 * on server that seq in new allocated fid is not yet known.
988 mutex_lock(&tgt->ltd_fid_mutex);
990 if (tgt == NULL || tgt->ltd_active == 0 || tgt->ltd_exp == NULL)
991 GOTO(out, rc = -ENODEV);
994 * Asking underlaying tgt layer to allocate new fid.
996 rc = obd_fid_alloc(tgt->ltd_exp, fid, NULL);
998 LASSERT(fid_is_sane(fid));
1004 mutex_unlock(&tgt->ltd_fid_mutex);
1008 int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
1009 struct md_op_data *op_data)
1011 struct obd_device *obd = class_exp2obd(exp);
1012 struct lmv_obd *lmv = &obd->u.lmv;
1017 LASSERT(op_data != NULL);
1018 LASSERT(fid != NULL);
1020 rc = lmv_placement_policy(obd, op_data, &mds);
1022 CERROR("Can't get target for allocating fid, "
1027 rc = __lmv_fid_alloc(lmv, fid, mds);
1029 CERROR("Can't alloc new fid, rc %d\n", rc);
1036 static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
1038 struct lmv_obd *lmv = &obd->u.lmv;
1039 struct lprocfs_static_vars lvars;
1040 struct lmv_desc *desc;
1044 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
1045 CERROR("LMV setup requires a descriptor\n");
1049 desc = (struct lmv_desc *)lustre_cfg_buf(lcfg, 1);
1050 if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
1051 CERROR("Lmv descriptor size wrong: %d > %d\n",
1052 (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1));
1056 OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32);
1057 if (lmv->tgts == NULL)
1059 lmv->tgts_size = 32;
1061 obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid);
1062 lmv->desc.ld_tgt_count = 0;
1063 lmv->desc.ld_active_tgt_count = 0;
1064 lmv->max_cookiesize = 0;
1065 lmv->max_def_easize = 0;
1066 lmv->max_easize = 0;
1067 lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
1069 spin_lock_init(&lmv->lmv_lock);
1070 mutex_init(&lmv->init_mutex);
1072 lprocfs_lmv_init_vars(&lvars);
1074 lprocfs_obd_setup(obd, lvars.obd_vars);
1077 rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
1078 0444, &lmv_proc_target_fops, obd);
1080 CWARN("%s: error adding LMV target_obd file: rc = %d\n",
1084 rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
1085 LUSTRE_CLI_FLD_HASH_DHT);
1087 CERROR("Can't init FLD, err %d\n", rc);
1097 static int lmv_cleanup(struct obd_device *obd)
1099 struct lmv_obd *lmv = &obd->u.lmv;
1102 fld_client_fini(&lmv->lmv_fld);
1103 if (lmv->tgts != NULL) {
1105 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1106 if (lmv->tgts[i] == NULL)
1108 lmv_del_target(lmv, i);
1110 OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size);
1116 static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf)
1118 struct lustre_cfg *lcfg = buf;
1119 struct obd_uuid obd_uuid;
1125 switch (lcfg->lcfg_command) {
1127 /* modify_mdc_tgts add 0:lustre-clilmv 1:lustre-MDT0000_UUID
1128 * 2:0 3:1 4:lustre-MDT0000-mdc_UUID */
1129 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(obd_uuid.uuid))
1130 GOTO(out, rc = -EINVAL);
1132 obd_str2uuid(&obd_uuid, lustre_cfg_buf(lcfg, 1));
1134 if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", &index) != 1)
1135 GOTO(out, rc = -EINVAL);
1136 if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", &gen) != 1)
1137 GOTO(out, rc = -EINVAL);
1138 rc = lmv_add_target(obd, &obd_uuid, index, gen);
1141 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
1142 GOTO(out, rc = -EINVAL);
1148 static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
1149 struct obd_statfs *osfs, __u64 max_age, __u32 flags)
1151 struct obd_device *obd = class_exp2obd(exp);
1152 struct lmv_obd *lmv = &obd->u.lmv;
1153 struct obd_statfs *temp;
1158 rc = lmv_check_connect(obd);
1162 OBD_ALLOC(temp, sizeof(*temp));
1166 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1167 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1170 rc = obd_statfs(env, lmv->tgts[i]->ltd_exp, temp,
1173 CERROR("can't stat MDS #%d (%s), error %d\n", i,
1174 lmv->tgts[i]->ltd_exp->exp_obd->obd_name,
1176 GOTO(out_free_temp, rc);
1181 /* If the statfs is from mount, it will needs
1182 * retrieve necessary information from MDT0.
1183 * i.e. mount does not need the merged osfs
1185 * And also clients can be mounted as long as
1186 * MDT0 is in service*/
1187 if (flags & OBD_STATFS_FOR_MDT0)
1188 GOTO(out_free_temp, rc);
1190 osfs->os_bavail += temp->os_bavail;
1191 osfs->os_blocks += temp->os_blocks;
1192 osfs->os_ffree += temp->os_ffree;
1193 osfs->os_files += temp->os_files;
1199 OBD_FREE(temp, sizeof(*temp));
1203 static int lmv_getstatus(struct obd_export *exp,
1205 struct obd_capa **pc)
1207 struct obd_device *obd = exp->exp_obd;
1208 struct lmv_obd *lmv = &obd->u.lmv;
1212 rc = lmv_check_connect(obd);
1216 rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid, pc);
1220 static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1221 struct obd_capa *oc, obd_valid valid, const char *name,
1222 const char *input, int input_size, int output_size,
1223 int flags, struct ptlrpc_request **request)
1225 struct obd_device *obd = exp->exp_obd;
1226 struct lmv_obd *lmv = &obd->u.lmv;
1227 struct lmv_tgt_desc *tgt;
1231 rc = lmv_check_connect(obd);
1235 tgt = lmv_find_target(lmv, fid);
1237 RETURN(PTR_ERR(tgt));
1239 rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1240 input_size, output_size, flags, request);
1245 static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1246 struct obd_capa *oc, obd_valid valid, const char *name,
1247 const char *input, int input_size, int output_size,
1248 int flags, __u32 suppgid,
1249 struct ptlrpc_request **request)
1251 struct obd_device *obd = exp->exp_obd;
1252 struct lmv_obd *lmv = &obd->u.lmv;
1253 struct lmv_tgt_desc *tgt;
1257 rc = lmv_check_connect(obd);
1261 tgt = lmv_find_target(lmv, fid);
1263 RETURN(PTR_ERR(tgt));
1265 rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1266 input_size, output_size, flags, suppgid,
1272 static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
1273 struct ptlrpc_request **request)
1275 struct obd_device *obd = exp->exp_obd;
1276 struct lmv_obd *lmv = &obd->u.lmv;
1277 struct lmv_tgt_desc *tgt;
1281 rc = lmv_check_connect(obd);
1285 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1287 RETURN(PTR_ERR(tgt));
1289 if (op_data->op_flags & MF_GET_MDT_IDX) {
1290 op_data->op_mds = tgt->ltd_idx;
1294 rc = md_getattr(tgt->ltd_exp, op_data, request);
1299 static int lmv_change_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1300 ldlm_iterator_t it, void *data)
1302 struct obd_device *obd = exp->exp_obd;
1303 struct lmv_obd *lmv = &obd->u.lmv;
1308 rc = lmv_check_connect(obd);
1312 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1315 * With DNE every object can have two locks in different namespaces:
1316 * lookup lock in space of MDT storing direntry and update/open lock in
1317 * space of MDT storing inode.
1319 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1320 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1322 md_change_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data);
1328 static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1329 ldlm_iterator_t it, void *data)
1331 struct obd_device *obd = exp->exp_obd;
1332 struct lmv_obd *lmv = &obd->u.lmv;
1337 rc = lmv_check_connect(obd);
1341 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1344 * With DNE every object can have two locks in different namespaces:
1345 * lookup lock in space of MDT storing direntry and update/open lock in
1346 * space of MDT storing inode.
1348 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1349 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1351 rc = md_find_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data);
1360 static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
1361 struct md_open_data *mod, struct ptlrpc_request **request)
1363 struct obd_device *obd = exp->exp_obd;
1364 struct lmv_obd *lmv = &obd->u.lmv;
1365 struct lmv_tgt_desc *tgt;
1369 rc = lmv_check_connect(obd);
1373 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1375 RETURN(PTR_ERR(tgt));
1377 CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1));
1378 rc = md_close(tgt->ltd_exp, op_data, mod, request);
1383 *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
1386 struct lmv_tgt_desc *tgt;
1388 tgt = lmv_find_target(lmv, fid);
1389 op_data->op_mds = tgt->ltd_idx;
1394 int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
1395 const void *data, int datalen, int mode, __u32 uid,
1396 __u32 gid, cfs_cap_t cap_effective, __u64 rdev,
1397 struct ptlrpc_request **request)
1399 struct obd_device *obd = exp->exp_obd;
1400 struct lmv_obd *lmv = &obd->u.lmv;
1401 struct lmv_tgt_desc *tgt;
1405 rc = lmv_check_connect(obd);
1409 if (!lmv->desc.ld_active_tgt_count)
1412 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1414 RETURN(PTR_ERR(tgt));
1416 rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data);
1420 CDEBUG(D_INODE, "CREATE '%*s' on "DFID" -> mds #%x\n",
1421 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1424 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1425 rc = md_create(tgt->ltd_exp, op_data, data, datalen, mode, uid, gid,
1426 cap_effective, rdev, request);
1429 if (*request == NULL)
1431 CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2));
1436 static int lmv_done_writing(struct obd_export *exp,
1437 struct md_op_data *op_data,
1438 struct md_open_data *mod)
1440 struct obd_device *obd = exp->exp_obd;
1441 struct lmv_obd *lmv = &obd->u.lmv;
1442 struct lmv_tgt_desc *tgt;
1446 rc = lmv_check_connect(obd);
1450 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1452 RETURN(PTR_ERR(tgt));
1454 rc = md_done_writing(tgt->ltd_exp, op_data, mod);
1459 lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1460 struct lookup_intent *it, struct md_op_data *op_data,
1461 struct lustre_handle *lockh, void *lmm, int lmmsize,
1462 int extra_lock_flags)
1464 struct ptlrpc_request *req = it->d.lustre.it_data;
1465 struct obd_device *obd = exp->exp_obd;
1466 struct lmv_obd *lmv = &obd->u.lmv;
1467 struct lustre_handle plock;
1468 struct lmv_tgt_desc *tgt;
1469 struct md_op_data *rdata;
1471 struct mdt_body *body;
1476 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1477 LASSERT(body != NULL);
1479 if (!(body->valid & OBD_MD_MDS))
1482 CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n",
1483 LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1));
1486 * We got LOOKUP lock, but we really need attrs.
1488 pmode = it->d.lustre.it_lock_mode;
1489 LASSERT(pmode != 0);
1490 memcpy(&plock, lockh, sizeof(plock));
1491 it->d.lustre.it_lock_mode = 0;
1492 it->d.lustre.it_data = NULL;
1495 it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
1496 ptlrpc_req_finished(req);
1498 tgt = lmv_find_target(lmv, &fid1);
1500 GOTO(out, rc = PTR_ERR(tgt));
1502 OBD_ALLOC_PTR(rdata);
1504 GOTO(out, rc = -ENOMEM);
1506 rdata->op_fid1 = fid1;
1507 rdata->op_bias = MDS_CROSS_REF;
1509 rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
1510 lmm, lmmsize, NULL, extra_lock_flags);
1511 OBD_FREE_PTR(rdata);
1514 ldlm_lock_decref(&plock, pmode);
1519 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1520 struct lookup_intent *it, struct md_op_data *op_data,
1521 struct lustre_handle *lockh, void *lmm, int lmmsize,
1522 struct ptlrpc_request **req, __u64 extra_lock_flags)
1524 struct obd_device *obd = exp->exp_obd;
1525 struct lmv_obd *lmv = &obd->u.lmv;
1526 struct lmv_tgt_desc *tgt;
1530 rc = lmv_check_connect(obd);
1534 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n",
1535 LL_IT2STR(it), PFID(&op_data->op_fid1));
1537 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1539 RETURN(PTR_ERR(tgt));
1541 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n",
1542 LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
1544 rc = md_enqueue(tgt->ltd_exp, einfo, it, op_data, lockh,
1545 lmm, lmmsize, req, extra_lock_flags);
1547 if (rc == 0 && it && it->it_op == IT_OPEN) {
1548 rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh,
1549 lmm, lmmsize, extra_lock_flags);
1555 lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
1556 struct ptlrpc_request **request)
1558 struct ptlrpc_request *req = NULL;
1559 struct obd_device *obd = exp->exp_obd;
1560 struct lmv_obd *lmv = &obd->u.lmv;
1561 struct lmv_tgt_desc *tgt;
1562 struct mdt_body *body;
1566 rc = lmv_check_connect(obd);
1570 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1572 RETURN(PTR_ERR(tgt));
1574 CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" -> mds #%d\n",
1575 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1578 rc = md_getattr_name(tgt->ltd_exp, op_data, request);
1582 body = req_capsule_server_get(&(*request)->rq_pill,
1584 LASSERT(body != NULL);
1586 if (body->valid & OBD_MD_MDS) {
1587 struct lu_fid rid = body->fid1;
1588 CDEBUG(D_INODE, "Request attrs for "DFID"\n",
1591 tgt = lmv_find_target(lmv, &rid);
1593 ptlrpc_req_finished(*request);
1594 RETURN(PTR_ERR(tgt));
1597 op_data->op_fid1 = rid;
1598 op_data->op_valid |= OBD_MD_FLCROSSREF;
1599 op_data->op_namelen = 0;
1600 op_data->op_name = NULL;
1601 rc = md_getattr_name(tgt->ltd_exp, op_data, &req);
1602 ptlrpc_req_finished(*request);
1609 #define md_op_data_fid(op_data, fl) \
1610 (fl == MF_MDC_CANCEL_FID1 ? &op_data->op_fid1 : \
1611 fl == MF_MDC_CANCEL_FID2 ? &op_data->op_fid2 : \
1612 fl == MF_MDC_CANCEL_FID3 ? &op_data->op_fid3 : \
1613 fl == MF_MDC_CANCEL_FID4 ? &op_data->op_fid4 : \
1616 static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data,
1617 int op_tgt, ldlm_mode_t mode, int bits, int flag)
1619 struct lu_fid *fid = md_op_data_fid(op_data, flag);
1620 struct obd_device *obd = exp->exp_obd;
1621 struct lmv_obd *lmv = &obd->u.lmv;
1622 struct lmv_tgt_desc *tgt;
1623 ldlm_policy_data_t policy = {{0}};
1627 if (!fid_is_sane(fid))
1630 tgt = lmv_find_target(lmv, fid);
1632 RETURN(PTR_ERR(tgt));
1634 if (tgt->ltd_idx != op_tgt) {
1635 CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid));
1636 policy.l_inodebits.bits = bits;
1637 rc = md_cancel_unused(tgt->ltd_exp, fid, &policy,
1638 mode, LCF_ASYNC, NULL);
1641 "EARLY_CANCEL skip operation target %d on "DFID"\n",
1643 op_data->op_flags |= flag;
1651 * llite passes fid of an target inode in op_data->op_fid1 and id of directory in
1654 static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
1655 struct ptlrpc_request **request)
1657 struct obd_device *obd = exp->exp_obd;
1658 struct lmv_obd *lmv = &obd->u.lmv;
1659 struct lmv_tgt_desc *tgt;
1663 rc = lmv_check_connect(obd);
1667 LASSERT(op_data->op_namelen != 0);
1669 CDEBUG(D_INODE, "LINK "DFID":%*s to "DFID"\n",
1670 PFID(&op_data->op_fid2), op_data->op_namelen,
1671 op_data->op_name, PFID(&op_data->op_fid1));
1673 op_data->op_fsuid = cfs_curproc_fsuid();
1674 op_data->op_fsgid = cfs_curproc_fsgid();
1675 op_data->op_cap = cfs_curproc_cap_pack();
1676 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1678 RETURN(PTR_ERR(tgt));
1681 * Cancel UPDATE lock on child (fid1).
1683 op_data->op_flags |= MF_MDC_CANCEL_FID2;
1684 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1685 MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1);
1689 rc = md_link(tgt->ltd_exp, op_data, request);
1694 static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
1695 const char *old, int oldlen, const char *new, int newlen,
1696 struct ptlrpc_request **request)
1698 struct obd_device *obd = exp->exp_obd;
1699 struct lmv_obd *lmv = &obd->u.lmv;
1700 struct lmv_tgt_desc *src_tgt;
1701 struct lmv_tgt_desc *tgt_tgt;
1705 LASSERT(oldlen != 0);
1707 CDEBUG(D_INODE, "RENAME %*s in "DFID" to %*s in "DFID"\n",
1708 oldlen, old, PFID(&op_data->op_fid1),
1709 newlen, new, PFID(&op_data->op_fid2));
1711 rc = lmv_check_connect(obd);
1715 op_data->op_fsuid = cfs_curproc_fsuid();
1716 op_data->op_fsgid = cfs_curproc_fsgid();
1717 op_data->op_cap = cfs_curproc_cap_pack();
1718 src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1719 if (IS_ERR(src_tgt))
1720 RETURN(PTR_ERR(src_tgt));
1722 tgt_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1723 if (IS_ERR(tgt_tgt))
1724 RETURN(PTR_ERR(tgt_tgt));
1726 * LOOKUP lock on src child (fid3) should also be cancelled for
1727 * src_tgt in mdc_rename.
1729 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1732 * Cancel UPDATE locks on tgt parent (fid2), tgt_tgt is its
1735 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1736 LCK_EX, MDS_INODELOCK_UPDATE,
1737 MF_MDC_CANCEL_FID2);
1740 * Cancel LOOKUP locks on tgt child (fid4) for parent tgt_tgt.
1743 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1744 LCK_EX, MDS_INODELOCK_LOOKUP,
1745 MF_MDC_CANCEL_FID4);
1749 * Cancel all the locks on tgt child (fid4).
1752 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1753 LCK_EX, MDS_INODELOCK_FULL,
1754 MF_MDC_CANCEL_FID4);
1757 rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen,
1758 new, newlen, request);
1762 static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
1763 void *ea, int ealen, void *ea2, int ea2len,
1764 struct ptlrpc_request **request,
1765 struct md_open_data **mod)
1767 struct obd_device *obd = exp->exp_obd;
1768 struct lmv_obd *lmv = &obd->u.lmv;
1769 struct lmv_tgt_desc *tgt;
1773 rc = lmv_check_connect(obd);
1777 CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n",
1778 PFID(&op_data->op_fid1), op_data->op_attr.ia_valid);
1780 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1781 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1783 RETURN(PTR_ERR(tgt));
1785 rc = md_setattr(tgt->ltd_exp, op_data, ea, ealen, ea2,
1786 ea2len, request, mod);
1791 static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
1792 struct obd_capa *oc, struct ptlrpc_request **request)
1794 struct obd_device *obd = exp->exp_obd;
1795 struct lmv_obd *lmv = &obd->u.lmv;
1796 struct lmv_tgt_desc *tgt;
1800 rc = lmv_check_connect(obd);
1804 tgt = lmv_find_target(lmv, fid);
1806 RETURN(PTR_ERR(tgt));
1808 rc = md_sync(tgt->ltd_exp, fid, oc, request);
1812 static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data,
1813 struct page **pages, struct ptlrpc_request **request)
1815 struct obd_device *obd = exp->exp_obd;
1816 struct lmv_obd *lmv = &obd->u.lmv;
1817 __u64 offset = op_data->op_offset;
1820 /* number of pages read, in CFS_PAGE_SIZE */
1822 /* number of pages transferred in LU_PAGE_SIZE */
1824 struct lmv_tgt_desc *tgt;
1825 struct lu_dirpage *dp;
1826 struct lu_dirent *ent;
1829 rc = lmv_check_connect(obd);
1833 CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n",
1834 offset, PFID(&op_data->op_fid1));
1837 * This case handle directory lookup in clustered metadata case (i.e.
1838 * split directory is located on multiple md servers.)
1839 * each server keeps directory entries for certain range of hashes.
1840 * E.g. we have N server and suppose hash range is 0 to MAX_HASH.
1841 * first server will keep records with hashes [ 0 ... MAX_HASH /N - 1],
1842 * second one with hashes [MAX_HASH / N ... 2 * MAX_HASH / N] and
1844 * readdir can simply start reading entries from 0 - N server in
1845 * order but that will not scale well as all client will request dir in
1846 * to server in same order.
1847 * Following algorithm does optimization:
1848 * Instead of doing readdir in 1, 2, ...., N order, client with a
1849 * rank R does readdir in R, R + 1, ..., N, 1, ... R - 1 order.
1850 * (every client has rank R)
1851 * But ll_readdir() expect offset range [0 to MAX_HASH/N) but
1852 * since client ask dir from MDS{R} client has pages with offsets
1853 * [R*MAX_HASH/N ... (R + 1)*MAX_HASH/N] there for we do hash_adj
1854 * on hash values that we get.
1855 * Since these codes might be still useful for sharded directory, so
1856 * Keeping this code for further reference
1859 seg_size = MAX_HASH_SIZE;
1860 do_div(seg_size, nr);
1861 los = obj->lo_stripes;
1862 tgt = lmv_get_target(lmv, los[0].ls_mds);
1863 rank = lmv_node_rank(tgt->ltd_exp, fid) % nr;
1865 do_div(tgt_tmp, seg_size);
1866 tgt0_idx = do_div(tgt_tmp, nr);
1867 tgt_idx = (tgt0_idx + rank) % nr;
1869 if (tgt_idx < tgt0_idx)
1872 * Last segment has unusual length due to division
1874 hash_adj = MAX_HASH_SIZE - seg_size * nr;
1878 hash_adj += rank * seg_size;
1880 CDEBUG(D_INODE, "Readpage hash adjustment: %x "LPX64" "
1881 LPX64"/%x -> "LPX64"/%x\n", rank, hash_adj,
1882 offset, tgt0_idx, offset + hash_adj, tgt_idx);
1884 offset = (offset + hash_adj) & MAX_HASH_SIZE;
1885 rid = lsm->mea_oinfo[tgt_idx].lmo_fid;
1886 tgt = lmv_get_target(lmv, lsm->mea_oinfo[tgt_idx].lmo_mds);
1888 CDEBUG(D_INODE, "Forward to "DFID" with offset %lu i %d\n",
1889 PFID(&rid), (unsigned long)offset, tgt_idx);
1892 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1894 RETURN(PTR_ERR(tgt));
1896 rc = md_readpage(tgt->ltd_exp, op_data, pages, request);
1900 nrdpgs = ((*request)->rq_bulk->bd_nob_transferred + CFS_PAGE_SIZE - 1)
1902 nlupgs = (*request)->rq_bulk->bd_nob_transferred >> LU_PAGE_SHIFT;
1903 LASSERT(!((*request)->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK));
1904 LASSERT(nrdpgs > 0 && nrdpgs <= op_data->op_npages);
1906 CDEBUG(D_INODE, "read %d(%d)/%d pages\n", nrdpgs, nlupgs,
1907 op_data->op_npages);
1909 for (i = 0; i < nrdpgs; i++) {
1910 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1911 struct lu_dirpage *first;
1915 struct lu_dirent *tmp = NULL;
1917 dp = cfs_kmap(pages[i]);
1918 ent = lu_dirent_start(dp);
1919 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1921 hash_end = dp->ldp_hash_end;
1926 for (tmp = ent; ent != NULL;
1927 tmp = ent, ent = lu_dirent_next(ent));
1928 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1929 dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);
1930 if (((unsigned long)dp & ~CFS_PAGE_MASK) && nlupgs > 0) {
1931 ent = lu_dirent_start(dp);
1934 /* enlarge the end entry lde_reclen from 0 to
1935 * first entry of next lu_dirpage, in this way
1936 * several lu_dirpages can be stored into one
1937 * client page on client. */
1938 tmp = ((void *)tmp) +
1939 le16_to_cpu(tmp->lde_reclen);
1941 cpu_to_le16((char *)(dp->ldp_entries) -
1946 first->ldp_hash_end = hash_end;
1947 first->ldp_flags &= ~cpu_to_le32(LDF_COLLIDE);
1948 first->ldp_flags |= flags & cpu_to_le32(LDF_COLLIDE);
1950 SET_BUT_UNUSED(tmp);
1952 cfs_kunmap(pages[i]);
1957 static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data,
1958 struct ptlrpc_request **request)
1960 struct obd_device *obd = exp->exp_obd;
1961 struct lmv_obd *lmv = &obd->u.lmv;
1962 struct lmv_tgt_desc *tgt = NULL;
1966 rc = lmv_check_connect(obd);
1970 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1972 RETURN(PTR_ERR(tgt));
1974 op_data->op_fsuid = cfs_curproc_fsuid();
1975 op_data->op_fsgid = cfs_curproc_fsgid();
1976 op_data->op_cap = cfs_curproc_cap_pack();
1979 * If child's fid is given, cancel unused locks for it if it is from
1980 * another export than parent.
1982 * LOOKUP lock for child (fid3) should also be cancelled on parent
1983 * tgt_tgt in mdc_unlink().
1985 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1988 * Cancel FULL locks on child (fid3).
1990 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1991 MDS_INODELOCK_FULL, MF_MDC_CANCEL_FID3);
1996 rc = md_unlink(tgt->ltd_exp, op_data, request);
2001 static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2003 struct lmv_obd *lmv = &obd->u.lmv;
2007 case OBD_CLEANUP_EARLY:
2008 /* XXX: here should be calling obd_precleanup() down to
2011 case OBD_CLEANUP_EXPORTS:
2012 fld_client_proc_fini(&lmv->lmv_fld);
2013 lprocfs_obd_cleanup(obd);
2021 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
2022 __u32 keylen, void *key, __u32 *vallen, void *val,
2023 struct lov_stripe_md *lsm)
2025 struct obd_device *obd;
2026 struct lmv_obd *lmv;
2030 obd = class_exp2obd(exp);
2032 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2033 exp->exp_handle.h_cookie);
2038 if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
2039 struct lmv_tgt_desc *tgt;
2042 rc = lmv_check_connect(obd);
2046 LASSERT(*vallen == sizeof(__u32));
2047 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2050 * All tgts should be connected when this gets called.
2052 if (tgt == NULL || tgt->ltd_exp == NULL)
2055 if (!obd_get_info(env, tgt->ltd_exp, keylen, key,
2060 } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) {
2061 rc = lmv_check_connect(obd);
2066 * Forwarding this request to first MDS, it should know LOV
2069 rc = obd_get_info(env, lmv->tgts[0]->ltd_exp, keylen, key,
2071 if (!rc && KEY_IS(KEY_CONN_DATA)) {
2072 exp->exp_connect_flags =
2073 ((struct obd_connect_data *)val)->ocd_connect_flags;
2076 } else if (KEY_IS(KEY_TGT_COUNT)) {
2077 *((int *)val) = lmv->desc.ld_tgt_count;
2081 CDEBUG(D_IOCTL, "Invalid key\n");
2085 int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
2086 obd_count keylen, void *key, obd_count vallen,
2087 void *val, struct ptlrpc_request_set *set)
2089 struct lmv_tgt_desc *tgt;
2090 struct obd_device *obd;
2091 struct lmv_obd *lmv;
2095 obd = class_exp2obd(exp);
2097 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2098 exp->exp_handle.h_cookie);
2103 if (KEY_IS(KEY_READ_ONLY) || KEY_IS(KEY_FLUSH_CTX)) {
2106 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2109 if (tgt == NULL || tgt->ltd_exp == NULL)
2112 err = obd_set_info_async(env, tgt->ltd_exp,
2113 keylen, key, vallen, val, set);
2124 int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
2125 struct lov_stripe_md *lsm)
2127 struct obd_device *obd = class_exp2obd(exp);
2128 struct lmv_obd *lmv = &obd->u.lmv;
2129 struct lmv_stripe_md *meap;
2130 struct lmv_stripe_md *lsmp;
2135 mea_size = lmv_get_easize(lmv);
2139 if (*lmmp && !lsm) {
2140 OBD_FREE_LARGE(*lmmp, mea_size);
2145 if (*lmmp == NULL) {
2146 OBD_ALLOC_LARGE(*lmmp, mea_size);
2154 lsmp = (struct lmv_stripe_md *)lsm;
2155 meap = (struct lmv_stripe_md *)*lmmp;
2157 if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR &&
2158 lsmp->mea_magic != MEA_MAGIC_ALL_CHARS)
2161 meap->mea_magic = cpu_to_le32(lsmp->mea_magic);
2162 meap->mea_count = cpu_to_le32(lsmp->mea_count);
2163 meap->mea_master = cpu_to_le32(lsmp->mea_master);
2165 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2166 meap->mea_ids[i] = meap->mea_ids[i];
2167 fid_cpu_to_le(&meap->mea_ids[i], &meap->mea_ids[i]);
2173 int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
2174 struct lov_mds_md *lmm, int lmm_size)
2176 struct obd_device *obd = class_exp2obd(exp);
2177 struct lmv_stripe_md **tmea = (struct lmv_stripe_md **)lsmp;
2178 struct lmv_stripe_md *mea = (struct lmv_stripe_md *)lmm;
2179 struct lmv_obd *lmv = &obd->u.lmv;
2185 mea_size = lmv_get_easize(lmv);
2189 if (*lsmp != NULL && lmm == NULL) {
2190 OBD_FREE_LARGE(*tmea, mea_size);
2195 LASSERT(mea_size == lmm_size);
2197 OBD_ALLOC_LARGE(*tmea, mea_size);
2204 if (mea->mea_magic == MEA_MAGIC_LAST_CHAR ||
2205 mea->mea_magic == MEA_MAGIC_ALL_CHARS ||
2206 mea->mea_magic == MEA_MAGIC_HASH_SEGMENT)
2208 magic = le32_to_cpu(mea->mea_magic);
2211 * Old mea is not handled here.
2213 CERROR("Old not supportable EA is found\n");
2217 (*tmea)->mea_magic = magic;
2218 (*tmea)->mea_count = le32_to_cpu(mea->mea_count);
2219 (*tmea)->mea_master = le32_to_cpu(mea->mea_master);
2221 for (i = 0; i < (*tmea)->mea_count; i++) {
2222 (*tmea)->mea_ids[i] = mea->mea_ids[i];
2223 fid_le_to_cpu(&(*tmea)->mea_ids[i], &(*tmea)->mea_ids[i]);
2228 static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
2229 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2230 ldlm_cancel_flags_t flags, void *opaque)
2232 struct obd_device *obd = exp->exp_obd;
2233 struct lmv_obd *lmv = &obd->u.lmv;
2239 LASSERT(fid != NULL);
2241 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2242 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL ||
2243 lmv->tgts[i]->ltd_active == 0)
2246 err = md_cancel_unused(lmv->tgts[i]->ltd_exp, fid,
2247 policy, mode, flags, opaque);
2254 int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
2257 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2261 rc = md_set_lock_data(lmv->tgts[0]->ltd_exp, lockh, data, bits);
2265 ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags,
2266 const struct lu_fid *fid, ldlm_type_t type,
2267 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2268 struct lustre_handle *lockh)
2270 struct obd_device *obd = exp->exp_obd;
2271 struct lmv_obd *lmv = &obd->u.lmv;
2276 CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid));
2279 * With CMD every object can have two locks in different namespaces:
2280 * lookup lock in space of mds storing direntry and update/open lock in
2281 * space of mds storing inode. Thus we check all targets, not only that
2282 * one fid was created in.
2284 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2285 if (lmv->tgts[i] == NULL ||
2286 lmv->tgts[i]->ltd_exp == NULL ||
2287 lmv->tgts[i]->ltd_active == 0)
2290 rc = md_lock_match(lmv->tgts[i]->ltd_exp, flags, fid,
2291 type, policy, mode, lockh);
2299 int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
2300 struct obd_export *dt_exp, struct obd_export *md_exp,
2301 struct lustre_md *md)
2303 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2305 return md_get_lustre_md(lmv->tgts[0]->ltd_exp, req, dt_exp, md_exp, md);
2308 int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
2310 struct obd_device *obd = exp->exp_obd;
2311 struct lmv_obd *lmv = &obd->u.lmv;
2315 obd_free_memmd(exp, (void *)&md->mea);
2316 RETURN(md_free_lustre_md(lmv->tgts[0]->ltd_exp, md));
2319 int lmv_set_open_replay_data(struct obd_export *exp,
2320 struct obd_client_handle *och,
2321 struct ptlrpc_request *open_req)
2323 struct obd_device *obd = exp->exp_obd;
2324 struct lmv_obd *lmv = &obd->u.lmv;
2325 struct lmv_tgt_desc *tgt;
2328 tgt = lmv_find_target(lmv, &och->och_fid);
2330 RETURN(PTR_ERR(tgt));
2332 RETURN(md_set_open_replay_data(tgt->ltd_exp, och, open_req));
2335 int lmv_clear_open_replay_data(struct obd_export *exp,
2336 struct obd_client_handle *och)
2338 struct obd_device *obd = exp->exp_obd;
2339 struct lmv_obd *lmv = &obd->u.lmv;
2340 struct lmv_tgt_desc *tgt;
2343 tgt = lmv_find_target(lmv, &och->och_fid);
2345 RETURN(PTR_ERR(tgt));
2347 RETURN(md_clear_open_replay_data(tgt->ltd_exp, och));
2350 static int lmv_get_remote_perm(struct obd_export *exp,
2351 const struct lu_fid *fid,
2352 struct obd_capa *oc, __u32 suppgid,
2353 struct ptlrpc_request **request)
2355 struct obd_device *obd = exp->exp_obd;
2356 struct lmv_obd *lmv = &obd->u.lmv;
2357 struct lmv_tgt_desc *tgt;
2361 rc = lmv_check_connect(obd);
2365 tgt = lmv_find_target(lmv, fid);
2367 RETURN(PTR_ERR(tgt));
2369 rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request);
2373 static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2376 struct obd_device *obd = exp->exp_obd;
2377 struct lmv_obd *lmv = &obd->u.lmv;
2378 struct lmv_tgt_desc *tgt;
2382 rc = lmv_check_connect(obd);
2386 tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid);
2388 RETURN(PTR_ERR(tgt));
2390 rc = md_renew_capa(tgt->ltd_exp, oc, cb);
2394 int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
2395 const struct req_msg_field *field, struct obd_capa **oc)
2397 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2399 return md_unpack_capa(lmv->tgts[0]->ltd_exp, req, field, oc);
2402 int lmv_intent_getattr_async(struct obd_export *exp,
2403 struct md_enqueue_info *minfo,
2404 struct ldlm_enqueue_info *einfo)
2406 struct md_op_data *op_data = &minfo->mi_data;
2407 struct obd_device *obd = exp->exp_obd;
2408 struct lmv_obd *lmv = &obd->u.lmv;
2409 struct lmv_tgt_desc *tgt = NULL;
2413 rc = lmv_check_connect(obd);
2417 tgt = lmv_find_target(lmv, &op_data->op_fid1);
2419 RETURN(PTR_ERR(tgt));
2421 rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo);
2425 int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
2426 struct lu_fid *fid, __u64 *bits)
2428 struct obd_device *obd = exp->exp_obd;
2429 struct lmv_obd *lmv = &obd->u.lmv;
2430 struct lmv_tgt_desc *tgt;
2434 rc = lmv_check_connect(obd);
2438 tgt = lmv_find_target(lmv, fid);
2440 RETURN(PTR_ERR(tgt));
2442 rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits);
2447 * For lmv, only need to send request to master MDT, and the master MDT will
2448 * process with other slave MDTs. The only exception is Q_GETOQUOTA for which
2449 * we directly fetch data from the slave MDTs.
2451 int lmv_quotactl(struct obd_device *unused, struct obd_export *exp,
2452 struct obd_quotactl *oqctl)
2454 struct obd_device *obd = class_exp2obd(exp);
2455 struct lmv_obd *lmv = &obd->u.lmv;
2456 struct lmv_tgt_desc *tgt = lmv->tgts[0];
2458 __u64 curspace, curinodes;
2461 if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) {
2462 CERROR("master lmv inactive\n");
2466 if (oqctl->qc_cmd != Q_GETOQUOTA) {
2467 rc = obd_quotactl(tgt->ltd_exp, oqctl);
2471 curspace = curinodes = 0;
2472 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2476 if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0)
2478 if (!tgt->ltd_active) {
2479 CDEBUG(D_HA, "mdt %d is inactive.\n", i);
2483 err = obd_quotactl(tgt->ltd_exp, oqctl);
2485 CERROR("getquota on mdt %d failed. %d\n", i, err);
2489 curspace += oqctl->qc_dqblk.dqb_curspace;
2490 curinodes += oqctl->qc_dqblk.dqb_curinodes;
2493 oqctl->qc_dqblk.dqb_curspace = curspace;
2494 oqctl->qc_dqblk.dqb_curinodes = curinodes;
2499 int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
2500 struct obd_quotactl *oqctl)
2502 struct obd_device *obd = class_exp2obd(exp);
2503 struct lmv_obd *lmv = &obd->u.lmv;
2504 struct lmv_tgt_desc *tgt;
2508 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2511 if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) {
2512 CERROR("lmv idx %d inactive\n", i);
2516 err = obd_quotacheck(tgt->ltd_exp, oqctl);
2524 struct obd_ops lmv_obd_ops = {
2525 .o_owner = THIS_MODULE,
2526 .o_setup = lmv_setup,
2527 .o_cleanup = lmv_cleanup,
2528 .o_precleanup = lmv_precleanup,
2529 .o_process_config = lmv_process_config,
2530 .o_connect = lmv_connect,
2531 .o_disconnect = lmv_disconnect,
2532 .o_statfs = lmv_statfs,
2533 .o_get_info = lmv_get_info,
2534 .o_set_info_async = lmv_set_info_async,
2535 .o_packmd = lmv_packmd,
2536 .o_unpackmd = lmv_unpackmd,
2537 .o_notify = lmv_notify,
2538 .o_get_uuid = lmv_get_uuid,
2539 .o_iocontrol = lmv_iocontrol,
2540 .o_quotacheck = lmv_quotacheck,
2541 .o_quotactl = lmv_quotactl
2544 struct md_ops lmv_md_ops = {
2545 .m_getstatus = lmv_getstatus,
2546 .m_change_cbdata = lmv_change_cbdata,
2547 .m_find_cbdata = lmv_find_cbdata,
2548 .m_close = lmv_close,
2549 .m_create = lmv_create,
2550 .m_done_writing = lmv_done_writing,
2551 .m_enqueue = lmv_enqueue,
2552 .m_getattr = lmv_getattr,
2553 .m_getxattr = lmv_getxattr,
2554 .m_getattr_name = lmv_getattr_name,
2555 .m_intent_lock = lmv_intent_lock,
2557 .m_rename = lmv_rename,
2558 .m_setattr = lmv_setattr,
2559 .m_setxattr = lmv_setxattr,
2561 .m_readpage = lmv_readpage,
2562 .m_unlink = lmv_unlink,
2563 .m_init_ea_size = lmv_init_ea_size,
2564 .m_cancel_unused = lmv_cancel_unused,
2565 .m_set_lock_data = lmv_set_lock_data,
2566 .m_lock_match = lmv_lock_match,
2567 .m_get_lustre_md = lmv_get_lustre_md,
2568 .m_free_lustre_md = lmv_free_lustre_md,
2569 .m_set_open_replay_data = lmv_set_open_replay_data,
2570 .m_clear_open_replay_data = lmv_clear_open_replay_data,
2571 .m_renew_capa = lmv_renew_capa,
2572 .m_unpack_capa = lmv_unpack_capa,
2573 .m_get_remote_perm = lmv_get_remote_perm,
2574 .m_intent_getattr_async = lmv_intent_getattr_async,
2575 .m_revalidate_lock = lmv_revalidate_lock
2578 int __init lmv_init(void)
2580 struct lprocfs_static_vars lvars;
2583 lprocfs_lmv_init_vars(&lvars);
2585 rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
2586 lvars.module_vars, LUSTRE_LMV_NAME, NULL);
2591 static void lmv_exit(void)
2593 class_unregister_type(LUSTRE_LMV_NAME);
2596 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2597 MODULE_DESCRIPTION("Lustre Logical Metadata Volume OBD driver");
2598 MODULE_LICENSE("GPL");
2600 module_init(lmv_init);
2601 module_exit(lmv_exit);