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 case LL_IOC_HSM_ACTION: {
870 struct md_op_data *op_data = karg;
871 struct lmv_tgt_desc *tgt;
873 tgt = lmv_find_target(lmv, &op_data->op_fid1);
877 rc = obd_iocontrol(cmd, lmv->tgts[0]->ltd_exp, len, karg, uarg);
881 for (i = 0; i < count; i++) {
882 struct obd_device *mdc_obd;
885 if (lmv->tgts[i] == NULL ||
886 lmv->tgts[i]->ltd_exp == NULL)
888 /* ll_umount_begin() sets force flag but for lmv, not
889 * mdc. Let's pass it through */
890 mdc_obd = class_exp2obd(lmv->tgts[i]->ltd_exp);
891 mdc_obd->obd_force = obddev->obd_force;
892 err = obd_iocontrol(cmd, lmv->tgts[i]->ltd_exp, len,
894 if (err == -ENODATA && cmd == OBD_IOC_POLL_QUOTACHECK) {
897 if (lmv->tgts[i]->ltd_active) {
898 CERROR("error: iocontrol MDC %s on MDT"
899 "idx %d cmd %x: err = %d\n",
900 lmv->tgts[i]->ltd_uuid.uuid,
915 static int lmv_all_chars_policy(int count, const char *name,
926 static int lmv_nid_policy(struct lmv_obd *lmv)
928 struct obd_import *imp;
932 * XXX: To get nid we assume that underlying obd device is mdc.
934 imp = class_exp2cliimp(lmv->tgts[0].ltd_exp);
935 id = imp->imp_connection->c_self ^ (imp->imp_connection->c_self >> 32);
936 return id % lmv->desc.ld_tgt_count;
939 static int lmv_choose_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
940 placement_policy_t placement)
943 case PLACEMENT_CHAR_POLICY:
944 return lmv_all_chars_policy(lmv->desc.ld_tgt_count,
946 op_data->op_namelen);
947 case PLACEMENT_NID_POLICY:
948 return lmv_nid_policy(lmv);
954 CERROR("Unsupported placement policy %x\n", placement);
960 * This is _inode_ placement policy function (not name).
962 static int lmv_placement_policy(struct obd_device *obd,
963 struct md_op_data *op_data,
966 LASSERT(mds != NULL);
968 /* Allocate new fid on target according to to different
969 * QOS policy. In DNE phase I, llite should always tell
970 * which MDT where the dir will be located */
971 *mds = op_data->op_mds;
976 int __lmv_fid_alloc(struct lmv_obd *lmv, struct lu_fid *fid,
979 struct lmv_tgt_desc *tgt;
983 tgt = lmv_get_target(lmv, mds);
986 * New seq alloc and FLD setup should be atomic. Otherwise we may find
987 * on server that seq in new allocated fid is not yet known.
989 mutex_lock(&tgt->ltd_fid_mutex);
991 if (tgt == NULL || tgt->ltd_active == 0 || tgt->ltd_exp == NULL)
992 GOTO(out, rc = -ENODEV);
995 * Asking underlaying tgt layer to allocate new fid.
997 rc = obd_fid_alloc(tgt->ltd_exp, fid, NULL);
999 LASSERT(fid_is_sane(fid));
1005 mutex_unlock(&tgt->ltd_fid_mutex);
1009 int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
1010 struct md_op_data *op_data)
1012 struct obd_device *obd = class_exp2obd(exp);
1013 struct lmv_obd *lmv = &obd->u.lmv;
1018 LASSERT(op_data != NULL);
1019 LASSERT(fid != NULL);
1021 rc = lmv_placement_policy(obd, op_data, &mds);
1023 CERROR("Can't get target for allocating fid, "
1028 rc = __lmv_fid_alloc(lmv, fid, mds);
1030 CERROR("Can't alloc new fid, rc %d\n", rc);
1037 static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
1039 struct lmv_obd *lmv = &obd->u.lmv;
1040 struct lprocfs_static_vars lvars;
1041 struct lmv_desc *desc;
1045 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
1046 CERROR("LMV setup requires a descriptor\n");
1050 desc = (struct lmv_desc *)lustre_cfg_buf(lcfg, 1);
1051 if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
1052 CERROR("Lmv descriptor size wrong: %d > %d\n",
1053 (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1));
1057 OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32);
1058 if (lmv->tgts == NULL)
1060 lmv->tgts_size = 32;
1062 obd_str2uuid(&lmv->desc.ld_uuid, desc->ld_uuid.uuid);
1063 lmv->desc.ld_tgt_count = 0;
1064 lmv->desc.ld_active_tgt_count = 0;
1065 lmv->max_cookiesize = 0;
1066 lmv->max_def_easize = 0;
1067 lmv->max_easize = 0;
1068 lmv->lmv_placement = PLACEMENT_CHAR_POLICY;
1070 spin_lock_init(&lmv->lmv_lock);
1071 mutex_init(&lmv->init_mutex);
1073 lprocfs_lmv_init_vars(&lvars);
1075 lprocfs_obd_setup(obd, lvars.obd_vars);
1078 rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
1079 0444, &lmv_proc_target_fops, obd);
1081 CWARN("%s: error adding LMV target_obd file: rc = %d\n",
1085 rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
1086 LUSTRE_CLI_FLD_HASH_DHT);
1088 CERROR("Can't init FLD, err %d\n", rc);
1098 static int lmv_cleanup(struct obd_device *obd)
1100 struct lmv_obd *lmv = &obd->u.lmv;
1103 fld_client_fini(&lmv->lmv_fld);
1104 if (lmv->tgts != NULL) {
1106 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1107 if (lmv->tgts[i] == NULL)
1109 lmv_del_target(lmv, i);
1111 OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size);
1117 static int lmv_process_config(struct obd_device *obd, obd_count len, void *buf)
1119 struct lustre_cfg *lcfg = buf;
1120 struct obd_uuid obd_uuid;
1126 switch (lcfg->lcfg_command) {
1128 /* modify_mdc_tgts add 0:lustre-clilmv 1:lustre-MDT0000_UUID
1129 * 2:0 3:1 4:lustre-MDT0000-mdc_UUID */
1130 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(obd_uuid.uuid))
1131 GOTO(out, rc = -EINVAL);
1133 obd_str2uuid(&obd_uuid, lustre_cfg_buf(lcfg, 1));
1135 if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", &index) != 1)
1136 GOTO(out, rc = -EINVAL);
1137 if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", &gen) != 1)
1138 GOTO(out, rc = -EINVAL);
1139 rc = lmv_add_target(obd, &obd_uuid, index, gen);
1142 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
1143 GOTO(out, rc = -EINVAL);
1149 static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
1150 struct obd_statfs *osfs, __u64 max_age, __u32 flags)
1152 struct obd_device *obd = class_exp2obd(exp);
1153 struct lmv_obd *lmv = &obd->u.lmv;
1154 struct obd_statfs *temp;
1159 rc = lmv_check_connect(obd);
1163 OBD_ALLOC(temp, sizeof(*temp));
1167 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1168 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1171 rc = obd_statfs(env, lmv->tgts[i]->ltd_exp, temp,
1174 CERROR("can't stat MDS #%d (%s), error %d\n", i,
1175 lmv->tgts[i]->ltd_exp->exp_obd->obd_name,
1177 GOTO(out_free_temp, rc);
1182 /* If the statfs is from mount, it will needs
1183 * retrieve necessary information from MDT0.
1184 * i.e. mount does not need the merged osfs
1186 * And also clients can be mounted as long as
1187 * MDT0 is in service*/
1188 if (flags & OBD_STATFS_FOR_MDT0)
1189 GOTO(out_free_temp, rc);
1191 osfs->os_bavail += temp->os_bavail;
1192 osfs->os_blocks += temp->os_blocks;
1193 osfs->os_ffree += temp->os_ffree;
1194 osfs->os_files += temp->os_files;
1200 OBD_FREE(temp, sizeof(*temp));
1204 static int lmv_getstatus(struct obd_export *exp,
1206 struct obd_capa **pc)
1208 struct obd_device *obd = exp->exp_obd;
1209 struct lmv_obd *lmv = &obd->u.lmv;
1213 rc = lmv_check_connect(obd);
1217 rc = md_getstatus(lmv->tgts[0]->ltd_exp, fid, pc);
1221 static int lmv_getxattr(struct obd_export *exp, const struct lu_fid *fid,
1222 struct obd_capa *oc, obd_valid valid, const char *name,
1223 const char *input, int input_size, int output_size,
1224 int flags, struct ptlrpc_request **request)
1226 struct obd_device *obd = exp->exp_obd;
1227 struct lmv_obd *lmv = &obd->u.lmv;
1228 struct lmv_tgt_desc *tgt;
1232 rc = lmv_check_connect(obd);
1236 tgt = lmv_find_target(lmv, fid);
1238 RETURN(PTR_ERR(tgt));
1240 rc = md_getxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1241 input_size, output_size, flags, request);
1246 static int lmv_setxattr(struct obd_export *exp, const struct lu_fid *fid,
1247 struct obd_capa *oc, obd_valid valid, const char *name,
1248 const char *input, int input_size, int output_size,
1249 int flags, __u32 suppgid,
1250 struct ptlrpc_request **request)
1252 struct obd_device *obd = exp->exp_obd;
1253 struct lmv_obd *lmv = &obd->u.lmv;
1254 struct lmv_tgt_desc *tgt;
1258 rc = lmv_check_connect(obd);
1262 tgt = lmv_find_target(lmv, fid);
1264 RETURN(PTR_ERR(tgt));
1266 rc = md_setxattr(tgt->ltd_exp, fid, oc, valid, name, input,
1267 input_size, output_size, flags, suppgid,
1273 static int lmv_getattr(struct obd_export *exp, struct md_op_data *op_data,
1274 struct ptlrpc_request **request)
1276 struct obd_device *obd = exp->exp_obd;
1277 struct lmv_obd *lmv = &obd->u.lmv;
1278 struct lmv_tgt_desc *tgt;
1282 rc = lmv_check_connect(obd);
1286 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1288 RETURN(PTR_ERR(tgt));
1290 if (op_data->op_flags & MF_GET_MDT_IDX) {
1291 op_data->op_mds = tgt->ltd_idx;
1295 rc = md_getattr(tgt->ltd_exp, op_data, request);
1300 static int lmv_change_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1301 ldlm_iterator_t it, void *data)
1303 struct obd_device *obd = exp->exp_obd;
1304 struct lmv_obd *lmv = &obd->u.lmv;
1309 rc = lmv_check_connect(obd);
1313 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1316 * With DNE every object can have two locks in different namespaces:
1317 * lookup lock in space of MDT storing direntry and update/open lock in
1318 * space of MDT storing inode.
1320 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1321 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1323 md_change_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data);
1329 static int lmv_find_cbdata(struct obd_export *exp, const struct lu_fid *fid,
1330 ldlm_iterator_t it, void *data)
1332 struct obd_device *obd = exp->exp_obd;
1333 struct lmv_obd *lmv = &obd->u.lmv;
1338 rc = lmv_check_connect(obd);
1342 CDEBUG(D_INODE, "CBDATA for "DFID"\n", PFID(fid));
1345 * With DNE every object can have two locks in different namespaces:
1346 * lookup lock in space of MDT storing direntry and update/open lock in
1347 * space of MDT storing inode.
1349 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1350 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL)
1352 rc = md_find_cbdata(lmv->tgts[i]->ltd_exp, fid, it, data);
1361 static int lmv_close(struct obd_export *exp, struct md_op_data *op_data,
1362 struct md_open_data *mod, struct ptlrpc_request **request)
1364 struct obd_device *obd = exp->exp_obd;
1365 struct lmv_obd *lmv = &obd->u.lmv;
1366 struct lmv_tgt_desc *tgt;
1370 rc = lmv_check_connect(obd);
1374 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1376 RETURN(PTR_ERR(tgt));
1378 CDEBUG(D_INODE, "CLOSE "DFID"\n", PFID(&op_data->op_fid1));
1379 rc = md_close(tgt->ltd_exp, op_data, mod, request);
1384 *lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
1387 struct lmv_tgt_desc *tgt;
1389 tgt = lmv_find_target(lmv, fid);
1390 op_data->op_mds = tgt->ltd_idx;
1395 int lmv_create(struct obd_export *exp, struct md_op_data *op_data,
1396 const void *data, int datalen, int mode, __u32 uid,
1397 __u32 gid, cfs_cap_t cap_effective, __u64 rdev,
1398 struct ptlrpc_request **request)
1400 struct obd_device *obd = exp->exp_obd;
1401 struct lmv_obd *lmv = &obd->u.lmv;
1402 struct lmv_tgt_desc *tgt;
1406 rc = lmv_check_connect(obd);
1410 if (!lmv->desc.ld_active_tgt_count)
1413 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1415 RETURN(PTR_ERR(tgt));
1417 rc = lmv_fid_alloc(exp, &op_data->op_fid2, op_data);
1421 CDEBUG(D_INODE, "CREATE '%*s' on "DFID" -> mds #%x\n",
1422 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1425 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1426 rc = md_create(tgt->ltd_exp, op_data, data, datalen, mode, uid, gid,
1427 cap_effective, rdev, request);
1430 if (*request == NULL)
1432 CDEBUG(D_INODE, "Created - "DFID"\n", PFID(&op_data->op_fid2));
1437 static int lmv_done_writing(struct obd_export *exp,
1438 struct md_op_data *op_data,
1439 struct md_open_data *mod)
1441 struct obd_device *obd = exp->exp_obd;
1442 struct lmv_obd *lmv = &obd->u.lmv;
1443 struct lmv_tgt_desc *tgt;
1447 rc = lmv_check_connect(obd);
1451 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1453 RETURN(PTR_ERR(tgt));
1455 rc = md_done_writing(tgt->ltd_exp, op_data, mod);
1460 lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1461 struct lookup_intent *it, struct md_op_data *op_data,
1462 struct lustre_handle *lockh, void *lmm, int lmmsize,
1463 int extra_lock_flags)
1465 struct ptlrpc_request *req = it->d.lustre.it_data;
1466 struct obd_device *obd = exp->exp_obd;
1467 struct lmv_obd *lmv = &obd->u.lmv;
1468 struct lustre_handle plock;
1469 struct lmv_tgt_desc *tgt;
1470 struct md_op_data *rdata;
1472 struct mdt_body *body;
1477 body = req_capsule_server_get(&req->rq_pill, &RMF_MDT_BODY);
1478 LASSERT(body != NULL);
1480 if (!(body->valid & OBD_MD_MDS))
1483 CDEBUG(D_INODE, "REMOTE_ENQUEUE '%s' on "DFID" -> "DFID"\n",
1484 LL_IT2STR(it), PFID(&op_data->op_fid1), PFID(&body->fid1));
1487 * We got LOOKUP lock, but we really need attrs.
1489 pmode = it->d.lustre.it_lock_mode;
1490 LASSERT(pmode != 0);
1491 memcpy(&plock, lockh, sizeof(plock));
1492 it->d.lustre.it_lock_mode = 0;
1493 it->d.lustre.it_data = NULL;
1496 it->d.lustre.it_disposition &= ~DISP_ENQ_COMPLETE;
1497 ptlrpc_req_finished(req);
1499 tgt = lmv_find_target(lmv, &fid1);
1501 GOTO(out, rc = PTR_ERR(tgt));
1503 OBD_ALLOC_PTR(rdata);
1505 GOTO(out, rc = -ENOMEM);
1507 rdata->op_fid1 = fid1;
1508 rdata->op_bias = MDS_CROSS_REF;
1510 rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
1511 lmm, lmmsize, NULL, extra_lock_flags);
1512 OBD_FREE_PTR(rdata);
1515 ldlm_lock_decref(&plock, pmode);
1520 lmv_enqueue(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
1521 struct lookup_intent *it, struct md_op_data *op_data,
1522 struct lustre_handle *lockh, void *lmm, int lmmsize,
1523 struct ptlrpc_request **req, __u64 extra_lock_flags)
1525 struct obd_device *obd = exp->exp_obd;
1526 struct lmv_obd *lmv = &obd->u.lmv;
1527 struct lmv_tgt_desc *tgt;
1531 rc = lmv_check_connect(obd);
1535 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID"\n",
1536 LL_IT2STR(it), PFID(&op_data->op_fid1));
1538 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1540 RETURN(PTR_ERR(tgt));
1542 CDEBUG(D_INODE, "ENQUEUE '%s' on "DFID" -> mds #%d\n",
1543 LL_IT2STR(it), PFID(&op_data->op_fid1), tgt->ltd_idx);
1545 rc = md_enqueue(tgt->ltd_exp, einfo, it, op_data, lockh,
1546 lmm, lmmsize, req, extra_lock_flags);
1548 if (rc == 0 && it && it->it_op == IT_OPEN) {
1549 rc = lmv_enqueue_remote(exp, einfo, it, op_data, lockh,
1550 lmm, lmmsize, extra_lock_flags);
1556 lmv_getattr_name(struct obd_export *exp,struct md_op_data *op_data,
1557 struct ptlrpc_request **request)
1559 struct ptlrpc_request *req = NULL;
1560 struct obd_device *obd = exp->exp_obd;
1561 struct lmv_obd *lmv = &obd->u.lmv;
1562 struct lmv_tgt_desc *tgt;
1563 struct mdt_body *body;
1567 rc = lmv_check_connect(obd);
1571 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1573 RETURN(PTR_ERR(tgt));
1575 CDEBUG(D_INODE, "GETATTR_NAME for %*s on "DFID" -> mds #%d\n",
1576 op_data->op_namelen, op_data->op_name, PFID(&op_data->op_fid1),
1579 rc = md_getattr_name(tgt->ltd_exp, op_data, request);
1583 body = req_capsule_server_get(&(*request)->rq_pill,
1585 LASSERT(body != NULL);
1587 if (body->valid & OBD_MD_MDS) {
1588 struct lu_fid rid = body->fid1;
1589 CDEBUG(D_INODE, "Request attrs for "DFID"\n",
1592 tgt = lmv_find_target(lmv, &rid);
1594 ptlrpc_req_finished(*request);
1595 RETURN(PTR_ERR(tgt));
1598 op_data->op_fid1 = rid;
1599 op_data->op_valid |= OBD_MD_FLCROSSREF;
1600 op_data->op_namelen = 0;
1601 op_data->op_name = NULL;
1602 rc = md_getattr_name(tgt->ltd_exp, op_data, &req);
1603 ptlrpc_req_finished(*request);
1610 #define md_op_data_fid(op_data, fl) \
1611 (fl == MF_MDC_CANCEL_FID1 ? &op_data->op_fid1 : \
1612 fl == MF_MDC_CANCEL_FID2 ? &op_data->op_fid2 : \
1613 fl == MF_MDC_CANCEL_FID3 ? &op_data->op_fid3 : \
1614 fl == MF_MDC_CANCEL_FID4 ? &op_data->op_fid4 : \
1617 static int lmv_early_cancel(struct obd_export *exp, struct md_op_data *op_data,
1618 int op_tgt, ldlm_mode_t mode, int bits, int flag)
1620 struct lu_fid *fid = md_op_data_fid(op_data, flag);
1621 struct obd_device *obd = exp->exp_obd;
1622 struct lmv_obd *lmv = &obd->u.lmv;
1623 struct lmv_tgt_desc *tgt;
1624 ldlm_policy_data_t policy = {{0}};
1628 if (!fid_is_sane(fid))
1631 tgt = lmv_find_target(lmv, fid);
1633 RETURN(PTR_ERR(tgt));
1635 if (tgt->ltd_idx != op_tgt) {
1636 CDEBUG(D_INODE, "EARLY_CANCEL on "DFID"\n", PFID(fid));
1637 policy.l_inodebits.bits = bits;
1638 rc = md_cancel_unused(tgt->ltd_exp, fid, &policy,
1639 mode, LCF_ASYNC, NULL);
1642 "EARLY_CANCEL skip operation target %d on "DFID"\n",
1644 op_data->op_flags |= flag;
1652 * llite passes fid of an target inode in op_data->op_fid1 and id of directory in
1655 static int lmv_link(struct obd_export *exp, struct md_op_data *op_data,
1656 struct ptlrpc_request **request)
1658 struct obd_device *obd = exp->exp_obd;
1659 struct lmv_obd *lmv = &obd->u.lmv;
1660 struct lmv_tgt_desc *tgt;
1664 rc = lmv_check_connect(obd);
1668 LASSERT(op_data->op_namelen != 0);
1670 CDEBUG(D_INODE, "LINK "DFID":%*s to "DFID"\n",
1671 PFID(&op_data->op_fid2), op_data->op_namelen,
1672 op_data->op_name, PFID(&op_data->op_fid1));
1674 op_data->op_fsuid = cfs_curproc_fsuid();
1675 op_data->op_fsgid = cfs_curproc_fsgid();
1676 op_data->op_cap = cfs_curproc_cap_pack();
1677 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1679 RETURN(PTR_ERR(tgt));
1682 * Cancel UPDATE lock on child (fid1).
1684 op_data->op_flags |= MF_MDC_CANCEL_FID2;
1685 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1686 MDS_INODELOCK_UPDATE, MF_MDC_CANCEL_FID1);
1690 rc = md_link(tgt->ltd_exp, op_data, request);
1695 static int lmv_rename(struct obd_export *exp, struct md_op_data *op_data,
1696 const char *old, int oldlen, const char *new, int newlen,
1697 struct ptlrpc_request **request)
1699 struct obd_device *obd = exp->exp_obd;
1700 struct lmv_obd *lmv = &obd->u.lmv;
1701 struct lmv_tgt_desc *src_tgt;
1702 struct lmv_tgt_desc *tgt_tgt;
1706 LASSERT(oldlen != 0);
1708 CDEBUG(D_INODE, "RENAME %*s in "DFID" to %*s in "DFID"\n",
1709 oldlen, old, PFID(&op_data->op_fid1),
1710 newlen, new, PFID(&op_data->op_fid2));
1712 rc = lmv_check_connect(obd);
1716 op_data->op_fsuid = cfs_curproc_fsuid();
1717 op_data->op_fsgid = cfs_curproc_fsgid();
1718 op_data->op_cap = cfs_curproc_cap_pack();
1719 src_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1720 if (IS_ERR(src_tgt))
1721 RETURN(PTR_ERR(src_tgt));
1723 tgt_tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid2);
1724 if (IS_ERR(tgt_tgt))
1725 RETURN(PTR_ERR(tgt_tgt));
1727 * LOOKUP lock on src child (fid3) should also be cancelled for
1728 * src_tgt in mdc_rename.
1730 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1733 * Cancel UPDATE locks on tgt parent (fid2), tgt_tgt is its
1736 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1737 LCK_EX, MDS_INODELOCK_UPDATE,
1738 MF_MDC_CANCEL_FID2);
1741 * Cancel LOOKUP locks on tgt child (fid4) for parent tgt_tgt.
1744 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1745 LCK_EX, MDS_INODELOCK_LOOKUP,
1746 MF_MDC_CANCEL_FID4);
1750 * Cancel all the locks on tgt child (fid4).
1753 rc = lmv_early_cancel(exp, op_data, src_tgt->ltd_idx,
1754 LCK_EX, MDS_INODELOCK_FULL,
1755 MF_MDC_CANCEL_FID4);
1758 rc = md_rename(src_tgt->ltd_exp, op_data, old, oldlen,
1759 new, newlen, request);
1763 static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,
1764 void *ea, int ealen, void *ea2, int ea2len,
1765 struct ptlrpc_request **request,
1766 struct md_open_data **mod)
1768 struct obd_device *obd = exp->exp_obd;
1769 struct lmv_obd *lmv = &obd->u.lmv;
1770 struct lmv_tgt_desc *tgt;
1774 rc = lmv_check_connect(obd);
1778 CDEBUG(D_INODE, "SETATTR for "DFID", valid 0x%x\n",
1779 PFID(&op_data->op_fid1), op_data->op_attr.ia_valid);
1781 op_data->op_flags |= MF_MDC_CANCEL_FID1;
1782 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1784 RETURN(PTR_ERR(tgt));
1786 rc = md_setattr(tgt->ltd_exp, op_data, ea, ealen, ea2,
1787 ea2len, request, mod);
1792 static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,
1793 struct obd_capa *oc, struct ptlrpc_request **request)
1795 struct obd_device *obd = exp->exp_obd;
1796 struct lmv_obd *lmv = &obd->u.lmv;
1797 struct lmv_tgt_desc *tgt;
1801 rc = lmv_check_connect(obd);
1805 tgt = lmv_find_target(lmv, fid);
1807 RETURN(PTR_ERR(tgt));
1809 rc = md_sync(tgt->ltd_exp, fid, oc, request);
1813 static int lmv_readpage(struct obd_export *exp, struct md_op_data *op_data,
1814 struct page **pages, struct ptlrpc_request **request)
1816 struct obd_device *obd = exp->exp_obd;
1817 struct lmv_obd *lmv = &obd->u.lmv;
1818 __u64 offset = op_data->op_offset;
1821 /* number of pages read, in CFS_PAGE_SIZE */
1823 /* number of pages transferred in LU_PAGE_SIZE */
1825 struct lmv_tgt_desc *tgt;
1826 struct lu_dirpage *dp;
1827 struct lu_dirent *ent;
1830 rc = lmv_check_connect(obd);
1834 CDEBUG(D_INODE, "READPAGE at "LPX64" from "DFID"\n",
1835 offset, PFID(&op_data->op_fid1));
1838 * This case handle directory lookup in clustered metadata case (i.e.
1839 * split directory is located on multiple md servers.)
1840 * each server keeps directory entries for certain range of hashes.
1841 * E.g. we have N server and suppose hash range is 0 to MAX_HASH.
1842 * first server will keep records with hashes [ 0 ... MAX_HASH /N - 1],
1843 * second one with hashes [MAX_HASH / N ... 2 * MAX_HASH / N] and
1845 * readdir can simply start reading entries from 0 - N server in
1846 * order but that will not scale well as all client will request dir in
1847 * to server in same order.
1848 * Following algorithm does optimization:
1849 * Instead of doing readdir in 1, 2, ...., N order, client with a
1850 * rank R does readdir in R, R + 1, ..., N, 1, ... R - 1 order.
1851 * (every client has rank R)
1852 * But ll_readdir() expect offset range [0 to MAX_HASH/N) but
1853 * since client ask dir from MDS{R} client has pages with offsets
1854 * [R*MAX_HASH/N ... (R + 1)*MAX_HASH/N] there for we do hash_adj
1855 * on hash values that we get.
1856 * Since these codes might be still useful for sharded directory, so
1857 * Keeping this code for further reference
1860 seg_size = MAX_HASH_SIZE;
1861 do_div(seg_size, nr);
1862 los = obj->lo_stripes;
1863 tgt = lmv_get_target(lmv, los[0].ls_mds);
1864 rank = lmv_node_rank(tgt->ltd_exp, fid) % nr;
1866 do_div(tgt_tmp, seg_size);
1867 tgt0_idx = do_div(tgt_tmp, nr);
1868 tgt_idx = (tgt0_idx + rank) % nr;
1870 if (tgt_idx < tgt0_idx)
1873 * Last segment has unusual length due to division
1875 hash_adj = MAX_HASH_SIZE - seg_size * nr;
1879 hash_adj += rank * seg_size;
1881 CDEBUG(D_INODE, "Readpage hash adjustment: %x "LPX64" "
1882 LPX64"/%x -> "LPX64"/%x\n", rank, hash_adj,
1883 offset, tgt0_idx, offset + hash_adj, tgt_idx);
1885 offset = (offset + hash_adj) & MAX_HASH_SIZE;
1886 rid = lsm->mea_oinfo[tgt_idx].lmo_fid;
1887 tgt = lmv_get_target(lmv, lsm->mea_oinfo[tgt_idx].lmo_mds);
1889 CDEBUG(D_INODE, "Forward to "DFID" with offset %lu i %d\n",
1890 PFID(&rid), (unsigned long)offset, tgt_idx);
1893 tgt = lmv_find_target(lmv, &op_data->op_fid1);
1895 RETURN(PTR_ERR(tgt));
1897 rc = md_readpage(tgt->ltd_exp, op_data, pages, request);
1901 nrdpgs = ((*request)->rq_bulk->bd_nob_transferred + CFS_PAGE_SIZE - 1)
1903 nlupgs = (*request)->rq_bulk->bd_nob_transferred >> LU_PAGE_SHIFT;
1904 LASSERT(!((*request)->rq_bulk->bd_nob_transferred & ~LU_PAGE_MASK));
1905 LASSERT(nrdpgs > 0 && nrdpgs <= op_data->op_npages);
1907 CDEBUG(D_INODE, "read %d(%d)/%d pages\n", nrdpgs, nlupgs,
1908 op_data->op_npages);
1910 for (i = 0; i < nrdpgs; i++) {
1911 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1912 struct lu_dirpage *first;
1916 struct lu_dirent *tmp = NULL;
1918 dp = cfs_kmap(pages[i]);
1919 ent = lu_dirent_start(dp);
1920 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1922 hash_end = dp->ldp_hash_end;
1927 for (tmp = ent; ent != NULL;
1928 tmp = ent, ent = lu_dirent_next(ent));
1929 #if CFS_PAGE_SIZE > LU_PAGE_SIZE
1930 dp = (struct lu_dirpage *)((char *)dp + LU_PAGE_SIZE);
1931 if (((unsigned long)dp & ~CFS_PAGE_MASK) && nlupgs > 0) {
1932 ent = lu_dirent_start(dp);
1935 /* enlarge the end entry lde_reclen from 0 to
1936 * first entry of next lu_dirpage, in this way
1937 * several lu_dirpages can be stored into one
1938 * client page on client. */
1939 tmp = ((void *)tmp) +
1940 le16_to_cpu(tmp->lde_reclen);
1942 cpu_to_le16((char *)(dp->ldp_entries) -
1947 first->ldp_hash_end = hash_end;
1948 first->ldp_flags &= ~cpu_to_le32(LDF_COLLIDE);
1949 first->ldp_flags |= flags & cpu_to_le32(LDF_COLLIDE);
1951 SET_BUT_UNUSED(tmp);
1953 cfs_kunmap(pages[i]);
1958 static int lmv_unlink(struct obd_export *exp, struct md_op_data *op_data,
1959 struct ptlrpc_request **request)
1961 struct obd_device *obd = exp->exp_obd;
1962 struct lmv_obd *lmv = &obd->u.lmv;
1963 struct lmv_tgt_desc *tgt = NULL;
1967 rc = lmv_check_connect(obd);
1971 tgt = lmv_locate_mds(lmv, op_data, &op_data->op_fid1);
1973 RETURN(PTR_ERR(tgt));
1975 op_data->op_fsuid = cfs_curproc_fsuid();
1976 op_data->op_fsgid = cfs_curproc_fsgid();
1977 op_data->op_cap = cfs_curproc_cap_pack();
1980 * If child's fid is given, cancel unused locks for it if it is from
1981 * another export than parent.
1983 * LOOKUP lock for child (fid3) should also be cancelled on parent
1984 * tgt_tgt in mdc_unlink().
1986 op_data->op_flags |= MF_MDC_CANCEL_FID1 | MF_MDC_CANCEL_FID3;
1989 * Cancel FULL locks on child (fid3).
1991 rc = lmv_early_cancel(exp, op_data, tgt->ltd_idx, LCK_EX,
1992 MDS_INODELOCK_FULL, MF_MDC_CANCEL_FID3);
1997 rc = md_unlink(tgt->ltd_exp, op_data, request);
2002 static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
2004 struct lmv_obd *lmv = &obd->u.lmv;
2008 case OBD_CLEANUP_EARLY:
2009 /* XXX: here should be calling obd_precleanup() down to
2012 case OBD_CLEANUP_EXPORTS:
2013 fld_client_proc_fini(&lmv->lmv_fld);
2014 lprocfs_obd_cleanup(obd);
2022 static int lmv_get_info(const struct lu_env *env, struct obd_export *exp,
2023 __u32 keylen, void *key, __u32 *vallen, void *val,
2024 struct lov_stripe_md *lsm)
2026 struct obd_device *obd;
2027 struct lmv_obd *lmv;
2031 obd = class_exp2obd(exp);
2033 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2034 exp->exp_handle.h_cookie);
2039 if (keylen >= strlen("remote_flag") && !strcmp(key, "remote_flag")) {
2040 struct lmv_tgt_desc *tgt;
2043 rc = lmv_check_connect(obd);
2047 LASSERT(*vallen == sizeof(__u32));
2048 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2051 * All tgts should be connected when this gets called.
2053 if (tgt == NULL || tgt->ltd_exp == NULL)
2056 if (!obd_get_info(env, tgt->ltd_exp, keylen, key,
2061 } else if (KEY_IS(KEY_MAX_EASIZE) || KEY_IS(KEY_CONN_DATA)) {
2062 rc = lmv_check_connect(obd);
2067 * Forwarding this request to first MDS, it should know LOV
2070 rc = obd_get_info(env, lmv->tgts[0]->ltd_exp, keylen, key,
2072 if (!rc && KEY_IS(KEY_CONN_DATA)) {
2073 exp->exp_connect_flags =
2074 ((struct obd_connect_data *)val)->ocd_connect_flags;
2077 } else if (KEY_IS(KEY_TGT_COUNT)) {
2078 *((int *)val) = lmv->desc.ld_tgt_count;
2082 CDEBUG(D_IOCTL, "Invalid key\n");
2086 int lmv_set_info_async(const struct lu_env *env, struct obd_export *exp,
2087 obd_count keylen, void *key, obd_count vallen,
2088 void *val, struct ptlrpc_request_set *set)
2090 struct lmv_tgt_desc *tgt;
2091 struct obd_device *obd;
2092 struct lmv_obd *lmv;
2096 obd = class_exp2obd(exp);
2098 CDEBUG(D_IOCTL, "Invalid client cookie "LPX64"\n",
2099 exp->exp_handle.h_cookie);
2104 if (KEY_IS(KEY_READ_ONLY) || KEY_IS(KEY_FLUSH_CTX)) {
2107 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2110 if (tgt == NULL || tgt->ltd_exp == NULL)
2113 err = obd_set_info_async(env, tgt->ltd_exp,
2114 keylen, key, vallen, val, set);
2125 int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
2126 struct lov_stripe_md *lsm)
2128 struct obd_device *obd = class_exp2obd(exp);
2129 struct lmv_obd *lmv = &obd->u.lmv;
2130 struct lmv_stripe_md *meap;
2131 struct lmv_stripe_md *lsmp;
2136 mea_size = lmv_get_easize(lmv);
2140 if (*lmmp && !lsm) {
2141 OBD_FREE_LARGE(*lmmp, mea_size);
2146 if (*lmmp == NULL) {
2147 OBD_ALLOC_LARGE(*lmmp, mea_size);
2155 lsmp = (struct lmv_stripe_md *)lsm;
2156 meap = (struct lmv_stripe_md *)*lmmp;
2158 if (lsmp->mea_magic != MEA_MAGIC_LAST_CHAR &&
2159 lsmp->mea_magic != MEA_MAGIC_ALL_CHARS)
2162 meap->mea_magic = cpu_to_le32(lsmp->mea_magic);
2163 meap->mea_count = cpu_to_le32(lsmp->mea_count);
2164 meap->mea_master = cpu_to_le32(lsmp->mea_master);
2166 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2167 meap->mea_ids[i] = meap->mea_ids[i];
2168 fid_cpu_to_le(&meap->mea_ids[i], &meap->mea_ids[i]);
2174 int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
2175 struct lov_mds_md *lmm, int lmm_size)
2177 struct obd_device *obd = class_exp2obd(exp);
2178 struct lmv_stripe_md **tmea = (struct lmv_stripe_md **)lsmp;
2179 struct lmv_stripe_md *mea = (struct lmv_stripe_md *)lmm;
2180 struct lmv_obd *lmv = &obd->u.lmv;
2186 mea_size = lmv_get_easize(lmv);
2190 if (*lsmp != NULL && lmm == NULL) {
2191 OBD_FREE_LARGE(*tmea, mea_size);
2196 LASSERT(mea_size == lmm_size);
2198 OBD_ALLOC_LARGE(*tmea, mea_size);
2205 if (mea->mea_magic == MEA_MAGIC_LAST_CHAR ||
2206 mea->mea_magic == MEA_MAGIC_ALL_CHARS ||
2207 mea->mea_magic == MEA_MAGIC_HASH_SEGMENT)
2209 magic = le32_to_cpu(mea->mea_magic);
2212 * Old mea is not handled here.
2214 CERROR("Old not supportable EA is found\n");
2218 (*tmea)->mea_magic = magic;
2219 (*tmea)->mea_count = le32_to_cpu(mea->mea_count);
2220 (*tmea)->mea_master = le32_to_cpu(mea->mea_master);
2222 for (i = 0; i < (*tmea)->mea_count; i++) {
2223 (*tmea)->mea_ids[i] = mea->mea_ids[i];
2224 fid_le_to_cpu(&(*tmea)->mea_ids[i], &(*tmea)->mea_ids[i]);
2229 static int lmv_cancel_unused(struct obd_export *exp, const struct lu_fid *fid,
2230 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2231 ldlm_cancel_flags_t flags, void *opaque)
2233 struct obd_device *obd = exp->exp_obd;
2234 struct lmv_obd *lmv = &obd->u.lmv;
2240 LASSERT(fid != NULL);
2242 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2243 if (lmv->tgts[i] == NULL || lmv->tgts[i]->ltd_exp == NULL ||
2244 lmv->tgts[i]->ltd_active == 0)
2247 err = md_cancel_unused(lmv->tgts[i]->ltd_exp, fid,
2248 policy, mode, flags, opaque);
2255 int lmv_set_lock_data(struct obd_export *exp, __u64 *lockh, void *data,
2258 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2262 rc = md_set_lock_data(lmv->tgts[0]->ltd_exp, lockh, data, bits);
2266 ldlm_mode_t lmv_lock_match(struct obd_export *exp, __u64 flags,
2267 const struct lu_fid *fid, ldlm_type_t type,
2268 ldlm_policy_data_t *policy, ldlm_mode_t mode,
2269 struct lustre_handle *lockh)
2271 struct obd_device *obd = exp->exp_obd;
2272 struct lmv_obd *lmv = &obd->u.lmv;
2277 CDEBUG(D_INODE, "Lock match for "DFID"\n", PFID(fid));
2280 * With CMD every object can have two locks in different namespaces:
2281 * lookup lock in space of mds storing direntry and update/open lock in
2282 * space of mds storing inode. Thus we check all targets, not only that
2283 * one fid was created in.
2285 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2286 if (lmv->tgts[i] == NULL ||
2287 lmv->tgts[i]->ltd_exp == NULL ||
2288 lmv->tgts[i]->ltd_active == 0)
2291 rc = md_lock_match(lmv->tgts[i]->ltd_exp, flags, fid,
2292 type, policy, mode, lockh);
2300 int lmv_get_lustre_md(struct obd_export *exp, struct ptlrpc_request *req,
2301 struct obd_export *dt_exp, struct obd_export *md_exp,
2302 struct lustre_md *md)
2304 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2306 return md_get_lustre_md(lmv->tgts[0]->ltd_exp, req, dt_exp, md_exp, md);
2309 int lmv_free_lustre_md(struct obd_export *exp, struct lustre_md *md)
2311 struct obd_device *obd = exp->exp_obd;
2312 struct lmv_obd *lmv = &obd->u.lmv;
2316 obd_free_memmd(exp, (void *)&md->mea);
2317 RETURN(md_free_lustre_md(lmv->tgts[0]->ltd_exp, md));
2320 int lmv_set_open_replay_data(struct obd_export *exp,
2321 struct obd_client_handle *och,
2322 struct ptlrpc_request *open_req)
2324 struct obd_device *obd = exp->exp_obd;
2325 struct lmv_obd *lmv = &obd->u.lmv;
2326 struct lmv_tgt_desc *tgt;
2329 tgt = lmv_find_target(lmv, &och->och_fid);
2331 RETURN(PTR_ERR(tgt));
2333 RETURN(md_set_open_replay_data(tgt->ltd_exp, och, open_req));
2336 int lmv_clear_open_replay_data(struct obd_export *exp,
2337 struct obd_client_handle *och)
2339 struct obd_device *obd = exp->exp_obd;
2340 struct lmv_obd *lmv = &obd->u.lmv;
2341 struct lmv_tgt_desc *tgt;
2344 tgt = lmv_find_target(lmv, &och->och_fid);
2346 RETURN(PTR_ERR(tgt));
2348 RETURN(md_clear_open_replay_data(tgt->ltd_exp, och));
2351 static int lmv_get_remote_perm(struct obd_export *exp,
2352 const struct lu_fid *fid,
2353 struct obd_capa *oc, __u32 suppgid,
2354 struct ptlrpc_request **request)
2356 struct obd_device *obd = exp->exp_obd;
2357 struct lmv_obd *lmv = &obd->u.lmv;
2358 struct lmv_tgt_desc *tgt;
2362 rc = lmv_check_connect(obd);
2366 tgt = lmv_find_target(lmv, fid);
2368 RETURN(PTR_ERR(tgt));
2370 rc = md_get_remote_perm(tgt->ltd_exp, fid, oc, suppgid, request);
2374 static int lmv_renew_capa(struct obd_export *exp, struct obd_capa *oc,
2377 struct obd_device *obd = exp->exp_obd;
2378 struct lmv_obd *lmv = &obd->u.lmv;
2379 struct lmv_tgt_desc *tgt;
2383 rc = lmv_check_connect(obd);
2387 tgt = lmv_find_target(lmv, &oc->c_capa.lc_fid);
2389 RETURN(PTR_ERR(tgt));
2391 rc = md_renew_capa(tgt->ltd_exp, oc, cb);
2395 int lmv_unpack_capa(struct obd_export *exp, struct ptlrpc_request *req,
2396 const struct req_msg_field *field, struct obd_capa **oc)
2398 struct lmv_obd *lmv = &exp->exp_obd->u.lmv;
2400 return md_unpack_capa(lmv->tgts[0]->ltd_exp, req, field, oc);
2403 int lmv_intent_getattr_async(struct obd_export *exp,
2404 struct md_enqueue_info *minfo,
2405 struct ldlm_enqueue_info *einfo)
2407 struct md_op_data *op_data = &minfo->mi_data;
2408 struct obd_device *obd = exp->exp_obd;
2409 struct lmv_obd *lmv = &obd->u.lmv;
2410 struct lmv_tgt_desc *tgt = NULL;
2414 rc = lmv_check_connect(obd);
2418 tgt = lmv_find_target(lmv, &op_data->op_fid1);
2420 RETURN(PTR_ERR(tgt));
2422 rc = md_intent_getattr_async(tgt->ltd_exp, minfo, einfo);
2426 int lmv_revalidate_lock(struct obd_export *exp, struct lookup_intent *it,
2427 struct lu_fid *fid, __u64 *bits)
2429 struct obd_device *obd = exp->exp_obd;
2430 struct lmv_obd *lmv = &obd->u.lmv;
2431 struct lmv_tgt_desc *tgt;
2435 rc = lmv_check_connect(obd);
2439 tgt = lmv_find_target(lmv, fid);
2441 RETURN(PTR_ERR(tgt));
2443 rc = md_revalidate_lock(tgt->ltd_exp, it, fid, bits);
2448 * For lmv, only need to send request to master MDT, and the master MDT will
2449 * process with other slave MDTs. The only exception is Q_GETOQUOTA for which
2450 * we directly fetch data from the slave MDTs.
2452 int lmv_quotactl(struct obd_device *unused, struct obd_export *exp,
2453 struct obd_quotactl *oqctl)
2455 struct obd_device *obd = class_exp2obd(exp);
2456 struct lmv_obd *lmv = &obd->u.lmv;
2457 struct lmv_tgt_desc *tgt = lmv->tgts[0];
2459 __u64 curspace, curinodes;
2462 if (!lmv->desc.ld_tgt_count || !tgt->ltd_active) {
2463 CERROR("master lmv inactive\n");
2467 if (oqctl->qc_cmd != Q_GETOQUOTA) {
2468 rc = obd_quotactl(tgt->ltd_exp, oqctl);
2472 curspace = curinodes = 0;
2473 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2477 if (tgt == NULL || tgt->ltd_exp == NULL || tgt->ltd_active == 0)
2479 if (!tgt->ltd_active) {
2480 CDEBUG(D_HA, "mdt %d is inactive.\n", i);
2484 err = obd_quotactl(tgt->ltd_exp, oqctl);
2486 CERROR("getquota on mdt %d failed. %d\n", i, err);
2490 curspace += oqctl->qc_dqblk.dqb_curspace;
2491 curinodes += oqctl->qc_dqblk.dqb_curinodes;
2494 oqctl->qc_dqblk.dqb_curspace = curspace;
2495 oqctl->qc_dqblk.dqb_curinodes = curinodes;
2500 int lmv_quotacheck(struct obd_device *unused, struct obd_export *exp,
2501 struct obd_quotactl *oqctl)
2503 struct obd_device *obd = class_exp2obd(exp);
2504 struct lmv_obd *lmv = &obd->u.lmv;
2505 struct lmv_tgt_desc *tgt;
2509 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
2512 if (tgt == NULL || tgt->ltd_exp == NULL || !tgt->ltd_active) {
2513 CERROR("lmv idx %d inactive\n", i);
2517 err = obd_quotacheck(tgt->ltd_exp, oqctl);
2525 struct obd_ops lmv_obd_ops = {
2526 .o_owner = THIS_MODULE,
2527 .o_setup = lmv_setup,
2528 .o_cleanup = lmv_cleanup,
2529 .o_precleanup = lmv_precleanup,
2530 .o_process_config = lmv_process_config,
2531 .o_connect = lmv_connect,
2532 .o_disconnect = lmv_disconnect,
2533 .o_statfs = lmv_statfs,
2534 .o_get_info = lmv_get_info,
2535 .o_set_info_async = lmv_set_info_async,
2536 .o_packmd = lmv_packmd,
2537 .o_unpackmd = lmv_unpackmd,
2538 .o_notify = lmv_notify,
2539 .o_get_uuid = lmv_get_uuid,
2540 .o_iocontrol = lmv_iocontrol,
2541 .o_quotacheck = lmv_quotacheck,
2542 .o_quotactl = lmv_quotactl
2545 struct md_ops lmv_md_ops = {
2546 .m_getstatus = lmv_getstatus,
2547 .m_change_cbdata = lmv_change_cbdata,
2548 .m_find_cbdata = lmv_find_cbdata,
2549 .m_close = lmv_close,
2550 .m_create = lmv_create,
2551 .m_done_writing = lmv_done_writing,
2552 .m_enqueue = lmv_enqueue,
2553 .m_getattr = lmv_getattr,
2554 .m_getxattr = lmv_getxattr,
2555 .m_getattr_name = lmv_getattr_name,
2556 .m_intent_lock = lmv_intent_lock,
2558 .m_rename = lmv_rename,
2559 .m_setattr = lmv_setattr,
2560 .m_setxattr = lmv_setxattr,
2562 .m_readpage = lmv_readpage,
2563 .m_unlink = lmv_unlink,
2564 .m_init_ea_size = lmv_init_ea_size,
2565 .m_cancel_unused = lmv_cancel_unused,
2566 .m_set_lock_data = lmv_set_lock_data,
2567 .m_lock_match = lmv_lock_match,
2568 .m_get_lustre_md = lmv_get_lustre_md,
2569 .m_free_lustre_md = lmv_free_lustre_md,
2570 .m_set_open_replay_data = lmv_set_open_replay_data,
2571 .m_clear_open_replay_data = lmv_clear_open_replay_data,
2572 .m_renew_capa = lmv_renew_capa,
2573 .m_unpack_capa = lmv_unpack_capa,
2574 .m_get_remote_perm = lmv_get_remote_perm,
2575 .m_intent_getattr_async = lmv_intent_getattr_async,
2576 .m_revalidate_lock = lmv_revalidate_lock
2579 int __init lmv_init(void)
2581 struct lprocfs_static_vars lvars;
2584 lprocfs_lmv_init_vars(&lvars);
2586 rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
2587 lvars.module_vars, LUSTRE_LMV_NAME, NULL);
2592 static void lmv_exit(void)
2594 class_unregister_type(LUSTRE_LMV_NAME);
2597 MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
2598 MODULE_DESCRIPTION("Lustre Logical Metadata Volume OBD driver");
2599 MODULE_LICENSE("GPL");
2601 module_init(lmv_init);
2602 module_exit(lmv_exit);