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.
6 * This file is part of Lustre, http://www.lustre.org.
8 * Lustre is free software; you can redistribute it and/or
9 * modify it under the terms of version 2 of the GNU General Public
10 * License as published by the Free Software Foundation.
12 * Lustre is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Lustre; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 # define EXPORT_SYMTAB
25 #define DEBUG_SUBSYSTEM S_LMV
27 #include <linux/slab.h>
28 #include <linux/module.h>
29 #include <linux/init.h>
30 #include <linux/slab.h>
31 #include <linux/pagemap.h>
32 #include <asm/div64.h>
33 #include <linux/seq_file.h>
35 #include <liblustre.h>
37 #include <linux/ext2_fs.h>
39 #include <linux/obd_support.h>
40 #include <linux/lustre_lib.h>
41 #include <linux/lustre_net.h>
42 #include <linux/lustre_idl.h>
43 #include <linux/lustre_dlm.h>
44 #include <linux/lustre_mds.h>
45 #include <linux/obd_class.h>
46 #include <linux/obd_ost.h>
47 #include <linux/lprocfs_status.h>
48 #include <linux/lustre_fsfilt.h>
49 #include <linux/obd_lmv.h>
50 #include "lmv_internal.h"
54 * -EINVAL : UUID can't be found in the LMV's target list
55 * -ENOTCONN: The UUID is found, but the target connection is bad (!)
56 * -EBADF : The UUID is found, but the OBD of the wrong type (!)
58 static int lmv_set_mdc_active(struct lmv_obd *lmv, struct obd_uuid *uuid,
61 struct obd_device *obd;
62 struct lmv_tgt_desc *tgt;
66 CDEBUG(D_INFO, "Searching in lmv %p for uuid %s (activate=%d)\n",
67 lmv, uuid->uuid, activate);
69 spin_lock(&lmv->lmv_lock);
70 for (i = 0, tgt = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgt++) {
71 if (tgt->ltd_exp == NULL)
74 CDEBUG(D_INFO, "lmv idx %d is %s conn "LPX64"\n",
75 i, tgt->uuid.uuid, tgt->ltd_exp->exp_handle.h_cookie);
76 if (strncmp(uuid->uuid, tgt->uuid.uuid, sizeof uuid->uuid) == 0)
80 if (i == lmv->desc.ld_tgt_count)
81 GOTO(out, rc = -EINVAL);
83 obd = class_exp2obd(tgt->ltd_exp);
85 GOTO(out, rc = -ENOTCONN);
87 CDEBUG(D_INFO, "Found OBD %s=%s device %d (%p) type %s at LMV idx %d\n",
88 obd->obd_name, obd->obd_uuid.uuid, obd->obd_minor, obd,
89 obd->obd_type->typ_name, i);
90 LASSERT(strcmp(obd->obd_type->typ_name, LUSTRE_MDC_NAME) == 0);
92 if (tgt->active == activate) {
93 CDEBUG(D_INFO, "OBD %p already %sactive!\n", obd,
94 activate ? "" : "in");
98 CDEBUG(D_INFO, "Marking OBD %p %sactive\n", obd, activate ? "" : "in");
100 tgt->active = activate;
102 lmv->desc.ld_active_tgt_count++;
104 lmv->desc.ld_active_tgt_count--;
108 spin_unlock(&lmv->lmv_lock);
112 static int lmv_notify(struct obd_device *obd, struct obd_device *watched,
116 struct obd_uuid *uuid;
118 if (strcmp(watched->obd_type->typ_name, LUSTRE_MDC_NAME)) {
119 CERROR("unexpected notification of %s %s!\n",
120 watched->obd_type->typ_name,
124 uuid = &watched->u.cli.cl_import->imp_target_uuid;
126 /* Set MDC as active before notifying the observer, so the
127 * observer can use the MDC normally.
129 rc = lmv_set_mdc_active(&obd->u.lmv, uuid, active);
131 CERROR("%sactivation of %s failed: %d\n",
132 active ? "" : "de", uuid->uuid, rc);
136 if (obd->obd_observer)
137 /* Pass the notification up the chain. */
138 rc = obd_notify(obd->obd_observer, watched, active);
143 int lmv_attach(struct obd_device *dev, obd_count len, void *data)
145 struct lprocfs_static_vars lvars;
149 lprocfs_init_vars(lmv, &lvars);
150 rc = lprocfs_obd_attach(dev, lvars.obd_vars);
153 struct proc_dir_entry *entry;
155 entry = create_proc_entry("target_obd", 0444, dev->obd_proc_entry);
158 /* entry->proc_fops = &lmv_proc_target_fops; */
165 int lmv_detach(struct obd_device *dev)
167 return lprocfs_obd_detach(dev);
170 /* This is fake connect function. Its purpose is to initialize lmv and
171 * say caller that everything is okay. Real connection will be performed
173 static int lmv_connect(struct lustre_handle *conn, struct obd_device *obd,
174 struct obd_uuid *cluuid)
176 struct lmv_obd *lmv = &obd->u.lmv;
177 struct obd_export *exp;
181 rc = class_connect(conn, obd, cluuid);
183 CERROR("class_connection() returned %d\n", rc);
187 exp = class_conn2export(conn);
188 /* We don't want to actually do the underlying connections more than
189 * once, so keep track. */
191 if (lmv->refcount > 1) {
192 class_export_put(exp);
196 lmv->cluuid = *cluuid;
203 void lmv_set_timeouts(struct obd_device *obd)
205 struct lmv_tgt_desc *tgts;
210 if (lmv->server_timeout == 0)
213 if (lmv->connected == 0)
216 for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
217 if (tgts->ltd_exp == NULL)
219 obd_set_info(tgts->ltd_exp, strlen("inter_mds"),
220 "inter_mds", 0, NULL);
224 /* Performs a check if passed obd is connected. If no - connect it. */
225 int lmv_check_connect(struct obd_device *obd) {
226 struct lmv_obd *lmv = &obd->u.lmv;
227 struct obd_uuid *cluuid;
228 struct lmv_tgt_desc *tgts;
229 struct obd_export *exp;
236 cluuid = &lmv->cluuid;
239 CDEBUG(D_OTHER, "time to connect %s to %s\n",
240 cluuid->uuid, obd->obd_name);
242 for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
243 struct obd_device *tgt_obd;
244 struct obd_uuid lmv_osc_uuid = { "LMV_OSC_UUID" };
245 struct lustre_handle conn = {0, };
247 LASSERT(tgts != NULL);
249 tgt_obd = class_find_client_obd(&tgts->uuid, LUSTRE_MDC_NAME,
252 CERROR("Target %s not attached\n", tgts->uuid.uuid);
253 GOTO(out_disc, rc = -EINVAL);
256 /* for MDS: don't connect to yourself */
257 if (obd_uuid_equals(&tgts->uuid, cluuid)) {
258 CDEBUG(D_OTHER, "don't connect back to %s\n",
260 tgts->ltd_exp = NULL;
264 CDEBUG(D_OTHER, "connect to %s(%s) - %s, %s FOR %s\n",
265 tgt_obd->obd_name, tgt_obd->obd_uuid.uuid,
266 tgts->uuid.uuid, obd->obd_uuid.uuid,
269 if (!tgt_obd->obd_set_up) {
270 CERROR("Target %s not set up\n", tgts->uuid.uuid);
271 GOTO(out_disc, rc = -EINVAL);
274 rc = obd_connect(&conn, tgt_obd, &lmv_osc_uuid);
276 CERROR("Target %s connect error %d\n",
277 tgts->uuid.uuid, rc);
280 tgts->ltd_exp = class_conn2export(&conn);
282 obd_init_ea_size(tgts->ltd_exp, lmv->max_easize,
283 lmv->max_cookiesize);
285 rc = obd_register_observer(tgt_obd, obd);
287 CERROR("Target %s register_observer error %d\n",
288 tgts->uuid.uuid, rc);
289 obd_disconnect(tgts->ltd_exp, 0);
293 lmv->desc.ld_active_tgt_count++;
296 CDEBUG(D_OTHER, "connected to %s(%s) successfully (%d)\n",
297 tgt_obd->obd_name, tgt_obd->obd_uuid.uuid,
298 atomic_read(&obd->obd_refcount));
301 lmv_set_timeouts(obd);
303 class_export_put(exp);
308 struct obd_uuid uuid;
310 --lmv->desc.ld_active_tgt_count;
312 /* save for CERROR below; (we know it's terminated) */
314 rc2 = obd_disconnect(tgts->ltd_exp, 0);
316 CERROR("error: LMV target %s disconnect on MDT idx %d: "
317 "error %d\n", uuid.uuid, i, rc2);
319 class_disconnect(exp, 0);
323 static int lmv_disconnect(struct obd_export *exp, int flags)
325 struct obd_device *obd = class_exp2obd(exp);
326 struct lmv_obd *lmv = &obd->u.lmv;
333 /* Only disconnect the underlying layers on the final disconnect. */
335 if (lmv->refcount != 0)
338 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
339 if (lmv->tgts[i].ltd_exp == NULL)
342 if (obd->obd_no_recov) {
343 /* Pass it on to our clients.
344 * XXX This should be an argument to disconnect,
345 * XXX not a back-door flag on the OBD. Ah well.
347 struct obd_device *mdc_obd;
348 mdc_obd = class_exp2obd(lmv->tgts[i].ltd_exp);
350 mdc_obd->obd_no_recov = 1;
353 CDEBUG(D_OTHER, "disconnected from %s(%s) successfully\n",
354 lmv->tgts[i].ltd_exp->exp_obd->obd_name,
355 lmv->tgts[i].ltd_exp->exp_obd->obd_uuid.uuid);
357 obd_register_observer(lmv->tgts[i].ltd_exp->exp_obd, NULL);
359 rc = obd_disconnect(lmv->tgts[i].ltd_exp, flags);
361 if (lmv->tgts[i].active) {
362 CERROR("Target %s disconnect error %d\n",
363 lmv->tgts[i].uuid.uuid, rc);
367 if (lmv->tgts[i].active) {
368 lmv->desc.ld_active_tgt_count--;
369 lmv->tgts[i].active = 0;
371 lmv->tgts[i].ltd_exp = NULL;
375 /* this is the case when no real connection is established by
376 * lmv_check_connect(). */
378 class_export_put(exp);
379 rc = class_disconnect(exp, 0);
383 static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
384 int len, void *karg, void *uarg)
386 struct obd_device *obddev = class_exp2obd(exp);
387 struct lmv_obd *lmv = &obddev->u.lmv;
388 int i, rc = 0, set = 0;
392 if (lmv->desc.ld_tgt_count == 0)
395 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
398 err = obd_iocontrol(cmd, lmv->tgts[i].ltd_exp,
401 if (lmv->tgts[i].active) {
402 CERROR("error: iocontrol MDC %s on MDT"
403 "idx %d: err = %d\n",
404 lmv->tgts[i].uuid.uuid, i, err);
417 static int lmv_setup(struct obd_device *obd, obd_count len, void *buf)
420 struct lmv_desc *desc;
421 struct obd_uuid *uuids;
422 struct lmv_tgt_desc *tgts;
423 struct lustre_cfg *lcfg = buf;
424 struct lmv_obd *lmv = &obd->u.lmv;
427 if (lcfg->lcfg_inllen1 < 1) {
428 CERROR("LMV setup requires a descriptor\n");
432 if (lcfg->lcfg_inllen2 < 1) {
433 CERROR("LMV setup requires an OST UUID list\n");
437 desc = (struct lmv_desc *)lcfg->lcfg_inlbuf1;
438 if (sizeof(*desc) > lcfg->lcfg_inllen1) {
439 CERROR("descriptor size wrong: %d > %d\n",
440 (int)sizeof(*desc), lcfg->lcfg_inllen1);
444 uuids = (struct obd_uuid *)lcfg->lcfg_inlbuf2;
445 if (sizeof(*uuids) * desc->ld_tgt_count != lcfg->lcfg_inllen2) {
446 CERROR("UUID array size wrong: %u * %u != %u\n",
447 sizeof(*uuids), desc->ld_tgt_count, lcfg->lcfg_inllen2);
451 lmv->bufsize = sizeof(struct lmv_tgt_desc) * desc->ld_tgt_count;
452 OBD_ALLOC(lmv->tgts, lmv->bufsize);
453 if (lmv->tgts == NULL) {
454 CERROR("Out of memory\n");
459 spin_lock_init(&lmv->lmv_lock);
461 for (i = 0, tgts = lmv->tgts; i < desc->ld_tgt_count; i++, tgts++)
462 tgts->uuid = uuids[i];
464 lmv->max_cookiesize = 0;
466 lmv->max_easize = sizeof(struct ll_fid) *
467 desc->ld_tgt_count + sizeof(struct mea);
469 rc = lmv_setup_mgr(obd);
471 CERROR("Can't setup LMV object manager, "
473 OBD_FREE(lmv->tgts, lmv->bufsize);
479 static int lmv_statfs(struct obd_device *obd, struct obd_statfs *osfs,
480 unsigned long max_age)
482 struct lmv_obd *lmv = &obd->u.lmv;
483 struct obd_statfs temp;
487 rc = lmv_check_connect(obd);
491 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
492 rc = obd_statfs(lmv->tgts[i].ltd_exp->exp_obd, &temp, max_age);
494 CERROR("can't stat MDS #%d (%s)\n", i,
495 lmv->tgts[i].ltd_exp->exp_obd->obd_name);
499 memcpy(osfs, &temp, sizeof(temp));
501 osfs->os_bavail += temp.os_bavail;
502 osfs->os_blocks += temp.os_blocks;
503 osfs->os_ffree += temp.os_ffree;
504 osfs->os_files += temp.os_files;
510 static int lmv_cleanup(struct obd_device *obd, int flags)
512 struct lmv_obd *lmv = &obd->u.lmv;
514 lmv_cleanup_mgr(obd);
515 OBD_FREE(lmv->tgts, lmv->bufsize);
519 static int lmv_getstatus(struct obd_export *exp, struct ll_fid *fid)
521 struct obd_device *obd = exp->exp_obd;
522 struct lmv_obd *lmv = &obd->u.lmv;
525 rc = lmv_check_connect(obd);
528 rc = md_getstatus(lmv->tgts[0].ltd_exp, fid);
533 static int lmv_getattr(struct obd_export *exp, struct ll_fid *fid,
534 unsigned long valid, unsigned int ea_size,
535 struct ptlrpc_request **request)
537 struct obd_device *obd = exp->exp_obd;
538 struct lmv_obd *lmv = &obd->u.lmv;
539 int rc, i = fid->mds;
543 rc = lmv_check_connect(obd);
547 LASSERT(i < lmv->desc.ld_tgt_count);
549 rc = md_getattr(lmv->tgts[i].ltd_exp, fid, valid,
554 obj = lmv_grab_obj(obd, fid);
556 CDEBUG(D_OTHER, "GETATTR for %lu/%lu/%lu %s\n",
557 (unsigned long)fid->mds, (unsigned long)fid->id,
558 (unsigned long)fid->generation, obj ? "(splitted)" : "");
560 /* if object is splitted, then we loop over all the slaves and gather
561 * size attribute. In ideal world we would have to gather also mds field
562 * from all slaves, as object is spread over the cluster and this is
563 * definitely interesting information and it is not good to loss it,
566 struct mds_body *body;
568 if (*request == NULL) {
573 body = lustre_msg_buf((*request)->rq_repmsg, 0,
575 LASSERT(body != NULL);
579 for (i = 0; i < obj->objcount; i++) {
581 /* skip master obj. */
582 if (fid_equal(&obj->fid, &obj->objs[i].fid))
585 body->size += obj->objs[i].size;
595 static int lmv_change_cbdata(struct obd_export *exp, struct ll_fid *fid,
596 ldlm_iterator_t it, void *data)
598 struct obd_device *obd = exp->exp_obd;
599 struct lmv_obd *lmv = &obd->u.lmv;
603 rc = lmv_check_connect(obd);
607 CDEBUG(D_OTHER, "CBDATA for %lu/%lu/%lu\n", (unsigned long)fid->mds,
608 (unsigned long)fid->id, (unsigned long)fid->generation);
610 LASSERT(fid->mds < lmv->desc.ld_tgt_count);
612 rc = md_change_cbdata(lmv->tgts[fid->mds].ltd_exp,
618 static int lmv_change_cbdata_name(struct obd_export *exp, struct ll_fid *pfid,
619 char *name, int len, struct ll_fid *cfid,
620 ldlm_iterator_t it, void *data)
622 struct obd_device *obd = exp->exp_obd;
623 struct lmv_obd *lmv = &obd->u.lmv;
628 rc = lmv_check_connect(obd);
632 LASSERT(pfid->mds < lmv->desc.ld_tgt_count);
633 LASSERT(cfid->mds < lmv->desc.ld_tgt_count);
635 CDEBUG(D_OTHER, "CBDATA for %lu/%lu/%lu:%*s -> %lu/%lu/%lu\n",
636 (unsigned long)pfid->mds, (unsigned long)pfid->id,
637 (unsigned long)pfid->generation, len, name,
638 (unsigned long)cfid->mds, (unsigned long)cfid->id,
639 (unsigned long)cfid->generation);
641 /* this is default mds for directory name belongs to. */
643 obj = lmv_grab_obj(obd, pfid);
645 /* directory is splitted. look for right mds for this name. */
646 mds = raw_name2idx(obj->objcount, name, len);
649 rc = md_change_cbdata(lmv->tgts[mds].ltd_exp, cfid, it, data);
653 static int lmv_valid_attrs(struct obd_export *exp, struct ll_fid *fid)
655 struct obd_device *obd = exp->exp_obd;
656 struct lmv_obd *lmv = &obd->u.lmv;
659 rc = lmv_check_connect(obd);
662 CDEBUG(D_OTHER, "validate %lu/%lu/%lu\n", (unsigned long) fid->mds,
663 (unsigned long) fid->id, (unsigned long) fid->generation);
664 LASSERT(fid->mds < lmv->desc.ld_tgt_count);
665 rc = md_valid_attrs(lmv->tgts[fid->mds].ltd_exp, fid);
669 int lmv_close(struct obd_export *exp, struct obdo *obdo,
670 struct obd_client_handle *och,
671 struct ptlrpc_request **request)
673 struct obd_device *obd = exp->exp_obd;
674 struct lmv_obd *lmv = &obd->u.lmv;
675 int rc, i = obdo->o_mds;
677 rc = lmv_check_connect(obd);
680 LASSERT(i < lmv->desc.ld_tgt_count);
681 CDEBUG(D_OTHER, "CLOSE %lu/%lu/%lu\n", (unsigned long) obdo->o_mds,
682 (unsigned long) obdo->o_id, (unsigned long) obdo->o_generation);
683 rc = md_close(lmv->tgts[i].ltd_exp, obdo, och, request);
687 int lmv_get_mea_and_update_object(struct obd_export *exp, struct ll_fid *fid)
689 struct obd_device *obd = exp->exp_obd;
690 struct lmv_obd *lmv = &obd->u.lmv;
691 struct ptlrpc_request *req = NULL;
698 mealen = MEA_SIZE_LMV(lmv);
700 valid = OBD_MD_FLEASIZE | OBD_MD_FLDIREA;
702 /* time to update mea of parent fid */
703 rc = md_getattr(lmv->tgts[fid->mds].ltd_exp, fid,
704 valid, mealen, &req);
706 CERROR("md_getattr() failed, error %d\n", rc);
710 rc = mdc_req2lustre_md(exp, req, 0, NULL, &md);
712 CERROR("mdc_req2lustre_md() failed, error %d\n", rc);
717 GOTO(cleanup, rc = -ENODATA);
719 obj = lmv_create_obj(exp, fid, md.mea);
724 obd_free_memmd(exp, (struct lov_stripe_md **)&md.mea);
728 ptlrpc_req_finished(req);
732 int lmv_create(struct obd_export *exp, struct mdc_op_data *op_data,
733 const void *data, int datalen, int mode, __u32 uid,
734 __u32 gid, __u64 rdev, struct ptlrpc_request **request)
736 struct obd_device *obd = exp->exp_obd;
737 struct lmv_obd *lmv = &obd->u.lmv;
738 struct mds_body *body;
743 rc = lmv_check_connect(obd);
747 if (!lmv->desc.ld_active_tgt_count)
750 obj = lmv_grab_obj(obd, &op_data->fid1);
752 mds = raw_name2idx(obj->objcount, op_data->name,
754 op_data->fid1 = obj->objs[mds].fid;
758 CDEBUG(D_OTHER, "CREATE '%*s' on %lu/%lu/%lu\n", op_data->namelen,
759 op_data->name, (unsigned long)op_data->fid1.mds,
760 (unsigned long)op_data->fid1.id,
761 (unsigned long)op_data->fid1.generation);
763 rc = md_create(lmv->tgts[op_data->fid1.mds].ltd_exp, op_data, data,
764 datalen, mode, uid, gid, rdev, request);
766 if (*request == NULL)
769 body = lustre_msg_buf((*request)->rq_repmsg, 0,
771 LASSERT(body != NULL);
773 CDEBUG(D_OTHER, "created. id = %lu, generation = %lu, "
774 "mds = %d\n", (unsigned long)body->fid1.id,
775 (unsigned long)body->fid1.generation, op_data->fid1.mds);
777 LASSERT(body->valid & OBD_MD_MDS ||
778 body->mds == op_data->fid1.mds);
779 } else if (rc == -ERESTART) {
780 /* directory got splitted. time to update local object and
781 * repeat the request with proper MDS */
782 rc = lmv_get_mea_and_update_object(exp, &op_data->fid1);
784 ptlrpc_req_finished(*request);
791 int lmv_done_writing(struct obd_export *exp, struct obdo *obdo)
793 struct obd_device *obd = exp->exp_obd;
794 struct lmv_obd *lmv = &obd->u.lmv;
797 rc = lmv_check_connect(obd);
801 /* FIXME: choose right MDC here */
802 CWARN("this method isn't implemented yet\n");
803 rc = md_done_writing(lmv->tgts[0].ltd_exp, obdo);
807 int lmv_enqueue_slaves(struct obd_export *exp, int locktype,
808 struct lookup_intent *it, int lockmode,
809 struct mdc_op_data *data, struct lustre_handle *lockh,
810 void *lmm, int lmmsize, ldlm_completion_callback cb_completion,
811 ldlm_blocking_callback cb_blocking, void *cb_data)
813 struct obd_device *obd = exp->exp_obd;
814 struct lmv_obd *lmv = &obd->u.lmv;
815 struct mea *mea = data->mea1;
816 struct mdc_op_data data2;
820 LASSERT(mea != NULL);
821 for (i = 0; i < mea->mea_count; i++) {
822 if (lmv->tgts[i].ltd_exp == NULL)
825 memset(&data2, 0, sizeof(data2));
826 data2.fid1 = mea->mea_fids[i];
827 mds = data2.fid1.mds;
829 rc = md_enqueue(lmv->tgts[mds].ltd_exp, locktype, it, lockmode,
830 &data2, lockh + i, lmm, lmmsize, cb_completion,
831 cb_blocking, cb_data);
833 CDEBUG(D_OTHER, "take lock on slave %lu/%lu/%lu -> %d/%d\n",
834 (unsigned long)mea->mea_fids[i].mds,
835 (unsigned long)mea->mea_fids[i].id,
836 (unsigned long)mea->mea_fids[i].generation,
837 rc, it->d.lustre.it_status);
840 if (it->d.lustre.it_data) {
841 struct ptlrpc_request *req;
842 req = (struct ptlrpc_request *) it->d.lustre.it_data;
843 ptlrpc_req_finished(req);
846 if (it->d.lustre.it_status)
847 GOTO(cleanup, rc = it->d.lustre.it_status);
852 /* drop all taken locks */
855 ldlm_lock_decref(lockh + i, lockmode);
861 int lmv_enqueue(struct obd_export *exp, int lock_type,
862 struct lookup_intent *it, int lock_mode,
863 struct mdc_op_data *data, struct lustre_handle *lockh,
864 void *lmm, int lmmsize, ldlm_completion_callback cb_completion,
865 ldlm_blocking_callback cb_blocking, void *cb_data)
867 struct obd_device *obd = exp->exp_obd;
868 struct lmv_obd *lmv = &obd->u.lmv;
873 rc = lmv_check_connect(obd);
877 if (it->it_op == IT_UNLINK) {
878 rc = lmv_enqueue_slaves(exp, lock_type, it, lock_mode,
879 data, lockh, lmm, lmmsize,
880 cb_completion, cb_blocking, cb_data);
885 obj = lmv_grab_obj(obd, &data->fid1);
887 /* directory is splitted. look for right mds for this
889 mds = raw_name2idx(obj->objcount, (char *)data->name,
891 data->fid1 = obj->objs[mds].fid;
895 CDEBUG(D_OTHER, "ENQUEUE '%s' on %lu/%lu\n", LL_IT2STR(it),
896 (unsigned long)data->fid1.id, (unsigned long)data->fid1.generation);
898 rc = md_enqueue(lmv->tgts[data->fid1.mds].ltd_exp, lock_type, it,
899 lock_mode, data, lockh, lmm, lmmsize, cb_completion,
900 cb_blocking, cb_data);
905 int lmv_getattr_name(struct obd_export *exp, struct ll_fid *fid,
906 char *filename, int namelen, unsigned long valid,
907 unsigned int ea_size, struct ptlrpc_request **request)
909 struct obd_device *obd = exp->exp_obd;
910 struct lmv_obd *lmv = &obd->u.lmv;
911 struct ll_fid rfid = *fid;
912 int rc, mds = fid->mds;
913 struct mds_body *body;
916 rc = lmv_check_connect(obd);
920 obj = lmv_grab_obj(obd, fid);
922 /* directory is splitted. look for right mds for this name */
923 mds = raw_name2idx(obj->objcount, filename, namelen - 1);
924 rfid = obj->objs[mds].fid;
928 CDEBUG(D_OTHER, "getattr_name for %*s on %lu/%lu/%lu -> %lu/%lu/%lu\n",
929 namelen, filename, (unsigned long)fid->mds,
930 (unsigned long)fid->id, (unsigned long)fid->generation,
931 (unsigned long)rfid.mds, (unsigned long)rfid.id,
932 (unsigned long)rfid.generation);
934 rc = md_getattr_name(lmv->tgts[mds].ltd_exp, &rfid, filename,
935 namelen, valid, ea_size, request);
937 /* this could be cross-node reference. in this case all we have
938 * right now is mds/ino/generation triple. we'd like to find
939 * other attributes */
940 body = lustre_msg_buf((*request)->rq_repmsg, 0, sizeof(*body));
941 LASSERT(body != NULL);
942 if (body->valid & OBD_MD_MDS) {
943 struct ptlrpc_request *req = NULL;
945 CDEBUG(D_OTHER, "request attrs for %lu/%lu/%lu\n",
946 (unsigned long) rfid.mds,
947 (unsigned long) rfid.id,
948 (unsigned long) rfid.generation);
949 rc = md_getattr_name(lmv->tgts[rfid.mds].ltd_exp, &rfid,
950 NULL, 1, valid, ea_size, &req);
951 ptlrpc_req_finished(*request);
954 } else if (rc == -ERESTART) {
955 /* directory got splitted. time to update local object and
956 * repeat the request with proper MDS */
957 rc = lmv_get_mea_and_update_object(exp, &rfid);
959 ptlrpc_req_finished(*request);
968 * llite passes fid of an target inode in data->fid1 and fid of directory in
971 int lmv_link(struct obd_export *exp, struct mdc_op_data *data,
972 struct ptlrpc_request **request)
974 struct obd_device *obd = exp->exp_obd;
975 struct lmv_obd *lmv = &obd->u.lmv;
980 rc = lmv_check_connect(obd);
984 if (data->namelen != 0) {
985 /* usual link request */
986 obj = lmv_grab_obj(obd, &data->fid1);
988 rc = raw_name2idx(obj->objcount, data->name,
990 data->fid1 = obj->objs[rc].fid;
994 CDEBUG(D_OTHER,"link %lu/%lu/%lu:%*s to %lu/%lu/%lu mds %lu\n",
995 (unsigned long)data->fid2.mds,
996 (unsigned long)data->fid2.id,
997 (unsigned long)data->fid2.generation,
998 data->namelen, data->name,
999 (unsigned long)data->fid1.mds,
1000 (unsigned long)data->fid1.id,
1001 (unsigned long)data->fid1.generation,
1002 (unsigned long)data->fid1.mds);
1004 /* request from MDS to acquire i_links for inode by fid1 */
1005 CDEBUG(D_OTHER, "inc i_nlinks for %lu/%lu/%lu\n",
1006 (unsigned long)data->fid1.mds,
1007 (unsigned long)data->fid1.id,
1008 (unsigned long)data->fid1.generation);
1011 rc = md_link(lmv->tgts[data->fid1.mds].ltd_exp, data, request);
1015 int lmv_rename(struct obd_export *exp, struct mdc_op_data *data,
1016 const char *old, int oldlen, const char *new, int newlen,
1017 struct ptlrpc_request **request)
1019 struct obd_device *obd = exp->exp_obd;
1020 struct lmv_obd *lmv = &obd->u.lmv;
1021 struct lmv_obj *obj;
1025 CDEBUG(D_OTHER, "rename %*s in %lu/%lu/%lu to %*s in %lu/%lu/%lu\n",
1026 oldlen, old, (unsigned long)data->fid1.mds,
1027 (unsigned long)data->fid1.id,
1028 (unsigned long)data->fid1.generation,
1029 newlen, new, (unsigned long) data->fid2.mds,
1030 (unsigned long) data->fid2.id,
1031 (unsigned long) data->fid2.generation);
1033 if (!fid_equal(&data->fid1, &data->fid2))
1034 CWARN("cross-node rename %lu/%lu/%lu:%*s to %lu/%lu/%lu:%*s\n",
1035 (unsigned long)data->fid1.mds,
1036 (unsigned long)data->fid1.id,
1037 (unsigned long)data->fid1.generation, oldlen, old,
1038 (unsigned long)data->fid2.mds,
1039 (unsigned long)data->fid2.id,
1040 (unsigned long)data->fid2.generation, newlen, new);
1042 rc = lmv_check_connect(obd);
1047 /* MDS with old dir entry is asking another MDS to create name
1050 "create %*s(%d/%d) in %lu/%lu/%lu pointing to %lu/%lu/%lu\n",
1051 newlen, new, oldlen, newlen,
1052 (unsigned long)data->fid2.mds,
1053 (unsigned long)data->fid2.id,
1054 (unsigned long)data->fid2.generation,
1055 (unsigned long)data->fid1.mds,
1056 (unsigned long)data->fid1.id,
1057 (unsigned long)data->fid1.generation);
1058 mds = data->fid2.mds;
1062 obj = lmv_grab_obj(obd, &data->fid1);
1064 /* directory is already splitted, so we have to forward request
1065 * to the right MDS */
1066 mds = raw_name2idx(obj->objcount, (char *)old, oldlen);
1067 data->fid1 = obj->objs[mds].fid;
1068 CDEBUG(D_OTHER, "forward to MDS #%u (%lu/%lu/%lu)\n", mds,
1069 (unsigned long)obj->objs[mds].fid.mds,
1070 (unsigned long)obj->objs[mds].fid.id,
1071 (unsigned long)obj->objs[mds].fid.generation);
1075 obj = lmv_grab_obj(obd, &data->fid2);
1077 /* directory is already splitted, so we have to forward request
1078 * to the right MDS */
1079 mds = raw_name2idx(obj->objcount, (char *)new, newlen);
1080 data->fid2 = obj->objs[mds].fid;
1081 CDEBUG(D_OTHER, "forward to MDS #%u (%lu/%lu/%lu)\n", mds,
1082 (unsigned long)obj->objs[mds].fid.mds,
1083 (unsigned long)obj->objs[mds].fid.id,
1084 (unsigned long)obj->objs[mds].fid.generation);
1088 mds = data->fid1.mds;
1091 rc = md_rename(lmv->tgts[mds].ltd_exp, data, old, oldlen,
1092 new, newlen, request);
1096 int lmv_setattr(struct obd_export *exp, struct mdc_op_data *data,
1097 struct iattr *iattr, void *ea, int ealen, void *ea2,
1098 int ea2len, struct ptlrpc_request **request)
1100 struct obd_device *obd = exp->exp_obd;
1101 struct lmv_obd *lmv = &obd->u.lmv;
1102 int rc = 0, i = data->fid1.mds;
1103 struct ptlrpc_request *req;
1104 struct mds_body *body;
1105 struct lmv_obj *obj;
1108 rc = lmv_check_connect(obd);
1112 obj = lmv_grab_obj(obd, &data->fid1);
1114 CDEBUG(D_OTHER, "SETATTR for %lu/%lu/%lu, valid 0x%x%s\n",
1115 (unsigned long)data->fid1.mds, (unsigned long)data->fid1.id,
1116 (unsigned long)data->fid1.generation, iattr->ia_valid,
1117 obj ? ", splitted" : "");
1120 for (i = 0; i < obj->objcount; i++) {
1121 data->fid1 = obj->objs[i].fid;
1123 rc = md_setattr(lmv->tgts[i].ltd_exp, data, iattr,
1124 ea, ealen, ea2, ea2len, &req);
1126 if (fid_equal(&obj->fid, &obj->objs[i].fid)) {
1127 /* this is master object and this request should
1128 * be returned back to llite */
1131 ptlrpc_req_finished(req);
1139 LASSERT(i < lmv->desc.ld_tgt_count);
1140 rc = md_setattr(lmv->tgts[i].ltd_exp, data, iattr, ea,
1141 ealen, ea2, ea2len, request);
1143 body = lustre_msg_buf((*request)->rq_repmsg, 0,
1145 LASSERT(body != NULL);
1146 LASSERT(body->mds == i);
1152 int lmv_sync(struct obd_export *exp, struct ll_fid *fid,
1153 struct ptlrpc_request **request)
1155 struct obd_device *obd = exp->exp_obd;
1156 struct lmv_obd *lmv = &obd->u.lmv;
1160 rc = lmv_check_connect(obd);
1164 rc = md_sync(lmv->tgts[0].ltd_exp, fid, request);
1168 int lmv_dirobj_blocking_ast(struct ldlm_lock *lock, struct ldlm_lock_desc *desc,
1169 void *data, int flag)
1171 struct lustre_handle lockh;
1172 struct lmv_obj *obj;
1177 case LDLM_CB_BLOCKING:
1178 ldlm_lock2handle(lock, &lockh);
1179 rc = ldlm_cli_cancel(&lockh);
1181 CDEBUG(D_INODE, "ldlm_cli_cancel: %d\n", rc);
1185 case LDLM_CB_CANCELING:
1186 /* time to drop cached attrs for dirobj */
1187 obj = lock->l_ast_data;
1189 CDEBUG(D_OTHER, "cancel %s on %lu/%lu, master %lu/%lu/%lu\n",
1190 lock->l_resource->lr_name.name[3] == 1 ? "LOOKUP" : "UPDATE",
1191 (unsigned long)lock->l_resource->lr_name.name[0],
1192 (unsigned long)lock->l_resource->lr_name.name[1],
1193 (unsigned long)obj->fid.mds, (unsigned long)obj->fid.id,
1194 (unsigned long)obj->fid.generation);
1204 void lmv_remove_dots(struct page *page)
1206 char *kaddr = page_address(page);
1207 unsigned limit = PAGE_CACHE_SIZE;
1208 unsigned offs, rec_len;
1209 struct ext2_dir_entry_2 *p;
1211 for (offs = 0; offs <= limit - EXT2_DIR_REC_LEN(1); offs += rec_len) {
1212 p = (struct ext2_dir_entry_2 *)(kaddr + offs);
1213 rec_len = le16_to_cpu(p->rec_len);
1215 if ((p->name_len == 1 && p->name[0] == '.') ||
1216 (p->name_len == 2 && p->name[0] == '.' && p->name[1] == '.'))
1221 int lmv_readpage(struct obd_export *exp, struct ll_fid *mdc_fid,
1222 __u64 offset, struct page *page,
1223 struct ptlrpc_request **request)
1225 struct obd_device *obd = exp->exp_obd;
1226 struct lmv_obd *lmv = &obd->u.lmv;
1227 struct ll_fid rfid = *mdc_fid;
1228 struct lmv_obj *obj;
1232 rc = lmv_check_connect(obd);
1236 LASSERT(mdc_fid->mds < lmv->desc.ld_tgt_count);
1237 CDEBUG(D_OTHER, "READPAGE at %llu from %lu/%lu/%lu\n",
1238 offset, (unsigned long) rfid.mds,
1239 (unsigned long) rfid.id,
1240 (unsigned long) rfid.generation);
1242 obj = lmv_grab_obj(obd, mdc_fid);
1246 /* find dirobj containing page with requested offset. */
1247 for (i = 0; i < obj->objcount; i++) {
1248 if (offset < obj->objs[i].size)
1250 offset -= obj->objs[i].size;
1252 rfid = obj->objs[i].fid;
1254 lmv_unlock_obj(obj);
1257 CDEBUG(D_OTHER, "forward to %lu/%lu/%lu with offset %lu\n",
1258 (unsigned long)rfid.mds, (unsigned long)rfid.id,
1259 (unsigned long)rfid.generation, (unsigned long)offset);
1261 rc = md_readpage(lmv->tgts[rfid.mds].ltd_exp, &rfid, offset,
1264 if (rc == 0 && !fid_equal(&rfid, mdc_fid))
1265 /* this page isn't from master object. To avoid "." and ".."
1266 * duplication in directory, we have to remove them from all
1268 lmv_remove_dots(page);
1273 int lmv_unlink_slaves(struct obd_export *exp, struct mdc_op_data *data,
1274 struct ptlrpc_request **req)
1276 struct obd_device *obd = exp->exp_obd;
1277 struct lmv_obd *lmv = &obd->u.lmv;
1278 struct mea *mea = data->mea1;
1279 struct mdc_op_data data2;
1283 LASSERT(mea != NULL);
1284 for (i = 0; i < mea->mea_count; i++) {
1285 if (lmv->tgts[i].ltd_exp == NULL)
1288 memset(&data2, 0, sizeof(data2));
1289 data2.fid1 = mea->mea_fids[i];
1290 data2.create_mode = MDS_MODE_DONT_LOCK | S_IFDIR;
1291 mds = data2.fid1.mds;
1292 rc = md_unlink(lmv->tgts[mds].ltd_exp, &data2, req);
1293 CDEBUG(D_OTHER, "unlink slave %lu/%lu/%lu -> %d\n",
1294 (unsigned long) mea->mea_fids[i].mds,
1295 (unsigned long) mea->mea_fids[i].id,
1296 (unsigned long) mea->mea_fids[i].generation, rc);
1298 ptlrpc_req_finished(*req);
1307 int lmv_delete_object(struct obd_export *exp, struct ll_fid *fid)
1311 if (!lmv_delete_obj(exp, fid)) {
1312 CDEBUG(D_OTHER, "Object %lu/%lu/%lu is not found.\n",
1313 (unsigned long)fid->mds, (unsigned long)fid->id,
1314 (unsigned long)fid->generation);
1320 int lmv_unlink(struct obd_export *exp, struct mdc_op_data *data,
1321 struct ptlrpc_request **request)
1323 struct obd_device *obd = exp->exp_obd;
1324 struct lmv_obd *lmv = &obd->u.lmv;
1328 rc = lmv_check_connect(obd);
1332 if (data->namelen == 0 && data->mea1 != NULL) {
1333 /* mds asks to remove slave objects */
1334 rc = lmv_unlink_slaves(exp, data, request);
1336 } else if (data->namelen != 0) {
1337 struct lmv_obj *obj;
1339 obj = lmv_grab_obj(obd, &data->fid1);
1341 i = raw_name2idx(obj->objcount, data->name,
1343 data->fid1 = obj->objs[i].fid;
1346 CDEBUG(D_OTHER, "unlink '%*s' in %lu/%lu/%lu -> %u\n",
1347 data->namelen, data->name,
1348 (unsigned long) data->fid1.mds,
1349 (unsigned long) data->fid1.id,
1350 (unsigned long) data->fid1.generation, i);
1352 CDEBUG(D_OTHER, "drop i_nlink on %lu/%lu/%lu\n",
1353 (unsigned long) data->fid1.mds,
1354 (unsigned long) data->fid1.id,
1355 (unsigned long) data->fid1.generation);
1357 rc = md_unlink(lmv->tgts[data->fid1.mds].ltd_exp, data, request);
1361 struct obd_device *lmv_get_real_obd(struct obd_export *exp,
1362 char *name, int len)
1364 struct obd_device *obd = exp->exp_obd;
1365 struct lmv_obd *lmv = &obd->u.lmv;
1369 rc = lmv_check_connect(obd);
1371 RETURN(ERR_PTR(rc));
1372 obd = lmv->tgts[0].ltd_exp->exp_obd;
1377 int lmv_init_ea_size(struct obd_export *exp, int easize, int cookiesize)
1379 struct obd_device *obd = exp->exp_obd;
1380 struct lmv_obd *lmv = &obd->u.lmv;
1381 int i, rc = 0, change = 0;
1384 if (lmv->max_easize < easize) {
1385 lmv->max_easize = easize;
1388 if (lmv->max_cookiesize < cookiesize) {
1389 lmv->max_cookiesize = cookiesize;
1395 if (lmv->connected == 0)
1398 for (i = 0; i < lmv->desc.ld_tgt_count; i++) {
1399 rc = obd_init_ea_size(lmv->tgts[i].ltd_exp, easize, cookiesize);
1401 CERROR("obd_init_ea_size() failed on MDT target %d, "
1402 "error %d.\n", i, rc);
1409 int lmv_obd_create_single(struct obd_export *exp, struct obdo *oa,
1410 struct lov_stripe_md **ea, struct obd_trans_info *oti)
1412 struct obd_device *obd = exp->exp_obd;
1413 struct lmv_obd *lmv = &obd->u.lmv;
1414 struct lov_stripe_md obj_md;
1415 struct lov_stripe_md *obj_mdp = &obj_md;
1419 rc = lmv_check_connect(obd);
1423 LASSERT(ea == NULL);
1424 LASSERT(oa->o_mds < lmv->desc.ld_tgt_count);
1426 rc = obd_create(lmv->tgts[oa->o_mds].ltd_exp, oa, &obj_mdp, oti);
1432 * to be called from MDS only
1434 int lmv_obd_create(struct obd_export *exp, struct obdo *oa,
1435 struct lov_stripe_md **ea, struct obd_trans_info *oti)
1437 struct obd_device *obd = exp->exp_obd;
1438 struct lmv_obd *lmv = &obd->u.lmv;
1444 rc = lmv_check_connect(obd);
1448 LASSERT(oa != NULL);
1451 rc = lmv_obd_create_single(exp, oa, NULL, oti);
1456 rc = obd_alloc_diskmd(exp, (struct lov_mds_md **)ea);
1458 CERROR("obd_alloc_diskmd() failed, error %d\n",
1469 mfid.generation = oa->o_generation;
1471 mea = (struct mea *)*ea;
1472 if (!mea->mea_count || mea->mea_count > lmv->desc.ld_tgt_count)
1473 mea->mea_count = lmv->desc.ld_tgt_count;
1475 mea->mea_master = -1;
1477 for (i = 0, c = 0; c < mea->mea_count &&
1478 i < lmv->desc.ld_tgt_count; i++) {
1479 struct lov_stripe_md obj_md;
1480 struct lov_stripe_md *obj_mdp = &obj_md;
1482 if (lmv->tgts[i].ltd_exp == NULL) {
1483 /* this is master MDS */
1484 mea->mea_fids[c].id = mfid.id;
1485 mea->mea_fids[c].generation = mfid.generation;
1486 mea->mea_fids[c].mds = i;
1487 mea->mea_master = i;
1492 /* "master" MDS should always be part of stripped dir, so scan
1494 if (mea->mea_master == -1 && c == mea->mea_count - 1)
1497 oa->o_valid = OBD_MD_FLGENER | OBD_MD_FLTYPE | OBD_MD_FLMODE
1498 | OBD_MD_FLUID | OBD_MD_FLGID | OBD_MD_FLID;
1500 rc = obd_create(lmv->tgts[c].ltd_exp, oa, &obj_mdp, oti);
1502 CERROR("obd_create() failed on MDT target %d, "
1503 "error %d\n", c, rc);
1507 mea->mea_fids[c].id = oa->o_id;
1508 mea->mea_fids[c].generation = oa->o_generation;
1509 mea->mea_fids[c].mds = i;
1511 CDEBUG(D_OTHER, "dirobj at mds %d: "LPU64"/%u\n",
1512 i, oa->o_id, oa->o_generation);
1513 CDEBUG(D_ERROR, "dirobj at mds %d: "LPU64"/%u\n",
1514 i, oa->o_id, oa->o_generation);
1516 LASSERT(c == mea->mea_count);
1517 CDEBUG(D_OTHER, "%d dirobjects created\n", (int) mea->mea_count);
1522 static int lmv_get_info(struct obd_export *exp, __u32 keylen,
1523 void *key, __u32 *vallen, void *val)
1525 struct obd_device *obd;
1526 struct lmv_obd *lmv;
1529 obd = class_exp2obd(exp);
1531 CDEBUG(D_IOCTL, "invalid client cookie "LPX64"\n",
1532 exp->exp_handle.h_cookie);
1537 if (keylen == 6 && memcmp(key, "mdsize", 6) == 0) {
1538 __u32 *mdsize = val;
1539 *vallen = sizeof(__u32);
1540 *mdsize = sizeof(struct ll_fid) * lmv->desc.ld_tgt_count
1541 + sizeof(struct mea);
1543 } else if (keylen == 6 && memcmp(key, "mdsnum", 6) == 0) {
1544 struct obd_uuid *cluuid = &lmv->cluuid;
1545 struct lmv_tgt_desc *tgts;
1546 __u32 *mdsnum = val;
1549 for (i = 0, tgts = lmv->tgts; i < lmv->desc.ld_tgt_count; i++, tgts++) {
1550 if (obd_uuid_equals(&tgts->uuid, cluuid)) {
1551 *vallen = sizeof(__u32);
1559 CDEBUG(D_IOCTL, "invalid key\n");
1563 int lmv_set_info(struct obd_export *exp, obd_count keylen,
1564 void *key, obd_count vallen, void *val)
1566 struct obd_device *obd;
1567 struct lmv_obd *lmv;
1570 obd = class_exp2obd(exp);
1572 CDEBUG(D_IOCTL, "invalid client cookie "LPX64"\n",
1573 exp->exp_handle.h_cookie);
1578 if (keylen >= strlen("client") && strcmp(key, "client") == 0) {
1579 struct lmv_tgt_desc *tgts;
1582 rc = lmv_check_connect(obd);
1586 for (i = 0, tgts = lmv->tgts;
1587 i < lmv->desc.ld_tgt_count; i++, tgts++) {
1588 rc = obd_set_info(tgts->ltd_exp, keylen, key, vallen, val);
1593 } else if (keylen >= strlen("inter_mds") && strcmp(key, "inter_mds") == 0) {
1594 lmv->server_timeout = 1;
1595 lmv_set_timeouts(obd);
1602 int lmv_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
1603 struct lov_stripe_md *lsm)
1605 struct obd_device *obd = class_exp2obd(exp);
1606 struct lmv_obd *lmv = &obd->u.lmv;
1610 mea_size = sizeof(struct ll_fid) *
1611 lmv->desc.ld_tgt_count + sizeof(struct mea);
1615 if (*lmmp && !lsm) {
1616 OBD_FREE(*lmmp, mea_size);
1621 if (*lmmp == NULL) {
1622 OBD_ALLOC(*lmmp, mea_size);
1630 #warning "MEA packing/convertation must be here! -bzzz"
1631 memcpy(*lmmp, lsm, mea_size);
1635 int lmv_unpackmd(struct obd_export *exp, struct lov_stripe_md **mem_tgt,
1636 struct lov_mds_md *disk_src, int mdsize)
1638 struct obd_device *obd = class_exp2obd(exp);
1639 struct lmv_obd *lmv = &obd->u.lmv;
1640 struct mea **tmea = (struct mea **) mem_tgt;
1641 struct mea *mea = (void *) disk_src;
1645 mea_size = sizeof(struct ll_fid) *
1646 lmv->desc.ld_tgt_count + sizeof(struct mea);
1647 if (mem_tgt == NULL)
1650 if (*mem_tgt != NULL && disk_src == NULL) {
1651 OBD_FREE(*tmea, mea_size);
1655 LASSERT(mea_size == mdsize);
1657 OBD_ALLOC(*tmea, mea_size);
1664 #warning "MEA unpacking/convertation must be here! -bzzz"
1665 memcpy(*tmea, mea, mdsize);
1669 int lmv_brw(int rw, struct obd_export *exp, struct obdo *oa,
1670 struct lov_stripe_md *ea, obd_count oa_bufs,
1671 struct brw_page *pgarr, struct obd_trans_info *oti)
1673 struct obd_device *obd = exp->exp_obd;
1674 struct lmv_obd *lmv = &obd->u.lmv;
1675 struct mea *mea = (struct mea *) ea;
1678 LASSERT(oa != NULL);
1679 LASSERT(ea != NULL);
1680 LASSERT(pgarr != NULL);
1681 LASSERT(oa->o_mds < lmv->desc.ld_tgt_count);
1683 oa->o_gr = mea->mea_fids[oa->o_mds].generation;
1684 oa->o_id = mea->mea_fids[oa->o_mds].id;
1685 oa->o_valid = OBD_MD_FLID | OBD_MD_FLGROUP;
1686 err = obd_brw(rw, lmv->tgts[oa->o_mds].ltd_exp, oa,
1687 NULL, oa_bufs, pgarr, oti);
1691 struct obd_ops lmv_obd_ops = {
1692 .o_owner = THIS_MODULE,
1693 .o_attach = lmv_attach,
1694 .o_detach = lmv_detach,
1695 .o_setup = lmv_setup,
1696 .o_cleanup = lmv_cleanup,
1697 .o_connect = lmv_connect,
1698 .o_disconnect = lmv_disconnect,
1699 .o_statfs = lmv_statfs,
1700 .o_get_info = lmv_get_info,
1701 .o_set_info = lmv_set_info,
1702 .o_create = lmv_obd_create,
1703 .o_packmd = lmv_packmd,
1704 .o_unpackmd = lmv_unpackmd,
1706 .o_init_ea_size = lmv_init_ea_size,
1707 .o_notify = lmv_notify,
1708 .o_iocontrol = lmv_iocontrol,
1711 struct md_ops lmv_md_ops = {
1712 .m_getstatus = lmv_getstatus,
1713 .m_getattr = lmv_getattr,
1714 .m_change_cbdata = lmv_change_cbdata,
1715 .m_change_cbdata_name = lmv_change_cbdata_name,
1716 .m_close = lmv_close,
1717 .m_create = lmv_create,
1718 .m_done_writing = lmv_done_writing,
1719 .m_enqueue = lmv_enqueue,
1720 .m_getattr_name = lmv_getattr_name,
1721 .m_intent_lock = lmv_intent_lock,
1723 .m_rename = lmv_rename,
1724 .m_setattr = lmv_setattr,
1726 .m_readpage = lmv_readpage,
1727 .m_unlink = lmv_unlink,
1728 .m_get_real_obd = lmv_get_real_obd,
1729 .m_valid_attrs = lmv_valid_attrs,
1730 .m_delete_object = lmv_delete_object,
1733 int __init lmv_init(void)
1735 struct lprocfs_static_vars lvars;
1738 lprocfs_init_vars(lmv, &lvars);
1739 rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
1740 lvars.module_vars, OBD_LMV_DEVICENAME);
1745 static void lmv_exit(void)
1747 class_unregister_type(OBD_LMV_DEVICENAME);
1750 MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
1751 MODULE_DESCRIPTION("Lustre Logical Metadata Volume OBD driver");
1752 MODULE_LICENSE("GPL");
1754 module_init(lmv_init);
1755 module_exit(lmv_exit);