1 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=8:tabstop=8:
4 * Copyright (C) 2002, 2003 Cluster File Systems, Inc.
5 * Author: Phil Schwan <phil@clusterfs.com>
6 * Peter Braam <braam@clusterfs.com>
7 * Mike Shaver <shaver@clusterfs.com>
9 * This file is part of Lustre, http://www.lustre.org.
11 * Lustre is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * Lustre is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with Lustre; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 # define EXPORT_SYMTAB
28 #define DEBUG_SUBSYSTEM S_LOV
30 #include <linux/slab.h>
31 #include <linux/module.h>
32 #include <linux/init.h>
33 #include <linux/slab.h>
34 #include <linux/pagemap.h>
35 #include <linux/seq_file.h>
36 #include <asm/div64.h>
38 #include <liblustre.h>
41 #include <linux/obd_support.h>
42 #include <linux/lustre_lib.h>
43 #include <linux/lustre_net.h>
44 #include <linux/lustre_idl.h>
45 #include <linux/lustre_dlm.h>
46 #include <linux/lustre_mds.h>
47 #include <linux/obd_class.h>
48 #include <linux/obd_lov.h>
49 #include <linux/obd_ost.h>
50 #include <linux/lprocfs_status.h>
51 #include <linux/lustre_audit.h>
52 #include "lov_internal.h"
55 #define MAX_STRING_SIZE 128
56 static int lov_connect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt,
57 int activate, struct obd_connect_data *conn_data,
58 unsigned long connect_flags)
60 struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
61 struct obd_uuid *tgt_uuid = &tgt->uuid;
64 struct proc_dir_entry *lov_proc_dir;
66 struct lov_obd *lov = &obd->u.lov;
67 struct lustre_handle conn = {0, };
68 struct obd_device *tgt_obd;
72 tgt_obd = class_find_client_obd(tgt_uuid, OBD_OSC_DEVICENAME,
76 CERROR("Target %s not attached\n", tgt_uuid->uuid);
80 if (!tgt_obd->obd_set_up) {
81 CERROR("Target %s not set up\n", tgt_uuid->uuid);
86 tgt_obd->obd_no_recov = 0;
87 ptlrpc_activate_import(tgt_obd->u.cli.cl_import);
90 if (tgt_obd->u.cli.cl_import->imp_invalid) {
91 CERROR("not connecting OSC %s; administratively "
92 "disabled\n", tgt_uuid->uuid);
93 rc = obd_register_observer(tgt_obd, obd);
95 CERROR("Target %s register_observer error %d; "
96 "will not be able to reactivate\n",
102 rc = obd_connect(&conn, tgt_obd, &lov_osc_uuid, conn_data,
105 CERROR("Target %s connect error %d\n", tgt_uuid->uuid, rc);
108 tgt->ltd_exp = class_conn2export(&conn);
110 rc = obd_register_observer(tgt_obd, obd);
112 CERROR("Target %s register_observer error %d\n",
114 obd_disconnect(tgt->ltd_exp, 0);
119 lov_tgt_set_flags(lov, tgt, LTD_ACTIVE);
122 lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
124 struct obd_device *osc_obd = class_conn2obd(&conn);
125 struct proc_dir_entry *osc_symlink;
126 char name[MAX_STRING_SIZE + 1];
128 LASSERT(osc_obd != NULL);
129 LASSERT(osc_obd->obd_type != NULL);
130 LASSERT(osc_obd->obd_type->typ_name != NULL);
131 name[MAX_STRING_SIZE] = '\0';
132 snprintf(name, MAX_STRING_SIZE, "../../../%s/%s",
133 osc_obd->obd_type->typ_name,
135 osc_symlink = proc_symlink(osc_obd->obd_name, lov_proc_dir,
137 if (osc_symlink == NULL) {
138 CERROR("could not register LOV target "
139 "/proc/fs/lustre/%s/%s/target_obds/%s\n",
140 obd->obd_type->typ_name, obd->obd_name,
142 lprocfs_remove(lov_proc_dir);
151 static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
152 struct obd_uuid *cluuid, struct obd_connect_data *data,
156 struct proc_dir_entry *lov_proc_dir;
158 struct lov_obd *lov = &obd->u.lov;
159 struct lov_tgt_desc *tgt;
160 struct obd_export *exp;
164 rc = class_connect(conn, obd, cluuid);
168 exp = class_conn2export(conn);
170 /* We don't want to actually do the underlying connections more than
171 * once, so keep track. */
173 if (lov->refcount > 1) {
174 class_export_put(exp);
179 lov_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
181 if (IS_ERR(lov_proc_dir)) {
182 CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
183 obd->obd_type->typ_name, obd->obd_name);
188 /* connect_flags is the MDS number, save for use in lov_add_obd */
189 lov->lov_connect_flags = flags;
190 for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) {
191 if (obd_uuid_empty(&tgt->uuid))
193 rc = lov_connect_obd(obd, tgt, 0, data, flags);
198 class_export_put(exp);
204 lprocfs_remove(lov_proc_dir);
208 struct obd_uuid uuid;
210 lov_tgt_clear_flags(lov, tgt, LTD_ACTIVE);
212 /* save for CERROR below; (we know it's terminated) */
214 rc2 = obd_disconnect(tgt->ltd_exp, 0);
216 CERROR("error: LOV target %s disconnect on OST idx %d: "
217 "rc = %d\n", uuid.uuid, i, rc2);
219 class_disconnect(exp, 0);
223 static int lov_disconnect_obd(struct obd_device *obd,
224 struct lov_tgt_desc *tgt,
228 struct proc_dir_entry *lov_proc_dir;
230 struct obd_device *osc_obd = class_exp2obd(tgt->ltd_exp);
231 struct lov_obd *lov = &obd->u.lov;
236 lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
238 struct proc_dir_entry *osc_symlink;
240 osc_symlink = lprocfs_srch(lov_proc_dir, osc_obd->obd_name);
242 lprocfs_remove(osc_symlink);
244 CERROR("/proc/fs/lustre/%s/%s/target_obds/%s missing\n",
245 obd->obd_type->typ_name, obd->obd_name,
250 if (obd->obd_no_recov) {
251 /* Pass it on to our clients.
252 * XXX This should be an argument to disconnect,
253 * XXX not a back-door flag on the OBD. Ah well.
256 osc_obd->obd_no_recov = 1;
259 /* XXX - shouldn't this be after the obd_disconnect() ? */
260 obd_register_observer(tgt->ltd_exp->exp_obd, NULL);
262 rc = obd_disconnect(tgt->ltd_exp, flags);
264 if (lov_tgt_active(lov, tgt, 0)) {
265 lov_tgt_decref(lov, tgt);
266 CERROR("Target %s disconnect error %d\n",
271 CDEBUG(D_CONFIG, "idx: %d flags: 0x%x active: %d\n",
272 tgt - lov->tgts, tgt->ltd_flags,
273 lov->desc.ld_active_tgt_count);
275 lov_tgt_clear_flags(lov, tgt, LTD_ACTIVE);
280 static int lov_disconnect(struct obd_export *exp, unsigned long flags)
282 struct obd_device *obd = class_exp2obd(exp);
284 struct proc_dir_entry *lov_proc_dir;
286 struct lov_obd *lov = &obd->u.lov;
287 struct lov_tgt_desc *tgt;
294 /* Only disconnect the underlying layers on the final disconnect. */
296 if (lov->refcount != 0)
299 for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) {
301 lov_disconnect_obd(obd, tgt, flags);
305 lov_proc_dir = lprocfs_srch(obd->obd_proc_entry, "target_obds");
307 lprocfs_remove(lov_proc_dir);
309 CERROR("/proc/fs/lustre/%s/%s/target_obds missing.",
310 obd->obd_type->typ_name, obd->obd_name);
315 rc = class_disconnect(exp, 0);
321 * -EINVAL : UUID can't be found in the LOV's target list
322 * -ENOTCONN: The UUID is found, but the target connection is bad (!)
323 * -EBADF : The UUID is found, but the OBD is the wrong type (!)
325 static int lov_set_osc_active(struct lov_obd *lov, struct obd_uuid *uuid,
328 struct lov_tgt_desc *tgt;
332 CDEBUG(D_INFO, "Searching in lov %p for uuid %s (activate=%d)\n",
333 lov, uuid->uuid, activate);
336 for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) {
337 if (tgt->ltd_exp == NULL)
340 CDEBUG(D_INFO, "lov idx %d is %s conn "LPX64"\n",
341 i, tgt->uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
343 if (obd_uuid_equals(uuid, &tgt->uuid))
347 if (i == lov->desc.ld_tgt_count)
348 GOTO(out, rc = -EINVAL);
351 if (tgt->ltd_flags & LTD_ACTIVE) {
352 CDEBUG(D_CONFIG|D_INFO, "OSC %s already active!\n",
356 CDEBUG(D_INFO, "Marking OSC %s active\n", uuid->uuid);
357 tgt->ltd_flags |= LTD_ACTIVE;
358 lov->desc.ld_active_tgt_count++;
360 if ((tgt->ltd_flags & LTD_ACTIVE) == 0) {
361 CDEBUG(D_CONFIG|D_INFO, "OSC %s already inactive!\n",
365 CDEBUG(D_INFO, "Marking OSC %s inactive\n", uuid->uuid);
366 tgt->ltd_flags &= ~LTD_ACTIVE;
367 lov->desc.ld_active_tgt_count--;
372 lov_tgts_unlock(lov);
376 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
377 int active, void *data)
379 struct obd_uuid *uuid;
383 if (strcmp(watched->obd_type->typ_name, OBD_OSC_DEVICENAME)) {
384 CERROR("unexpected notification of %s %s!\n",
385 watched->obd_type->typ_name,
390 uuid = &watched->u.cli.cl_import->imp_target_uuid;
392 /* Set OSC as active before notifying the observer, so the
393 * observer can use the OSC normally.
395 rc = lov_set_osc_active(&obd->u.lov, uuid, active);
397 CERROR("%sactivation of %s failed: %d\n",
398 active ? "" : "de", uuid->uuid, rc);
402 if (obd->obd_observer)
403 /* Pass the notification up the chain. */
404 rc = obd_notify(obd->obd_observer, watched, active, data);
409 int lov_attach(struct obd_device *dev, obd_count len, void *data)
411 struct lprocfs_static_vars lvars;
414 lprocfs_init_vars(lov, &lvars);
415 rc = lprocfs_obd_attach(dev, lvars.obd_vars);
418 struct proc_dir_entry *entry;
420 entry = create_proc_entry("target_obd_status", 0444,
421 dev->obd_proc_entry);
425 entry->proc_fops = &lov_proc_target_fops;
433 int lov_detach(struct obd_device *dev)
435 return lprocfs_obd_detach(dev);
438 static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
440 struct lov_obd *lov = &obd->u.lov;
441 struct lustre_cfg *lcfg = buf;
442 struct lov_desc *desc;
446 if (LUSTRE_CFG_BUFLEN(lcfg, 1) < 1) {
447 CERROR("LOV setup requires a descriptor\n");
451 desc = (struct lov_desc *)lustre_cfg_string(lcfg, 1);
452 if (sizeof(*desc) > LUSTRE_CFG_BUFLEN(lcfg, 1)) {
453 CERROR("descriptor size wrong: %d > %d\n",
454 (int)sizeof(*desc), LUSTRE_CFG_BUFLEN(lcfg, 1));
458 /* Because of 64-bit divide/mod operations only work with a 32-bit
459 * divisor in a 32-bit kernel, we cannot support a stripe width
460 * of 4GB or larger on 32-bit CPUs.
463 count = desc->ld_default_stripe_count;
464 if (count && (count * desc->ld_default_stripe_size) > ~0UL) {
465 CERROR("LOV: stripe width "LPU64"x%u > %lu on 32-bit system\n",
466 desc->ld_default_stripe_size, count, ~0UL);
469 if (desc->ld_tgt_count > 0) {
470 lov->bufsize= sizeof(struct lov_tgt_desc) * desc->ld_tgt_count;
472 lov->bufsize = sizeof(struct lov_tgt_desc) * LOV_MAX_TGT_COUNT;
474 OBD_ALLOC(lov->tgts, lov->bufsize);
475 if (lov->tgts == NULL) {
477 CERROR("couldn't allocate %d bytes for target table.\n",
482 desc->ld_tgt_count = 0;
483 desc->ld_active_tgt_count = 0;
485 spin_lock_init(&lov->lov_lock);
486 sema_init(&lov->lov_llog_sem, 1);
487 init_waitqueue_head(&lov->lov_tgt_waitq);
492 static int lov_cleanup(struct obd_device *obd, int flags)
494 struct lov_obd *lov = &obd->u.lov;
496 OBD_FREE(lov->tgts, lov->bufsize);
501 lov_add_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen)
503 struct lov_obd *lov = &obd->u.lov;
504 struct lov_tgt_desc *tgt;
508 CDEBUG(D_CONFIG, "uuid: %s idx: %d gen: %d\n",
509 uuidp->uuid, index, gen);
511 if ((index < 0) || (index >= LOV_MAX_TGT_COUNT)) {
512 CERROR("request to add OBD %s at invalid index: %d\n",
518 CERROR("request to add OBD %s with invalid generation: %d\n",
523 tgt = lov->tgts + index;
527 if (!obd_uuid_empty(&tgt->uuid)) {
528 lov_tgts_unlock(lov);
529 CERROR("OBD already assigned at LOV target index %d\n",
535 /* XXX - add a sanity check on the generation number. */
539 if (index >= lov->desc.ld_tgt_count)
540 lov->desc.ld_tgt_count = index + 1;
542 lov_tgts_unlock(lov);
544 CDEBUG(D_CONFIG, "idx: %d ltd_gen: %d ld_tgt_count: %d\n",
545 index, tgt->ltd_gen, lov->desc.ld_tgt_count);
547 if (lov->refcount == 0)
550 /* We don't need to lock the tgt entry here because the
551 * config events are single threaded. Therefore only the
552 * current thread can be changing the tgts tbl. */
554 struct obd_device *osc_obd;
556 osc_obd = class_exp2obd(tgt->ltd_exp);
558 osc_obd->obd_no_recov = 0;
561 rc = lov_connect_obd(obd, tgt, 0, NULL, lov->lov_connect_flags);
565 if (obd->obd_observer) {
566 /* tell the mds_lov about the new target */
567 rc = obd_notify(obd->obd_observer, tgt->ltd_exp->exp_obd, 1,
573 if (rc && tgt->ltd_exp != NULL)
574 lov_disconnect_obd(obd, tgt, 0);
579 lov_del_obd(struct obd_device *obd, struct obd_uuid *uuidp, int index, int gen)
581 struct lov_obd *lov = &obd->u.lov;
582 struct lov_tgt_desc *tgt;
583 struct l_wait_info lwi = { 0 };
584 int count = lov->desc.ld_tgt_count;
588 CDEBUG(D_CONFIG, "uuid: %s idx: %d gen: %d\n",
589 uuidp->uuid, index, gen);
591 if (index >= count) {
592 CERROR("LOV target index %d >= number of LOV OBDs %d.\n",
597 tgt = lov->tgts + index;
599 if (obd_uuid_empty(&tgt->uuid)) {
600 CERROR("LOV target at index %d is not setup.\n", index);
604 if (!obd_uuid_equals(uuidp, &tgt->uuid)) {
605 CERROR("LOV target UUID %s at index %d doesn't match %s.\n",
606 tgt->uuid.uuid, index, uuidp->uuid);
610 lov_tgt_set_flags(lov, tgt, LTD_DEL_PENDING);
613 struct obd_device *osc_obd;
615 rc = obd_cancel_unused(tgt->ltd_exp, NULL,
616 LDLM_FL_CONFIG_CHANGE, NULL);
618 CWARN("obd_cancel_unused(osc): %d\n", rc);
620 osc_obd = class_exp2obd(tgt->ltd_exp);
622 osc_obd->obd_no_recov = 1;
623 rc = obd_llog_finish(osc_obd, &osc_obd->obd_llogs, 1);
625 CERROR("osc_llog_finish error: %d\n", rc);
628 lov_disconnect_obd(obd, tgt, 0);
631 CDEBUG(D_CONFIG, "Sleeping until LOV target index %d UUID %s "
632 "is quiesced; ltd_refcount: %d ld_active_tgt_count: %d.\n",
633 index, uuidp->uuid, tgt->ltd_refcount,
634 lov->desc.ld_active_tgt_count);
636 /* XXX - should we set a timeout ? */
637 lwi = LWI_TIMEOUT_INTR(0, NULL, NULL, NULL);
638 rc = l_wait_event(lov->lov_tgt_waitq, (tgt->ltd_refcount == 0), &lwi);
640 lov_tgt_clear_flags(lov, tgt, LTD_DEL_PENDING);
641 CERROR("LOV target delete UUID %s index %d aborted: %d.\n",
642 uuidp->uuid, index, rc);
646 CDEBUG(D_CONFIG, "LOV target index %d UUID %s is quiesced; "
647 "ltd_refcount: %d ld_active_tgt_count: %d.\n",
648 index, uuidp->uuid, tgt->ltd_refcount,
649 lov->desc.ld_active_tgt_count);
651 /* XXX - right now there is a dependency on ld_tgt_count being the
652 * maximum tgt index for computing the mds_max_easize. So we can't
655 /* lt_gen = 0 will mean it will not match the gen of any valid loi */
656 memset(tgt, 0, sizeof(*tgt));
660 static int lov_process_config(struct obd_device *obd, obd_count len, void *buf)
662 struct lustre_cfg *lcfg = buf;
663 struct obd_uuid obd_uuid;
670 switch(cmd = lcfg->lcfg_command) {
671 case LCFG_LOV_ADD_OBD:
672 case LCFG_LOV_DEL_OBD: {
673 if (LUSTRE_CFG_BUFLEN(lcfg, 1) > sizeof(obd_uuid.uuid))
674 GOTO(out, rc = -EINVAL);
676 obd_str2uuid(&obd_uuid, lustre_cfg_string(lcfg, 1));
678 if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", &index) != 1)
679 GOTO(out, rc = -EINVAL);
680 if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", &gen) != 1)
681 GOTO(out, rc = -EINVAL);
682 if (cmd == LCFG_LOV_ADD_OBD)
683 rc = lov_add_obd(obd, &obd_uuid, index, gen);
685 rc = lov_del_obd(obd, &obd_uuid, index, gen);
689 CERROR("Unknown command: %d\n", lcfg->lcfg_command);
690 GOTO(out, rc = -EINVAL);
699 #define log2(n) ffz(~(n))
702 static int lov_clear_orphans(struct obd_export *export,
704 struct lov_stripe_md **ea,
705 struct obd_trans_info *oti)
709 struct obd_uuid *ost_uuid = NULL;
710 struct lov_tgt_desc *tgt;
714 LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS &&
715 src_oa->o_flags == OBD_FL_DELORPHAN);
717 lov = &export->exp_obd->u.lov;
719 tmp_oa = obdo_alloc();
723 if (src_oa->o_valid & OBD_MD_FLINLINE) {
724 ost_uuid = (struct obd_uuid *)src_oa->o_inline;
725 CDEBUG(D_HA, "clearing orphans only for %s\n",
729 for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) {
730 struct lov_stripe_md obj_md;
731 struct lov_stripe_md *obj_mdp = &obj_md;
735 /* if called for a specific target, we don't
736 care if it is not active. */
737 if (lov_tgt_active(lov, tgt, 0)) {
739 } else if (ost_uuid == NULL) {
740 CDEBUG(D_HA, "lov idx %d inactive\n", i);
744 if (ost_uuid && !obd_uuid_equals(ost_uuid, &tgt->uuid)) {
746 lov_tgt_decref(lov, tgt);
751 * setting up objid OSS objects should be destroyed starting
754 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
755 tmp_oa->o_valid |= OBD_MD_FLID;
756 tmp_oa->o_id = oti->oti_objid[i];
758 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
759 err = obd_create(tgt->ltd_exp, tmp_oa, NULL, 0, &obj_mdp, oti);
761 /* This export will be disabled until it is recovered,
762 and then orphan recovery will be completed. */
763 CERROR("error in orphan recovery on OST idx %d/%d: "
764 "rc = %d\n", i, lov->desc.ld_tgt_count, err);
767 lov_tgt_decref(lov, tgt);
777 /* the LOV expects oa->o_id to be set to the LOV object id */
779 lov_create(struct obd_export *exp, struct obdo *src_oa,
780 void *acl, int acl_size, struct lov_stripe_md **ea,
781 struct obd_trans_info *oti)
783 struct lov_request_set *set = NULL;
784 struct list_head *pos;
793 if ((src_oa->o_valid & OBD_MD_FLFLAGS) &&
794 src_oa->o_flags == OBD_FL_DELORPHAN) {
795 rc = lov_clear_orphans(exp, src_oa, ea, oti);
799 LASSERT(oti->oti_flags & OBD_MODE_CROW);
801 /* main creation loop */
802 rc = lov_prep_create_set(exp, ea, src_oa, oti, &set);
806 lov = &exp->exp_obd->u.lov;
808 list_for_each (pos, &set->set_list) {
809 struct lov_request *req =
810 list_entry(pos, struct lov_request, rq_link);
812 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
813 rc = obd_create(lov->tgts[req->rq_idx].ltd_exp,
814 req->rq_oa, NULL, 0, &req->rq_md, oti);
815 lov_update_create_set(set, req, rc);
817 rc = lov_fini_create_set(set, ea);
821 #define lsm_bad_magic(LSMP) \
823 struct lov_stripe_md *_lsm__ = (LSMP); \
826 CERROR("LOV requires striping ea\n"); \
828 } else if (_lsm__->lsm_magic != LOV_MAGIC) { \
829 CERROR("LOV striping magic bad %#x != %#x\n", \
830 _lsm__->lsm_magic, LOV_MAGIC); \
836 static int lov_destroy(struct obd_export *exp, struct obdo *oa,
837 struct lov_stripe_md *lsm, struct obd_trans_info *oti)
839 struct lov_request_set *set;
840 struct lov_request *req;
841 struct list_head *pos;
846 if (lsm_bad_magic(lsm))
849 if (!exp || !exp->exp_obd)
852 lov = &exp->exp_obd->u.lov;
853 rc = lov_prep_destroy_set(exp, oa, lsm, oti, &set);
857 list_for_each (pos, &set->set_list) {
859 req = list_entry(pos, struct lov_request, rq_link);
861 /* XXX update the cookie position */
862 oti->oti_logcookies = set->set_cookies + req->rq_stripe;
863 rc = obd_destroy(lov->tgts[req->rq_idx].ltd_exp, req->rq_oa,
865 err = lov_update_common_set(set, req, rc);
867 CERROR("error: destroying objid "LPX64" subobj "
868 LPX64" on OST idx %d: rc = %d\n",
869 set->set_oa->o_id, req->rq_oa->o_id,
875 lov_fini_destroy_set(set);
879 static int lov_getattr(struct obd_export *exp, struct obdo *oa,
880 struct lov_stripe_md *lsm)
882 struct lov_request_set *set;
883 struct lov_request *req;
884 struct list_head *pos;
889 if (lsm_bad_magic(lsm))
892 if (!exp || !exp->exp_obd)
895 lov = &exp->exp_obd->u.lov;
897 rc = lov_prep_getattr_set(exp, oa, lsm, &set);
901 list_for_each (pos, &set->set_list) {
902 req = list_entry(pos, struct lov_request, rq_link);
904 CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
905 "%u\n", oa->o_id, req->rq_stripe, req->rq_oa->o_id,
908 rc = obd_getattr(lov->tgts[req->rq_idx].ltd_exp,
910 err = lov_update_common_set(set, req, rc);
912 CERROR("error: getattr objid "LPX64" subobj "
913 LPX64" on OST idx %d: rc = %d\n",
914 set->set_oa->o_id, req->rq_oa->o_id,
920 rc = lov_fini_getattr_set(set);
926 static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, void *data,
929 struct lov_request_set *lovset = (struct lov_request_set *)data;
932 /* don't do attribute merge if this aysnc op failed */
934 lovset->set_completes = 0;
935 lov_fini_getattr_set(lovset);
937 rc = lov_fini_getattr_set(lovset);
942 static int lov_getattr_async(struct obd_export *exp, struct obdo *oa,
943 struct lov_stripe_md *lsm,
944 struct ptlrpc_request_set *rqset)
946 struct lov_request_set *lovset;
948 struct list_head *pos;
949 struct lov_request *req;
953 if (lsm_bad_magic(lsm))
956 if (!exp || !exp->exp_obd)
959 lov = &exp->exp_obd->u.lov;
961 rc = lov_prep_getattr_set(exp, oa, lsm, &lovset);
965 CDEBUG(D_INFO, "objid "LPX64": %ux%u byte stripes\n",
966 lsm->lsm_object_id, lsm->lsm_stripe_count, lsm->lsm_stripe_size);
968 list_for_each (pos, &lovset->set_list) {
969 req = list_entry(pos, struct lov_request, rq_link);
971 CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
972 "%u\n", oa->o_id, req->rq_stripe, req->rq_oa->o_id,
974 rc = obd_getattr_async(lov->tgts[req->rq_idx].ltd_exp,
975 req->rq_oa, NULL, rqset);
977 CERROR("error: getattr objid "LPX64" subobj "
978 LPX64" on OST idx %d: rc = %d\n",
979 lovset->set_oa->o_id, req->rq_oa->o_id,
983 lov_update_common_set(lovset, req, rc);
987 LASSERT (rqset->set_interpret == NULL);
988 rqset->set_interpret = lov_getattr_interpret;
989 rqset->set_arg = (void *)lovset;
993 lov_fini_getattr_set(lovset);
997 static int lov_setattr(struct obd_export *exp, struct obdo *src_oa,
998 struct lov_stripe_md *lsm, struct obd_trans_info *oti)
1000 struct lov_request_set *set;
1001 struct lov_obd *lov;
1002 struct list_head *pos;
1003 struct lov_request *req;
1004 int err = 0, rc = 0;
1007 if (lsm_bad_magic(lsm))
1010 if (!exp || !exp->exp_obd)
1013 LASSERT(!(src_oa->o_valid & ~(OBD_MD_FLID|OBD_MD_FLTYPE | OBD_MD_FLMODE|
1014 OBD_MD_FLATIME | OBD_MD_FLMTIME |
1015 OBD_MD_FLCTIME | OBD_MD_FLFLAGS |
1016 OBD_MD_FLSIZE | OBD_MD_FLGROUP |
1017 OBD_MD_FLUID | OBD_MD_FLGID |
1018 OBD_MD_FLINLINE | OBD_MD_FLIFID)));
1020 LASSERT(!(src_oa->o_valid & OBD_MD_FLGROUP) || src_oa->o_gr > 0);
1022 lov = &exp->exp_obd->u.lov;
1023 rc = lov_prep_setattr_set(exp, src_oa, lsm, NULL, &set);
1027 list_for_each (pos, &set->set_list) {
1028 req = list_entry(pos, struct lov_request, rq_link);
1030 rc = obd_setattr(lov->tgts[req->rq_idx].ltd_exp, req->rq_oa,
1032 err = lov_update_common_set(set, req, rc);
1034 CERROR("error: setattr objid "LPX64" subobj "
1035 LPX64" on OST idx %d: rc = %d\n",
1036 set->set_oa->o_id, req->rq_oa->o_id,
1042 err = lov_fini_setattr_set(set);
1048 static int lov_revalidate_policy(struct lov_obd *lov, struct lov_stripe_md *lsm)
1050 static int next_idx = 0;
1051 struct lov_tgt_desc *tgt;
1055 /* XXX - we should do something clever and take lsm
1056 * into account but just do round robin for now. */
1058 /* last_idx must always be less that count because
1059 * ld_tgt_count currently cannot shrink. */
1060 count = lov->desc.ld_tgt_count;
1062 for (i = next_idx, tgt = lov->tgts + i; i < count; i++, tgt++) {
1063 if (lov_tgt_active(lov, tgt, 0)) {
1064 next_idx = (i + 1) % count;
1069 for (i = 0, tgt = lov->tgts; i < next_idx; i++, tgt++) {
1070 if (lov_tgt_active(lov, tgt, 0)) {
1071 next_idx = (i + 1) % count;
1079 static int lov_revalidate_md(struct obd_export *exp, struct obdo *src_oa,
1080 struct lov_stripe_md *ea,
1081 struct obd_trans_info *oti)
1083 struct obd_export *osc_exp;
1084 struct lov_obd *lov = &exp->exp_obd->u.lov;
1085 struct lov_stripe_md *lsm = ea;
1086 struct lov_stripe_md obj_md;
1087 struct lov_stripe_md *obj_mdp = &obj_md;
1088 struct lov_oinfo *loi;
1089 struct obdo *tmp_oa;
1090 int ost_idx, updates = 0, i;
1093 tmp_oa = obdo_alloc();
1097 loi = lsm->lsm_oinfo;
1098 for (i = 0; i < lsm->lsm_stripe_count; i++, loi++) {
1099 struct lov_tgt_desc *tgt;
1102 if (!lov_tgt_changed(lov, loi))
1105 /* returns an active tgt. tgt->ltd_refcount is incremented. */
1106 ost_idx = lov_revalidate_policy(lov, lsm);
1108 /* FIXME: punt for now. */
1109 CERROR("lov_revalidate_policy failed; no active "
1114 /* create a new object */
1115 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
1116 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
1117 tgt = lov->tgts + ost_idx;
1118 osc_exp = tgt->ltd_exp;
1119 rc = obd_create(osc_exp, tmp_oa, NULL, 0, &obj_mdp, oti);
1121 lov_tgt_decref(lov, tgt);
1122 CERROR("error creating new subobj at idx %d; "
1123 "rc = %d\n", ost_idx, rc);
1128 "replacing idx %d gen %d objid "LPX64" subobj "LPX64" "
1129 "with idx %d gen %d objid "LPX64" subobj "LPX64".\n",
1130 loi->loi_ost_idx, loi->loi_ost_gen,
1131 loi->loi_id, loi->loi_gr,
1132 ost_idx, tgt->ltd_gen, tmp_oa->o_id, tmp_oa->o_gr);
1135 oti->oti_objid[ost_idx] = tmp_oa->o_id;
1136 loi->loi_id = tmp_oa->o_id;
1137 loi->loi_gr = tmp_oa->o_gr;
1138 loi->loi_ost_idx = ost_idx;
1139 loi->loi_ost_gen = tgt->ltd_gen;
1140 lov_tgt_decref(lov, tgt);
1144 /* If we got an error revalidating an entry there's no need to
1145 * cleanup up objects we allocated here because the bad entry
1146 * still points to a deleted OST. */
1152 /* FIXME: maybe we'll just make one node the authoritative attribute node, then
1153 * we can send this 'punch' to just the authoritative node and the nodes
1154 * that the punch will affect. */
1155 static int lov_punch(struct obd_export *exp, struct obdo *oa,
1156 struct lov_stripe_md *lsm, obd_off start,
1157 obd_off end, struct obd_trans_info *oti,
1158 struct lustre_capa *capa)
1160 struct lov_request_set *set;
1161 struct lov_obd *lov;
1162 struct list_head *pos;
1163 struct lov_request *req;
1164 int err = 0, rc = 0;
1167 if (lsm_bad_magic(lsm))
1170 if (!exp || !exp->exp_obd)
1173 lov = &exp->exp_obd->u.lov;
1174 rc = lov_prep_punch_set(exp, oa, lsm, start, end, oti, &set);
1178 list_for_each (pos, &set->set_list) {
1179 req = list_entry(pos, struct lov_request, rq_link);
1181 rc = obd_punch(lov->tgts[req->rq_idx].ltd_exp, req->rq_oa,
1182 NULL, req->rq_extent.start,
1183 req->rq_extent.end, NULL, capa);
1184 err = lov_update_punch_set(set, req, rc);
1186 CERROR("error: punch objid "LPX64" subobj "LPX64
1187 " on OST idx %d: rc = %d\n", set->set_oa->o_id,
1188 req->rq_oa->o_id, req->rq_idx, rc);
1193 err = lov_fini_punch_set(set);
1199 static int lov_sync(struct obd_export *exp, struct obdo *oa,
1200 struct lov_stripe_md *lsm, obd_off start, obd_off end)
1202 struct lov_request_set *set;
1203 struct lov_obd *lov;
1204 struct list_head *pos;
1205 struct lov_request *req;
1206 int err = 0, rc = 0;
1209 if (lsm_bad_magic(lsm))
1215 lov = &exp->exp_obd->u.lov;
1216 rc = lov_prep_sync_set(exp, oa, lsm, start, end, &set);
1220 list_for_each (pos, &set->set_list) {
1221 req = list_entry(pos, struct lov_request, rq_link);
1223 rc = obd_sync(lov->tgts[req->rq_idx].ltd_exp, req->rq_oa,
1224 NULL, req->rq_extent.start, req->rq_extent.end);
1225 err = lov_update_common_set(set, req, rc);
1227 CERROR("error: fsync objid "LPX64" subobj "LPX64
1228 " on OST idx %d: rc = %d\n", set->set_oa->o_id,
1229 req->rq_oa->o_id, req->rq_idx, rc);
1234 err = lov_fini_sync_set(set);
1240 static int lov_brw_check(struct lov_obd *lov, struct obdo *oa,
1241 struct lov_stripe_md *lsm,
1242 obd_count oa_bufs, struct brw_page *pga)
1247 /* The caller just wants to know if there's a chance that this
1248 * I/O can succeed */
1249 for (i = 0; i < oa_bufs; i++) {
1250 struct lov_oinfo *loi;
1251 struct lov_tgt_desc *tgt;
1255 if (!lov_stripe_intersects(lsm, i, pga[i].disk_offset,
1256 pga[i].disk_offset + pga[i].count,
1260 stripe = lov_stripe_number(lsm, pga[i].disk_offset);
1261 loi = lsm->lsm_oinfo + stripe;
1262 tgt = lov->tgts + loi->loi_ost_idx;
1264 if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) {
1265 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1268 rc = obd_brw(OBD_BRW_CHECK, tgt->ltd_exp, oa,
1269 NULL, 1, &pga[i], NULL);
1270 lov_tgt_decref(lov, tgt);
1277 static int lov_brw(int cmd, struct obd_export *exp, struct obdo *src_oa,
1278 struct lov_stripe_md *lsm, obd_count oa_bufs,
1279 struct brw_page *pga, struct obd_trans_info *oti)
1281 struct lov_request_set *set;
1282 struct lov_request *req;
1283 struct list_head *pos;
1284 struct lov_obd *lov = &exp->exp_obd->u.lov;
1288 if (lsm_bad_magic(lsm))
1291 if (cmd == OBD_BRW_CHECK) {
1292 rc = lov_brw_check(lov, src_oa, lsm, oa_bufs, pga);
1296 rc = lov_prep_brw_set(exp, src_oa, lsm, oa_bufs, pga, oti, &set);
1300 list_for_each (pos, &set->set_list) {
1301 struct obd_export *sub_exp;
1302 struct brw_page *sub_pga;
1303 req = list_entry(pos, struct lov_request, rq_link);
1305 sub_exp = lov->tgts[req->rq_idx].ltd_exp;
1306 sub_pga = set->set_pga + req->rq_pgaidx;
1307 rc = obd_brw(cmd, sub_exp, req->rq_oa, req->rq_md,
1308 req->rq_oabufs, sub_pga, oti);
1311 lov_update_common_set(set, req, rc);
1314 err = lov_fini_brw_set(set);
1320 static int lov_brw_interpret(struct ptlrpc_request_set *reqset, void *data,
1323 struct lov_request_set *lovset = (struct lov_request_set *)data;
1327 lovset->set_completes = 0;
1328 lov_fini_brw_set(lovset);
1330 rc = lov_fini_brw_set(lovset);
1336 static int lov_brw_async(int cmd, struct obd_export *exp, struct obdo *oa,
1337 struct lov_stripe_md *lsm, obd_count oa_bufs,
1338 struct brw_page *pga, struct ptlrpc_request_set *set,
1339 struct obd_trans_info *oti)
1341 struct lov_request_set *lovset;
1342 struct lov_request *req;
1343 struct list_head *pos;
1344 struct lov_obd *lov = &exp->exp_obd->u.lov;
1348 if (lsm_bad_magic(lsm))
1351 if (cmd == OBD_BRW_CHECK) {
1352 rc = lov_brw_check(lov, oa, lsm, oa_bufs, pga);
1356 rc = lov_prep_brw_set(exp, oa, lsm, oa_bufs, pga, oti, &lovset);
1360 list_for_each (pos, &lovset->set_list) {
1361 struct obd_export *sub_exp;
1362 struct brw_page *sub_pga;
1363 req = list_entry(pos, struct lov_request, rq_link);
1365 sub_exp = lov->tgts[req->rq_idx].ltd_exp;
1366 sub_pga = lovset->set_pga + req->rq_pgaidx;
1367 rc = obd_brw_async(cmd, sub_exp, req->rq_oa, req->rq_md,
1368 req->rq_oabufs, sub_pga, set, oti);
1371 lov_update_common_set(lovset, req, rc);
1374 LASSERT(set->set_interpret == NULL);
1375 set->set_interpret = (set_interpreter_func)lov_brw_interpret;
1376 set->set_arg = (void *)lovset;
1380 lov_fini_brw_set(lovset);
1384 static int lov_ap_make_ready(void *data, int cmd)
1386 struct lov_async_page *lap = LAP_FROM_COOKIE(data);
1388 return lap->lap_caller_ops->ap_make_ready(lap->lap_caller_data, cmd);
1390 static int lov_ap_refresh_count(void *data, int cmd)
1392 struct lov_async_page *lap = LAP_FROM_COOKIE(data);
1394 return lap->lap_caller_ops->ap_refresh_count(lap->lap_caller_data,
1397 static void lov_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
1399 struct lov_async_page *lap = LAP_FROM_COOKIE(data);
1401 lap->lap_caller_ops->ap_fill_obdo(lap->lap_caller_data, cmd, oa);
1402 /* XXX woah, shouldn't we be altering more here? size? */
1403 oa->o_id = lap->lap_loi_id;
1406 static void lov_ap_completion(void *data, int cmd, struct obdo *oa, int rc)
1408 struct lov_async_page *lap = LAP_FROM_COOKIE(data);
1410 /* in a raid1 regime this would down a count of many ios
1411 * in flight, onl calling the caller_ops completion when all
1412 * the raid1 ios are complete */
1413 lap->lap_caller_ops->ap_completion(lap->lap_caller_data, cmd, oa, rc);
1416 static struct obd_async_page_ops lov_async_page_ops = {
1417 .ap_make_ready = lov_ap_make_ready,
1418 .ap_refresh_count = lov_ap_refresh_count,
1419 .ap_fill_obdo = lov_ap_fill_obdo,
1420 .ap_completion = lov_ap_completion,
1423 static int lov_prep_async_page(struct obd_export *exp,
1424 struct lov_stripe_md *lsm,
1425 struct lov_oinfo *loi, struct page *page,
1426 obd_off offset, struct obd_async_page_ops *ops,
1427 void *data, void **res)
1429 struct lov_obd *lov = &exp->exp_obd->u.lov;
1430 struct lov_tgt_desc *tgt;
1431 struct lov_async_page *lap;
1435 if (lsm_bad_magic(lsm))
1437 LASSERT(loi == NULL);
1439 stripe = lov_stripe_number(lsm, offset);
1440 loi = &lsm->lsm_oinfo[stripe];
1442 OBD_ALLOC(lap, sizeof(*lap));
1446 lap->lap_magic = LAP_MAGIC;
1447 lap->lap_caller_ops = ops;
1448 lap->lap_caller_data = data;
1450 /* FIXME handle multiple oscs after landing b_raid1 */
1451 lap->lap_stripe = stripe;
1452 switch (lsm->lsm_pattern) {
1453 case LOV_PATTERN_RAID0:
1454 lov_stripe_offset(lsm, offset, lap->lap_stripe,
1455 &lap->lap_sub_offset);
1457 case LOV_PATTERN_CMOBD:
1458 lap->lap_sub_offset = offset;
1464 /* so the callback doesn't need the lsm */
1465 lap->lap_loi_id = loi->loi_id;
1467 tgt = lov->tgts + loi->loi_ost_idx;
1469 if (lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) {
1470 rc = obd_prep_async_page(tgt->ltd_exp, lsm, loi, page,
1471 lap->lap_sub_offset,
1472 &lov_async_page_ops, lap,
1473 &lap->lap_sub_cookie);
1479 OBD_FREE(lap, sizeof(*lap));
1482 CDEBUG(D_CACHE, "lap %p page %p cookie %p off "LPU64"\n", lap, page,
1483 lap->lap_sub_cookie, offset);
1488 static int lov_queue_async_io(struct obd_export *exp,
1489 struct lov_stripe_md *lsm,
1490 struct lov_oinfo *loi, void *cookie,
1491 int cmd, obd_off off, int count,
1492 obd_flags brw_flags, obd_flags async_flags)
1494 struct lov_obd *lov = &exp->exp_obd->u.lov;
1495 struct lov_tgt_desc *tgt;
1496 struct lov_async_page *lap;
1499 LASSERT(loi == NULL);
1501 if (lsm_bad_magic(lsm))
1504 lap = LAP_FROM_COOKIE(cookie);
1505 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1506 tgt = lov->tgts + loi->loi_ost_idx;
1508 if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen) &&
1509 !lov_tgt_pending(lov, tgt, loi->loi_ost_gen))
1512 rc = obd_queue_async_io(tgt->ltd_exp, lsm, loi, lap->lap_sub_cookie,
1513 cmd, off, count, brw_flags, async_flags);
1515 lov_tgt_decref(lov, tgt);
1519 static int lov_set_async_flags(struct obd_export *exp,
1520 struct lov_stripe_md *lsm,
1521 struct lov_oinfo *loi, void *cookie,
1522 obd_flags async_flags)
1524 struct lov_obd *lov = &exp->exp_obd->u.lov;
1525 struct lov_tgt_desc *tgt;
1526 struct lov_async_page *lap;
1529 LASSERT(loi == NULL);
1531 if (lsm_bad_magic(lsm))
1534 lap = LAP_FROM_COOKIE(cookie);
1535 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1536 tgt = lov->tgts + loi->loi_ost_idx;
1538 if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen) &&
1539 !lov_tgt_pending(lov, tgt, loi->loi_ost_gen))
1542 rc = obd_set_async_flags(tgt->ltd_exp, lsm, loi, lap->lap_sub_cookie,
1545 lov_tgt_decref(lov, tgt);
1549 static int lov_queue_group_io(struct obd_export *exp,
1550 struct lov_stripe_md *lsm,
1551 struct lov_oinfo *loi,
1552 struct obd_io_group *oig, void *cookie,
1553 int cmd, obd_off off, int count,
1554 obd_flags brw_flags, obd_flags async_flags)
1556 struct lov_obd *lov = &exp->exp_obd->u.lov;
1557 struct lov_tgt_desc *tgt;
1558 struct lov_async_page *lap;
1561 LASSERT(loi == NULL);
1563 if (lsm_bad_magic(lsm))
1566 lap = LAP_FROM_COOKIE(cookie);
1567 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1568 tgt = lov->tgts + loi->loi_ost_idx;
1570 if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen) &&
1571 !lov_tgt_pending(lov, tgt, loi->loi_ost_gen))
1574 rc = obd_queue_group_io(tgt->ltd_exp, lsm, loi, oig,
1575 lap->lap_sub_cookie, cmd, off, count,
1576 brw_flags, async_flags);
1578 lov_tgt_decref(lov, tgt);
1582 /* this isn't exactly optimal. we may have queued sync io in oscs on
1583 * all stripes, but we don't record that fact at queue time. so we
1584 * trigger sync io on all stripes. */
1585 static int lov_trigger_group_io(struct obd_export *exp,
1586 struct lov_stripe_md *lsm,
1587 struct lov_oinfo *loi,
1588 struct obd_io_group *oig)
1590 struct lov_obd *lov = &exp->exp_obd->u.lov;
1593 LASSERT(loi == NULL);
1595 if (lsm_bad_magic(lsm))
1598 loi = lsm->lsm_oinfo;
1599 for (i = 0; i < lsm->lsm_stripe_count; i++, loi++) {
1600 struct lov_tgt_desc *tgt = lov->tgts + loi->loi_ost_idx;
1602 if (!lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) {
1603 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1607 err = obd_trigger_group_io(tgt->ltd_exp, lsm, loi, oig);
1609 lov_tgt_decref(lov, tgt);
1611 if (rc == 0 && err != 0)
1617 static int lov_teardown_async_page(struct obd_export *exp,
1618 struct lov_stripe_md *lsm,
1619 struct lov_oinfo *loi, void *cookie)
1621 struct lov_obd *lov = &exp->exp_obd->u.lov;
1622 struct lov_tgt_desc *tgt;
1623 struct lov_async_page *lap;
1627 LASSERT(loi == NULL);
1629 if (lsm_bad_magic(lsm))
1632 lap = LAP_FROM_COOKIE(cookie);
1634 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1635 tgt = lov->tgts + loi->loi_ost_idx;
1637 rc = obd_teardown_async_page(tgt->ltd_exp, lsm, loi,
1638 lap->lap_sub_cookie);
1639 lov_tgt_decref(lov, tgt);
1642 CERROR("unable to teardown sub cookie %p: %d\n",
1643 lap->lap_sub_cookie, rc);
1646 OBD_FREE(lap, sizeof(*lap));
1650 static int lov_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
1651 __u32 type, ldlm_policy_data_t *policy, __u32 mode,
1652 int *flags, void *bl_cb, void *cp_cb, void *gl_cb,
1653 void *data,__u32 lvb_len, void *lvb_swabber,
1654 struct lustre_handle *lockh)
1656 struct lov_request_set *set;
1657 struct lov_request *req;
1658 struct list_head *pos;
1659 struct lustre_handle *lov_lockhp;
1660 struct lov_obd *lov;
1662 int save_flags = *flags;
1665 if (lsm_bad_magic(lsm))
1668 /* we should never be asked to replay a lock this way. */
1669 LASSERT((*flags & LDLM_FL_REPLAY) == 0);
1671 if (!exp || !exp->exp_obd)
1674 lov = &exp->exp_obd->u.lov;
1675 rc = lov_prep_enqueue_set(exp, lsm, policy, mode, lockh, &set);
1679 list_for_each (pos, &set->set_list) {
1680 ldlm_policy_data_t sub_policy;
1681 req = list_entry(pos, struct lov_request, rq_link);
1682 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
1683 LASSERT(lov_lockhp);
1685 *flags = save_flags;
1686 sub_policy.l_extent.start = req->rq_extent.start;
1687 sub_policy.l_extent.end = req->rq_extent.end;
1689 rc = obd_enqueue(lov->tgts[req->rq_idx].ltd_exp, req->rq_md,
1690 type, &sub_policy, mode, flags, bl_cb,
1691 cp_cb, gl_cb, data, lvb_len, lvb_swabber,
1693 rc = lov_update_enqueue_set(set, req, rc, save_flags);
1698 lov_fini_enqueue_set(set, mode);
1702 static int lov_match(struct obd_export *exp, struct lov_stripe_md *lsm,
1703 __u32 type, ldlm_policy_data_t *policy, __u32 mode,
1704 int *flags, void *data, struct lustre_handle *lockh)
1706 struct lov_request_set *set;
1707 struct lov_request *req;
1708 struct list_head *pos;
1709 struct lov_obd *lov = &exp->exp_obd->u.lov;
1710 struct lustre_handle *lov_lockhp;
1711 int lov_flags, rc = 0;
1714 if (lsm_bad_magic(lsm))
1717 if (!exp || !exp->exp_obd)
1720 lov = &exp->exp_obd->u.lov;
1721 rc = lov_prep_match_set(exp, lsm, policy, mode, lockh, &set);
1725 list_for_each (pos, &set->set_list) {
1726 ldlm_policy_data_t sub_policy;
1727 req = list_entry(pos, struct lov_request, rq_link);
1728 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
1729 LASSERT(lov_lockhp);
1731 sub_policy.l_extent.start = req->rq_extent.start;
1732 sub_policy.l_extent.end = req->rq_extent.end;
1735 rc = obd_match(lov->tgts[req->rq_idx].ltd_exp, req->rq_md,
1736 type, &sub_policy, mode, &lov_flags, data,
1738 rc = lov_update_match_set(set, req, rc);
1742 lov_fini_match_set(set, mode, *flags);
1746 static int lov_change_cbdata(struct obd_export *exp,
1747 struct lov_stripe_md *lsm, ldlm_iterator_t it,
1750 struct lov_obd *lov;
1751 struct lov_oinfo *loi;
1755 if (lsm_bad_magic(lsm))
1758 if (!exp || !exp->exp_obd)
1761 LASSERT(lsm->lsm_object_gr > 0);
1763 lov = &exp->exp_obd->u.lov;
1764 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
1765 struct lov_tgt_desc *tgt = lov->tgts + loi->loi_ost_idx;
1766 struct lov_stripe_md submd;
1768 submd.lsm_object_id = loi->loi_id;
1769 submd.lsm_object_gr = lsm->lsm_object_gr;
1770 submd.lsm_stripe_count = 0;
1771 rc = obd_change_cbdata(tgt->ltd_exp, &submd, it, data);
1772 lov_tgt_decref(lov, tgt);
1777 static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm,
1778 __u32 mode, struct lustre_handle *lockh)
1780 struct lov_request_set *set;
1781 struct lov_request *req;
1782 struct list_head *pos;
1783 struct lov_obd *lov = &exp->exp_obd->u.lov;
1784 struct lustre_handle *lov_lockhp;
1785 int err = 0, rc = 0;
1788 if (lsm_bad_magic(lsm))
1791 if (!exp || !exp->exp_obd)
1794 LASSERT(lsm->lsm_object_gr > 0);
1797 lov = &exp->exp_obd->u.lov;
1798 rc = lov_prep_cancel_set(exp, lsm, mode, lockh, &set);
1802 list_for_each (pos, &set->set_list) {
1803 req = list_entry(pos, struct lov_request, rq_link);
1804 lov_lockhp = set->set_lockh->llh_handles + req->rq_stripe;
1806 rc = obd_cancel(lov->tgts[req->rq_idx].ltd_exp, req->rq_md,
1808 rc = lov_update_common_set(set, req, rc);
1810 CERROR("error: cancel objid "LPX64" subobj "
1811 LPX64" on OST idx %d: rc = %d\n",
1813 req->rq_md->lsm_object_id, req->rq_idx, rc);
1818 lov_fini_cancel_set(set);
1822 static int lov_cancel_unused(struct obd_export *exp,
1823 struct lov_stripe_md *lsm,
1824 int flags, void *opaque)
1826 struct lov_obd *lov;
1827 struct lov_oinfo *loi;
1828 struct lov_tgt_desc *tgt;
1832 lov = &exp->exp_obd->u.lov;
1835 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgt++) {
1838 if (lov_tgt_ready(lov, tgt, 0)) {
1839 err = obd_cancel_unused(tgt->ltd_exp, NULL,
1841 lov_tgt_decref(lov, tgt);
1843 if (obd_uuid_empty(&tgt->uuid))
1845 CERROR("error: cancel unused "
1846 "OST idx %d: OST inactive.\n", i);
1855 if (lsm_bad_magic(lsm))
1858 if (!exp || !exp->exp_obd)
1861 LASSERT(lsm->lsm_object_gr > 0);
1863 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
1864 struct lov_stripe_md submd;
1867 submd.lsm_object_id = loi->loi_id;
1868 submd.lsm_object_gr = lsm->lsm_object_gr;
1869 submd.lsm_stripe_count = 0;
1871 tgt = lov->tgts + loi->loi_ost_idx;
1872 if (lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) {
1873 err = obd_cancel_unused(tgt->ltd_exp, &submd, flags,
1875 lov_tgt_decref(lov, tgt);
1876 if (err && lov_tgt_ready(lov, tgt, loi->loi_ost_gen)) {
1877 lov_tgt_decref(lov, tgt);
1878 CERROR("error: cancel unused objid "LPX64" "
1879 "subobj "LPX64" OST idx %d: rc = %d\n",
1880 lsm->lsm_object_id, loi->loi_id,
1881 loi->loi_ost_idx, err);
1885 CERROR("error: cancel unused objid "LPX64" "
1886 "subobj "LPX64" on OST idx %d: OST inactive.\n",
1888 loi->loi_id, loi->loi_ost_idx);
1897 #define LOV_U64_MAX ((__u64)~0ULL)
1898 #define LOV_SUM_MAX(tot, add) \
1900 if ((tot) + (add) < (tot)) \
1901 (tot) = LOV_U64_MAX; \
1906 static int lov_statfs(struct obd_device *obd, struct obd_statfs *osfs,
1907 unsigned long max_age)
1909 struct lov_obd *lov = &obd->u.lov;
1910 struct lov_tgt_desc *tgt = lov->tgts;
1911 struct obd_statfs lov_sfs;
1918 /* We only get block data from the OBD */
1919 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgt++) {
1922 if (!lov_tgt_active(lov, tgt, 0)) {
1923 CDEBUG(D_HA, "lov idx %d inactive\n", i);
1927 err = obd_statfs(class_exp2obd(tgt->ltd_exp), &lov_sfs,max_age);
1928 lov_tgt_decref(lov, tgt);
1930 if (lov_tgt_active(lov, tgt, 0)) {
1931 lov_tgt_decref(lov, tgt);
1939 memcpy(osfs, &lov_sfs, sizeof(lov_sfs));
1942 osfs->os_bfree += lov_sfs.os_bfree;
1943 osfs->os_bavail += lov_sfs.os_bavail;
1944 osfs->os_blocks += lov_sfs.os_blocks;
1945 /* XXX not sure about this one - depends on policy.
1946 * - could be minimum if we always stripe on all OBDs
1947 * (but that would be wrong for any other policy,
1948 * if one of the OBDs has no more objects left)
1949 * - could be sum if we stripe whole objects
1950 * - could be average, just to give a nice number
1952 * To give a "reasonable" (if not wholly accurate)
1953 * number, we divide the total number of free objects
1954 * by expected stripe count (watch out for overflow).
1956 LOV_SUM_MAX(osfs->os_files, lov_sfs.os_files);
1957 LOV_SUM_MAX(osfs->os_ffree, lov_sfs.os_ffree);
1962 __u32 expected_stripes = lov->desc.ld_default_stripe_count ?
1963 lov->desc.ld_default_stripe_count :
1964 lov->desc.ld_active_tgt_count;
1966 if ((lov->desc.ld_default_stripe_count == 0) ||
1967 (lov->desc.ld_default_stripe_count >
1968 lov->desc.ld_active_tgt_count)) {
1969 expected_stripes = lov->desc.ld_active_tgt_count;
1971 expected_stripes = lov->desc.ld_default_stripe_count;
1974 if (osfs->os_files != LOV_U64_MAX)
1975 do_div(osfs->os_files, expected_stripes);
1976 if (osfs->os_ffree != LOV_U64_MAX)
1977 do_div(osfs->os_ffree, expected_stripes);
1984 static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
1985 void *karg, void *uarg)
1987 struct obd_device *obddev = class_exp2obd(exp);
1988 struct lov_obd *lov = &obddev->u.lov;
1989 struct lov_tgt_desc *tgt;
1990 int i, rc, count = lov->desc.ld_tgt_count;
1991 struct obd_uuid *uuidp;
1995 case OBD_IOC_LOV_GET_CONFIG: {
1996 struct obd_ioctl_data *data = karg;
1997 struct lov_desc *desc;
2003 if (obd_ioctl_getdata(&buf, &len, (void *)uarg))
2006 data = (struct obd_ioctl_data *)buf;
2008 if (sizeof(*desc) > data->ioc_inllen1) {
2009 obd_ioctl_freedata(buf, len);
2013 if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
2014 obd_ioctl_freedata(buf, len);
2018 if (sizeof(__u32) * count > data->ioc_inllen3) {
2019 obd_ioctl_freedata(buf, len);
2023 desc = (struct lov_desc *)data->ioc_inlbuf1;
2024 memcpy(desc, &(lov->desc), sizeof(*desc));
2026 uuidp = (struct obd_uuid *)data->ioc_inlbuf2;
2027 genp = (__u32 *)data->ioc_inlbuf3;
2028 /* the uuid will be empty for deleted OSTs */
2031 for (i = 0; i < count; i++, uuidp++, genp++, tgt++) {
2032 obd_str2uuid(uuidp, (char *)tgt->uuid.uuid);
2033 *genp = tgt->ltd_gen;
2035 lov_tgts_unlock(lov);
2037 rc = copy_to_user((void *)uarg, buf, len);
2040 obd_ioctl_freedata(buf, len);
2043 case LL_IOC_LOV_SETSTRIPE:
2044 rc = lov_setstripe(exp, karg, uarg);
2046 case LL_IOC_LOV_GETSTRIPE:
2047 rc = lov_getstripe(exp, karg, uarg);
2049 case LL_IOC_LOV_SETEA:
2050 rc = lov_setea(exp, karg, uarg);
2057 for (i = 0, tgt = lov->tgts; i < count; i++, tgt++) {
2060 if (!lov_tgt_active(lov, tgt, 0)) {
2061 CERROR("error: iocontrol failed for OSC %s on "
2062 "OST idx %d: OST inactive.\n",
2069 err = obd_iocontrol(cmd, tgt->ltd_exp, len, karg, uarg);
2070 lov_tgt_decref(lov, tgt);
2072 if (lov_tgt_ready(lov, tgt, 0)) {
2073 lov_tgt_decref(lov, tgt);
2074 CERROR("error: iocontrol OSC %s on OST "
2075 "idx %d cmd %x: err = %d\n",
2076 lov->tgts[i].uuid.uuid, i,
2092 static int lov_get_info(struct obd_export *exp, __u32 keylen,
2093 void *key, __u32 *vallen, void *val)
2095 struct obd_device *obddev = class_exp2obd(exp);
2096 struct lov_obd *lov = &obddev->u.lov;
2097 struct lov_tgt_desc *tgt;
2101 if (!vallen || !val)
2104 if (keylen > strlen("lock_to_stripe") &&
2105 strcmp(key, "lock_to_stripe") == 0) {
2108 struct ldlm_lock *lock;
2109 struct lov_stripe_md *lsm;
2111 struct lov_oinfo *loi;
2112 struct ldlm_res_id *res_id = &data->lock->l_resource->lr_name;
2113 __u32 *stripe = val;
2115 if (*vallen < sizeof(*stripe))
2117 *vallen = sizeof(*stripe);
2119 /* XXX This is another one of those bits that will need to
2120 * change if we ever actually support nested LOVs. It uses
2121 * the lock's export to find out which stripe it is. */
2122 /* XXX - it's assumed all the locks for deleted OSTs have
2123 * been cancelled. Also, the export for deleted OSTs will
2124 * be NULL and won't match the lock's export. */
2126 for (i = 0, loi = data->lsm->lsm_oinfo;
2127 i < data->lsm->lsm_stripe_count;
2129 if (lov->tgts[loi->loi_ost_idx].ltd_exp ==
2130 data->lock->l_conn_export &&
2131 loi->loi_id == res_id->name[0] &&
2132 loi->loi_gr == res_id->name[2]) {
2133 lov_tgts_unlock(lov);
2138 lov_tgts_unlock(lov);
2139 LDLM_ERROR(data->lock, "lock on inode without such object");
2140 dump_lsm(D_ERROR, data->lsm);
2141 portals_debug_dumpstack(NULL);
2143 } else if (keylen >= strlen("size_to_stripe") &&
2144 strcmp(key, "size_to_stripe") == 0) {
2148 struct lov_stripe_md *lsm;
2151 if (*vallen < sizeof(*data))
2154 data->size = lov_size_to_stripe(data->lsm, data->size,
2155 data->stripe_number);
2157 } else if (keylen >= strlen("last_id") && strcmp(key, "last_id") == 0) {
2158 __u32 size = sizeof(obd_id);
2163 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgt++) {
2164 if (!lov_tgt_active(lov, tgt, 0))
2166 rc = obd_get_info(tgt->ltd_exp, keylen, key, &size,
2168 lov_tgt_decref(lov, tgt);
2173 } else if (keylen >= strlen("lovdesc") && strcmp(key, "lovdesc") == 0) {
2174 struct lov_desc *desc_ret = val;
2175 *desc_ret = lov->desc;
2183 static int lov_set_info(struct obd_export *exp, obd_count keylen,
2184 void *key, obd_count vallen, void *val)
2186 struct obd_device *obddev = class_exp2obd(exp);
2187 struct lov_obd *lov = &obddev->u.lov;
2188 struct lov_tgt_desc *tgt;
2192 #define KEY_IS(str) \
2193 (keylen == strlen(str) && memcmp(key, str, keylen) == 0)
2195 if (KEY_IS("async")) {
2196 struct lov_desc *desc = &lov->desc;
2198 if (vallen != sizeof(int))
2200 lov->async = *((int*) val);
2204 for (i = 0; i < desc->ld_tgt_count; i++, tgt++) {
2205 struct obd_uuid *tgt_uuid = &tgt->uuid;
2206 struct obd_device *tgt_obd;
2208 tgt_obd = class_find_client_obd(tgt_uuid,
2212 CERROR("Target %s not attached\n",
2219 err = obd_set_info(tgt_obd->obd_self_export,
2220 keylen, key, vallen, val);
2222 CERROR("Failed to set async on target %s\n",
2228 lov_tgts_unlock(lov);
2232 if (KEY_IS("mds_conn")) {
2233 if (vallen != sizeof(__u32))
2235 } else if (KEY_IS("unlinked") || KEY_IS("unrecovery")) {
2238 } else if (KEY_IS("sec") || KEY_IS("sec_flags")) {
2239 struct lov_tgt_desc *tgt;
2240 struct obd_export *exp;
2245 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgt++) {
2247 /* during setup time the connections to osc might
2248 * haven't been established.
2251 struct obd_device *tgt_obd;
2253 tgt_obd = class_find_client_obd(&tgt->uuid,
2257 CERROR("can't set security flavor, "
2258 "device %s not attached?\n",
2263 exp = tgt_obd->obd_self_export;
2266 err = obd_set_info(exp, keylen, key, vallen, val);
2270 lov_tgts_unlock(lov);
2273 } else if (KEY_IS("auditlog")) {
2275 struct audit_msg * msg = val;
2276 int i = 0, len = sizeof(nid);
2277 struct obd_export * ost_exp;
2278 //try to find client nid
2279 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
2280 if (!lov->tgts[i].ltd_exp)
2282 rc = obd_get_info(lov->tgts[i].ltd_exp, 10,
2283 "client_nid", &len, &nid);
2288 i = (__u32)nid % lov->desc.ld_tgt_count;
2290 CDEBUG(D_INFO, "Select OST %i for nid %.8x\n",i, (__u32)nid);
2292 ost_exp = lov->tgts[i].ltd_exp;
2294 CERROR("can't send auditlog data,"
2295 "device %s is not attached?\n",
2296 lov->tgts[i].uuid.uuid);
2300 rc = obd_set_info(ost_exp, keylen, key, vallen, val);
2303 } else if (KEY_IS("audit_obj")) {
2304 struct audit_lov_msg * msg = val;
2306 struct obd_export * ost_exp;
2307 struct lov_oinfo *loi;
2308 struct obdo *oa = NULL;
2314 //set audit for all objects of file
2315 CDEBUG(D_INFO, "Set audit 0x%x for objects\n", (__u32)msg->mask);
2316 //use o_fid to store audit mask
2317 oa->o_fid = msg->mask;
2318 oa->o_uid = msg->uid;
2319 oa->o_gid = msg->gid;
2320 //iterate over all objects and set audit for each
2321 for (i = 0, loi = msg->lsm->lsm_oinfo;
2322 i < msg->lsm->lsm_stripe_count; i++, loi++) {
2323 index = loi->loi_ost_idx;
2324 ost_exp = lov->tgts[index].ltd_exp;
2326 CERROR("can't send audit_obj data,"
2327 "device %s is not attached?\n",
2328 lov->tgts[i].uuid.uuid);
2331 oa->o_id = loi->loi_id;
2332 oa->o_gr = loi->loi_gr;
2334 obd_set_info(ost_exp, keylen, key, sizeof(*oa), oa);
2339 } else if (KEY_IS("audit")) {
2341 struct obd_export * ost_exp;
2343 //set audit for whole fs on OSS
2344 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
2345 ost_exp = lov->tgts[i].ltd_exp;
2347 CERROR("can't send audit_fs data,"
2348 "device %s is not attached?\n",
2349 lov->tgts[i].uuid.uuid);
2352 obd_set_info(ost_exp, keylen, key, vallen, val);
2356 } else if (KEY_IS("flush_cred") || KEY_IS("crypto_cb") ||
2357 KEY_IS("capa_key")) {
2358 struct lov_tgt_desc *tgt;
2362 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgt++) {
2363 if (!lov_tgt_active(lov, tgt, 0))
2365 rc = obd_set_info(tgt->ltd_exp,
2366 keylen, key, vallen, val);
2367 lov_tgt_decref(lov, tgt);
2373 } else if (KEY_IS("setext")) {
2374 struct lov_tgt_desc *tgt;
2377 for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count;
2381 rc = obd_set_info(tgt->ltd_exp,
2382 keylen, key, vallen, val);
2393 for (i = 0; i < lov->desc.ld_tgt_count; i++, tgt++) {
2397 if (!obd_uuid_equals(val, &tgt->uuid))
2399 } else if (!lov_tgt_active(lov, tgt, 0)) {
2405 err = obd_set_info(tgt->ltd_exp, keylen, key, vallen, val);
2409 lov_tgt_decref(lov, tgt);
2416 struct lov_multi_wait {
2417 struct ldlm_lock *lock;
2423 int lov_complete_many(struct obd_export *exp, struct lov_stripe_md *lsm,
2424 struct lustre_handle *lockh)
2426 struct lov_lock_handles *lov_lockh = NULL;
2427 struct lustre_handle *lov_lockhp;
2428 struct lov_obd *lov;
2429 struct lov_oinfo *loi;
2430 struct lov_multi_wait *queues;
2434 if (lsm_bad_magic(lsm))
2437 if (!exp || !exp->exp_obd)
2440 LASSERT(lockh != NULL);
2441 if (lsm->lsm_stripe_count > 1) {
2442 lov_lockh = lov_handle2llh(lockh);
2443 if (lov_lockh == NULL) {
2444 CERROR("LOV: invalid lov lock handle %p\n", lockh);
2448 lov_lockhp = lov_lockh->llh_handles;
2453 OBD_ALLOC(queues, lsm->lsm_stripe_count * sizeof(*queues));
2455 GOTO(out, rc = -ENOMEM);
2457 lov = &exp->exp_obd->u.lov;
2458 for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count;
2459 i++, loi++, lov_lockhp++) {
2460 struct ldlm_lock *lock;
2461 struct obd_device *obd;
2462 unsigned long irqflags;
2464 lock = ldlm_handle2lock(lov_lockhp);
2466 CDEBUG(D_HA, "lov idx %d subobj "LPX64" no lock?\n",
2467 loi->loi_ost_idx, loi->loi_id);
2468 queues[i].completed = 1;
2472 queues[i].lock = lock;
2473 init_waitqueue_entry(&(queues[i].wait), current);
2474 add_wait_queue(lock->l_waitq, &(queues[i].wait));
2476 obd = class_exp2obd(lock->l_conn_export);
2478 imp = obd->u.cli.cl_import;
2480 spin_lock_irqsave(&imp->imp_lock, irqflags);
2481 queues[i].generation = imp->imp_generation;
2482 spin_unlock_irqrestore(&imp->imp_lock, irqflags);
2486 lwi = LWI_TIMEOUT_INTR(obd_timeout * HZ, ldlm_expired_completion_wait,
2487 interrupted_completion_wait, &lwd);
2488 rc = l_wait_event_added(check_multi_complete(queues, lsm), &lwi);
2490 for (i = 0; i < lsm->lsm_stripe_count; i++)
2491 remove_wait_queue(lock->l_waitq, &(queues[i].wait));
2493 if (rc == -EINTR || rc == -ETIMEDOUT) {
2499 if (lov_lockh != NULL)
2500 lov_llh_put(lov_lockh);
2505 struct obd_ops lov_obd_ops = {
2506 .o_owner = THIS_MODULE,
2507 .o_attach = lov_attach,
2508 .o_detach = lov_detach,
2509 .o_setup = lov_setup,
2510 .o_cleanup = lov_cleanup,
2511 .o_process_config = lov_process_config,
2512 .o_connect = lov_connect,
2513 .o_disconnect = lov_disconnect,
2514 .o_statfs = lov_statfs,
2515 .o_packmd = lov_packmd,
2516 .o_unpackmd = lov_unpackmd,
2517 .o_revalidate_md = lov_revalidate_md,
2518 .o_create = lov_create,
2519 .o_destroy = lov_destroy,
2520 .o_getattr = lov_getattr,
2521 .o_getattr_async = lov_getattr_async,
2522 .o_setattr = lov_setattr,
2524 .o_brw_async = lov_brw_async,
2525 .o_prep_async_page = lov_prep_async_page,
2526 .o_queue_async_io = lov_queue_async_io,
2527 .o_set_async_flags = lov_set_async_flags,
2528 .o_queue_group_io = lov_queue_group_io,
2529 .o_trigger_group_io = lov_trigger_group_io,
2530 .o_teardown_async_page = lov_teardown_async_page,
2531 .o_adjust_kms = lov_adjust_kms,
2532 .o_punch = lov_punch,
2534 .o_enqueue = lov_enqueue,
2535 .o_match = lov_match,
2536 .o_change_cbdata = lov_change_cbdata,
2537 .o_cancel = lov_cancel,
2538 .o_cancel_unused = lov_cancel_unused,
2539 .o_iocontrol = lov_iocontrol,
2540 .o_get_info = lov_get_info,
2541 .o_set_info = lov_set_info,
2542 .o_llog_init = lov_llog_init,
2543 .o_llog_finish = lov_llog_finish,
2544 .o_notify = lov_notify,
2547 int __init lov_init(void)
2549 struct lprocfs_static_vars lvars;
2553 lprocfs_init_vars(lov, &lvars);
2554 rc = class_register_type(&lov_obd_ops, NULL, lvars.module_vars,
2555 OBD_LOV_DEVICENAME);
2560 static void /*__exit*/ lov_exit(void)
2562 class_unregister_type(OBD_LOV_DEVICENAME);
2565 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
2566 MODULE_DESCRIPTION("Lustre Logical Object Volume OBD driver");
2567 MODULE_LICENSE("GPL");
2569 module_init(lov_init);
2570 module_exit(lov_exit);