/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
- */
-/*
- * Copyright (c) 2012, 2013, Intel Corporation.
- * Use is subject to license terms.
+ *
+ * Copyright (c) 2012, 2014, Intel Corporation.
*/
/*
* This file is part of Lustre, http://www.lustre.org/
uint64_t dirhash)
{
struct osd_device *d = osd_obj2dev(o);
- zap_cursor_init_serialized(zc, d->od_os, o->oo_db->db_object, dirhash);
+ osd_zap_cursor_init_serialized(zc, d->od_os,
+ o->oo_db->db_object, dirhash);
}
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;
int rc;
ENTRY;
- /* XXX: check capa ? */
+ if (obj->oo_destroyed)
+ RETURN(ERR_PTR(-ENOENT));
LASSERT(lu_object_exists(lo));
LASSERT(obj->oo_db);
LASSERT(osd_object_is_zap(obj->oo_db));
LASSERT(info);
- if (info->oti_it_inline) {
- OBD_ALLOC_PTR(it);
- if (it == NULL)
- RETURN(ERR_PTR(-ENOMEM));
- } else {
- it = &info->oti_it_zap;
- info->oti_it_inline = 1;
- }
+ OBD_SLAB_ALLOC_PTR_GFP(it, osd_zapit_cachep, GFP_NOFS);
+ if (it == NULL)
+ RETURN(ERR_PTR(-ENOMEM));
rc = osd_obj_cursor_init(&it->ozi_zc, obj, 0);
if (rc != 0) {
- if (it != &info->oti_it_zap)
- OBD_FREE_PTR(it);
- else
- info->oti_it_inline = 0;
-
+ OBD_SLAB_FREE_PTR(it, osd_zapit_cachep);
RETURN(ERR_PTR(rc));
}
it->ozi_obj = obj;
- it->ozi_capa = capa;
it->ozi_reset = 1;
lu_object_get(lo);
static void osd_index_it_fini(const struct lu_env *env, struct dt_it *di)
{
- struct osd_thread_info *info = osd_oti_get(env);
struct osd_zap_it *it = (struct osd_zap_it *)di;
struct osd_object *obj;
ENTRY;
osd_zap_cursor_fini(it->ozi_zc);
lu_object_put(env, &obj->oo_dt.do_lu);
- if (it != &info->oti_it_zap)
- OBD_FREE_PTR(it);
- else
- info->oti_it_inline = 0;
+ OBD_SLAB_FREE_PTR(it, osd_zapit_cachep);
EXIT;
}
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);
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);
}
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);
}
static int osd_seq_exists(const struct lu_env *env, struct osd_device *osd,
- obd_seq seq)
+ u64 seq)
{
struct lu_seq_range *range = &osd_oti_get(env)->oti_seq_range;
struct seq_server_site *ss = osd_seq_site(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);
}
* \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
*/
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);
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));
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);
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);
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;
zap_attribute_t *za = &osd_oti_get(env)->oti_za;
int rc;
+ ENTRY;
+
/* temp. storage should be enough for any key supported by ZFS */
CLASSERT(sizeof(za->za_name) <= sizeof(it->ozi_name));
it->ozi_pos++;
if (it->ozi_pos <=2)
RETURN(0);
- }
- zap_cursor_advance(it->ozi_zc);
+ } else {
+ zap_cursor_advance(it->ozi_zc);
+ }
/*
* According to current API we need to return error if its last entry.
osd_it_append_attrs(lde, attr, 2, IFTODT(S_IFDIR));
lde->lde_reclen = cpu_to_le16(lu_dirent_calc_size(2, attr));
rc = osd_find_parent_fid(env, &it->ozi_obj->oo_dt, &lde->lde_fid);
- /*
- * early Orion code was not setting LinkEA, so it's possible
- * some setups still have objects with no LinkEA set.
- * but at that time .. was a real record in the directory
- * so we should try to lookup .. in ZAP
- */
- if (rc != -ENOENT)
- GOTO(out, rc);
+
+ /* ENOENT happens at the root of filesystem so ignore it */
+ if (rc == -ENOENT)
+ rc = 0;
+ GOTO(out, rc);
}
LASSERT(lde);
}
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);
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);
}
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);
};
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;
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)
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)