X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fosd-zfs%2Fosd_oi.c;h=706b9e47c74f04b08c1fed5961c5a680f3860d47;hb=2dc1bb8b7a53077fce8632aabe65b2ce8048a550;hp=f5e941b04f8002e0fd14eea86675744935b7c7f4;hpb=073a1b04c5fc4b38717d70748d88ded614e9365d;p=fs%2Flustre-release.git diff --git a/lustre/osd-zfs/osd_oi.c b/lustre/osd-zfs/osd_oi.c index f5e941b..706b9e4 100644 --- a/lustre/osd-zfs/osd_oi.c +++ b/lustre/osd-zfs/osd_oi.c @@ -28,7 +28,7 @@ * Use is subject to license terms. */ /* - * Copyright (c) 2012, Intel Corporation. + * Copyright (c) 2012, 2013, Intel Corporation. * Use is subject to license terms. */ /* @@ -43,9 +43,6 @@ * Author: Di Wang */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_OSD #include @@ -96,14 +93,11 @@ static const struct named_oid oids[] = { { MGS_CONFIGS_OID, NULL /*MOUNT_CONFIGS_DIR*/ }, { FID_SEQ_SRV_OID, "seq_srv" }, { FID_SEQ_CTL_OID, "seq_ctl" }, - { MDD_CAPA_KEYS_OID, NULL /*CAPA_KEYS*/ }, { FLD_INDEX_OID, "fld" }, { MDD_LOV_OBJ_OID, LOV_OBJID }, { OFD_HEALTH_CHECK_OID, HEALTH_CHECK }, { ACCT_USER_OID, "acct_usr_inode" }, { ACCT_GROUP_OID, "acct_grp_inode" }, - { MDD_ROOT_INDEX_OID, NULL }, - { MDD_ORPHAN_OID, NULL }, { 0, NULL } }; @@ -177,7 +171,7 @@ osd_oi_create(const struct lu_env *env, struct osd_device *o, la->la_valid = LA_MODE | LA_UID | LA_GID; la->la_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO; la->la_uid = la->la_gid = 0; - __osd_zap_create(env, &o->od_objset, &db, tx, la, oi_tag, 0); + __osd_zap_create(env, &o->od_objset, &db, tx, la, parent, oi_tag, 0); zde->zde_dnode = db->db_object; zde->zde_pad = 0; @@ -220,25 +214,26 @@ int osd_fld_lookup(const struct lu_env *env, struct osd_device *osd, int rc; if (fid_is_idif(fid)) { - range->lsr_flags = LU_SEQ_RANGE_OST; + fld_range_set_ost(range); range->lsr_index = fid_idif_ost_idx(fid); return 0; } - if (!fid_is_norm(fid)) { - range->lsr_flags = LU_SEQ_RANGE_MDT; + if (!fid_seq_in_fldb(fid_seq(fid))) { + fld_range_set_mdt(range); if (ss != NULL) + /* FIXME: If ss is NULL, it suppose not get lsr_index + * at all */ range->lsr_index = ss->ss_node_id; return 0; } LASSERT(ss != NULL); - range->lsr_flags = -1; + fld_range_set_any(range); rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), range); - if (rc != 0) { - CERROR("%s can not find "DFID": rc = %d\n", - osd2lu_dev(osd)->ld_obd->obd_name, PFID(fid), rc); - } + if (rc != 0) + CERROR("%s: cannot find FLD range for "DFID": rc = %d\n", + osd_name(osd), PFID(fid), rc); return rc; } @@ -255,14 +250,14 @@ int fid_is_on_ost(const struct lu_env *env, struct osd_device *osd, rc = osd_fld_lookup(env, osd, fid, range); if (rc != 0) { CERROR("%s: Can not lookup fld for "DFID"\n", - osd2lu_dev(osd)->ld_obd->obd_name, PFID(fid)); + osd_name(osd), PFID(fid)); RETURN(rc); } CDEBUG(D_INFO, "fid "DFID" range "DRANGE"\n", PFID(fid), PRANGE(range)); - if (range->lsr_flags == LU_SEQ_RANGE_OST) + if (fld_range_is_ost(range)) RETURN(1); RETURN(0); @@ -341,21 +336,18 @@ static struct osd_seq *osd_find_or_add_seq(const struct lu_env *env, fid_seq_is_mdt0(seq)) ? LPU64 : LPX64i, fid_seq_is_idif(seq) ? 0 : seq); - rc = osd_oi_create(env, osd, oi.oi_zapid, seq_name, &odb); + rc = osd_oi_find_or_create(env, osd, oi.oi_zapid, seq_name, &odb); if (rc != 0) { CERROR("%s: Can not create %s : rc = %d\n", osd_name(osd), seq_name, rc); GOTO(out, rc); } - if (seq == 0) - osd->od_ost_compat_grp0 = odb; - for (i = 0; i < OSD_OST_MAP_SIZE; i++) { sprintf(key, "d%d", i); rc = osd_oi_find_or_create(env, osd, odb, key, &sdb); if (rc) - GOTO(out, osd_seq = ERR_PTR(rc)); + GOTO(out, rc); osd_seq->os_compat_dirs[i] = sdb; } @@ -394,12 +386,13 @@ osd_get_idx_for_ost_obj(const struct lu_env *env, struct osd_device *osd, PFID(fid)); return PTR_ERR(osd_seq); } - rc = fid_ostid_pack(fid, &osd_oti_get(env)->oti_ostid); + + rc = fid_to_ostid(fid, &osd_oti_get(env)->oti_ostid); LASSERT(rc == 0); /* we should not get here with IGIF */ - b = osd_oti_get(env)->oti_ostid.oi_id % OSD_OST_MAP_SIZE; + b = ostid_id(&osd_oti_get(env)->oti_ostid) % OSD_OST_MAP_SIZE; LASSERT(osd_seq->os_compat_dirs[b]); - sprintf(buf, LPU64, osd_oti_get(env)->oti_ostid.oi_id); + sprintf(buf, LPU64, ostid_id(&osd_oti_get(env)->oti_ostid)); return osd_seq->os_compat_dirs[b]; } @@ -437,10 +430,8 @@ uint64_t osd_get_name_n_idx(const struct lu_env *env, struct osd_device *osd, LASSERT(fid); LASSERT(buf); - if (fid_is_on_ost(env, osd, fid) == 1) { + if (fid_is_on_ost(env, osd, fid) == 1 || fid_seq(fid) == FID_SEQ_ECHO) { zapid = osd_get_idx_for_ost_obj(env, osd, fid, buf); - } else if (fid_is_last_id(fid)) { - zapid = osd->od_ost_compat_grp0; } else if (unlikely(fid_seq(fid) == FID_SEQ_LOCAL_FILE)) { /* special objects with fixed known fids get their name */ char *name = oid2name(fid_oid(fid)); @@ -684,6 +675,107 @@ osd_oi_init_compat(const struct lu_env *env, struct osd_device *o) RETURN(rc); } +static char *root2convert = "ROOT"; +/* + * due to DNE requirements we have to change sequence of /ROOT object + * so that it doesn't belong to the local sequence FID_SEQ_LOCAL_FILE + * but a normal sequence living on MDS#0 + * this is the sole purpose of this function. + * + * This is only needed for pre-production 2.4 ZFS filesystems, and + * can be removed in the future. + */ +int osd_convert_root_to_new_seq(const struct lu_env *env, + struct osd_device *o) +{ + struct luz_direntry *lze = &osd_oti_get(env)->oti_zde; + char *buf = osd_oti_get(env)->oti_str; + struct lu_fid newfid; + uint64_t zapid; + dmu_tx_t *tx = NULL; + int rc; + ENTRY; + + /* ignore OSTs */ + if (strstr(o->od_svname, "MDT") == NULL) + RETURN(0); + + /* lookup /ROOT */ + rc = -zap_lookup(o->od_objset.os, o->od_root, root2convert, 8, + sizeof(*lze) / 8, (void *)lze); + /* doesn't exist or let actual user to handle the error */ + if (rc) + RETURN(0); + + CDEBUG(D_OTHER, "%s: /ROOT -> "DFID" -> "LPU64"\n", o->od_svname, + PFID(&lze->lzd_fid), (long long int) lze->lzd_reg.zde_dnode); + + /* already right one? */ + if (fid_seq(&lze->lzd_fid) == FID_SEQ_ROOT) + return 0; + + tx = dmu_tx_create(o->od_objset.os); + if (tx == NULL) + return -ENOMEM; + + dmu_tx_hold_bonus(tx, o->od_root); + + /* declare delete/insert of the name */ + dmu_tx_hold_zap(tx, o->od_root, TRUE, root2convert); + dmu_tx_hold_zap(tx, o->od_root, FALSE, root2convert); + + /* declare that we'll remove object from fid-dnode mapping */ + zapid = osd_get_name_n_idx(env, o, &lze->lzd_fid, buf); + dmu_tx_hold_bonus(tx, zapid); + dmu_tx_hold_zap(tx, zapid, FALSE, buf); + + /* declare that we'll add object to fid-dnode mapping */ + newfid.f_seq = FID_SEQ_ROOT; + newfid.f_oid = 1; + newfid.f_ver = 0; + zapid = osd_get_name_n_idx(env, o, &newfid, buf); + dmu_tx_hold_bonus(tx, zapid); + dmu_tx_hold_zap(tx, zapid, TRUE, buf); + + rc = -dmu_tx_assign(tx, TXG_WAIT); + if (rc) + GOTO(err, rc); + + rc = -zap_remove(o->od_objset.os, o->od_root, root2convert, tx); + if (rc) + GOTO(err, rc); + + /* remove from OI */ + zapid = osd_get_name_n_idx(env, o, &lze->lzd_fid, buf); + rc = -zap_remove(o->od_objset.os, zapid, buf, tx); + if (rc) + GOTO(err, rc); + + lze->lzd_fid = newfid; + rc = -zap_add(o->od_objset.os, o->od_root, root2convert, + 8, sizeof(*lze) / 8, (void *)lze, tx); + if (rc) + GOTO(err, rc); + + /* add to OI with the new fid */ + zapid = osd_get_name_n_idx(env, o, &newfid, buf); + rc = -zap_add(o->od_objset.os, zapid, buf, 8, 1, &lze->lzd_reg, tx); + if (rc) + GOTO(err, rc); + + + /* LMA will be updated in mdd_compat_fixes */ + dmu_tx_commit(tx); + + RETURN(rc); + +err: + if (tx) + dmu_tx_abort(tx); + CERROR("%s: can't convert to new fid: rc = %d\n", o->od_svname, rc); + RETURN(rc); +} + /** * Initialize the OIs by either opening or creating them as needed. */