From e1a430be4a4a08e39b945a35a04c8286353fb6fc Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Wed, 12 Sep 2012 20:30:03 +0400 Subject: [PATCH] LU-1304 osd: ->do_ah_init() to accept new object being created so that OSD API implementation can initialize some default values, etc. Signed-off-by: Alex Zhuravlev Change-Id: If4bda7626b4406f906a95df3704885c4531567ee Reviewed-on: http://review.whamcloud.com/3959 Tested-by: Hudson Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong --- lustre/include/dt_object.h | 1 + lustre/mdd/mdd_dir.c | 10 ++++++++++ lustre/mdd/mdd_internal.h | 3 +++ lustre/mdd/mdd_object.c | 16 +++++++++++----- lustre/osd-ldiskfs/osd_handler.c | 3 ++- lustre/osd-zfs/osd_object.c | 3 ++- 6 files changed, 29 insertions(+), 7 deletions(-) diff --git a/lustre/include/dt_object.h b/lustre/include/dt_object.h index 6cdd013..a16c981 100644 --- a/lustre/include/dt_object.h +++ b/lustre/include/dt_object.h @@ -382,6 +382,7 @@ struct dt_object_operations { void (*do_ah_init)(const struct lu_env *env, struct dt_allocation_hint *ah, struct dt_object *parent, + struct dt_object *child, cfs_umode_t child_mode); /** * Create new object on this device. diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index e3c8fb5..7d5eedc 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -1655,6 +1655,7 @@ static int mdd_create_data(const struct lu_env *env, struct md_object *pobj, struct lov_mds_md *lmm = NULL; int lmm_size = 0; struct thandle *handle; + struct lu_attr *attr = &mdd_env_info(env)->mti_la_for_fix; int rc; ENTRY; @@ -1670,6 +1671,13 @@ static int mdd_create_data(const struct lu_env *env, struct md_object *pobj, if (rc) RETURN(rc); + rc = mdd_la_get(env, son, attr, mdd_object_capa(env, son)); + if (rc) + RETURN(rc); + + /* calling ->ah_make_hint() is used to transfer information from parent */ + mdd_object_make_hint(env, mdd_pobj, son, attr); + handle = mdd_trans_create(env, mdd); if (IS_ERR(handle)) GOTO(out_free, rc = PTR_ERR(handle)); @@ -2130,6 +2138,8 @@ static int mdd_create(const struct lu_env *env, got_def_acl = 1; } + mdd_object_make_hint(env, mdd_pobj, son, attr); + handle = mdd_trans_create(env, mdd); if (IS_ERR(handle)) GOTO(out_free, rc = PTR_ERR(handle)); diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 4396734..5a03b8c 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -450,6 +450,9 @@ int mdd_quota_finvalidate(const struct lu_env *env, struct md_device *m, int mdd_lov_destroy(const struct lu_env *env, struct mdd_device *mdd, struct mdd_object *obj, struct lu_attr *la); +void mdd_object_make_hint(const struct lu_env *env, struct mdd_object *parent, + struct mdd_object *child, struct lu_attr *attr); + static inline void mdd_object_put(const struct lu_env *env, struct mdd_object *o) { diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index ef9193f..05d7b24 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -981,11 +981,6 @@ int mdd_object_create_internal(const struct lu_env *env, struct mdd_object *p, dof->u.dof_idx.di_feat = feat; - /* @hint will be initialized by underlying device. */ - next->do_ops->do_ah_init(env, hint, - p ? mdd_object_child(p) : NULL, - attr->la_mode & S_IFMT); - rc = mdo_create_obj(env, c, attr, hint, dof, handle); LASSERT(ergo(rc == 0, mdd_object_exists(c))); } else @@ -2252,6 +2247,17 @@ static int mdd_ref_add(const struct lu_env *env, struct md_object *obj, RETURN(rc); } +void mdd_object_make_hint(const struct lu_env *env, struct mdd_object *parent, + struct mdd_object *child, struct lu_attr *attr) +{ + struct dt_allocation_hint *hint = &mdd_env_info(env)->mti_hint; + struct dt_object *np = parent ? mdd_object_child(parent) : NULL; + struct dt_object *nc = mdd_object_child(child); + + /* @hint will be initialized by underlying device. */ + nc->do_ops->do_ah_init(env, hint, np, nc, attr->la_mode & S_IFMT); +} + /* * do NOT or the MAY_*'s, you'll get the weakest */ diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index aee20d7..78d8916 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -1901,7 +1901,8 @@ static osd_obj_type_f osd_create_type_f(enum dt_format_type type) static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah, - struct dt_object *parent, cfs_umode_t child_mode) + struct dt_object *parent, struct dt_object *child, + cfs_umode_t child_mode) { LASSERT(ah); diff --git a/lustre/osd-zfs/osd_object.c b/lustre/osd-zfs/osd_object.c index 6b1373d..e88f4e1 100644 --- a/lustre/osd-zfs/osd_object.c +++ b/lustre/osd-zfs/osd_object.c @@ -1007,7 +1007,8 @@ static int osd_attr_set(const struct lu_env *env, struct dt_object *dt, */ static void osd_ah_init(const struct lu_env *env, struct dt_allocation_hint *ah, - struct dt_object *parent, cfs_umode_t child_mode) + struct dt_object *parent, struct dt_object *child, + cfs_umode_t child_mode) { LASSERT(ah); -- 1.8.3.1