to follow ZFS on-disk format osd_object_create() should
initialize regular attribute storing parent dnode.
parent dnode is taken from object passed to create as an
allocation hint.
Signed-off-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Change-Id: I1b4b4b5d7c6989c39f6bdecd52af48f270ad5beb
Reviewed-on: http://review.whamcloud.com/5642
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Nathaniel Clark <nathaniel.l.clark@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
int osd_object_sa_update(struct osd_object *obj, sa_attr_type_t type,
void *buf, uint32_t buflen, struct osd_thandle *oh);
int __osd_zap_create(const struct lu_env *env, udmu_objset_t *uos,
int osd_object_sa_update(struct osd_object *obj, sa_attr_type_t type,
void *buf, uint32_t buflen, struct osd_thandle *oh);
int __osd_zap_create(const struct lu_env *env, udmu_objset_t *uos,
- dmu_buf_t **zap_dbp, dmu_tx_t *tx,
- struct lu_attr *la, void *tag, zap_flags_t flags);
+ dmu_buf_t **zap_dbp, dmu_tx_t *tx, struct lu_attr *la,
+ uint64_t parent, void *tag, zap_flags_t flags);
int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos,
int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos,
- dmu_buf_t **dbp, dmu_tx_t *tx,
- struct lu_attr *la, void *tag);
+ dmu_buf_t **dbp, dmu_tx_t *tx, struct lu_attr *la,
+ uint64_t parent, void *tag);
int __osd_object_free(udmu_objset_t *uos, uint64_t oid, dmu_tx_t *tx);
/* osd_oi.c */
int __osd_object_free(udmu_objset_t *uos, uint64_t oid, dmu_tx_t *tx);
/* osd_oi.c */
LASSERT(ah);
memset(ah, 0, sizeof(*ah));
LASSERT(ah);
memset(ah, 0, sizeof(*ah));
+ ah->dah_parent = parent;
ah->dah_mode = child_mode;
}
ah->dah_mode = child_mode;
}
-int __osd_attr_init(const struct lu_env *env, udmu_objset_t *uos,
- uint64_t oid, dmu_tx_t *tx, struct lu_attr *la)
+int __osd_attr_init(const struct lu_env *env, udmu_objset_t *uos, uint64_t oid,
+ dmu_tx_t *tx, struct lu_attr *la, uint64_t parent)
{
sa_bulk_attr_t *bulk;
sa_handle_t *sa_hdl;
struct osa_attr *osa = &osd_oti_get(env)->oti_osa;
uint64_t gen;
{
sa_bulk_attr_t *bulk;
sa_handle_t *sa_hdl;
struct osa_attr *osa = &osd_oti_get(env)->oti_osa;
uint64_t gen;
uint64_t crtime[2];
timestruc_t now;
int cnt;
uint64_t crtime[2];
timestruc_t now;
int cnt;
gen = dmu_tx_get_txg(tx);
ZFS_TIME_ENCODE(&now, crtime);
gen = dmu_tx_get_txg(tx);
ZFS_TIME_ENCODE(&now, crtime);
- /* XXX: this should be real id of parent for ZPL access, but we have no
- * such info in OSD, probably it can be part of dt_object_format */
- parent = 0;
osa->atime[0] = la->la_atime;
osa->ctime[0] = la->la_ctime;
osa->atime[0] = la->la_atime;
osa->ctime[0] = la->la_ctime;
* to a transaction group.
*/
int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos,
* to a transaction group.
*/
int __osd_object_create(const struct lu_env *env, udmu_objset_t *uos,
- dmu_buf_t **dbp, dmu_tx_t *tx,
- struct lu_attr *la, void *tag)
+ dmu_buf_t **dbp, dmu_tx_t *tx, struct lu_attr *la,
+ uint64_t parent, void *tag)
la->la_size = 0;
la->la_nlink = 1;
la->la_size = 0;
la->la_nlink = 1;
- return __osd_attr_init(env, uos, oid, tx, la);
+ return __osd_attr_init(env, uos, oid, tx, la, parent);
* a conversion from the different internal ZAP hash formats being used. */
int __osd_zap_create(const struct lu_env *env, udmu_objset_t *uos,
dmu_buf_t **zap_dbp, dmu_tx_t *tx,
* a conversion from the different internal ZAP hash formats being used. */
int __osd_zap_create(const struct lu_env *env, udmu_objset_t *uos,
dmu_buf_t **zap_dbp, dmu_tx_t *tx,
- struct lu_attr *la, void *tag, zap_flags_t flags)
+ struct lu_attr *la, uint64_t parent,
+ void *tag, zap_flags_t flags)
la->la_size = 2;
la->la_nlink = 1;
la->la_size = 2;
la->la_nlink = 1;
- return __osd_attr_init(env, uos, oid, tx, la);
+ return __osd_attr_init(env, uos, oid, tx, la, parent);
}
static dmu_buf_t *osd_mkidx(const struct lu_env *env, struct osd_device *osd,
}
static dmu_buf_t *osd_mkidx(const struct lu_env *env, struct osd_device *osd,
- struct lu_attr *la, struct osd_thandle *oh)
+ struct lu_attr *la, uint64_t parent,
+ struct osd_thandle *oh)
* binary keys */
LASSERT(S_ISREG(la->la_mode));
rc = __osd_zap_create(env, &osd->od_objset, &db, oh->ot_tx, la,
* binary keys */
LASSERT(S_ISREG(la->la_mode));
rc = __osd_zap_create(env, &osd->od_objset, &db, oh->ot_tx, la,
- osd_obj_tag, ZAP_FLAG_UINT64_KEY);
+ parent, osd_obj_tag, ZAP_FLAG_UINT64_KEY);
if (rc)
return ERR_PTR(rc);
return db;
}
static dmu_buf_t *osd_mkdir(const struct lu_env *env, struct osd_device *osd,
if (rc)
return ERR_PTR(rc);
return db;
}
static dmu_buf_t *osd_mkdir(const struct lu_env *env, struct osd_device *osd,
- struct lu_attr *la, struct osd_thandle *oh)
+ struct lu_attr *la, uint64_t parent,
+ struct osd_thandle *oh)
{
dmu_buf_t *db;
int rc;
LASSERT(S_ISDIR(la->la_mode));
rc = __osd_zap_create(env, &osd->od_objset, &db, oh->ot_tx, la,
{
dmu_buf_t *db;
int rc;
LASSERT(S_ISDIR(la->la_mode));
rc = __osd_zap_create(env, &osd->od_objset, &db, oh->ot_tx, la,
+ parent, osd_obj_tag, 0);
if (rc)
return ERR_PTR(rc);
return db;
}
static dmu_buf_t* osd_mkreg(const struct lu_env *env, struct osd_device *osd,
if (rc)
return ERR_PTR(rc);
return db;
}
static dmu_buf_t* osd_mkreg(const struct lu_env *env, struct osd_device *osd,
- struct lu_attr *la, struct osd_thandle *oh)
+ struct lu_attr *la, uint64_t parent,
+ struct osd_thandle *oh)
{
dmu_buf_t *db;
int rc;
LASSERT(S_ISREG(la->la_mode));
rc = __osd_object_create(env, &osd->od_objset, &db, oh->ot_tx, la,
{
dmu_buf_t *db;
int rc;
LASSERT(S_ISREG(la->la_mode));
rc = __osd_object_create(env, &osd->od_objset, &db, oh->ot_tx, la,
if (rc)
return ERR_PTR(rc);
if (rc)
return ERR_PTR(rc);
}
static dmu_buf_t *osd_mksym(const struct lu_env *env, struct osd_device *osd,
}
static dmu_buf_t *osd_mksym(const struct lu_env *env, struct osd_device *osd,
- struct lu_attr *la, struct osd_thandle *oh)
+ struct lu_attr *la, uint64_t parent,
+ struct osd_thandle *oh)
{
dmu_buf_t *db;
int rc;
LASSERT(S_ISLNK(la->la_mode));
rc = __osd_object_create(env, &osd->od_objset, &db, oh->ot_tx, la,
{
dmu_buf_t *db;
int rc;
LASSERT(S_ISLNK(la->la_mode));
rc = __osd_object_create(env, &osd->od_objset, &db, oh->ot_tx, la,
if (rc)
return ERR_PTR(rc);
return db;
}
static dmu_buf_t *osd_mknod(const struct lu_env *env, struct osd_device *osd,
if (rc)
return ERR_PTR(rc);
return db;
}
static dmu_buf_t *osd_mknod(const struct lu_env *env, struct osd_device *osd,
- struct lu_attr *la, struct osd_thandle *oh)
+ struct lu_attr *la, uint64_t parent,
+ struct osd_thandle *oh)
la->la_valid |= LA_RDEV;
rc = __osd_object_create(env, &osd->od_objset, &db, oh->ot_tx, la,
la->la_valid |= LA_RDEV;
rc = __osd_object_create(env, &osd->od_objset, &db, oh->ot_tx, la,
if (rc)
return ERR_PTR(rc);
return db;
}
if (rc)
return ERR_PTR(rc);
return db;
}
-typedef dmu_buf_t *(*osd_obj_type_f)(const struct lu_env *env, struct osd_device *osd,
- struct lu_attr *la, struct osd_thandle *oh);
+typedef dmu_buf_t *(*osd_obj_type_f)(const struct lu_env *env,
+ struct osd_device *osd,
+ struct lu_attr *la,
+ uint64_t parent,
+ struct osd_thandle *oh);
static osd_obj_type_f osd_create_type_f(enum dt_format_type type)
{
static osd_obj_type_f osd_create_type_f(enum dt_format_type type)
{
LASSERT(obj->oo_db == NULL);
LASSERT(obj->oo_db == NULL);
- db = osd_create_type_f(dof->dof_type)(env, osd, attr, oh);
+ /* to follow ZFS on-disk format we need
+ * to initialize parent dnode properly */
+ zapid = 0;
+ if (hint && hint->dah_parent)
+ zapid = osd_dt_obj(hint->dah_parent)->oo_db->db_object;
+
+ db = osd_create_type_f(dof->dof_type)(env, osd, attr, zapid, oh);
if (IS_ERR(db))
GOTO(out, rc = PTR_ERR(th));
if (IS_ERR(db))
GOTO(out, rc = PTR_ERR(th));
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;
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;
zde->zde_dnode = db->db_object;
zde->zde_pad = 0;
la->la_valid = LA_MODE;
la->la_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
la->la_valid = LA_MODE;
la->la_mode = S_IFDIR | S_IRUGO | S_IWUSR | S_IXUGO;
- rc = __osd_zap_create(env, uos, &xa_zap_db, tx, la, FTAG, 0);
+ rc = __osd_zap_create(env, uos, &xa_zap_db, tx, la,
+ obj->oo_db->db_object, FTAG, 0);
la->la_valid = LA_MODE;
la->la_mode = S_IFREG | S_IRUGO | S_IWUSR;
la->la_valid = LA_MODE;
la->la_mode = S_IFREG | S_IRUGO | S_IWUSR;
- rc = __osd_object_create(env, uos, &xa_data_db, tx, la, FTAG);
+ rc = __osd_object_create(env, uos, &xa_data_db, tx, la,
+ obj->oo_xattr, FTAG);
if (rc)
goto out;
xa_data_obj = xa_data_db->db_object;
if (rc)
goto out;
xa_data_obj = xa_data_db->db_object;