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);
868 for (i = 0; i < count; i++) {
869 struct obd_device *mdc_obd;
872 if (lmv->tgts[i] == NULL ||
873 lmv->tgts[i]->ltd_exp == NULL)
875 /* ll_umount_begin() sets force flag but for lmv, not
876 * mdc. Let's pass it through */
877 mdc_obd = class_exp2obd(lmv->tgts[i]->ltd_exp);
878 mdc_obd->obd_force = obddev->obd_force;
879 err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len,
881 if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) {
884 if (lmv->tgts[i]->ltd_active) {
885 CERROR("error: iocontrol MDC %s on MDT"
886 "idx %d cmd %x: err = %d\n",
887 lmv->tgts[i]->ltd_uuid.uuid,
902 static int lmv_all_chars_policy(int count, const char *name,
913 static int lmv_nid_policy(struct lmv_obd *lmv)
915 struct obd_import *imp;
919 * XXX: To get nid we assume that underlying obd device is mdc.
921 imp = class_exp2cliimp(lmv->tgts[0].ltd_exp);
922 id = imp->imp_connection->c_self ^ (imp->imp_connection->c_self >> 32);
923 return id % lmv->desc.ld_tgt_count;
926 static int lmv_choose_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
927 placement_policy_t placement)
930 case PLACEMENT_CHAR_POLICY:
931 return lmv_all_chars_policy(lmv->desc.ld_tgt_count,
933 op_data->op_namelen);
934 case PLACEMENT_NID_POLICY:
935 return lmv_nid_policy(lmv);
941 CERROR("Unsupported placement policy %x\n", placement);
947 * This is _inode_ placement policy function (not name).
949 static int lmv_placement_policy(struct obd_device *obd,
950 struct md_op_data *op_data,
953 LASSERT(mds != NULL);
955 /* Allocate new fid on target according to to different
956 * QOS policy. In DNE phase I, llite should always tell
957 * which MDT where the dir will be located */
958 *mds = op_data->op_mds;
963 int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
966 struct lmv_tgt_desc *tgt;
970 tgt = lmv_get_target(lmv, mds);
973 * New seq alloc and FLD setup should be atomic. Otherwise we may find
974 * on server that seq in new allocated fid is not yet known.
976 mutex_lock(&tgt->ltd_fid_mutex);
978 if (tgt == NULL || tgt->ltd_active == 0 || tgt->ltd_exp == NULL)
979 GOTO(out, rc = -ENODEV);
982 * Asking underlaying tgt layer to allocate new fid.
984 rc = obd_fid_alloc(tgt->ltd_exp, fid, NULL);
986 LASSERT(fid_is_sane(fid));
992 mutex_unlock(&tgt->ltd_fid_mutex);
996 int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
997 struct md_op_data *op_data)
999 struct obd_device *obd = class_exp2obd(exp);
1000 struct lmv_obd *lmv = &obd->u.lmv;
1005 LASSERT(op_data != NULL);
1006 LASSERT(fid != NULL);
1008 rc = lmv_placement_policy(obd, op_data, &mds);
1010 CERROR("Can't get target for allocating fid, "
1015 rc = __lmv_fid_alloc(lmv, fid, mds);
1017 CERROR("Can't alloc new fid, rc %d\n", rc);
1024 static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
1026 struct lmv_obd *lmv = &obd->u.lmv;
1027 struct lprocfs_static_vars lvars;
1028 struct lmv_desc *desc;
1032 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
1033 CERROR("LMV setup requires a descriptor\n");
1037 desc = (struct lmv_desc *)lustre_cfg_buf(lcfg, 1);
1038 if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
1039 CERROR("Lmv descriptor size wrong: %d > %d\n",
1040 (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1));
1044 OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32);
1045 if (lmv->tgts == NULL)
1047 lmv->tgts_size = 32;
1049 obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid);
1050 lmv->desc.ld_tgt_count = 0;
1051 lmv->desc.ld_active_tgt_count = 0;
1052 lmv->max_cookiesize = 0;
1053 lmv->max_def_easize = 0;
1054 lmv->max_easize = 0;
1055 lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
1057 spin_lock_init(&lmv->lmv_lock);
1058 mutex_init(&lmv->init_mutex);
1060 lprocfs_lmv_init_vars(&lvars);
1062 lprocfs_obd_setup(obd, lvars.obd_vars);
1065 rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
1066 0444, &lmv_proc_target_fops, obd);
1068 CWARN("%s: error adding LMV target_obd file: rc = %d\n",
1072 rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
1073 LUSTRE_CLI_FLD_HASH_DHT);
1075 CERROR("Can't init FLD, err %d\n", rc);
1085 static int lmv_cleanup(struct obd_device *obd)
1087 struct lmv_obd *lmv = &obd->u.lmv;
1090 fld_client_fini(&lmv->lmv_fld);
1091 if (lmv->tgts != NULL) {
1093 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1094 if (lmv->tgts[i] == NULL)
1096 lmv_del_target(lmv, i);
1098 OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size);
1104 static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf)
1106 struct lustre_cfg *lcfg = buf;
1107 struct obd_uuid obd_uuid;
1113 switch (lcfg->lcfg_command) {
1115 /* modify_mdc_tgts add 0:lustre-clilmv 1:lustre-MDT0000_UUID
1116 * 2:0 3:1 4:lustre-MDT0000-mdc_UUID */
1117 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(obd_uuid.uuid))
1118 GOTO(out, rc = -EINVAL);
1120 obd_str2uuid(&obd_uuid, lustre_cfg_buf(lcfg, 1));
1122 if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", &index) != 1)
1123 GOTO(out, rc = -EINVAL);
1124 if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", &gen) != 1)
1125 GOTO(out, rc = -EINVAL);
1126 rc = lmv_add_target(obd, &obd_uuid, index, gen);
1129 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
1130 GOTO(out, rc = -EINVAL);
1136 static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
1137 struct obd_statfs *osfs, __u64 max_age, __u32 flags)
1139 struct obd_device *obd = class_exp2obd(exp);
1140 struct lmv_obd *lmv = &obd->u.lmv;
1141 struct obd_statfs *temp;
1146 rc = lmv_check_connect(obd);
1150 OBD_ALLOC(temp, sizeof(*temp));
1154 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1155 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1158 rc = obd_statfs(env, lmv->tgts[i]->ltd_exp, temp,
1161 CERROR("can't stat MDS #%d (%s), error %d\n", i,
1162 lmv->tgts[i]->ltd_exp->exp_obd->obd_name,
1164 GOTO(out_free_temp, rc);
1169 /* If the statfs is from mount, it will needs
1170 * retrieve necessary information from MDT0.
1171 * i.e. mount does not need the merged osfs
1173 * And also clients can be mounted as long as
1174 * MDT0 is in service*/
1175 if (flags & OBD_STATFS_FOR_MDT0)
1176 GOTO(out_free_temp, rc);
1178 osfs->os_bavail += temp->os_bavail;
1179 osfs->os_blocks += temp->os_blocks;
1180 osfs->os_ffree += temp->os_ffree;
1181 osfs->os_files += temp->os_files;
1187 OBD_FREE(temp, sizeof(*temp));
1191 static int lmv_getstatus(struct obd_export *exp,
1193 struct obd_capa **pc)
1195 struct obd_device *obd = exp->exp_obd;
1196 struct lmv_obd *lmv = &obd->u.lmv;
1200 rc = lmv_check_connect(obd);
1204 rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid, pc);
1208 static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1209 struct obd_capa *oc, obd_valid valid, const char *name,
1210 const char *input, int input_size, int output_size,
1211 int flags, struct ptlrpc_request **request)
1213 struct obd_device *obd = exp->exp_obd;
1214 struct lmv_obd *lmv = &obd->u.lmv;
1215 struct lmv_tgt_desc *tgt;
1219 rc = lmv_check_connect(obd);
1223 tgt = lmv_find_target(lmv, fid);
1225 RETURN(PTR_ERR(tgt));
1227 rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1228 input_size, output_size, flags, request);
1233 static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1234 struct obd_capa *oc, obd_valid valid, const char *name,
1235 const char *input, int input_size, int output_size,
1236 int flags, __u32 suppgid,
1237 struct ptlrpc_request **request)
1239 struct obd_device *obd = exp->exp_obd;
1240 struct lmv_obd *lmv = &obd->u.lmv;
1241 struct lmv_tgt_desc *tgt;
1245 rc = lmv_check_connect(obd);
1249 tgt = lmv_find_target(lmv, fid);
1251 RETURN(PTR_ERR(tgt));
1253 rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1254 input_size, output_size, flags, suppgid,
1260 static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
1261 struct ptlrpc_request **request)
1263 struct obd_device *obd = exp->exp_obd;
1264 struct lmv_obd *lmv = &obd->u.lmv;
1265 struct lmv_tgt_desc *tgt;
1269 rc = lmv_check_connect(obd);
1273 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1275 RETURN(PTR_ERR(tgt));
1277 if (op_data->op_flags & MF_GET_MDT_IDX) {
1278 op_data->op_mds = tgt->ltd_idx;
1282 rc = md_getattr(tgt->ltd_exp, op_data, request);
1287 static int lmv_change_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1288 ldlm_iterator_t it, void *data)
1290 struct obd_device *obd = exp->exp_obd;
1291 struct lmv_obd *lmv = &obd->u.lmv;
1296 rc = lmv_check_connect(obd);
1300 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1303 * With DNE every object can have two locks in different namespaces:
1304 * lookup lock in space of MDT storing direntry and update/open lock in
1305 * space of MDT storing inode.
1307 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1308 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1310 md_change_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data);
1316 static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1317 ldlm_iterator_t it, void *data)
1319 struct obd_device *obd = exp->exp_obd;
1320 struct lmv_obd *lmv = &obd->u.lmv;
1325 rc = lmv_check_connect(obd);
1329 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1332 * With DNE every object can have two locks in different namespaces:
1333 * lookup lock in space of MDT storing direntry and update/open lock in
1334 * space of MDT storing inode.
1336 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1337 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1339 rc = md_find_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data);
1348 static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
1349 struct md_open_data *mod, struct ptlrpc_request **request)
1351 struct obd_device *obd = exp->exp_obd;
1352 struct lmv_obd *lmv = &obd->u.lmv;
1353 struct lmv_tgt_desc *tgt;
1357 rc = lmv_check_connect(obd);
1361 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1363 RETURN(PTR_ERR(tgt));
1365 CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1));
1366 rc = md_close(tgt->ltd_exp, op_data, mod, request);
1371 *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
1374 struct lmv_tgt_desc *tgt;
1376 tgt = lmv_find_target(lmv, fid);
1377 op_data->op_mds = tgt->ltd_idx;
1382 int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
1383 const void *data, int datalen, int mode, __u32 uid,
1384 __u32 gid, cfs_cap_t cap_effective, __u64 rdev,
1385 struct ptlrpc_request **request)
1387 struct obd_device *obd = exp->exp_obd;
1388 struct lmv_obd *lmv = &obd->u.lmv;
1389 struct lmv_tgt_desc *tgt;
1393 rc = lmv_check_connect(obd);
1397 if (!lmv->desc.ld_active_tgt_count)
1400 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1402 RETURN(PTR_ERR(tgt));
1404 rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data);
1408 CDEBUG(D_INODE, "CREATE '%*s' on "DFID" -> mds #%x\n",
1409 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1412 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1413 rc = md_create(tgt->ltd_exp, op_data, data, datalen, mode, uid, gid,
1414 cap_effective, rdev, request);
1417 if (*request == NULL)
1419 CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2));
1424 static int lmv_done_writing(struct obd_export *exp,
1425 struct md_op_data *op_data,
1426 struct md_open_data *mod)
1428 struct obd_device *obd = exp->exp_obd;
1429 struct lmv_obd *lmv = &obd->u.lmv;
1430 struct lmv_tgt_desc *tgt;
1434 rc = lmv_check_connect(obd);
1438 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1440 RETURN(PTR_ERR(tgt));
1442 rc = md_done_writing(tgt->ltd_exp, op_data, mod);
1447 lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1448 struct lookup_intent *it, struct md_op_data *op_data,
1449 struct lustre_handle *lockh, void *lmm, int lmmsize,
1450 int extra_lock_flags)
1452 struct ptlrpc_request *req = it->d.lustre.it_data;
1453 struct obd_device *obd = exp->exp_obd;
1454 struct lmv_obd *lmv = &obd->u.lmv;
1455 struct lustre_handle plock;
1456 struct lmv_tgt_desc *tgt;
1457 struct md_op_data *rdata;
1459 struct mdt_body *body;
1464 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1465 LASSERT(body != NULL);
1467 if (!(body->valid & OBD_MD_MDS))
1470 CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n",
1471 LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1));
1474 * We got LOOKUP lock, but we really need attrs.
1476 pmode = it->d.lustre.it_lock_mode;
1477 LASSERT(pmode != 0);
1478 memcpy(&plock, lockh, sizeof(plock));
1479 it->d.lustre.it_lock_mode = 0;
1480 it->d.lustre.it_data = NULL;
1483 it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
1484 ptlrpc_req_finished(req);
1486 tgt = lmv_find_target(lmv, &fid1);
1488 GOTO(out, rc = PTR_ERR(tgt));
1490 OBD_ALLOC_PTR(rdata);
1492 GOTO(out, rc = -ENOMEM);
1494 rdata->op_fid1 = fid1;
1495 rdata->op_bias = MDS_CROSS_REF;
1497 rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
1498 lmm, lmmsize, NULL, extra_lock_flags);
1499 OBD_FREE_PTR(rdata);
1502 ldlm_lock_decref(&plock, pmode);
1507 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1508 struct lookup_intent *it, struct md_op_data *op_data,
1509 struct lustre_handle *lockh, void *lmm, int lmmsize,
1510 struct ptlrpc_request **req, __u64 extra_lock_flags)
1512 struct obd_device *obd = exp->exp_obd;
1513 struct lmv_obd *lmv = &obd->u.lmv;
1514 struct lmv_tgt_desc *tgt;
1518 rc = lmv_check_connect(obd);
1522 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n",
1523 LL_IT2STR(it), PFID(&op_data->op_fid1));
1525 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1527 RETURN(PTR_ERR(tgt));
1529 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n",
1530 LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
1532 rc = md_enqueue(tgt->ltd_exp, einfo, it, op_data, lockh,
1533 lmm, lmmsize, req, extra_lock_flags);
1535 if (rc == 0 && it && it->it_op == IT_OPEN) {
1536 rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh,
1537 lmm, lmmsize, extra_lock_flags);
1543 lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
1544 struct ptlrpc_request **request)
1546 struct ptlrpc_request *req = NULL;
1547 struct obd_device *obd = exp->exp_obd;
1548 struct lmv_obd *lmv = &obd->u.lmv;
1549 struct lmv_tgt_desc *tgt;
1550 struct mdt_body *body;
1554 rc = lmv_check_connect(obd);
1558 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1560 RETURN(PTR_ERR(tgt));
1562 CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" -> mds #%d\n",
1563 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1566 rc = md_getattr_name(tgt->ltd_exp, op_data, request);
1570 body = req_capsule_server_get(&(*request)->rq_pill,
1572 LASSERT(body != NULL);
1574 if (body->valid & OBD_MD_MDS) {
1575 struct lu_fid rid = body->fid1;
1576 CDEBUG(D_INODE, "Request attrs for "DFID"\n",
1579 tgt = lmv_find_target(lmv, &rid);
1581 ptlrpc_req_finished(*request);
1582 RETURN(PTR_ERR(tgt));
1585 op_data->op_fid1 = rid;
1586 op_data->op_valid |= OBD_MD_FLCROSSREF;
1587 op_data->op_namelen = 0;
1588 op_data->op_name = NULL;
1589 rc = md_getattr_name(tgt->ltd_exp, op_data, &req);
1590 ptlrpc_req_finished(*request);
1597 #define md_op_data_fid(op_data, fl) \
1598 (fl == MF_MDC_CANCEL_FID1 ? &op_data->op_fid1 : \
1599 fl == MF_MDC_CANCEL_FID2 ? &op_data->op_fid2 : \
1600 fl == MF_MDC_CANCEL_FID3 ? &op_data->op_fid3 : \
1601 fl == MF_MDC_CANCEL_FID4 ? &op_data->op_fid4 : \
1604 static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data,
1605 int op_tgt, ldlm_mode_t mode, int bits, int flag)
1607 struct lu_fid *fid = md_op_data_fid(op_data, flag);
1608 struct obd_device *obd = exp->exp_obd;
1609 struct lmv_obd *lmv = &obd->u.lmv;
1610 struct lmv_tgt_desc *tgt;
1611 ldlm_policy_data_t policy = {{0}};
1615 if (!fid_is_sane(fid))
1618 tgt = lmv_find_target(lmv, fid);
1620 RETURN(PTR_ERR(tgt));
1622 if (tgt->ltd_idx != op_tgt) {
1623 CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid));
1624 policy.l_inodebits.bits = bits;
1625 rc = md_cancel_unused(tgt->ltd_exp, fid, &policy,
1626 mode, LCF_ASYNC, NULL);
1629 "EARLY_CANCEL skip operation target %d on "DFID"\n",
1631 op_data->op_flags |= flag;
1639 * llite passes fid of an target inode in op_data->op_fid1 and id of directory in
1642 static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
1643 struct ptlrpc_request **request)
1645 struct obd_device *obd = exp->exp_obd;
1646 struct lmv_obd *lmv = &obd->u.lmv;
1647 struct lmv_tgt_desc *tgt;
1651 rc = lmv_check_connect(obd);
1655 LASSERT(op_data->op_namelen != 0);
1657 CDEBUG(D_INODE, "LINK "DFID":%*s to "DFID"\n",
1658 PFID(&op_data->op_fid2), op_data->op_namelen,
1659 op_data->op_name, PFID(&op_data->op_fid1));
1661 op_data->op_fsuid = cfs_curproc_fsuid();
1662 op_data->op_fsgid = cfs_curproc_fsgid();
1663 op_data->op_cap = cfs_curproc_cap_pack();
1664 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1666 RETURN(PTR_ERR(tgt));
1669 * Cancel UPDATE lock on child (fid1).
1671 op_data->op_flags |= MF_MDC_CANCEL_FID2;
1672 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1673 MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1);
1677 rc = md_link(tgt->ltd_exp, op_data, request);
1682 static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
1683 const char *old, int oldlen, const char *new, int newlen,
1684 struct ptlrpc_request **request)
1686 struct obd_device *obd = exp->exp_obd;
1687 struct lmv_obd *lmv = &obd->u.lmv;
1688 struct lmv_tgt_desc *src_tgt;
1689 struct lmv_tgt_desc *tgt_tgt;
1693 LASSERT(oldlen != 0);
1695 CDEBUG(D_INODE, "RENAME %*s in "DFID" to %*s in "DFID"\n",
1696 oldlen, old, PFID(&op_data->op_fid1),
1697 newlen, new, PFID(&op_data->op_fid2));
1699 rc = lmv_check_connect(obd);
1703 op_data->op_fsuid = cfs_curproc_fsuid();
1704 op_data->op_fsgid = cfs_curproc_fsgid();
1705 op_data->op_cap = cfs_curproc_cap_pack();
1706 src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1707 if (IS_ERR(src_tgt))
1708 RETURN(PTR_ERR(src_tgt));
1710 tgt_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1711 if (IS_ERR(tgt_tgt))
1712 RETURN(PTR_ERR(tgt_tgt));
1714 * LOOKUP lock on src child (fid3) should also be cancelled for
1715 * src_tgt in mdc_rename.
1717 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1720 * Cancel UPDATE locks on tgt parent (fid2), tgt_tgt is its
1723 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1724 LCK_EX, MDS_INODELOCK_UPDATE,
1725 MF_MDC_CANCEL_FID2);
1728 * Cancel LOOKUP locks on tgt child (fid4) for parent tgt_tgt.
1731 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1732 LCK_EX, MDS_INODELOCK_LOOKUP,
1733 MF_MDC_CANCEL_FID4);
1737 * Cancel all the locks on tgt child (fid4).
1740 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1741 LCK_EX, MDS_INODELOCK_FULL,
1742 MF_MDC_CANCEL_FID4);
1745 rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen,
1746 new, newlen, request);
1750 static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
1751 void *ea, int ealen, void *ea2, int ea2len,
1752 struct ptlrpc_request **request,
1753 struct md_open_data **mod)
1755 struct obd_device *obd = exp->exp_obd;
1756 struct lmv_obd *lmv = &obd->u.lmv;
1757 struct lmv_tgt_desc *tgt;
1761 rc = lmv_check_connect(obd);
1765 CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n",
1766 PFID(&op_data->op_fid1), op_data->op_attr.ia_valid);
1768 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1769 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1771 RETURN(PTR_ERR(tgt));
1773 rc = md_setattr(tgt->ltd_exp, op_data, ea, ealen, ea2,
1774 ea2len, request, mod);
1779 static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
1780 struct obd_capa *oc, struct ptlrpc_request **request)
1782 struct obd_device *obd = exp->exp_obd;
1783 struct lmv_obd *lmv = &obd->u.lmv;
1784 struct lmv_tgt_desc *tgt;
1788 rc = lmv_check_connect(obd);
1792 tgt = lmv_find_target(lmv, fid);
1794 RETURN(PTR_ERR(tgt));
1796 rc = md_sync(tgt->ltd_exp, fid, oc, request);
1800 static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data,
1801 struct page **pages, struct ptlrpc_request **request)
1803 struct obd_device *obd = exp->exp_obd;
1804 struct lmv_obd *lmv = &obd->u.lmv;
1805 __u64 offset = op_data->op_offset;
1808 /* number of pages read, in CFS_PAGE_SIZE */
1810 /* number of pages transferred in LU_PAGE_SIZE */
1812 struct lmv_tgt_desc *tgt;
1813 struct lu_dirpage *dp;
1814 struct lu_dirent *ent;
1817 rc = lmv_check_connect(obd);
1821 CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n",
1822 offset, PFID(&op_data->op_fid1));
1825 * This case handle directory lookup in clustered metadata case (i.e.
1826 * split directory is located on multiple md servers.)
1827 * each server keeps directory entries for certain range of hashes.
1828 * E.g. we have N server and suppose hash range is 0 to MAX_HASH.
1829 * first server will keep records with hashes [ 0 ... MAX_HASH /N - 1],
1830 * second one with hashes [MAX_HASH / N ... 2 * MAX_HASH / N] and
1832 * readdir can simply start reading entries from 0 - N server in
1833 * order but that will not scale well as all client will request dir in
1834 * to server in same order.
1835 * Following algorithm does optimization:
1836 * Instead of doing readdir in 1, 2, ...., N order, client with a
1837 * rank R does readdir in R, R + 1, ..., N, 1, ... R - 1 order.
1838 * (every client has rank R)
1839 * But ll_readdir() expect offset range [0 to MAX_HASH/N) but
1840 * since client ask dir from MDS{R} client has pages with offsets
1841 * [R*MAX_HASH/N ... (R + 1)*MAX_HASH/N] there for we do hash_adj
1842 * on hash values that we get.
1843 * Since these codes might be still useful for sharded directory, so
1844 * Keeping this code for further reference
1847 seg_size = MAX_HASH_SIZE;
1848 do_div(seg_size, nr);
1849 los = obj->lo_stripes;
1850 tgt = lmv_get_target(lmv, los[0].ls_mds);
1851 rank = lmv_node_rank(tgt->ltd_exp, fid) % nr;
1853 do_div(tgt_tmp, seg_size);
1854 tgt0_idx = do_div(tgt_tmp, nr);
1855 tgt_idx = (tgt0_idx + rank) % nr;
1857 if (tgt_idx < tgt0_idx)
1860 * Last segment has unusual length due to division
1862 hash_adj = MAX_HASH_SIZE - seg_size * nr;
1866 hash_adj += rank * seg_size;
1868 CDEBUG(D_INODE, "Readpage hash adjustment: %x "LPX64" "
1869 LPX64"/%x -> "LPX64"/%x\n", rank, hash_adj,
1870 offset, tgt0_idx, offset + hash_adj, tgt_idx);
1872 offset = (offset + hash_adj) & MAX_HASH_SIZE;
1873 rid = lsm->mea_oinfo[tgt_idx].lmo_fid;
1874 tgt = lmv_get_target(lmv, lsm->mea_oinfo[tgt_idx].lmo_mds);
1876 CDEBUG(D_INODE, "Forward to "DFID" with offset %lu i %d\n",
1877 PFID(&rid), (unsigned long)offset, tgt_idx);
1880 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1882 RETURN(PTR_ERR(tgt));
1884 rc = md_readpage(tgt->ltd_exp, op_data, pages, request);
1888 nrdpgs = ((*request)->rq_bulk->bd_nob_transferred + CFS_PAGE_SIZE - 1)
1890 nlupgs = (*request)->rq_bulk->bd_nob_transferred >> LU_PAGE_SHIFT;
1891 LASSERT(!((*request)->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK));
1892 LASSERT(nrdpgs > 0 && nrdpgs <= op_data->op_npages);
1894 CDEBUG(D_INODE, "read %d(%d)/%d pages\n", nrdpgs, nlupgs,
1895 op_data->op_npages);
1897 for (i = 0; i < nrdpgs; i++) {
1898 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1899 struct lu_dirpage *first;
1903 struct lu_dirent *tmp = NULL;
1905 dp = cfs_kmap(pages[i]);
1906 ent = lu_dirent_start(dp);
1907 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1909 hash_end = dp->ldp_hash_end;
1914 for (tmp = ent; ent != NULL;
1915 tmp = ent, ent = lu_dirent_next(ent));
1916 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1917 dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);
1918 if (((unsigned long)dp & ~CFS_PAGE_MASK) && nlupgs > 0) {
1919 ent = lu_dirent_start(dp);
1922 /* enlarge the end entry lde_reclen from 0 to
1923 * first entry of next lu_dirpage, in this way
1924 * several lu_dirpages can be stored into one
1925 * client page on client. */
1926 tmp = ((void *)tmp) +
1927 le16_to_cpu(tmp->lde_reclen);
1929 cpu_to_le16((char *)(dp->ldp_entries) -
1934 first->ldp_hash_end = hash_end;
1935 first->ldp_flags &= ~cpu_to_le32(LDF_COLLIDE);
1936 first->ldp_flags |= flags & cpu_to_le32(LDF_COLLIDE);
1938 SET_BUT_UNUSED(tmp);
1940 cfs_kunmap(pages[i]);
1945 static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data,
1946 struct ptlrpc_request **request)
1948 struct obd_device *obd = exp->exp_obd;
1949 struct lmv_obd *lmv = &obd->u.lmv;
1950 struct lmv_tgt_desc *tgt = NULL;
1954 rc = lmv_check_connect(obd);
1958 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1960 RETURN(PTR_ERR(tgt));
1962 op_data->op_fsuid = cfs_curproc_fsuid();
1963 op_data->op_fsgid = cfs_curproc_fsgid();
1964 op_data->op_cap = cfs_curproc_cap_pack();
1967 * If child's fid is given, cancel unused locks for it if it is from
1968 * another export than parent.
1970 * LOOKUP lock for child (fid3) should also be cancelled on parent
1971 * tgt_tgt in mdc_unlink().
1973 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1976 * Cancel FULL locks on child (fid3).
1978 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1979 MDS_INODELOCK_FULL, MF_MDC_CANCEL_FID3);
1984 rc = md_unlink(tgt->ltd_exp, op_data, request);
1989 static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
1991 struct lmv_obd *lmv = &obd->u.lmv;
1995 case OBD_CLEANUP_EARLY:
1996 /* XXX: here should be calling obd_precleanup() down to
1999 case OBD_CLEANUP_EXPORTS:
2000 fld_client_proc_fini(&lmv->lmv_fld);
2001 lprocfs_obd_cleanup(obd);
2009 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
2010 __u32 keylen, void *key, __u32 *vallen, void *val,
2011 struct lov_stripe_md *lsm)
2013 struct obd_device *obd;
2014 struct lmv_obd *lmv;
2018 obd = class_exp2obd(exp);
2020 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2021 exp->exp_handle.h_cookie);
2026 if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
2027 struct lmv_tgt_desc *tgt;
2030 rc = lmv_check_connect(obd);
2034 LASSERT(*vallen == sizeof(__u32));
2035 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2038 * All tgts should be connected when this gets called.
2040 if (tgt == NULL || tgt->ltd_exp == NULL)
2043 if (!obd_get_info(env, tgt->ltd_exp, keylen, key,
2048 } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) {
2049 rc = lmv_check_connect(obd);
2054 * Forwarding this request to first MDS, it should know LOV
2057 rc = obd_get_info(env, lmv->tgts[0]->ltd_exp, keylen, key,
2059 if (!rc && KEY_IS(KEY_CONN_DATA)) {
2060 exp->exp_connect_flags =
2061 ((struct obd_connect_data *)val)->ocd_connect_flags;
2064 } else if (KEY_IS(KEY_TGT_COUNT)) {
2065 *((int *)val) = lmv->desc.ld_tgt_count;
2069 CDEBUG(D_IOCTL, "Invalid key\n");
2073 int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
2074 obd_count keylen, void *key, obd_count vallen,
2075 void *val, struct ptlrpc_request_set *set)
2077 struct lmv_tgt_desc *tgt;
2078 struct obd_device *obd;
2079 struct lmv_obd *lmv;
2083 obd = class_exp2obd(exp);
2085 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2086 exp->exp_handle.h_cookie);
2091 if (KEY_IS(KEY_READ_ONLY) || KEY_IS(KEY_FLUSH_CTX)) {
2094 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2097 if (tgt == NULL || tgt->ltd_exp == NULL)
2100 err = obd_set_info_async(env, tgt->ltd_exp,
2101 keylen, key, vallen, val, set);
2112 int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
2113 struct lov_stripe_md *lsm)
2115 struct obd_device *obd = class_exp2obd(exp);
2116 struct lmv_obd *lmv = &obd->u.lmv;
2117 struct lmv_stripe_md *meap;
2118 struct lmv_stripe_md *lsmp;
2123 mea_size = lmv_get_easize(lmv);
2127 if (*lmmp && !lsm) {
2128 OBD_FREE_LARGE(*lmmp, mea_size);
2133 if (*lmmp == NULL) {
2134 OBD_ALLOC_LARGE(*lmmp, mea_size);
2142 lsmp = (struct lmv_stripe_md *)lsm;
2143 meap = (struct lmv_stripe_md *)*lmmp;
2145 if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR &&
2146 lsmp->mea_magic != MEA_MAGIC_ALL_CHARS)
2149 meap->mea_magic = cpu_to_le32(lsmp->mea_magic);
2150 meap->mea_count = cpu_to_le32(lsmp->mea_count);
2151 meap->mea_master = cpu_to_le32(lsmp->mea_master);
2153 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2154 meap->mea_ids[i] = meap->mea_ids[i];
2155 fid_cpu_to_le(&meap->mea_ids[i], &meap->mea_ids[i]);
2161 int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
2162 struct lov_mds_md *lmm, int lmm_size)
2164 struct obd_device *obd = class_exp2obd(exp);
2165 struct lmv_stripe_md **tmea = (struct lmv_stripe_md **)lsmp;
2166 struct lmv_stripe_md *mea = (struct lmv_stripe_md *)lmm;
2167 struct lmv_obd *lmv = &obd->u.lmv;
2173 mea_size = lmv_get_easize(lmv);
2177 if (*lsmp != NULL && lmm == NULL) {
2178 OBD_FREE_LARGE(*tmea, mea_size);
2183 LASSERT(mea_size == lmm_size);
2185 OBD_ALLOC_LARGE(*tmea, mea_size);
2192 if (mea->mea_magic == MEA_MAGIC_LAST_CHAR ||
2193 mea->mea_magic == MEA_MAGIC_ALL_CHARS ||
2194 mea->mea_magic == MEA_MAGIC_HASH_SEGMENT)
2196 magic = le32_to_cpu(mea->mea_magic);
2199 * Old mea is not handled here.
2201 CERROR("Old not supportable EA is found\n");
2205 (*tmea)->mea_magic = magic;
2206 (*tmea)->mea_count = le32_to_cpu(mea->mea_count);
2207 (*tmea)->mea_master = le32_to_cpu(mea->mea_master);
2209 for (i = 0; i < (*tmea)->mea_count; i++) {
2210 (*tmea)->mea_ids[i] = mea->mea_ids[i];
2211 fid_le_to_cpu(&(*tmea)->mea_ids[i], &(*tmea)->mea_ids[i]);
2216 static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
2217 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2218 ldlm_cancel_flags_t flags, void *opaque)
2220 struct obd_device *obd = exp->exp_obd;
2221 struct lmv_obd *lmv = &obd->u.lmv;
2227 LASSERT(fid != NULL);
2229 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2230 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL ||
2231 lmv->tgts[i]->ltd_active == 0)
2234 err = md_cancel_unused(lmv->tgts[i]->ltd_exp, fid,
2235 policy, mode, flags, opaque);
2242 int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
2245 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2249 rc = md_set_lock_data(lmv->tgts[0]->ltd_exp, lockh, data, bits);
2253 ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags,
2254 const struct lu_fid *fid, ldlm_type_t type,
2255 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2256 struct lustre_handle *lockh)
2258 struct obd_device *obd = exp->exp_obd;
2259 struct lmv_obd *lmv = &obd->u.lmv;
2264 CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid));
2267 * With CMD every object can have two locks in different namespaces:
2268 * lookup lock in space of mds storing direntry and update/open lock in
2269 * space of mds storing inode. Thus we check all targets, not only that
2270 * one fid was created in.
2272 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2273 if (lmv->tgts[i] == NULL ||
2274 lmv->tgts[i]->ltd_exp == NULL ||
2275 lmv->tgts[i]->ltd_active == 0)
2278 rc = md_lock_match(lmv->tgts[i]->ltd_exp, flags, fid,
2279 type, policy, mode, lockh);
2287 int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
2288 struct obd_export *dt_exp, struct obd_export *md_exp,
2289 struct lustre_md *md)
2291 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2293 return md_get_lustre_md(lmv->tgts[0]->ltd_exp, req, dt_exp, md_exp, md);
2296 int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
2298 struct obd_device *obd = exp->exp_obd;
2299 struct lmv_obd *lmv = &obd->u.lmv;
2303 obd_free_memmd(exp, (void *)&md->mea);
2304 RETURN(md_free_lustre_md(lmv->tgts[0]->ltd_exp, md));
2307 int lmv_set_open_replay_data(struct obd_export *exp,
2308 struct obd_client_handle *och,
2309 struct ptlrpc_request *open_req)
2311 struct obd_device *obd = exp->exp_obd;
2312 struct lmv_obd *lmv = &obd->u.lmv;
2313 struct lmv_tgt_desc *tgt;
2316 tgt = lmv_find_target(lmv, &och->och_fid);
2318 RETURN(PTR_ERR(tgt));
2320 RETURN(md_set_open_replay_data(tgt->ltd_exp, och, open_req));
2323 int lmv_clear_open_replay_data(struct obd_export *exp,
2324 struct obd_client_handle *och)
2326 struct obd_device *obd = exp->exp_obd;
2327 struct lmv_obd *lmv = &obd->u.lmv;
2328 struct lmv_tgt_desc *tgt;
2331 tgt = lmv_find_target(lmv, &och->och_fid);
2333 RETURN(PTR_ERR(tgt));
2335 RETURN(md_clear_open_replay_data(tgt->ltd_exp, och));
2338 static int lmv_get_remote_perm(struct obd_export *exp,
2339 const struct lu_fid *fid,
2340 struct obd_capa *oc, __u32 suppgid,
2341 struct ptlrpc_request **request)
2343 struct obd_device *obd = exp->exp_obd;
2344 struct lmv_obd *lmv = &obd->u.lmv;
2345 struct lmv_tgt_desc *tgt;
2349 rc = lmv_check_connect(obd);
2353 tgt = lmv_find_target(lmv, fid);
2355 RETURN(PTR_ERR(tgt));
2357 rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request);
2361 static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2364 struct obd_device *obd = exp->exp_obd;
2365 struct lmv_obd *lmv = &obd->u.lmv;
2366 struct lmv_tgt_desc *tgt;
2370 rc = lmv_check_connect(obd);
2374 tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid);
2376 RETURN(PTR_ERR(tgt));
2378 rc = md_renew_capa(tgt->ltd_exp, oc, cb);
2382 int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
2383 const struct req_msg_field *field, struct obd_capa **oc)
2385 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2387 return md_unpack_capa(lmv->tgts[0]->ltd_exp, req, field, oc);
2390 int lmv_intent_getattr_async(struct obd_export *exp,
2391 struct md_enqueue_info *minfo,
2392 struct ldlm_enqueue_info *einfo)
2394 struct md_op_data *op_data = &minfo->mi_data;
2395 struct obd_device *obd = exp->exp_obd;
2396 struct lmv_obd *lmv = &obd->u.lmv;
2397 struct lmv_tgt_desc *tgt = NULL;
2401 rc = lmv_check_connect(obd);
2405 tgt = lmv_find_target(lmv, &op_data->op_fid1);
2407 RETURN(PTR_ERR(tgt));
2409 rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo);
2413 int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
2414 struct lu_fid *fid, __u64 *bits)
2416 struct obd_device *obd = exp->exp_obd;
2417 struct lmv_obd *lmv = &obd->u.lmv;
2418 struct lmv_tgt_desc *tgt;
2422 rc = lmv_check_connect(obd);
2426 tgt = lmv_find_target(lmv, fid);
2428 RETURN(PTR_ERR(tgt));
2430 rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits);
2435 * For lmv, only need to send request to master MDT, and the master MDT will
2436 * process with other slave MDTs. The only exception is Q_GETOQUOTA for which
2437 * we directly fetch data from the slave MDTs.
2439 int lmv_quotactl(struct obd_device *unused, struct obd_export *exp,
2440 struct obd_quotactl *oqctl)
2442 struct obd_device *obd = class_exp2obd(exp);
2443 struct lmv_obd *lmv = &obd->u.lmv;
2444 struct lmv_tgt_desc *tgt = lmv->tgts[0];
2446 __u64 curspace, curinodes;
2449 if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) {
2450 CERROR("master lmv inactive\n");
2454 if (oqctl->qc_cmd != Q_GETOQUOTA) {
2455 rc = obd_quotactl(tgt->ltd_exp, oqctl);
2459 curspace = curinodes = 0;
2460 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2464 if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0)
2466 if (!tgt->ltd_active) {
2467 CDEBUG(D_HA, "mdt %d is inactive.\n", i);
2471 err = obd_quotactl(tgt->ltd_exp, oqctl);
2473 CERROR("getquota on mdt %d failed. %d\n", i, err);
2477 curspace += oqctl->qc_dqblk.dqb_curspace;
2478 curinodes += oqctl->qc_dqblk.dqb_curinodes;
2481 oqctl->qc_dqblk.dqb_curspace = curspace;
2482 oqctl->qc_dqblk.dqb_curinodes = curinodes;
2487 int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
2488 struct obd_quotactl *oqctl)
2490 struct obd_device *obd = class_exp2obd(exp);
2491 struct lmv_obd *lmv = &obd->u.lmv;
2492 struct lmv_tgt_desc *tgt;
2496 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2499 if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) {
2500 CERROR("lmv idx %d inactive\n", i);
2504 err = obd_quotacheck(tgt->ltd_exp, oqctl);
2512 struct obd_ops lmv_obd_ops = {
2513 .o_owner = THIS_MODULE,
2514 .o_setup = lmv_setup,
2515 .o_cleanup = lmv_cleanup,
2516 .o_precleanup = lmv_precleanup,
2517 .o_process_config = lmv_process_config,
2518 .o_connect = lmv_connect,
2519 .o_disconnect = lmv_disconnect,
2520 .o_statfs = lmv_statfs,
2521 .o_get_info = lmv_get_info,
2522 .o_set_info_async = lmv_set_info_async,
2523 .o_packmd = lmv_packmd,
2524 .o_unpackmd = lmv_unpackmd,
2525 .o_notify = lmv_notify,
2526 .o_get_uuid = lmv_get_uuid,
2527 .o_iocontrol = lmv_iocontrol,
2528 .o_quotacheck = lmv_quotacheck,
2529 .o_quotactl = lmv_quotactl
2532 struct md_ops lmv_md_ops = {
2533 .m_getstatus = lmv_getstatus,
2534 .m_change_cbdata = lmv_change_cbdata,
2535 .m_find_cbdata = lmv_find_cbdata,
2536 .m_close = lmv_close,
2537 .m_create = lmv_create,
2538 .m_done_writing = lmv_done_writing,
2539 .m_enqueue = lmv_enqueue,
2540 .m_getattr = lmv_getattr,
2541 .m_getxattr = lmv_getxattr,
2542 .m_getattr_name = lmv_getattr_name,
2543 .m_intent_lock = lmv_intent_lock,
2545 .m_rename = lmv_rename,
2546 .m_setattr = lmv_setattr,
2547 .m_setxattr = lmv_setxattr,
2549 .m_readpage = lmv_readpage,
2550 .m_unlink = lmv_unlink,
2551 .m_init_ea_size = lmv_init_ea_size,
2552 .m_cancel_unused = lmv_cancel_unused,
2553 .m_set_lock_data = lmv_set_lock_data,
2554 .m_lock_match = lmv_lock_match,
2555 .m_get_lustre_md = lmv_get_lustre_md,
2556 .m_free_lustre_md = lmv_free_lustre_md,
2557 .m_set_open_replay_data = lmv_set_open_replay_data,
2558 .m_clear_open_replay_data = lmv_clear_open_replay_data,
2559 .m_renew_capa = lmv_renew_capa,
2560 .m_unpack_capa = lmv_unpack_capa,
2561 .m_get_remote_perm = lmv_get_remote_perm,
2562 .m_intent_getattr_async = lmv_intent_getattr_async,
2563 .m_revalidate_lock = lmv_revalidate_lock
2566 int __init lmv_init(void)
2568 struct lprocfs_static_vars lvars;
2571 lprocfs_lmv_init_vars(&lvars);
2573 rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
2574 lvars.module_vars, LUSTRE_LMV_NAME, NULL);
2579 static void lmv_exit(void)
2581 class_unregister_type(LUSTRE_LMV_NAME);
2584 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2585 MODULE_DESCRIPTION("Lustre Logical Metadata Volume OBD driver");
2586 MODULE_LICENSE("GPL");
2588 module_init(lmv_init);
2589 module_exit(lmv_exit);