From 26230e2b5544b30bdaca5a245f3c573116fc8476 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 25 Sep 2014 21:02:55 -0400 Subject: [PATCH] Revert "LU-3489 osd-zfs: varsize index support" This seems to be causing LU-5649 This reverts commit d9e627c09ccc5c22aa10704020fb9f45bcf26ed0. --- lustre/osd-zfs/osd_index.c | 79 ++++++++++--------------------------------- lustre/osd-zfs/osd_internal.h | 11 ++---- 2 files changed, 21 insertions(+), 69 deletions(-) diff --git a/lustre/osd-zfs/osd_index.c b/lustre/osd-zfs/osd_index.c index 29b0d68..29df71d 100644 --- a/lustre/osd-zfs/osd_index.c +++ b/lustre/osd-zfs/osd_index.c @@ -1046,43 +1046,20 @@ static struct dt_index_operations osd_dir_ops = { /* * Primitives for index files using binary keys. + * XXX: only 64-bit keys are supported for now. */ -static int osd_prepare_key(struct osd_object *o, __u64 *dst, - const struct dt_key *src) -{ - int size; - - LASSERT(dst); - LASSERT(src); - - /* align keysize to 64bit */ - size = (o->oo_keysize + sizeof(__u64) - 1) / sizeof(__u64); - size *= sizeof(__u64); - - LASSERT(size <= MAXNAMELEN); - - if (unlikely(size > o->oo_keysize)) - memset(dst + o->oo_keysize, 0, size - o->oo_keysize); - memcpy(dst, (const char *)src, o->oo_keysize); - - return size; -} - 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 osd_object *obj = osd_dt_obj(dt); struct osd_device *osd = osd_obj2dev(obj); - __u64 *k = osd_oti_get(env)->oti_key64; int rc; ENTRY; - rc = osd_prepare_key(obj, k, key); - rc = -zap_lookup_uint64(osd->od_objset.os, obj->oo_db->db_object, - k, rc, obj->oo_recusize, obj->oo_recsize, + (const __u64 *)key, 1, 8, obj->oo_recsize, (void *)rec); RETURN(rc == 0 ? 1 : rc); } @@ -1120,7 +1097,6 @@ static int osd_index_insert(const struct lu_env *env, struct dt_object *dt, struct osd_object *obj = osd_dt_obj(dt); struct osd_device *osd = osd_obj2dev(obj); struct osd_thandle *oh; - __u64 *k = osd_oti_get(env)->oti_key64; int rc; ENTRY; @@ -1131,11 +1107,9 @@ static int osd_index_insert(const struct lu_env *env, struct dt_object *dt, oh = container_of0(th, struct osd_thandle, ot_super); - rc = osd_prepare_key(obj, k, key); - /* Insert (key,oid) into ZAP */ rc = -zap_add_uint64(osd->od_objset.os, obj->oo_db->db_object, - k, rc, obj->oo_recusize, obj->oo_recsize, + (const __u64 *)key, 1, 8, obj->oo_recsize, (void *)rec, oh->ot_tx); RETURN(rc); } @@ -1167,7 +1141,6 @@ static int osd_index_delete(const struct lu_env *env, struct dt_object *dt, struct osd_object *obj = osd_dt_obj(dt); struct osd_device *osd = osd_obj2dev(obj); struct osd_thandle *oh; - __u64 *k = osd_oti_get(env)->oti_key64; int rc; ENTRY; @@ -1175,11 +1148,9 @@ static int osd_index_delete(const struct lu_env *env, struct dt_object *dt, LASSERT(th != NULL); oh = container_of0(th, struct osd_thandle, ot_super); - rc = osd_prepare_key(obj, k, key); - /* Remove binary key from the ZAP */ rc = -zap_remove_uint64(osd->od_objset.os, obj->oo_db->db_object, - k, rc, oh->ot_tx); + (const __u64 *)key, 1, oh->ot_tx); RETURN(rc); } @@ -1194,11 +1165,8 @@ static int osd_index_it_get(const struct lu_env *env, struct dt_it *di, LASSERT(it); LASSERT(it->ozi_zc); - /* - * XXX: we need a binary version of zap_cursor_move_to_key() - * to implement this API */ - if (*((const __u64 *)key) != 0) - CERROR("NOT IMPLEMETED YET (move to %Lx)\n", *((__u64 *)key)); + /* XXX: API is broken at the moment */ + LASSERT(*((const __u64 *)key) == 0); zap_cursor_fini(it->ozi_zc); memset(it->ozi_zc, 0, sizeof(*it->ozi_zc)); @@ -1236,7 +1204,6 @@ static struct dt_key *osd_index_it_key(const struct lu_env *env, const struct dt_it *di) { struct osd_zap_it *it = (struct osd_zap_it *)di; - struct osd_object *obj = it->ozi_obj; zap_attribute_t *za = &osd_oti_get(env)->oti_za; int rc = 0; ENTRY; @@ -1247,7 +1214,7 @@ static struct dt_key *osd_index_it_key(const struct lu_env *env, RETURN(ERR_PTR(rc)); /* the binary key is stored in the name */ - memcpy(&it->ozi_key, za->za_name, obj->oo_keysize); + it->ozi_key = *((__u64 *)za->za_name); RETURN((struct dt_key *)&it->ozi_key); } @@ -1255,9 +1222,8 @@ static struct dt_key *osd_index_it_key(const struct lu_env *env, static int osd_index_it_key_size(const struct lu_env *env, const struct dt_it *di) { - struct osd_zap_it *it = (struct osd_zap_it *)di; - struct osd_object *obj = it->ozi_obj; - RETURN(obj->oo_keysize); + /* we only support 64-bit binary keys for the time being */ + RETURN(sizeof(__u64)); } static int osd_index_it_rec(const struct lu_env *env, const struct dt_it *di, @@ -1267,7 +1233,6 @@ static int osd_index_it_rec(const struct lu_env *env, const struct dt_it *di, struct osd_zap_it *it = (struct osd_zap_it *)di; struct osd_object *obj = it->ozi_obj; struct osd_device *osd = osd_obj2dev(obj); - __u64 *k = osd_oti_get(env)->oti_key64; int rc; ENTRY; @@ -1276,11 +1241,9 @@ static int osd_index_it_rec(const struct lu_env *env, const struct dt_it *di, if (rc) RETURN(rc); - rc = osd_prepare_key(obj, k, (const struct dt_key *)za->za_name); - rc = -zap_lookup_uint64(osd->od_objset.os, obj->oo_db->db_object, - k, rc, obj->oo_recusize, obj->oo_recsize, - (void *)rec); + (const __u64 *)za->za_name, 1, 8, + obj->oo_recsize, (void *)rec); RETURN(rc); } @@ -1376,9 +1339,10 @@ int osd_index_try(const struct lu_env *env, struct dt_object *dt, if ((feat->dif_flags & ~DT_IND_UPDATE) != 0) RETURN(-EINVAL); - if (feat->dif_keysize_max > ZAP_MAXNAMELEN) - RETURN(-E2BIG); - if (feat->dif_keysize_max != feat->dif_keysize_min) + /* Although the zap_*_uint64() primitives support large keys, we + * limit ourselves to 64-bit keys for now */ + if (feat->dif_keysize_max != sizeof(__u64) || + feat->dif_keysize_min != sizeof(__u64)) RETURN(-EINVAL); /* As for the record size, it should be a multiple of 8 bytes @@ -1386,18 +1350,11 @@ int osd_index_try(const struct lu_env *env, struct dt_object *dt, */ if (feat->dif_recsize_max > ZAP_MAXVALUELEN) RETURN(-E2BIG); - if (feat->dif_recsize_max != feat->dif_recsize_min) + if (feat->dif_recsize_max != feat->dif_recsize_min || + (feat->dif_recsize_max & (sizeof(__u64) - 1))) RETURN(-EINVAL); - obj->oo_keysize = feat->dif_keysize_max; - obj->oo_recsize = feat->dif_recsize_max; - obj->oo_recusize = 1; - - /* ZFS prefers to work with array of 64bits */ - if ((obj->oo_recsize & 7) == 0) { - obj->oo_recsize >>= 3; - obj->oo_recusize = 8; - } + obj->oo_recsize = feat->dif_recsize_max / sizeof(__u64); dt->do_index_ops = &osd_index_ops; } diff --git a/lustre/osd-zfs/osd_internal.h b/lustre/osd-zfs/osd_internal.h index a1a33e1..2c1a0bc 100644 --- a/lustre/osd-zfs/osd_internal.h +++ b/lustre/osd-zfs/osd_internal.h @@ -104,7 +104,7 @@ struct osd_zap_it { * 3 - real records */ unsigned ozi_pos:3; union { - char ozi_name[MAXNAMELEN]; /* file name for dir */ + char ozi_name[NAME_MAX + 1]; /* file name for dir */ __u64 ozi_key; /* binary key for index files */ }; }; @@ -167,10 +167,7 @@ struct osd_thread_info { }; char oti_str[64]; - union { - char oti_key[MAXNAMELEN + 1]; - __u64 oti_key64[(MAXNAMELEN + 1)/sizeof(__u64)]; - }; + char oti_key[MAXNAMELEN + 1]; struct lustre_mdt_attrs oti_mdt_attrs; struct lu_attr oti_la; @@ -307,9 +304,7 @@ struct osd_object { uint64_t oo_xattr; /* record size for index file */ - unsigned char oo_keysize; - unsigned char oo_recsize; - unsigned char oo_recusize; /* unit size */ + int oo_recsize; }; int osd_statfs(const struct lu_env *, struct dt_device *, struct obd_statfs *); -- 1.8.3.1