lu_object_put(env, &obj->oo_dt.do_lu);
}
+static int osd_remote_fid(const struct lu_env *env, struct osd_device *osd,
+ struct lu_fid *fid)
+{
+ struct lu_seq_range *range = &osd_oti_get(env)->oti_seq_range;
+ struct seq_server_site *ss = osd_seq_site(osd);
+ int rc;
+ ENTRY;
+
+ if (!fid_is_norm(fid) && !fid_is_root(fid))
+ RETURN(0);
+
+ rc = osd_fld_lookup(env, osd, fid, range);
+ if (rc != 0) {
+ CERROR("%s: Can not lookup fld for "DFID"\n",
+ osd_name(osd), PFID(fid));
+ RETURN(rc);
+ }
+
+ RETURN(ss->ss_node_id != range->lsr_index);
+}
+
/**
* Inserts (key, value) pair in \a directory object.
*
struct osd_device *osd = osd_obj2dev(parent);
struct lu_fid *fid = (struct lu_fid *)rec;
struct osd_thandle *oh;
- struct osd_object *child;
+ struct osd_object *child = NULL;
__u32 attr;
char *name = (char *)key;
int rc;
LASSERT(th != NULL);
oh = container_of0(th, struct osd_thandle, ot_super);
- child = osd_object_find(env, dt, fid);
- if (IS_ERR(child))
- RETURN(PTR_ERR(child));
+ rc = osd_remote_fid(env, osd, fid);
+ if (rc < 0) {
+ CERROR("%s: Can not find object "DFID": rc = %d\n",
+ osd->od_svname, PFID(fid), rc);
+ RETURN(rc);
+ }
+
+ if (unlikely(rc == 1)) {
+ /* Insert remote entry */
+ memset(&oti->oti_zde.lzd_reg, 0, sizeof(oti->oti_zde.lzd_reg));
+ oti->oti_zde.lzd_reg.zde_type = IFTODT(S_IFDIR & S_IFMT);
+ } else {
+ /*
+ * To simulate old Orion setups with ./.. stored in the
+ * directories
+ */
+ /* Insert local entry */
+ child = osd_object_find(env, dt, fid);
+ if (IS_ERR(child))
+ RETURN(PTR_ERR(child));
-/*
- * to simulate old Orion setups with ./.. stored in the directories
- */
#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 3, 91, 0)
#define OSD_ZFS_INSERT_DOTS_FOR_TESTING__
#endif
-
- LASSERT(child->oo_db);
- if (name[0] == '.') {
- if (name[1] == 0) {
- /* do not store ".", instead generate it
- * during iteration */
+ LASSERT(child->oo_db);
+ if (name[0] == '.') {
+ if (name[1] == 0) {
+ /* do not store ".", instead generate it
+ * during iteration */
#ifndef OSD_ZFS_INSERT_DOTS_FOR_TESTING
- GOTO(out, rc = 0);
+ GOTO(out, rc = 0);
#endif
- } else if (name[1] == '.' && name[2] == 0) {
- /* update parent dnode in the child.
- * later it will be used to generate ".." */
- udmu_objset_t *uos = &osd->od_objset;
- rc = osd_object_sa_update(parent, SA_ZPL_PARENT(uos),
- &child->oo_db->db_object,
- 8, oh);
-
+ } else if (name[1] == '.' && name[2] == 0) {
+ /* update parent dnode in the child.
+ * later it will be used to generate ".." */
+ udmu_objset_t *uos = &osd->od_objset;
+ rc = osd_object_sa_update(parent, SA_ZPL_PARENT(uos),
+ &child->oo_db->db_object,
+ 8, oh);
#ifndef OSD_ZFS_INSERT_DOTS_FOR_TESTING
- GOTO(out, rc);
+ GOTO(out, rc);
#endif
+ }
}
+ CLASSERT(sizeof(oti->oti_zde.lzd_reg) == 8);
+ CLASSERT(sizeof(oti->oti_zde) % 8 == 0);
+ attr = child->oo_dt.do_lu.lo_header ->loh_attr;
+ oti->oti_zde.lzd_reg.zde_type = IFTODT(attr & S_IFMT);
+ oti->oti_zde.lzd_reg.zde_dnode = child->oo_db->db_object;
}
- CLASSERT(sizeof(oti->oti_zde.lzd_reg) == 8);
- CLASSERT(sizeof(oti->oti_zde) % 8 == 0);
- attr = child->oo_dt.do_lu.lo_header ->loh_attr;
- oti->oti_zde.lzd_reg.zde_type = IFTODT(attr & S_IFMT);
- oti->oti_zde.lzd_reg.zde_dnode = child->oo_db->db_object;
oti->oti_zde.lzd_fid = *fid;
-
/* Insert (key,oid) into ZAP */
rc = -zap_add(osd->od_objset.os, parent->oo_db->db_object,
(char *)key, 8, sizeof(oti->oti_zde) / 8,
#ifndef OSD_ZFS_INSERT_DOTS_FOR_TESTING
out:
#endif
- osd_object_put(env, child);
+ if (child != NULL)
+ osd_object_put(env, child);
RETURN(rc);
}
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;
}