Whamcloud - gitweb
Revert "LU-4865 zfs: grow block size by write pattern"
[fs/lustre-release.git] / lustre / osd-zfs / osd_index.c
index b28f65f..9780e43 100644 (file)
@@ -27,7 +27,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2014, Intel Corporation.
+ * Copyright (c) 2012, 2015, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -151,8 +151,7 @@ static inline int osd_obj_cursor_init(zap_cursor_t **zc, struct osd_object *o,
 
 static struct dt_it *osd_index_it_init(const struct lu_env *env,
                                       struct dt_object *dt,
-                                      __u32 unused,
-                                      struct lustre_capa *capa)
+                                      __u32 unused)
 {
        struct osd_thread_info  *info = osd_oti_get(env);
        struct osd_zap_it       *it;
@@ -161,7 +160,8 @@ static struct dt_it *osd_index_it_init(const struct lu_env *env,
        int                      rc;
        ENTRY;
 
-       /* XXX: check capa ? */
+       if (obj->oo_destroyed)
+               RETURN(ERR_PTR(-ENOENT));
 
        LASSERT(lu_object_exists(lo));
        LASSERT(obj->oo_db);
@@ -179,7 +179,6 @@ static struct dt_it *osd_index_it_init(const struct lu_env *env,
        }
 
        it->ozi_obj   = obj;
-       it->ozi_capa  = capa;
        it->ozi_reset = 1;
        lu_object_get(lo);
 
@@ -328,10 +327,9 @@ static int osd_find_parent_fid(const struct lu_env *env, struct dt_object *o,
        buf.lb_buf = osd_oti_get(env)->oti_buf;
        buf.lb_len = sizeof(osd_oti_get(env)->oti_buf);
 
-       rc = osd_xattr_get(env, o, &buf, XATTR_NAME_LINK, BYPASS_CAPA);
+       rc = osd_xattr_get(env, o, &buf, XATTR_NAME_LINK);
        if (rc == -ERANGE) {
-               rc = osd_xattr_get(env, o, &LU_BUF_NULL,
-                                  XATTR_NAME_LINK, BYPASS_CAPA);
+               rc = osd_xattr_get(env, o, &LU_BUF_NULL, XATTR_NAME_LINK);
                if (rc < 0)
                        RETURN(rc);
                LASSERT(rc > 0);
@@ -339,7 +337,7 @@ static int osd_find_parent_fid(const struct lu_env *env, struct dt_object *o,
                if (buf.lb_buf == NULL)
                        RETURN(-ENOMEM);
                buf.lb_len = rc;
-               rc = osd_xattr_get(env, o, &buf, XATTR_NAME_LINK, BYPASS_CAPA);
+               rc = osd_xattr_get(env, o, &buf, XATTR_NAME_LINK);
        }
        if (rc < 0)
                GOTO(out, rc);
@@ -387,8 +385,7 @@ out:
 }
 
 static int osd_dir_lookup(const struct lu_env *env, struct dt_object *dt,
-                         struct dt_rec *rec, const struct dt_key *key,
-                         struct lustre_capa *capa)
+                         struct dt_rec *rec, const struct dt_key *key)
 {
        struct osd_thread_info *oti = osd_oti_get(env);
        struct osd_object  *obj = osd_dt_obj(dt);
@@ -525,8 +522,9 @@ static int osd_seq_exists(const struct lu_env *env, struct osd_device *osd,
 
        rc = osd_fld_lookup(env, osd, seq, range);
        if (rc != 0) {
-               CERROR("%s: Can not lookup fld for "LPX64"\n",
-                      osd_name(osd), seq);
+               if (rc != -ENOENT)
+                       CERROR("%s: Can not lookup fld for "LPX64"\n",
+                              osd_name(osd), seq);
                RETURN(0);
        }
 
@@ -563,7 +561,6 @@ static int osd_remote_fid(const struct lu_env *env, struct osd_device *osd,
  *      \param  key     key for index
  *      \param  rec     record reference
  *      \param  th      transaction handler
- *      \param  capa    capability descriptor
  *      \param  ignore_quota update should not affect quota
  *
  *      \retval  0  success
@@ -571,8 +568,7 @@ static int osd_remote_fid(const struct lu_env *env, struct osd_device *osd,
  */
 static int osd_dir_insert(const struct lu_env *env, struct dt_object *dt,
                          const struct dt_rec *rec, const struct dt_key *key,
-                         struct thandle *th, struct lustre_capa *capa,
-                         int ignore_quota)
+                         struct thandle *th, int ignore_quota)
 {
        struct osd_thread_info *oti = osd_oti_get(env);
        struct osd_object   *parent = osd_dt_obj(dt);
@@ -676,8 +672,9 @@ static int osd_declare_dir_delete(const struct lu_env *env,
                                  const struct dt_key *key,
                                  struct thandle *th)
 {
-       struct osd_object *obj = osd_dt_obj(dt);
+       struct osd_object  *obj = osd_dt_obj(dt);
        struct osd_thandle *oh;
+       uint64_t            dnode;
        ENTRY;
 
        LASSERT(dt_object_exists(dt));
@@ -686,17 +683,20 @@ static int osd_declare_dir_delete(const struct lu_env *env,
        LASSERT(th != NULL);
        oh = container_of0(th, struct osd_thandle, ot_super);
 
-       LASSERT(obj->oo_db);
-       LASSERT(osd_object_is_zap(obj->oo_db));
-
-       dmu_tx_hold_zap(oh->ot_tx, obj->oo_db->db_object, TRUE, (char *)key);
+       if (dt_object_exists(dt)) {
+               LASSERT(obj->oo_db);
+               LASSERT(osd_object_is_zap(obj->oo_db));
+               dnode = obj->oo_db->db_object;
+       } else {
+               dnode = DMU_NEW_OBJECT;
+       }
+       dmu_tx_hold_zap(oh->ot_tx, dnode, TRUE, (char *)key);
 
        RETURN(0);
 }
 
 static int osd_dir_delete(const struct lu_env *env, struct dt_object *dt,
-                         const struct dt_key *key, struct thandle *th,
-                         struct lustre_capa *capa)
+                         const struct dt_key *key, struct thandle *th)
 {
        struct osd_object *obj = osd_dt_obj(dt);
        struct osd_device *osd = osd_obj2dev(obj);
@@ -706,8 +706,8 @@ static int osd_dir_delete(const struct lu_env *env, struct dt_object *dt,
        int rc;
        ENTRY;
 
-       LASSERT(obj->oo_db);
-       LASSERT(osd_object_is_zap(obj->oo_db));
+       LASSERT(zap_db);
+       LASSERT(osd_object_is_zap(zap_db));
 
        LASSERT(th != NULL);
        oh = container_of0(th, struct osd_thandle, ot_super);
@@ -736,12 +736,11 @@ static int osd_dir_delete(const struct lu_env *env, struct dt_object *dt,
 
 static struct dt_it *osd_dir_it_init(const struct lu_env *env,
                                     struct dt_object *dt,
-                                    __u32 unused,
-                                    struct lustre_capa *capa)
+                                    __u32 unused)
 {
        struct osd_zap_it *it;
 
-       it = (struct osd_zap_it *)osd_index_it_init(env, dt, unused, capa);
+       it = (struct osd_zap_it *)osd_index_it_init(env, dt, unused);
        if (!IS_ERR(it))
                it->ozi_pos = 0;
 
@@ -1139,8 +1138,7 @@ static int osd_prepare_key_uint64(struct osd_object *o, __u64 *dst,
 }
 
 static int osd_index_lookup(const struct lu_env *env, struct dt_object *dt,
-                       struct dt_rec *rec, const struct dt_key *key,
-                       struct lustre_capa *capa)
+                       struct dt_rec *rec, const struct dt_key *key)
 {
        struct osd_object *obj = osd_dt_obj(dt);
        struct osd_device *osd = osd_obj2dev(obj);
@@ -1183,8 +1181,7 @@ static int osd_declare_index_insert(const struct lu_env *env,
 
 static int osd_index_insert(const struct lu_env *env, struct dt_object *dt,
                            const struct dt_rec *rec, const struct dt_key *key,
-                           struct thandle *th, struct lustre_capa *capa,
-                           int ignore_quota)
+                           struct thandle *th, int ignore_quota)
 {
        struct osd_object  *obj = osd_dt_obj(dt);
        struct osd_device  *osd = osd_obj2dev(obj);
@@ -1230,8 +1227,7 @@ static int osd_declare_index_delete(const struct lu_env *env,
 }
 
 static int osd_index_delete(const struct lu_env *env, struct dt_object *dt,
-                           const struct dt_key *key, struct thandle *th,
-                           struct lustre_capa *capa)
+                           const struct dt_key *key, struct thandle *th)
 {
        struct osd_object  *obj = osd_dt_obj(dt);
        struct osd_device  *osd = osd_obj2dev(obj);
@@ -1416,8 +1412,7 @@ struct osd_metadnode_it {
 };
 
 static struct dt_it *osd_zfs_otable_it_init(const struct lu_env *env,
-                                           struct dt_object *dt, __u32 attr,
-                                           struct lustre_capa *capa)
+                                           struct dt_object *dt, __u32 attr)
 {
        struct osd_device       *dev   = osd_dev(dt->do_lu.lo_dev);
        struct osd_metadnode_it *it;
@@ -1621,8 +1616,6 @@ int osd_index_try(const struct lu_env *env, struct dt_object *dt,
        struct osd_object *obj = osd_dt_obj(dt);
        ENTRY;
 
-       LASSERT(dt_object_exists(dt));
-
        /*
         * XXX: implement support for fixed-size keys sorted with natural
         *      numerical way (not using internal hash value)
@@ -1635,17 +1628,16 @@ int osd_index_try(const struct lu_env *env, struct dt_object *dt,
                RETURN(0);
        }
 
-       LASSERT(obj->oo_db != NULL);
+       LASSERT(!dt_object_exists(dt) || obj->oo_db != NULL);
        if (likely(feat == &dt_directory_features)) {
-               if (osd_object_is_zap(obj->oo_db))
+               if (!dt_object_exists(dt) || osd_object_is_zap(obj->oo_db))
                        dt->do_index_ops = &osd_dir_ops;
                else
                        RETURN(-ENOTDIR);
        } else if (unlikely(feat == &dt_acct_features)) {
                LASSERT(fid_is_acct(lu_object_fid(&dt->do_lu)));
                dt->do_index_ops = &osd_acct_index_ops;
-       } else if (osd_object_is_zap(obj->oo_db) &&
-                  dt->do_index_ops == NULL) {
+       } else if (dt->do_index_ops == NULL) {
                /* For index file, we don't support variable key & record sizes
                 * and the key has to be unique */
                if ((feat->dif_flags & ~DT_IND_UPDATE) != 0)