+struct lu_object *lod_object_alloc(const struct lu_env *env,
+ const struct lu_object_header *hdr,
+ struct lu_device *dev)
+{
+ struct lod_object *lod_obj;
+ struct lu_object *lu_obj;
+ ENTRY;
+
+ OBD_SLAB_ALLOC_PTR_GFP(lod_obj, lod_object_kmem, GFP_NOFS);
+ if (lod_obj == NULL)
+ RETURN(ERR_PTR(-ENOMEM));
+
+ lu_obj = lod2lu_obj(lod_obj);
+ dt_object_init(&lod_obj->ldo_obj, NULL, dev);
+ lod_obj->ldo_obj.do_ops = &lod_obj_ops;
+ lu_obj->lo_ops = &lod_lu_obj_ops;
+
+ RETURN(lu_obj);
+}
+
+static int lod_cleanup_desc_tgts(const struct lu_env *env,
+ struct lod_device *lod,
+ struct lod_tgt_descs *ltd,
+ struct lustre_cfg *lcfg)
+{
+ struct lu_device *next;
+ int rc = 0;
+ int i;
+
+ lod_getref(ltd);
+ if (ltd->ltd_tgts_size <= 0) {
+ lod_putref(lod, ltd);
+ return 0;
+ }
+ cfs_foreach_bit(ltd->ltd_tgt_bitmap, i) {
+ struct lod_tgt_desc *tgt;
+ int rc1;
+
+ tgt = LTD_TGT(ltd, i);
+ LASSERT(tgt && tgt->ltd_tgt);
+ next = &tgt->ltd_tgt->dd_lu_dev;
+ rc1 = next->ld_ops->ldo_process_config(env, next, lcfg);
+ if (rc1) {
+ CERROR("%s: error cleaning up LOD index %u: cmd %#x"
+ ": rc = %d\n", lod2obd(lod)->obd_name, i,
+ lcfg->lcfg_command, rc1);
+ rc = rc1;
+ }
+ }
+ lod_putref(lod, ltd);
+ return rc;
+}
+
+static int lodname2mdt_index(char *lodname, long *index)
+{
+ char *ptr, *tmp;
+
+ /* The lodname suppose to be fsname-MDTxxxx-mdtlov */
+ ptr = strrchr(lodname, '-');
+ if (ptr == NULL) {
+ CERROR("invalid MDT index in '%s'\n", lodname);
+ return -EINVAL;
+ }
+
+ if (strncmp(ptr, "-mdtlov", 7) != 0) {
+ CERROR("invalid MDT index in '%s'\n", lodname);
+ return -EINVAL;
+ }
+
+ if ((unsigned long)ptr - (unsigned long)lodname <= 8) {
+ CERROR("invalid MDT index in '%s'\n", lodname);
+ return -EINVAL;
+ }
+
+ if (strncmp(ptr - 8, "-MDT", 4) != 0) {
+ CERROR("invalid MDT index in '%s'\n", lodname);
+ return -EINVAL;
+ }
+
+ *index = simple_strtol(ptr - 4, &tmp, 16);
+ if (*tmp != '-' || *index > INT_MAX || *index < 0) {
+ CERROR("invalid MDT index in '%s'\n", lodname);
+ return -EINVAL;
+ }
+ return 0;
+}
+
+/**
+ * Procss config log on LOD
+ * \param env environment info
+ * \param dev lod device
+ * \param lcfg config log
+ *
+ * Add osc config log,
+ * marker 20 (flags=0x01, v2.2.49.56) lustre-OST0001 'add osc'
+ * add_uuid nid=192.168.122.162@tcp(0x20000c0a87aa2) 0: 1:nidxxx
+ * attach 0:lustre-OST0001-osc-MDT0001 1:osc 2:lustre-MDT0001-mdtlov_UUID
+ * setup 0:lustre-OST0001-osc-MDT0001 1:lustre-OST0001_UUID 2:nid
+ * lov_modify_tgts add 0:lustre-MDT0001-mdtlov 1:lustre-OST0001_UUID 2:1 3:1
+ * marker 20 (flags=0x02, v2.2.49.56) lustre-OST0001 'add osc'
+ *
+ * Add mdc config log
+ * marker 10 (flags=0x01, v2.2.49.56) lustre-MDT0000 'add osp'
+ * add_uuid nid=192.168.122.162@tcp(0x20000c0a87aa2) 0: 1:nid
+ * attach 0:lustre-MDT0000-osp-MDT0001 1:osp 2:lustre-MDT0001-mdtlov_UUID
+ * setup 0:lustre-MDT0000-osp-MDT0001 1:lustre-MDT0000_UUID 2:nid
+ * modify_mdc_tgts add 0:lustre-MDT0001 1:lustre-MDT0000_UUID 2:0 3:1
+ * marker 10 (flags=0x02, v2.2.49.56) lustre-MDT0000_UUID 'add osp'
+ **/