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>
52 #include "lov_internal.h"
54 static int lov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off,
55 int stripeno, obd_off *obd_off);
58 int lov_attach(struct obd_device *dev, obd_count len, void *data)
60 struct lprocfs_static_vars lvars;
63 lprocfs_init_vars(lov, &lvars);
64 rc = lprocfs_obd_attach(dev, lvars.obd_vars);
67 struct proc_dir_entry *entry;
69 entry = create_proc_entry("target_obd", 0444,
74 entry->proc_fops = &lov_proc_target_fops;
82 int lov_detach(struct obd_device *dev)
84 return lprocfs_obd_detach(dev);
87 static int lov_connect(struct lustre_handle *conn, struct obd_device *obd,
88 struct obd_uuid *cluuid)
90 struct ptlrpc_request *req = NULL;
91 struct lov_obd *lov = &obd->u.lov;
92 struct lov_desc *desc = &lov->desc;
93 struct lov_tgt_desc *tgts;
94 struct obd_export *exp;
98 rc = class_connect(conn, obd, cluuid);
102 exp = class_conn2export(conn);
104 /* We don't want to actually do the underlying connections more than
105 * once, so keep track. */
107 if (lov->refcount > 1) {
108 class_export_put(exp);
112 for (i = 0, tgts = lov->tgts; i < desc->ld_tgt_count; i++, tgts++) {
113 struct obd_uuid *tgt_uuid = &tgts->uuid;
114 struct obd_device *tgt_obd;
115 struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
116 struct lustre_handle conn = {0, };
118 LASSERT( tgt_uuid != NULL);
120 tgt_obd = class_find_client_obd(tgt_uuid, LUSTRE_OSC_NAME,
124 CERROR("Target %s not attached\n", tgt_uuid->uuid);
125 GOTO(out_disc, rc = -EINVAL);
128 if (!tgt_obd->obd_set_up) {
129 CERROR("Target %s not set up\n", tgt_uuid->uuid);
130 GOTO(out_disc, rc = -EINVAL);
133 if (tgt_obd->u.cli.cl_import->imp_invalid) {
134 CERROR("not connecting OSC %s; administratively "
135 "disabled\n", tgt_uuid->uuid);
136 rc = obd_register_observer(tgt_obd, obd);
138 CERROR("Target %s register_observer error %d; "
139 "will not be able to reactivate\n",
145 rc = obd_connect(&conn, tgt_obd, &lov_osc_uuid);
147 CERROR("Target %s connect error %d\n", tgt_uuid->uuid,
151 tgts->ltd_exp = class_conn2export(&conn);
153 rc = obd_register_observer(tgt_obd, obd);
155 CERROR("Target %s register_observer error %d\n",
157 obd_disconnect(tgts->ltd_exp, 0);
161 desc->ld_active_tgt_count++;
165 ptlrpc_req_finished(req);
166 class_export_put(exp);
171 struct obd_uuid uuid;
173 --desc->ld_active_tgt_count;
175 /* save for CERROR below; (we know it's terminated) */
177 rc2 = obd_disconnect(tgts->ltd_exp, 0);
179 CERROR("error: LOV target %s disconnect on OST idx %d: "
180 "rc = %d\n", uuid.uuid, i, rc2);
182 class_disconnect(exp, 0);
186 static int lov_disconnect(struct obd_export *exp, int flags)
188 struct obd_device *obd = class_exp2obd(exp);
189 struct lov_obd *lov = &obd->u.lov;
196 /* Only disconnect the underlying layers on the final disconnect. */
198 if (lov->refcount != 0)
201 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
202 if (lov->tgts[i].ltd_exp == NULL)
205 if (obd->obd_no_recov) {
206 /* Pass it on to our clients.
207 * XXX This should be an argument to disconnect,
208 * XXX not a back-door flag on the OBD. Ah well.
210 struct obd_device *osc_obd;
211 osc_obd = class_exp2obd(lov->tgts[i].ltd_exp);
213 osc_obd->obd_no_recov = 1;
216 obd_register_observer(lov->tgts[i].ltd_exp->exp_obd, NULL);
218 rc = obd_disconnect(lov->tgts[i].ltd_exp, flags);
220 if (lov->tgts[i].active) {
221 CERROR("Target %s disconnect error %d\n",
222 lov->tgts[i].uuid.uuid, rc);
226 if (lov->tgts[i].active) {
227 lov->desc.ld_active_tgt_count--;
228 lov->tgts[i].active = 0;
230 lov->tgts[i].ltd_exp = NULL;
234 rc = class_disconnect(exp, 0);
240 * -EINVAL : UUID can't be found in the LOV's target list
241 * -ENOTCONN: The UUID is found, but the target connection is bad (!)
242 * -EBADF : The UUID is found, but the OBD is the wrong type (!)
244 static int lov_set_osc_active(struct lov_obd *lov, struct obd_uuid *uuid,
247 struct obd_device *obd;
248 struct lov_tgt_desc *tgt;
252 CDEBUG(D_INFO, "Searching in lov %p for uuid %s (activate=%d)\n",
253 lov, uuid->uuid, activate);
255 spin_lock(&lov->lov_lock);
256 for (i = 0, tgt = lov->tgts; i < lov->desc.ld_tgt_count; i++, tgt++) {
257 CDEBUG(D_INFO, "lov idx %d is %s conn "LPX64"\n",
258 i, tgt->uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
259 if (strncmp(uuid->uuid, tgt->uuid.uuid, sizeof uuid->uuid) == 0)
263 if (i == lov->desc.ld_tgt_count)
264 GOTO(out, rc = -EINVAL);
266 obd = class_exp2obd(tgt->ltd_exp);
268 /* This can happen if OST failure races with node shutdown */
269 GOTO(out, rc = -ENOTCONN);
272 CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LOV idx %d\n",
273 obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd,
274 obd->obd_type->typ_name, i);
275 LASSERT(strcmp(obd->obd_type->typ_name, "osc") == 0);
277 if (tgt->active == activate) {
278 CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd,
279 activate ? "" : "in");
283 CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in");
285 tgt->active = activate;
287 lov->desc.ld_active_tgt_count++;
289 lov->desc.ld_active_tgt_count--;
293 spin_unlock(&lov->lov_lock);
297 static int lov_notify(struct obd_device *obd, struct obd_device *watched,
301 struct obd_uuid *uuid;
303 if (strcmp(watched->obd_type->typ_name, "osc")) {
304 CERROR("unexpected notification of %s %s!\n",
305 watched->obd_type->typ_name,
309 uuid = &watched->u.cli.cl_import->imp_target_uuid;
312 * Must notify (MDS) before we mark the OSC as active, so that
313 * the orphan deletion happens without interference from racing
316 if (obd->obd_observer) {
317 /* Pass the notification up the chain. */
318 rc = obd_notify(obd->obd_observer, watched, active);
323 rc = lov_set_osc_active(&obd->u.lov, uuid, active);
326 CERROR("%sactivation of %s failed: %d\n",
327 active ? "" : "de", uuid->uuid, rc);
332 static int lov_setup(struct obd_device *obd, obd_count len, void *buf)
334 struct lustre_cfg *lcfg = buf;
335 struct lov_desc *desc;
336 struct lov_obd *lov = &obd->u.lov;
337 struct obd_uuid *uuids;
338 struct lov_tgt_desc *tgts;
344 if (lcfg->lcfg_inllen1 < 1) {
345 CERROR("LOV setup requires a descriptor\n");
349 if (lcfg->lcfg_inllen2 < 1) {
350 CERROR("LOV setup requires an OST UUID list\n");
354 desc = (struct lov_desc *)lcfg->lcfg_inlbuf1;
355 if (sizeof(*desc) > lcfg->lcfg_inllen1) {
356 CERROR("descriptor size wrong: %d > %d\n",
357 (int)sizeof(*desc), lcfg->lcfg_inllen1);
361 count = desc->ld_tgt_count;
362 uuids = (struct obd_uuid *)lcfg->lcfg_inlbuf2;
363 if (sizeof(*uuids) * count != lcfg->lcfg_inllen2) {
364 CERROR("UUID array size wrong: %u * %u != %u\n",
365 (int)sizeof(*uuids), count, lcfg->lcfg_inllen2);
369 /* Because of 64-bit divide/mod operations only work with a 32-bit
370 * divisor in a 32-bit kernel, we cannot support a stripe width
371 * of 4GB or larger on 32-bit CPUs.
373 if ((desc->ld_default_stripe_count ?
374 desc->ld_default_stripe_count : desc->ld_tgt_count) *
375 desc->ld_default_stripe_size > ~0UL) {
376 CERROR("LOV: stripe width "LPU64"x%u > %lu on 32-bit system\n",
377 desc->ld_default_stripe_size,
378 desc->ld_default_stripe_count ?
379 desc->ld_default_stripe_count : desc->ld_tgt_count,~0UL);
383 lov->bufsize = sizeof(struct lov_tgt_desc) * count;
384 OBD_ALLOC(lov->tgts, lov->bufsize);
385 if (lov->tgts == NULL) {
386 CERROR("Out of memory\n");
391 spin_lock_init(&lov->lov_lock);
393 for (i = 0, tgts = lov->tgts; i < desc->ld_tgt_count; i++, tgts++) {
394 struct obd_uuid *uuid = &tgts->uuid;
396 /* NULL termination already checked */
404 static int lov_cleanup(struct obd_device *obd, int flags)
406 struct lov_obd *lov = &obd->u.lov;
408 OBD_FREE(lov->tgts, lov->bufsize);
413 /* compute object size given "stripeno" and the ost size */
414 static obd_size lov_stripe_size(struct lov_stripe_md *lsm, obd_size ost_size,
417 unsigned long ssize = lsm->lsm_stripe_size;
418 unsigned long swidth = ssize * lsm->lsm_stripe_count;
419 unsigned long stripe_size;
425 /* do_div(a, b) returns a % b, and a = a / b */
426 stripe_size = do_div(ost_size, ssize);
429 lov_size = ost_size * swidth + stripeno * ssize + stripe_size;
431 lov_size = (ost_size - 1) * swidth + (stripeno + 1) * ssize;
436 static void lov_merge_attrs(struct obdo *tgt, struct obdo *src, obd_flag valid,
437 struct lov_stripe_md *lsm, int stripeno, int *set)
439 valid &= src->o_valid;
442 if (valid & OBD_MD_FLSIZE) {
443 /* this handles sparse files properly */
446 lov_size = lov_stripe_size(lsm, src->o_size, stripeno);
447 if (lov_size > tgt->o_size)
448 tgt->o_size = lov_size;
450 if (valid & OBD_MD_FLBLOCKS)
451 tgt->o_blocks += src->o_blocks;
452 if (valid & OBD_MD_FLBLKSZ)
453 tgt->o_blksize += src->o_blksize;
454 if (valid & OBD_MD_FLCTIME && tgt->o_ctime < src->o_ctime)
455 tgt->o_ctime = src->o_ctime;
456 if (valid & OBD_MD_FLMTIME && tgt->o_mtime < src->o_mtime)
457 tgt->o_mtime = src->o_mtime;
459 memcpy(tgt, src, sizeof(*tgt));
460 tgt->o_id = lsm->lsm_object_id;
461 if (valid & OBD_MD_FLSIZE)
462 tgt->o_size = lov_stripe_size(lsm,src->o_size,stripeno);
468 #define log2(n) ffz(~(n))
471 static int lov_clear_orphans(struct obd_export *export, struct obdo *src_oa,
472 struct lov_stripe_md **ea,
473 struct obd_trans_info *oti)
477 struct obd_uuid *ost_uuid = NULL;
481 LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS &&
482 src_oa->o_flags == OBD_FL_DELORPHAN);
484 lov = &export->exp_obd->u.lov;
486 tmp_oa = obdo_alloc();
490 if (src_oa->o_valid & OBD_MD_FLINLINE) {
491 ost_uuid = (struct obd_uuid *)src_oa->o_inline;
492 CDEBUG(D_HA, "clearing orphans only for %s\n",
496 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
497 struct lov_stripe_md obj_md;
498 struct lov_stripe_md *obj_mdp = &obj_md;
501 /* if called for a specific target, we don't
502 care if it is not active. */
503 if (lov->tgts[i].active == 0 && ost_uuid == NULL) {
504 CDEBUG(D_HA, "lov idx %d inactive\n", i);
508 if (ost_uuid && !obd_uuid_equals(ost_uuid, &lov->tgts[i].uuid))
511 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
513 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
514 err = obd_create(lov->tgts[i].ltd_exp, tmp_oa, &obj_mdp, oti);
516 CERROR("error in orphan recovery on OST idx %d/%d: "
517 "rc = %d\n", i, lov->desc.ld_tgt_count, err);
529 #define LOV_CREATE_RESEED_INTERVAL 1000
531 /* the LOV expects oa->o_id to be set to the LOV object id */
532 static int lov_create(struct obd_export *exp, struct obdo *src_oa,
533 struct lov_stripe_md **ea, struct obd_trans_info *oti)
535 static int ost_start_idx, ost_start_count;
537 struct lov_stripe_md *lsm;
538 struct lov_oinfo *loi = NULL;
539 struct obdo *tmp_oa, *ret_oa;
540 struct llog_cookie *cookies = NULL;
541 unsigned ost_count, ost_idx;
542 int set = 0, obj_alloc = 0, cookie_sent = 0, rc = 0, i;
547 if ((src_oa->o_valid & OBD_MD_FLFLAGS) &&
548 src_oa->o_flags == OBD_FL_DELORPHAN) {
549 rc = lov_clear_orphans(exp, src_oa, ea, oti);
556 lov = &exp->exp_obd->u.lov;
558 if (!lov->desc.ld_active_tgt_count)
561 /* Recreate a specific object id at the given OST index */
562 if (src_oa->o_valid & OBD_MD_FLFLAGS && src_oa->o_flags &
563 OBD_FL_RECREATE_OBJS) {
564 struct lov_stripe_md obj_md;
565 struct lov_stripe_md *obj_mdp = &obj_md;
567 ost_idx = src_oa->o_nlink;
571 if (ost_idx >= lov->desc.ld_tgt_count)
573 for (i = 0; i < lsm->lsm_stripe_count; i++) {
574 if (lsm->lsm_oinfo[i].loi_ost_idx == ost_idx) {
575 if (lsm->lsm_oinfo[i].loi_id != src_oa->o_id)
580 if (i == lsm->lsm_stripe_count)
583 rc = obd_create(lov->tgts[ost_idx].ltd_exp, src_oa, &obj_mdp, oti);
587 ret_oa = obdo_alloc();
591 tmp_oa = obdo_alloc();
593 GOTO(out_oa, rc = -ENOMEM);
598 ost_count = lov_get_stripecnt(lov, 0);
600 /* If the MDS file was truncated up to some size, stripe over
601 * enough OSTs to allow the file to be created at that size. */
602 if (src_oa->o_valid & OBD_MD_FLSIZE) {
603 stripes=((src_oa->o_size+LUSTRE_STRIPE_MAXBYTES)>>12)-1;
604 do_div(stripes, (__u32)(LUSTRE_STRIPE_MAXBYTES >> 12));
606 if (stripes > lov->desc.ld_active_tgt_count)
608 if (stripes > ost_count)
614 rc = lov_alloc_memmd(&lsm, stripes, lov->desc.ld_pattern ?
615 lov->desc.ld_pattern : LOV_PATTERN_RAID0);
622 ost_count = lov->desc.ld_tgt_count;
624 LASSERT(src_oa->o_valid & OBD_MD_FLID);
625 lsm->lsm_object_id = src_oa->o_id;
626 if (!lsm->lsm_stripe_size)
627 lsm->lsm_stripe_size = lov->desc.ld_default_stripe_size;
628 if (!lsm->lsm_pattern) {
629 lsm->lsm_pattern = lov->desc.ld_pattern ?
630 lov->desc.ld_pattern : LOV_PATTERN_RAID0;
633 if (*ea == NULL || lsm->lsm_oinfo[0].loi_ost_idx >= ost_count) {
634 if (ost_start_count <= 0) {
635 ost_start_idx = ll_insecure_random_int();
636 ost_start_count = LOV_CREATE_RESEED_INTERVAL;
639 ost_start_idx += lsm->lsm_stripe_count;
641 ost_idx = ost_start_idx % ost_count;
643 ost_idx = lsm->lsm_oinfo[0].loi_ost_idx;
646 CDEBUG(D_INODE, "allocating %d subobjs for objid "LPX64" at idx %d\n",
647 lsm->lsm_stripe_count, lsm->lsm_object_id, ost_idx);
649 /* XXX LOV STACKING: need to figure out how many real OSCs */
650 if (oti && (src_oa->o_valid & OBD_MD_FLCOOKIE)) {
651 oti_alloc_cookies(oti, lsm->lsm_stripe_count);
652 if (!oti->oti_logcookies)
653 GOTO(out_cleanup, rc = -ENOMEM);
654 cookies = oti->oti_logcookies;
657 loi = lsm->lsm_oinfo;
658 for (i = 0; i < ost_count; i++, ost_idx = (ost_idx + 1) % ost_count) {
659 struct lov_stripe_md obj_md;
660 struct lov_stripe_md *obj_mdp = &obj_md;
663 if (lov->tgts[ost_idx].active == 0) {
664 CDEBUG(D_HA, "lov idx %d inactive\n", ost_idx);
668 /* create data objects with "parent" OA */
669 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
671 /* XXX When we start creating objects on demand, we need to
672 * make sure that we always create the object on the
673 * stripe which holds the existing file size.
675 if (src_oa->o_valid & OBD_MD_FLSIZE) {
676 if (lov_stripe_offset(lsm, src_oa->o_size, i,
677 &tmp_oa->o_size) < 0 &&
681 CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n",
682 i, tmp_oa->o_size, src_oa->o_size);
686 /* XXX: LOV STACKING: use real "obj_mdp" sub-data */
687 err = obd_create(lov->tgts[ost_idx].ltd_exp, tmp_oa, &obj_mdp,
690 if (lov->tgts[ost_idx].active) {
691 CERROR("error creating objid "LPX64" sub-object"
692 " on OST idx %d/%d: rc = %d\n",
693 src_oa->o_id, ost_idx,
694 lsm->lsm_stripe_count, err);
696 CERROR("obd_create returned invalid "
706 oti->oti_objid[ost_idx] = tmp_oa->o_id;
707 loi->loi_id = tmp_oa->o_id;
708 loi->loi_ost_idx = ost_idx;
709 CDEBUG(D_INODE, "objid "LPX64" has subobj "LPX64" at idx %d\n",
710 lsm->lsm_object_id, loi->loi_id, ost_idx);
712 lov_merge_attrs(ret_oa, tmp_oa, tmp_oa->o_valid, lsm,
717 ++oti->oti_logcookies;
718 if (tmp_oa->o_valid & OBD_MD_FLCOOKIE)
723 /* If we have allocated enough objects, we are OK */
724 if (obj_alloc == lsm->lsm_stripe_count)
725 GOTO(out_done, rc = 0);
728 if (obj_alloc == 0) {
731 GOTO(out_cleanup, rc);
734 /* If we were passed specific striping params, then a failure to
735 * meet those requirements is an error, since we can't reallocate
736 * that memory (it might be part of a larger array or something).
738 * We can only get here if lsm_stripe_count was originally > 1.
741 CERROR("can't lstripe objid "LPX64": have %u want %u, rc %d\n",
742 lsm->lsm_object_id, obj_alloc, lsm->lsm_stripe_count,rc);
745 GOTO(out_cleanup, rc);
747 struct lov_stripe_md *lsm_new;
748 /* XXX LOV STACKING call into osc for sizes */
749 unsigned oldsize, newsize;
751 if (oti && cookies && cookie_sent) {
752 oldsize = lsm->lsm_stripe_count * sizeof(*cookies);
753 newsize = obj_alloc * sizeof(*cookies);
755 oti_alloc_cookies(oti, obj_alloc);
756 if (oti->oti_logcookies) {
757 memcpy(oti->oti_logcookies, cookies, newsize);
758 OBD_FREE(cookies, oldsize);
759 cookies = oti->oti_logcookies;
761 CWARN("'leaking' %d bytes\n", oldsize-newsize);
765 CWARN("using fewer stripes for object "LPX64": old %u new %u\n",
766 lsm->lsm_object_id, lsm->lsm_stripe_count, obj_alloc);
767 oldsize = lov_stripe_md_size(lsm->lsm_stripe_count);
768 newsize = lov_stripe_md_size(obj_alloc);
769 OBD_ALLOC(lsm_new, newsize);
770 if (lsm_new != NULL) {
771 memcpy(lsm_new, lsm, newsize);
772 lsm_new->lsm_stripe_count = obj_alloc;
773 OBD_FREE(lsm, newsize);
776 CWARN("'leaking' %d bytes\n", oldsize - newsize);
783 if (src_oa->o_valid & OBD_MD_FLSIZE &&
784 ret_oa->o_size != src_oa->o_size) {
785 CERROR("original size "LPU64" isn't new object size "LPU64"\n",
786 src_oa->o_size, ret_oa->o_size);
789 ret_oa->o_id = src_oa->o_id;
790 memcpy(src_oa, ret_oa, sizeof(*src_oa));
796 if (oti && cookies) {
797 oti->oti_logcookies = cookies;
799 oti_free_cookies(oti);
800 src_oa->o_valid &= ~OBD_MD_FLCOOKIE;
802 src_oa->o_valid |= OBD_MD_FLCOOKIE;
808 while (obj_alloc-- > 0) {
809 struct obd_export *sub_exp;
813 sub_exp = lov->tgts[loi->loi_ost_idx].ltd_exp;
814 /* destroy already created objects here */
815 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
816 tmp_oa->o_id = loi->loi_id;
818 err = obd_destroy(sub_exp, tmp_oa, NULL, oti);
820 CERROR("Failed to uncreate objid "LPX64" subobj "LPX64
821 " on OST idx %d: rc = %d\n", src_oa->o_id,
822 loi->loi_id, loi->loi_ost_idx, err);
825 obd_free_memmd(exp, &lsm);
829 #define lsm_bad_magic(LSMP) \
831 struct lov_stripe_md *_lsm__ = (LSMP); \
834 CERROR("LOV requires striping ea\n"); \
836 } else if (_lsm__->lsm_magic != LOV_MAGIC) { \
837 CERROR("LOV striping magic bad %#x != %#x\n", \
838 _lsm__->lsm_magic, LOV_MAGIC); \
844 static int lov_destroy(struct obd_export *exp, struct obdo *oa,
845 struct lov_stripe_md *lsm, struct obd_trans_info *oti)
849 struct lov_oinfo *loi;
853 if (lsm_bad_magic(lsm))
856 if (!exp || !exp->exp_obd)
859 lov = &exp->exp_obd->u.lov;
860 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
862 if (lov->tgts[loi->loi_ost_idx].active == 0) {
863 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
864 /* Orphan clean up will (someday) fix this up. */
868 memcpy(&tmp, oa, sizeof(tmp));
869 tmp.o_id = loi->loi_id;
870 err = obd_destroy(lov->tgts[loi->loi_ost_idx].ltd_exp, &tmp,
872 if (err && lov->tgts[loi->loi_ost_idx].active) {
873 CERROR("error: destroying objid "LPX64" subobj "
874 LPX64" on OST idx %d: rc = %d\n",
875 oa->o_id, loi->loi_id, loi->loi_ost_idx, err);
883 static int lov_getattr(struct obd_export *exp, struct obdo *oa,
884 struct lov_stripe_md *lsm)
888 struct lov_oinfo *loi;
889 int i, rc = 0, set = 0;
892 if (lsm_bad_magic(lsm))
895 if (!exp || !exp->exp_obd)
898 lov = &exp->exp_obd->u.lov;
900 CDEBUG(D_INFO, "objid "LPX64": %ux%u byte stripes\n",
901 lsm->lsm_object_id, lsm->lsm_stripe_count, lsm->lsm_stripe_size);
902 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
905 if (lov->tgts[loi->loi_ost_idx].active == 0) {
906 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
910 CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
911 "%u\n", oa->o_id, i, loi->loi_id, loi->loi_ost_idx);
912 /* create data objects with "parent" OA */
913 memcpy(&tmp, oa, sizeof(tmp));
914 tmp.o_id = loi->loi_id;
916 err = obd_getattr(lov->tgts[loi->loi_ost_idx].ltd_exp, &tmp,
919 if (lov->tgts[loi->loi_ost_idx].active) {
920 CERROR("error: getattr objid "LPX64" subobj "
921 LPX64" on OST idx %d: rc = %d\n",
922 oa->o_id, loi->loi_id, loi->loi_ost_idx,
927 lov_merge_attrs(oa, &tmp, tmp.o_valid, lsm, i, &set);
935 static int lov_getattr_interpret(struct ptlrpc_request_set *rqset, void *data,
938 struct lov_getattr_async_args *aa = data;
939 struct lov_stripe_md *lsm = aa->aa_lsm;
940 struct obdo *oa = aa->aa_oa;
941 struct obdo *obdos = aa->aa_obdos;
942 struct lov_oinfo *loi;
948 /* NB all stripe requests succeeded to get here */
950 for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count;
952 if (obdos[i].o_valid == 0) /* inactive stripe */
955 lov_merge_attrs(oa, &obdos[i], obdos[i].o_valid, lsm,
960 CERROR ("No stripes had valid attrs\n");
965 OBD_FREE (obdos, lsm->lsm_stripe_count * sizeof (*obdos));
969 static int lov_getattr_async(struct obd_export *exp, struct obdo *oa,
970 struct lov_stripe_md *lsm,
971 struct ptlrpc_request_set *rqset)
975 struct lov_oinfo *loi;
976 struct lov_getattr_async_args *aa;
977 int i, rc = 0, set = 0;
980 if (lsm_bad_magic(lsm))
983 if (!exp || !exp->exp_obd)
986 lov = &exp->exp_obd->u.lov;
988 OBD_ALLOC (obdos, lsm->lsm_stripe_count * sizeof (*obdos));
992 CDEBUG(D_INFO, "objid "LPX64": %ux%u byte stripes\n",
993 lsm->lsm_object_id, lsm->lsm_stripe_count, lsm->lsm_stripe_size);
994 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
997 if (lov->tgts[loi->loi_ost_idx].active == 0) {
998 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
999 /* leaves obdos[i].obd_valid unset */
1003 CDEBUG(D_INFO, "objid "LPX64"[%d] has subobj "LPX64" at idx "
1004 "%u\n", oa->o_id, i, loi->loi_id, loi->loi_ost_idx);
1005 /* create data objects with "parent" OA */
1006 memcpy(&obdos[i], oa, sizeof(obdos[i]));
1007 obdos[i].o_id = loi->loi_id;
1009 err = obd_getattr_async(lov->tgts[loi->loi_ost_idx].ltd_exp,
1010 &obdos[i], NULL, rqset);
1012 CERROR("error: getattr objid "LPX64" subobj "
1013 LPX64" on OST idx %d: rc = %d\n",
1014 oa->o_id, loi->loi_id, loi->loi_ost_idx,
1016 GOTO(out_obdos, rc = err);
1021 GOTO (out_obdos, rc = -EIO);
1023 LASSERT (rqset->set_interpret == NULL);
1024 rqset->set_interpret = lov_getattr_interpret;
1025 LASSERT (sizeof (rqset->set_args) >= sizeof (*aa));
1026 aa = (struct lov_getattr_async_args *)&rqset->set_args;
1029 aa->aa_obdos = obdos;
1034 OBD_FREE (obdos, lsm->lsm_stripe_count * sizeof (*obdos));
1040 static int lov_setattr(struct obd_export *exp, struct obdo *src_oa,
1041 struct lov_stripe_md *lsm, struct obd_trans_info *oti)
1043 struct obdo *tmp_oa, *ret_oa;
1044 struct lov_obd *lov;
1045 struct lov_oinfo *loi;
1046 int rc = 0, i, set = 0;
1049 if (lsm_bad_magic(lsm))
1052 if (!exp || !exp->exp_obd)
1055 /* for now, we only expect time updates here */
1056 LASSERT(!(src_oa->o_valid & ~(OBD_MD_FLID|OBD_MD_FLTYPE | OBD_MD_FLMODE|
1057 OBD_MD_FLATIME | OBD_MD_FLMTIME |
1058 OBD_MD_FLCTIME | OBD_MD_FLFLAGS |
1060 ret_oa = obdo_alloc();
1064 tmp_oa = obdo_alloc();
1066 GOTO(out_oa, rc = -ENOMEM);
1068 lov = &exp->exp_obd->u.lov;
1069 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
1072 if (lov->tgts[loi->loi_ost_idx].active == 0) {
1073 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1077 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
1078 tmp_oa->o_id = loi->loi_id;
1080 if (src_oa->o_valid & OBD_MD_FLSIZE) {
1081 if (lov_stripe_offset(lsm, src_oa->o_size, i,
1082 &tmp_oa->o_size) < 0 &&
1086 CDEBUG(D_INODE, "stripe %d has size "LPU64"/"LPU64"\n",
1087 i, tmp_oa->o_size, src_oa->o_size);
1090 err = obd_setattr(lov->tgts[loi->loi_ost_idx].ltd_exp, tmp_oa,
1093 if (lov->tgts[loi->loi_ost_idx].active) {
1094 CERROR("error: setattr objid "LPX64" subobj "
1095 LPX64" on OST idx %d: rc = %d\n",
1096 src_oa->o_id, loi->loi_id,
1097 loi->loi_ost_idx, err);
1103 lov_merge_attrs(ret_oa, tmp_oa, tmp_oa->o_valid, lsm, i, &set);
1108 ret_oa->o_id = src_oa->o_id;
1109 memcpy(src_oa, ret_oa, sizeof(*src_oa));
1118 /* we have an offset in file backed by an lov and want to find out where
1119 * that offset lands in our given stripe of the file. for the easy
1120 * case where the offset is within the stripe, we just have to scale the
1121 * offset down to make it relative to the stripe instead of the lov.
1123 * the harder case is what to do when the offset doesn't intersect the
1124 * stripe. callers will want start offsets clamped ahead to the start
1125 * of the nearest stripe in the file. end offsets similarly clamped to the
1126 * nearest ending byte of a stripe in the file:
1128 * all this function does is move offsets to the nearest region of the
1129 * stripe, and it does its work "mod" the full length of all the stripes.
1130 * consider a file with 3 stripes:
1133 * ---------------------------------------------------------------------
1134 * | 0 | 1 | 2 | 0 | 1 | 2 |
1135 * ---------------------------------------------------------------------
1137 * to find stripe 1's offsets for S and E, it divides by the full stripe
1138 * width and does its math in the context of a single set of stripes:
1141 * -----------------------------------
1143 * -----------------------------------
1145 * it'll notice that E is outside stripe 1 and clamp it to the end of the
1146 * stripe, then multiply it back out by lov_off to give the real offsets in
1150 * ---------------------------------------------------------------------
1151 * | 1 | 1 | 1 | 1 | 1 | 1 |
1152 * ---------------------------------------------------------------------
1154 * it would have done similarly and pulled S forward to the start of a 1
1155 * stripe if, say, S had landed in a 0 stripe.
1157 * this rounding isn't always correct. consider an E lov offset that lands
1158 * on a 0 stripe, the "mod stripe width" math will pull it forward to the
1159 * start of a 1 stripe, when in fact it wanted to be rounded back to the end
1160 * of a previous 1 stripe. this logic is handled by callers and this is why:
1162 * this function returns < 0 when the offset was "before" the stripe and
1163 * was moved forward to the start of the stripe in question; 0 when it
1164 * falls in the stripe and no shifting was done; > 0 when the offset
1165 * was outside the stripe and was pulled back to its final byte. */
1166 static int lov_stripe_offset(struct lov_stripe_md *lsm, obd_off lov_off,
1167 int stripeno, obd_off *obd_off)
1169 unsigned long ssize = lsm->lsm_stripe_size;
1170 unsigned long swidth = ssize * lsm->lsm_stripe_count;
1171 unsigned long stripe_off, this_stripe;
1174 if (lov_off == OBD_OBJECT_EOF) {
1175 *obd_off = OBD_OBJECT_EOF;
1179 /* do_div(a, b) returns a % b, and a = a / b */
1180 stripe_off = do_div(lov_off, swidth);
1182 this_stripe = stripeno * ssize;
1183 if (stripe_off < this_stripe) {
1187 stripe_off -= this_stripe;
1189 if (stripe_off >= ssize) {
1195 *obd_off = lov_off * ssize + stripe_off;
1199 /* given an extent in an lov and a stripe, calculate the extent of the stripe
1200 * that is contained within the lov extent. this returns true if the given
1201 * stripe does intersect with the lov extent. */
1202 static int lov_stripe_intersects(struct lov_stripe_md *lsm, int stripeno,
1203 obd_off start, obd_off end,
1204 obd_off *obd_start, obd_off *obd_end)
1206 int start_side, end_side;
1208 start_side = lov_stripe_offset(lsm, start, stripeno, obd_start);
1209 end_side = lov_stripe_offset(lsm, end, stripeno, obd_end);
1211 CDEBUG(D_INODE, "["LPU64"->"LPU64"] -> [(%d) "LPU64"->"LPU64" (%d)]\n",
1212 start, end, start_side, *obd_start, *obd_end, end_side);
1214 /* this stripe doesn't intersect the file extent when neither
1215 * start or the end intersected the stripe and obd_start and
1216 * obd_end got rounded up to the save value. */
1217 if (start_side != 0 && end_side != 0 && *obd_start == *obd_end)
1220 /* as mentioned in the lov_stripe_offset commentary, end
1221 * might have been shifted in the wrong direction. This
1222 * happens when an end offset is before the stripe when viewed
1223 * through the "mod stripe size" math. we detect it being shifted
1224 * in the wrong direction and touch it up.
1225 * interestingly, this can't underflow since end must be > start
1226 * if we passed through the previous check.
1227 * (should we assert for that somewhere?) */
1234 /* compute which stripe number "lov_off" will be written into */
1235 static int lov_stripe_number(struct lov_stripe_md *lsm, obd_off lov_off)
1237 unsigned long ssize = lsm->lsm_stripe_size;
1238 unsigned long swidth = ssize * lsm->lsm_stripe_count;
1239 unsigned long stripe_off;
1241 stripe_off = do_div(lov_off, swidth);
1243 return stripe_off / ssize;
1246 /* FIXME: maybe we'll just make one node the authoritative attribute node, then
1247 * we can send this 'punch' to just the authoritative node and the nodes
1248 * that the punch will affect. */
1249 static int lov_punch(struct obd_export *exp, struct obdo *oa,
1250 struct lov_stripe_md *lsm,
1251 obd_off start, obd_off end, struct obd_trans_info *oti)
1254 struct lov_obd *lov;
1255 struct lov_oinfo *loi;
1259 if (lsm_bad_magic(lsm))
1262 if (!exp || !exp->exp_obd)
1265 lov = &exp->exp_obd->u.lov;
1266 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
1267 obd_off starti, endi;
1270 if (lov->tgts[loi->loi_ost_idx].active == 0) {
1271 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1275 if (!lov_stripe_intersects(lsm, i, start, end, &starti, &endi))
1278 /* create data objects with "parent" OA */
1279 memcpy(&tmp, oa, sizeof(tmp));
1280 tmp.o_id = loi->loi_id;
1282 err = obd_punch(lov->tgts[loi->loi_ost_idx].ltd_exp, &tmp, NULL,
1283 starti, endi, NULL);
1285 if (lov->tgts[loi->loi_ost_idx].active) {
1286 CERROR("error: punch objid "LPX64" subobj "LPX64
1287 " on OST idx %d: rc = %d\n", oa->o_id,
1288 loi->loi_id, loi->loi_ost_idx, err);
1297 static int lov_sync(struct obd_export *exp, struct obdo *oa,
1298 struct lov_stripe_md *lsm, obd_off start, obd_off end)
1301 struct lov_obd *lov;
1302 struct lov_oinfo *loi;
1306 if (lsm_bad_magic(lsm))
1316 lov = &exp->exp_obd->u.lov;
1317 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
1318 obd_off starti, endi;
1321 if (lov->tgts[loi->loi_ost_idx].active == 0) {
1322 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1326 if (!lov_stripe_intersects(lsm, i, start, end, &starti, &endi))
1329 memcpy(tmp, oa, sizeof(*tmp));
1330 tmp->o_id = loi->loi_id;
1332 err = obd_sync(lov->tgts[loi->loi_ost_idx].ltd_exp, tmp, NULL,
1335 if (lov->tgts[loi->loi_ost_idx].active) {
1336 CERROR("error: fsync objid "LPX64" subobj "LPX64
1337 " on OST idx %d: rc = %d\n", oa->o_id,
1338 loi->loi_id, loi->loi_ost_idx, err);
1349 static int lov_brw_check(struct lov_obd *lov, struct obdo *oa,
1350 struct lov_stripe_md *lsm,
1351 obd_count oa_bufs, struct brw_page *pga)
1355 /* The caller just wants to know if there's a chance that this
1356 * I/O can succeed */
1357 for (i = 0; i < oa_bufs; i++) {
1358 int stripe = lov_stripe_number(lsm, pga[i].off);
1359 int ost = lsm->lsm_oinfo[stripe].loi_ost_idx;
1360 struct ldlm_extent ext, subext;
1361 ext.start = pga[i].off;
1362 ext.end = pga[i].off + pga[i].count;
1364 if (!lov_stripe_intersects(lsm, i, ext.start, ext.end,
1365 &subext.start, &subext.end))
1368 if (lov->tgts[ost].active == 0) {
1369 CDEBUG(D_HA, "lov idx %d inactive\n", ost);
1372 rc = obd_brw(OBD_BRW_CHECK, lov->tgts[stripe].ltd_exp, oa,
1373 NULL, 1, &pga[i], NULL);
1380 static int lov_brw(int cmd, struct obd_export *exp, struct obdo *src_oa,
1381 struct lov_stripe_md *lsm, obd_count oa_bufs,
1382 struct brw_page *pga, struct obd_trans_info *oti)
1388 struct lov_stripe_md lsm;
1390 } *stripeinfo, *si, *si_last;
1391 struct obdo *ret_oa = NULL, *tmp_oa = NULL;
1392 struct lov_obd *lov;
1393 struct brw_page *ioarr;
1394 struct lov_oinfo *loi;
1395 int rc = 0, i, *where, stripe_count = lsm->lsm_stripe_count, set = 0;
1398 if (lsm_bad_magic(lsm))
1401 lov = &exp->exp_obd->u.lov;
1403 if (cmd == OBD_BRW_CHECK) {
1404 rc = lov_brw_check(lov, src_oa, lsm, oa_bufs, pga);
1408 OBD_ALLOC(stripeinfo, stripe_count * sizeof(*stripeinfo));
1412 OBD_ALLOC(where, sizeof(*where) * oa_bufs);
1414 GOTO(out_sinfo, rc = -ENOMEM);
1416 OBD_ALLOC(ioarr, sizeof(*ioarr) * oa_bufs);
1418 GOTO(out_where, rc = -ENOMEM);
1421 ret_oa = obdo_alloc();
1423 GOTO(out_ioarr, rc = -ENOMEM);
1425 tmp_oa = obdo_alloc();
1427 GOTO(out_oa, rc = -ENOMEM);
1430 for (i = 0; i < oa_bufs; i++) {
1431 where[i] = lov_stripe_number(lsm, pga[i].off);
1432 stripeinfo[where[i]].bufct++;
1435 for (i = 0, loi = lsm->lsm_oinfo, si_last = si = stripeinfo;
1436 i < stripe_count; i++, loi++, si_last = si, si++) {
1438 si->index = si_last->index + si_last->bufct;
1439 si->lsm.lsm_object_id = loi->loi_id;
1440 si->ost_idx = loi->loi_ost_idx;
1443 for (i = 0; i < oa_bufs; i++) {
1444 int which = where[i];
1447 shift = stripeinfo[which].index + stripeinfo[which].subcount;
1448 LASSERT(shift < oa_bufs);
1449 ioarr[shift] = pga[i];
1450 lov_stripe_offset(lsm, pga[i].off, which, &ioarr[shift].off);
1451 stripeinfo[which].subcount++;
1454 for (i = 0, si = stripeinfo; i < stripe_count; i++, si++) {
1455 int shift = si->index;
1457 if (lov->tgts[si->ost_idx].active == 0) {
1458 CDEBUG(D_HA, "lov idx %d inactive\n", si->ost_idx);
1459 GOTO(out_oa, rc = -EIO);
1463 LASSERT(shift < oa_bufs);
1465 memcpy(tmp_oa, src_oa, sizeof(*tmp_oa));
1467 tmp_oa->o_id = si->lsm.lsm_object_id;
1468 rc = obd_brw(cmd, lov->tgts[si->ost_idx].ltd_exp,
1469 tmp_oa, &si->lsm, si->bufct,
1470 &ioarr[shift], oti);
1472 GOTO(out_ioarr, rc);
1474 lov_merge_attrs(ret_oa, tmp_oa, tmp_oa->o_valid, lsm,
1479 ret_oa->o_id = src_oa->o_id;
1480 memcpy(src_oa, ret_oa, sizeof(*src_oa));
1489 OBD_FREE(ioarr, sizeof(*ioarr) * oa_bufs);
1491 OBD_FREE(where, sizeof(*where) * oa_bufs);
1493 OBD_FREE(stripeinfo, stripe_count * sizeof(*stripeinfo));
1497 static int lov_brw_interpret(struct ptlrpc_request_set *reqset, void *data,
1500 struct lov_brw_async_args *aa = data;
1501 struct lov_stripe_md *lsm = aa->aa_lsm;
1502 obd_count oa_bufs = aa->aa_oa_bufs;
1503 struct obdo *oa = aa->aa_oa;
1504 struct obdo *obdos = aa->aa_obdos;
1505 struct brw_page *ioarr = aa->aa_ioarr;
1506 struct lov_oinfo *loi;
1511 /* NB all stripe requests succeeded to get here */
1513 for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count;
1515 if (obdos[i].o_valid == 0) /* inactive stripe */
1518 lov_merge_attrs(oa, &obdos[i], obdos[i].o_valid, lsm,
1523 CERROR("No stripes had valid attrs\n");
1527 oa->o_id = lsm->lsm_object_id;
1529 OBD_FREE(obdos, lsm->lsm_stripe_count * sizeof(*obdos));
1530 OBD_FREE(ioarr, sizeof(*ioarr) * oa_bufs);
1534 static int lov_brw_async(int cmd, struct obd_export *exp, struct obdo *oa,
1535 struct lov_stripe_md *lsm, obd_count oa_bufs,
1536 struct brw_page *pga, struct ptlrpc_request_set *set,
1537 struct obd_trans_info *oti)
1543 struct lov_stripe_md lsm;
1545 } *stripeinfo, *si, *si_last;
1546 struct lov_obd *lov;
1547 struct brw_page *ioarr;
1548 struct obdo *obdos = NULL;
1549 struct lov_oinfo *loi;
1550 struct lov_brw_async_args *aa;
1551 int rc = 0, i, *where, stripe_count = lsm->lsm_stripe_count;
1554 if (lsm_bad_magic(lsm))
1557 lov = &exp->exp_obd->u.lov;
1559 if (cmd == OBD_BRW_CHECK) {
1560 rc = lov_brw_check(lov, oa, lsm, oa_bufs, pga);
1564 OBD_ALLOC(stripeinfo, stripe_count * sizeof(*stripeinfo));
1568 OBD_ALLOC(where, sizeof(*where) * oa_bufs);
1570 GOTO(out_sinfo, rc = -ENOMEM);
1573 OBD_ALLOC(obdos, sizeof(*obdos) * stripe_count);
1575 GOTO(out_where, rc = -ENOMEM);
1578 OBD_ALLOC(ioarr, sizeof(*ioarr) * oa_bufs);
1580 GOTO(out_obdos, rc = -ENOMEM);
1582 for (i = 0; i < oa_bufs; i++) {
1583 where[i] = lov_stripe_number(lsm, pga[i].off);
1584 stripeinfo[where[i]].bufct++;
1587 for (i = 0, loi = lsm->lsm_oinfo, si_last = si = stripeinfo;
1588 i < stripe_count; i++, loi++, si_last = si, si++) {
1590 si->index = si_last->index + si_last->bufct;
1591 si->lsm.lsm_object_id = loi->loi_id;
1592 si->ost_idx = loi->loi_ost_idx;
1595 memcpy(&obdos[i], oa, sizeof(*obdos));
1596 obdos[i].o_id = si->lsm.lsm_object_id;
1600 for (i = 0; i < oa_bufs; i++) {
1601 int which = where[i];
1604 shift = stripeinfo[which].index + stripeinfo[which].subcount;
1605 LASSERT(shift < oa_bufs);
1606 ioarr[shift] = pga[i];
1607 lov_stripe_offset(lsm, pga[i].off, which, &ioarr[shift].off);
1608 stripeinfo[which].subcount++;
1611 for (i = 0, si = stripeinfo; i < stripe_count; i++, si++) {
1612 int shift = si->index;
1617 if (lov->tgts[si->ost_idx].active == 0) {
1618 CDEBUG(D_HA, "lov idx %d inactive\n", si->ost_idx);
1619 GOTO(out_ioarr, rc = -EIO);
1622 LASSERT(shift < oa_bufs);
1624 rc = obd_brw_async(cmd, lov->tgts[si->ost_idx].ltd_exp,
1625 &obdos[i], &si->lsm, si->bufct,
1626 &ioarr[shift], set, oti);
1628 GOTO(out_ioarr, rc);
1631 LASSERT(set->set_interpret == NULL);
1632 set->set_interpret = (set_interpreter_func)lov_brw_interpret;
1633 LASSERT(sizeof(set->set_args) >= sizeof(struct lov_brw_async_args));
1634 aa = (struct lov_brw_async_args *)&set->set_args;
1636 aa->aa_obdos = obdos;
1638 aa->aa_ioarr = ioarr;
1639 aa->aa_oa_bufs = oa_bufs;
1641 /* Don't free ioarr or obdos - that's done in lov_brw_interpret */
1642 GOTO(out_where, rc);
1645 OBD_FREE(ioarr, sizeof(*ioarr) * oa_bufs);
1647 OBD_FREE(obdos, stripe_count * sizeof(*obdos));
1649 OBD_FREE(where, sizeof(*where) * oa_bufs);
1651 OBD_FREE(stripeinfo, stripe_count * sizeof(*stripeinfo));
1655 struct lov_async_page *lap_from_cookie(void *cookie)
1657 struct lov_async_page *lap = cookie;
1658 if (lap->lap_magic != LAP_MAGIC)
1659 return ERR_PTR(-EINVAL);
1663 static int lov_ap_make_ready(void *data, int cmd)
1665 struct lov_async_page *lap = lap_from_cookie(data);
1666 /* XXX should these assert? */
1670 return lap->lap_caller_ops->ap_make_ready(lap->lap_caller_data, cmd);
1672 static int lov_ap_refresh_count(void *data, int cmd)
1674 struct lov_async_page *lap = lap_from_cookie(data);
1678 return lap->lap_caller_ops->ap_refresh_count(lap->lap_caller_data,
1681 static void lov_ap_fill_obdo(void *data, int cmd, struct obdo *oa)
1683 struct lov_async_page *lap = lap_from_cookie(data);
1684 /* XXX should these assert? */
1688 lap->lap_caller_ops->ap_fill_obdo(lap->lap_caller_data, cmd, oa);
1689 /* XXX woah, shouldn't we be altering more here? size? */
1690 oa->o_id = lap->lap_loi_id;
1692 static void lov_ap_completion(void *data, int cmd, int rc)
1694 struct lov_async_page *lap = lap_from_cookie(data);
1698 /* in a raid1 regime this would down a count of many ios
1699 * in flight, onl calling the caller_ops completion when all
1700 * the raid1 ios are complete */
1701 lap->lap_caller_ops->ap_completion(lap->lap_caller_data, cmd, rc);
1704 static struct obd_async_page_ops lov_async_page_ops = {
1705 .ap_make_ready = lov_ap_make_ready,
1706 .ap_refresh_count = lov_ap_refresh_count,
1707 .ap_fill_obdo = lov_ap_fill_obdo,
1708 .ap_completion = lov_ap_completion,
1711 int lov_prep_async_page(struct obd_export *exp, struct lov_stripe_md *lsm,
1712 struct lov_oinfo *loi, struct page *page,
1713 obd_off offset, struct obd_async_page_ops *ops,
1714 void *data, void **res)
1716 struct lov_obd *lov = &exp->exp_obd->u.lov;
1717 struct lov_async_page *lap;
1721 if (lsm_bad_magic(lsm))
1723 LASSERT(loi == NULL);
1725 OBD_ALLOC(lap, sizeof(*lap));
1729 lap->lap_magic = LAP_MAGIC;
1730 lap->lap_caller_ops = ops;
1731 lap->lap_caller_data = data;
1733 /* for now only raid 0 which passes through */
1734 lap->lap_stripe = lov_stripe_number(lsm, offset);
1735 lov_stripe_offset(lsm, offset, lap->lap_stripe, &lap->lap_sub_offset);
1736 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1738 /* so the callback doesn't need the lsm */
1739 lap->lap_loi_id = loi->loi_id;
1741 rc = obd_prep_async_page(lov->tgts[loi->loi_ost_idx].ltd_exp,
1742 lsm, loi, page, lap->lap_sub_offset,
1743 &lov_async_page_ops, lap,
1744 &lap->lap_sub_cookie);
1746 OBD_FREE(lap, sizeof(*lap));
1749 CDEBUG(D_CACHE, "lap %p page %p cookie %p off "LPU64"\n", lap, page,
1750 lap->lap_sub_cookie, offset);
1755 static int lov_queue_async_io(struct obd_export *exp,
1756 struct lov_stripe_md *lsm,
1757 struct lov_oinfo *loi, void *cookie,
1758 int cmd, obd_off off, int count,
1759 obd_flag brw_flags, obd_flag async_flags)
1761 struct lov_obd *lov = &exp->exp_obd->u.lov;
1762 struct lov_async_page *lap;
1765 LASSERT(loi == NULL);
1767 if (lsm_bad_magic(lsm))
1770 lap = lap_from_cookie(cookie);
1772 RETURN(PTR_ERR(lap));
1774 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1775 rc = obd_queue_async_io(lov->tgts[loi->loi_ost_idx].ltd_exp, lsm,
1776 loi, lap->lap_sub_cookie, cmd, off, count,
1777 brw_flags, async_flags);
1781 static int lov_set_async_flags(struct obd_export *exp,
1782 struct lov_stripe_md *lsm,
1783 struct lov_oinfo *loi, void *cookie,
1784 obd_flag async_flags)
1786 struct lov_obd *lov = &exp->exp_obd->u.lov;
1787 struct lov_async_page *lap;
1790 LASSERT(loi == NULL);
1792 if (lsm_bad_magic(lsm))
1795 lap = lap_from_cookie(cookie);
1797 RETURN(PTR_ERR(lap));
1799 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1800 rc = obd_set_async_flags(lov->tgts[loi->loi_ost_idx].ltd_exp,
1801 lsm, loi, lap->lap_sub_cookie, async_flags);
1805 static int lov_queue_sync_io(struct obd_export *exp,
1806 struct lov_stripe_md *lsm,
1807 struct lov_oinfo *loi,
1808 struct obd_sync_io_container *osic, void *cookie,
1809 int cmd, obd_off off, int count,
1812 struct lov_obd *lov = &exp->exp_obd->u.lov;
1813 struct lov_async_page *lap;
1816 LASSERT(loi == NULL);
1818 if (lsm_bad_magic(lsm))
1821 lap = lap_from_cookie(cookie);
1823 RETURN(PTR_ERR(lap));
1825 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1826 rc = obd_queue_sync_io(lov->tgts[loi->loi_ost_idx].ltd_exp, lsm, loi,
1827 osic, lap->lap_sub_cookie, cmd, off, count,
1832 /* this isn't exactly optimal. we may have queued sync io in oscs on
1833 * all stripes, but we don't record that fact at queue time. so we
1834 * trigger sync io on all stripes. */
1835 static int lov_trigger_sync_io(struct obd_export *exp,
1836 struct lov_stripe_md *lsm,
1837 struct lov_oinfo *loi,
1838 struct obd_sync_io_container *osic)
1840 struct lov_obd *lov = &exp->exp_obd->u.lov;
1843 LASSERT(loi == NULL);
1845 if (lsm_bad_magic(lsm))
1848 for (i = 0, loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count;
1850 err = obd_trigger_sync_io(lov->tgts[loi->loi_ost_idx].ltd_exp,
1852 if (rc == 0 && err != 0)
1858 static int lov_teardown_async_page(struct obd_export *exp,
1859 struct lov_stripe_md *lsm,
1860 struct lov_oinfo *loi, void *cookie)
1862 struct lov_obd *lov = &exp->exp_obd->u.lov;
1863 struct lov_async_page *lap;
1866 LASSERT(loi == NULL);
1868 if (lsm_bad_magic(lsm))
1871 lap = lap_from_cookie(cookie);
1873 RETURN(PTR_ERR(lap));
1875 loi = &lsm->lsm_oinfo[lap->lap_stripe];
1876 rc = obd_teardown_async_page(lov->tgts[loi->loi_ost_idx].ltd_exp,
1877 lsm, loi, lap->lap_sub_cookie);
1879 CERROR("unable to teardown sub cookie %p: %d\n",
1880 lap->lap_sub_cookie, rc);
1883 OBD_FREE(lap, sizeof(*lap));
1887 static int lov_enqueue(struct obd_export *exp, struct lov_stripe_md *lsm,
1888 struct lustre_handle *parent_lock,
1889 __u32 type, void *cookie, int cookielen, __u32 mode,
1890 int *flags, void *cb, void *data,
1891 struct lustre_handle *lockh)
1893 struct lov_obd *lov;
1894 struct lov_oinfo *loi;
1895 struct lov_stripe_md submd;
1896 struct ldlm_extent *extent = cookie;
1900 if (lsm_bad_magic(lsm))
1903 /* we should never be asked to replay a lock this way. */
1904 LASSERT((*flags & LDLM_FL_REPLAY) == 0);
1906 if (!exp || !exp->exp_obd)
1909 lov = &exp->exp_obd->u.lov;
1910 loi = lsm->lsm_oinfo;
1911 if (lov->tgts[loi->loi_ost_idx].active == 0) {
1912 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1916 /* XXX LOV STACKING: submd should be from the subobj */
1917 submd.lsm_object_id = loi->loi_id;
1918 submd.lsm_stripe_count = 0;
1919 /* XXX submd is not fully initialized here */
1921 rc = obd_enqueue(lov->tgts[loi->loi_ost_idx].ltd_exp, &submd,
1922 parent_lock, type, extent, sizeof(*extent),
1923 mode, flags, cb, data, lockh);
1925 if (rc != ELDLM_OK) {
1926 memset(lockh, 0, sizeof(*lockh));
1927 if (lov->tgts[loi->loi_ost_idx].active)
1928 CERROR("error: enqueue objid "LPX64" subobj "
1929 LPX64" on OST idx %d: rc = %d\n",
1930 lsm->lsm_object_id, loi->loi_id,
1931 loi->loi_ost_idx, rc);
1936 static int lov_match(struct obd_export *exp, struct lov_stripe_md *lsm,
1937 __u32 type, void *cookie, int cookielen, __u32 mode,
1938 int *flags, void *data, struct lustre_handle *lockh)
1940 struct lov_obd *lov;
1941 struct lov_oinfo *loi;
1942 struct lov_stripe_md submd;
1943 struct ldlm_extent *extent = cookie;
1947 if (lsm_bad_magic(lsm))
1950 if (!exp || !exp->exp_obd)
1953 lov = &exp->exp_obd->u.lov;
1954 loi = lsm->lsm_oinfo;
1955 if (lov->tgts[loi->loi_ost_idx].active == 0) {
1956 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1960 /* XXX LOV STACKING: submd should be from the subobj */
1961 submd.lsm_object_id = loi->loi_id;
1962 submd.lsm_stripe_count = 0;
1963 /* XXX submd is not fully initialized here */
1964 rc = obd_match(lov->tgts[loi->loi_ost_idx].ltd_exp, &submd, type,
1965 extent, sizeof(*extent), mode, flags, data, lockh);
1969 static int lov_change_cbdata(struct obd_export *exp,
1970 struct lov_stripe_md *lsm, ldlm_iterator_t it,
1973 struct lov_obd *lov;
1974 struct lov_oinfo *loi;
1978 if (lsm_bad_magic(lsm))
1981 if (!exp || !exp->exp_obd)
1984 lov = &exp->exp_obd->u.lov;
1985 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
1986 struct lov_stripe_md submd;
1987 if (lov->tgts[loi->loi_ost_idx].active == 0)
1988 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
1990 submd.lsm_object_id = loi->loi_id;
1991 submd.lsm_stripe_count = 0;
1992 rc = obd_change_cbdata(lov->tgts[loi->loi_ost_idx].ltd_exp,
1998 static int lov_cancel(struct obd_export *exp, struct lov_stripe_md *lsm,
1999 __u32 mode, struct lustre_handle *lockh)
2001 struct lov_obd *lov;
2002 struct lov_oinfo *loi;
2003 struct lov_stripe_md submd;
2007 if (lsm_bad_magic(lsm))
2010 if (!exp || !exp->exp_obd)
2013 lov = &exp->exp_obd->u.lov;
2014 loi = lsm->lsm_oinfo;
2016 /* XXX LOV STACKING: submd should be from the subobj */
2017 submd.lsm_object_id = loi->loi_id;
2018 submd.lsm_stripe_count = 0;
2019 rc = obd_cancel(lov->tgts[loi->loi_ost_idx].ltd_exp, &submd,
2021 if (rc && lov->tgts[loi->loi_ost_idx].active)
2022 CERROR("error: cancel objid "LPX64" subobj "
2023 LPX64" on OST idx %d: rc = %d\n",
2024 lsm->lsm_object_id, loi->loi_id, loi->loi_ost_idx, rc);
2030 static int lov_cancel_unused(struct obd_export *exp,
2031 struct lov_stripe_md *lsm, int flags, void *opaque)
2033 struct lov_obd *lov;
2034 struct lov_oinfo *loi;
2038 if (lsm_bad_magic(lsm))
2041 if (!exp || !exp->exp_obd)
2044 lov = &exp->exp_obd->u.lov;
2045 for (i = 0,loi = lsm->lsm_oinfo; i < lsm->lsm_stripe_count; i++,loi++) {
2046 struct lov_stripe_md submd;
2049 if (lov->tgts[loi->loi_ost_idx].active == 0)
2050 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
2052 submd.lsm_object_id = loi->loi_id;
2053 submd.lsm_stripe_count = 0;
2054 err = obd_cancel_unused(lov->tgts[loi->loi_ost_idx].ltd_exp,
2055 &submd, flags, opaque);
2056 if (err && lov->tgts[loi->loi_ost_idx].active) {
2057 CERROR("error: cancel unused objid "LPX64" subobj "LPX64
2058 " on OST idx %d: rc = %d\n", lsm->lsm_object_id,
2059 loi->loi_id, loi->loi_ost_idx, err);
2067 #define LOV_U64_MAX ((__u64)~0ULL)
2068 #define LOV_SUM_MAX(tot, add) \
2070 if ((tot) + (add) < (tot)) \
2071 (tot) = LOV_U64_MAX; \
2076 static int lov_statfs(struct obd_device *obd, struct obd_statfs *osfs,
2077 unsigned long max_age)
2079 struct lov_obd *lov = &obd->u.lov;
2080 struct obd_statfs lov_sfs;
2087 /* We only get block data from the OBD */
2088 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
2091 if (!lov->tgts[i].active) {
2092 CDEBUG(D_HA, "lov idx %d inactive\n", i);
2096 err = obd_statfs(class_exp2obd(lov->tgts[i].ltd_exp), &lov_sfs,
2099 if (lov->tgts[i].active && !rc)
2105 memcpy(osfs, &lov_sfs, sizeof(lov_sfs));
2108 osfs->os_bfree += lov_sfs.os_bfree;
2109 osfs->os_bavail += lov_sfs.os_bavail;
2110 osfs->os_blocks += lov_sfs.os_blocks;
2111 /* XXX not sure about this one - depends on policy.
2112 * - could be minimum if we always stripe on all OBDs
2113 * (but that would be wrong for any other policy,
2114 * if one of the OBDs has no more objects left)
2115 * - could be sum if we stripe whole objects
2116 * - could be average, just to give a nice number
2118 * To give a "reasonable" (if not wholly accurate)
2119 * number, we divide the total number of free objects
2120 * by expected stripe count (watch out for overflow).
2122 LOV_SUM_MAX(osfs->os_files, lov_sfs.os_files);
2123 LOV_SUM_MAX(osfs->os_ffree, lov_sfs.os_ffree);
2128 __u32 expected_stripes = lov->desc.ld_default_stripe_count ?
2129 lov->desc.ld_default_stripe_count :
2130 lov->desc.ld_active_tgt_count;
2132 if (osfs->os_files != LOV_U64_MAX)
2133 do_div(osfs->os_files, expected_stripes);
2134 if (osfs->os_ffree != LOV_U64_MAX)
2135 do_div(osfs->os_ffree, expected_stripes);
2142 static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
2143 void *karg, void *uarg)
2145 struct obd_device *obddev = class_exp2obd(exp);
2146 struct lov_obd *lov = &obddev->u.lov;
2147 int i, count = lov->desc.ld_tgt_count;
2148 struct obd_uuid *uuidp;
2154 case OBD_IOC_LOV_GET_CONFIG: {
2155 struct obd_ioctl_data *data = karg;
2156 struct lov_tgt_desc *tgtdesc;
2157 struct lov_desc *desc;
2162 if (obd_ioctl_getdata(&buf, &len, (void *)uarg))
2165 data = (struct obd_ioctl_data *)buf;
2167 if (sizeof(*desc) > data->ioc_inllen1) {
2172 if (sizeof(uuidp->uuid) * count > data->ioc_inllen2) {
2177 desc = (struct lov_desc *)data->ioc_inlbuf1;
2178 memcpy(desc, &(lov->desc), sizeof(*desc));
2180 uuidp = (struct obd_uuid *)data->ioc_inlbuf2;
2181 tgtdesc = lov->tgts;
2182 for (i = 0; i < count; i++, uuidp++, tgtdesc++)
2183 obd_str2uuid(uuidp, tgtdesc->uuid.uuid);
2185 rc = copy_to_user((void *)uarg, buf, len);
2188 obd_ioctl_freedata(buf, len);
2191 case LL_IOC_LOV_SETSTRIPE:
2192 rc = lov_setstripe(exp, karg, uarg);
2194 case LL_IOC_LOV_GETSTRIPE:
2195 rc = lov_getstripe(exp, karg, uarg);
2197 case LL_IOC_LOV_SETEA:
2198 rc = lov_setea(exp, karg, uarg);
2205 for (i = 0; i < count; i++) {
2208 err = obd_iocontrol(cmd, lov->tgts[i].ltd_exp,
2211 if (lov->tgts[i].active) {
2212 CERROR("error: iocontrol OSC %s on OST"
2213 "idx %d: err = %d\n",
2214 lov->tgts[i].uuid.uuid, i, err);
2229 static int lov_get_info(struct obd_export *exp, __u32 keylen,
2230 void *key, __u32 *vallen, void *val)
2232 struct obd_device *obddev = class_exp2obd(exp);
2233 struct lov_obd *lov = &obddev->u.lov;
2237 if (!vallen || !val)
2240 if (keylen > strlen("lock_to_stripe") &&
2241 strcmp(key, "lock_to_stripe") == 0) {
2244 struct ldlm_lock *lock;
2245 struct lov_stripe_md *lsm;
2247 struct lov_oinfo *loi;
2248 __u32 *stripe = val;
2250 if (*vallen < sizeof(*stripe))
2252 *vallen = sizeof(*stripe);
2254 /* XXX This is another one of those bits that will need to
2255 * change if we ever actually support nested LOVs. It uses
2256 * the lock's export to find out which stripe it is. */
2257 for (i = 0, loi = data->lsm->lsm_oinfo;
2258 i < data->lsm->lsm_stripe_count;
2260 if (lov->tgts[loi->loi_ost_idx].ltd_exp ==
2261 data->lock->l_conn_export) {
2267 } else if (keylen >= strlen("last_id") && strcmp(key, "last_id") == 0) {
2269 int rc, size = sizeof(obd_id);
2270 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
2271 if (!lov->tgts[i].active)
2273 rc = obd_get_info(lov->tgts[i].ltd_exp, keylen, key,
2279 } else if (keylen >= strlen("lovdesc") && strcmp(key, "lovdesc") == 0) {
2280 struct lov_desc *desc_ret = val;
2281 *desc_ret = lov->desc;
2289 static int lov_set_info(struct obd_export *exp, obd_count keylen,
2290 void *key, obd_count vallen, void *val)
2292 struct obd_device *obddev = class_exp2obd(exp);
2293 struct lov_obd *lov = &obddev->u.lov;
2297 #define KEY_IS(str) \
2298 (keylen == strlen(str) && memcmp(key, str, keylen) == 0)
2300 if (KEY_IS("next_id")) {
2301 if (vallen != lov->desc.ld_tgt_count)
2303 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
2306 if (!lov->tgts[i].active)
2309 er = obd_set_info(lov->tgts[i].ltd_exp, keylen, key,
2310 sizeof(obd_id), ((obd_id*)val) + i);
2317 if (KEY_IS("growth_count")) {
2318 if (vallen != sizeof(int))
2320 } else if (KEY_IS("mds_conn") || KEY_IS("unlinked")) {
2327 for (i = 0; i < lov->desc.ld_tgt_count; i++) {
2330 if (!lov->tgts[i].active)
2333 er = obd_set_info(lov->tgts[i].ltd_exp, keylen, key, vallen,
2344 static int lov_lock_contains(struct obd_export *exp, struct lov_stripe_md *lsm,
2345 struct ldlm_lock *lock, obd_off offset)
2347 struct lov_obd *lov;
2348 struct lov_oinfo *loi;
2349 struct lov_stripe_md submd;
2353 LASSERT(lsm != NULL);
2357 lov = &exp->exp_obd->u.lov;
2358 loi = lsm->lsm_oinfo;
2360 if (lov->tgts[loi->loi_ost_idx].active == 0) {
2361 CDEBUG(D_HA, "lov idx %d inactive\n", loi->loi_ost_idx);
2365 /* XXX submd is not fully initialized here */
2366 /* XXX LOV STACKING: submd should be from the subobj */
2367 submd.lsm_object_id = loi->loi_id;
2368 submd.lsm_stripe_count = 0;
2370 rc = obd_lock_contains(lov->tgts[loi->loi_ost_idx].ltd_exp, &submd,
2375 struct obd_ops lov_obd_ops = {
2376 o_owner: THIS_MODULE,
2377 o_attach: lov_attach,
2378 o_detach: lov_detach,
2380 o_cleanup: lov_cleanup,
2381 o_connect: lov_connect,
2382 o_disconnect: lov_disconnect,
2383 o_statfs: lov_statfs,
2384 o_packmd: lov_packmd,
2385 o_unpackmd: lov_unpackmd,
2386 o_create: lov_create,
2387 o_destroy: lov_destroy,
2388 o_getattr: lov_getattr,
2389 o_getattr_async: lov_getattr_async,
2390 o_setattr: lov_setattr,
2392 o_brw_async: lov_brw_async,
2393 .o_prep_async_page = lov_prep_async_page,
2394 .o_queue_async_io = lov_queue_async_io,
2395 .o_set_async_flags = lov_set_async_flags,
2396 .o_queue_sync_io = lov_queue_sync_io,
2397 .o_trigger_sync_io = lov_trigger_sync_io,
2398 .o_teardown_async_page lov_teardown_async_page,
2401 o_enqueue: lov_enqueue,
2403 o_change_cbdata: lov_change_cbdata,
2404 o_cancel: lov_cancel,
2405 o_cancel_unused: lov_cancel_unused,
2406 o_iocontrol: lov_iocontrol,
2407 o_get_info: lov_get_info,
2408 o_set_info: lov_set_info,
2409 o_llog_init: lov_llog_init,
2410 o_llog_finish: lov_llog_finish,
2411 o_lock_contains:lov_lock_contains,
2412 o_notify: lov_notify,
2415 int __init lov_init(void)
2417 struct lprocfs_static_vars lvars;
2420 lprocfs_init_vars(lov, &lvars);
2421 rc = class_register_type(&lov_obd_ops, lvars.module_vars,
2422 OBD_LOV_DEVICENAME);
2427 static void /*__exit*/ lov_exit(void)
2429 class_unregister_type(OBD_LOV_DEVICENAME);
2432 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
2433 MODULE_DESCRIPTION("Lustre Logical Object Volume OBD driver");
2434 MODULE_LICENSE("GPL");
2436 module_init(lov_init);
2437 module_exit(lov_exit);