Whamcloud - gitweb
LU-3531 mdt: delete striped directory
[fs/lustre-release.git] / lustre / osp / osp_md_object.c
index 6ef3019..fc468d3 100644 (file)
@@ -144,8 +144,7 @@ int osp_md_object_create(const struct lu_env *env, struct dt_object *dt,
         * if creation reaches here, it means the object has been created
         * successfully */
        dt->do_lu.lo_header->loh_attr |= LOHA_EXISTS | (attr->la_mode & S_IFMT);
-       if (S_ISDIR(attr->la_mode))
-               obj->opo_empty = 1;
+       obj->opo_empty = 1;
 
        return 0;
 }
@@ -228,10 +227,8 @@ static void osp_md_ah_init(const struct lu_env *env,
        ah->dah_mode = child_mode;
 }
 
-static int osp_md_declare_attr_set(const struct lu_env *env,
-                                  struct dt_object *dt,
-                                  const struct lu_attr *attr,
-                                  struct thandle *th)
+int osp_md_declare_attr_set(const struct lu_env *env, struct dt_object *dt,
+                           const struct lu_attr *attr, struct thandle *th)
 {
        struct osp_thread_info *osi = osp_env_info(env);
        struct update_request  *update;
@@ -263,9 +260,9 @@ static int osp_md_declare_attr_set(const struct lu_env *env,
        return rc;
 }
 
-static int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt,
-                          const struct lu_attr *attr, struct thandle *th,
-                          struct lustre_capa *capa)
+int osp_md_attr_set(const struct lu_env *env, struct dt_object *dt,
+                   const struct lu_attr *attr, struct thandle *th,
+                   struct lustre_capa *capa)
 {
        CDEBUG(D_INFO, "attr set object "DFID"\n",
               PFID(&dt->do_lu.lo_header->loh_fid));
@@ -613,23 +610,22 @@ static int osp_md_object_lock(const struct lu_env *env,
                              struct dt_object *dt,
                              struct lustre_handle *lh,
                              struct ldlm_enqueue_info *einfo,
-                             void *policy)
+                             ldlm_policy_data_t *policy)
 {
-       struct osp_thread_info *info = osp_env_info(env);
-       struct ldlm_res_id     *res_id = &info->osi_resid;
-       struct dt_device       *dt_dev = lu2dt_dev(dt->do_lu.lo_dev);
-       struct osp_device      *osp = dt2osp_dev(dt_dev);
-       struct ptlrpc_request  *req = NULL;
-       int                     rc = 0;
-       __u64                   flags = 0;
-       ldlm_mode_t             mode;
+       struct osp_thread_info  *info = osp_env_info(env);
+       struct ldlm_res_id      *res_id = &info->osi_resid;
+       struct dt_device        *dt_dev = lu2dt_dev(dt->do_lu.lo_dev);
+       struct osp_device       *osp = dt2osp_dev(dt_dev);
+       struct ptlrpc_request   *req;
+       int                     rc = 0;
+       __u64                   flags = 0;
+       ldlm_mode_t             mode;
 
        fid_build_reg_res_name(lu_object_fid(&dt->do_lu), res_id);
 
        mode = ldlm_lock_match(osp->opd_obd->obd_namespace,
                               LDLM_FL_BLOCK_GRANTED, res_id,
-                              einfo->ei_type,
-                              (ldlm_policy_data_t *)policy,
+                              einfo->ei_type, policy,
                               einfo->ei_mode, lh, 0);
        if (mode > 0)
                return ELDLM_OK;
@@ -647,6 +643,19 @@ static int osp_md_object_lock(const struct lu_env *env,
        return rc == ELDLM_OK ? 0 : -EIO;
 }
 
+static int osp_md_object_unlock(const struct lu_env *env,
+                               struct dt_object *dt,
+                               struct ldlm_enqueue_info *einfo,
+                               ldlm_policy_data_t *policy)
+{
+       struct lustre_handle    *lockh = einfo->ei_cbdata;
+
+       /* unlock finally */
+       ldlm_lock_decref(lockh, einfo->ei_mode);
+
+       return 0;
+}
+
 struct dt_object_operations osp_md_obj_ops = {
        .do_read_lock         = osp_md_object_read_lock,
        .do_write_lock        = osp_md_object_write_lock,
@@ -670,4 +679,5 @@ struct dt_object_operations osp_md_obj_ops = {
        .do_xattr_set         = osp_xattr_set,
        .do_index_try         = osp_md_index_try,
        .do_object_lock       = osp_md_object_lock,
+       .do_object_unlock     = osp_md_object_unlock,
 };