struct seq_server_site *ss = osd_seq_site(osd);
int rc;
+ if (fid_is_root(fid)) {
+ range->lsr_flags = LU_SEQ_RANGE_MDT;
+ range->lsr_index = 0;
+ return 0;
+ }
+
if (fid_is_idif(fid)) {
range->lsr_flags = LU_SEQ_RANGE_OST;
range->lsr_index = fid_idif_ost_idx(fid);
if (!fid_is_norm(fid)) {
range->lsr_flags = LU_SEQ_RANGE_MDT;
+ /* If ss is NULL, it suppose not get lsr_index at all */
if (ss != NULL)
range->lsr_index = ss->ss_node_id;
return 0;
LASSERT(ss != NULL);
range->lsr_flags = -1;
rc = fld_server_lookup(env, ss->ss_server_fld, fid_seq(fid), range);
- if (rc != 0) {
+ if (rc != 0)
CERROR("%s can not find "DFID": rc = %d\n",
- osd2lu_dev(osd)->ld_obd->obd_name, PFID(fid), rc);
- }
+ osd_name(osd), PFID(fid), rc);
return 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);
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));
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.
*/