Whamcloud - gitweb
LU-1304 osd: ->do_ah_init() to accept new object
authorAlex Zhuravlev <bzzz@whamcloud.com>
Wed, 12 Sep 2012 16:30:03 +0000 (20:30 +0400)
committerOleg Drokin <green@whamcloud.com>
Thu, 20 Sep 2012 04:00:15 +0000 (00:00 -0400)
being created so that OSD API implementation can
initialize some default values, etc.

Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Change-Id: If4bda7626b4406f906a95df3704885c4531567ee
Reviewed-on: http://review.whamcloud.com/3959
Tested-by: Hudson
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Jinshan Xiong <jinshan.xiong@whamcloud.com>
lustre/include/dt_object.h
lustre/mdd/mdd_dir.c
lustre/mdd/mdd_internal.h
lustre/mdd/mdd_object.c
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-zfs/osd_object.c

index 6cdd013..a16c981 100644 (file)
@@ -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.
index e3c8fb5..7d5eedc 100644 (file)
@@ -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));
index 4396734..5a03b8c 100644 (file)
@@ -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)
 {
index ef9193f..05d7b24 100644 (file)
@@ -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
  */
index aee20d7..78d8916 100644 (file)
@@ -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);
 
index 6b1373d..e88f4e1 100644 (file)
@@ -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);