X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fmdd%2Fmdd_orphans.c;h=9aa132b34f5c009241b8255bf0bc6176abdf30f3;hb=536f1a6294569f8638f372c9e17a4fb2bf829313;hp=e3649038b5a29226ed3393e72b148397a67da076;hpb=21b0820ab8b596ae4daf4a0a31e3725e52e0590a;p=fs%2Flustre-release.git diff --git a/lustre/mdd/mdd_orphans.c b/lustre/mdd/mdd_orphans.c index e364903..9aa132b 100644 --- a/lustre/mdd/mdd_orphans.c +++ b/lustre/mdd/mdd_orphans.c @@ -27,7 +27,7 @@ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. * - * Copyright (c) 2011, 2012, Intel Corporation. + * Copyright (c) 2011, 2013, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -156,7 +156,7 @@ static inline void mdd_orphan_ref_del(const struct lu_env *env, int orph_declare_index_insert(const struct lu_env *env, struct mdd_object *obj, - cfs_umode_t mode, struct thandle *th) + umode_t mode, struct thandle *th) { struct mdd_device *mdd = mdo2mdd(&obj->mod_obj); struct dt_key *key; @@ -326,11 +326,12 @@ static int orphan_object_destroy(const struct lu_env *env, int rc = 0; ENTRY; - th = mdd_trans_create(env, mdd); - if (IS_ERR(th)) { - CERROR("Cannot get thandle\n"); - RETURN(-ENOMEM); - } + th = mdd_trans_create(env, mdd); + if (IS_ERR(th)) { + CERROR("Cannot get thandle\n"); + RETURN(PTR_ERR(th)); + } + rc = orph_declare_index_delete(env, obj, th); if (rc) GOTO(stop, rc); @@ -518,26 +519,32 @@ out: */ int orph_index_init(const struct lu_env *env, struct mdd_device *mdd) { - struct lu_fid fid; - struct dt_object *d; - int rc = 0; - ENTRY; - - d = dt_store_open(env, mdd->mdd_child, "", orph_index_name, &fid); - if (!IS_ERR(d)) { - mdd->mdd_orphans = d; - if (!dt_try_as_dir(env, d)) { - rc = -ENOTDIR; - CERROR("\"%s\" is not an index! : rc = %d\n", - orph_index_name, rc); - } - } else { - CERROR("cannot find \"%s\" obj %d\n", - orph_index_name, (int)PTR_ERR(d)); - rc = PTR_ERR(d); - } - - RETURN(rc); + struct lu_fid fid; + struct dt_object *d; + int rc = 0; + + ENTRY; + + /* create PENDING dir */ + fid_zero(&fid); + rc = mdd_local_file_create(env, mdd, &mdd->mdd_local_root_fid, + orph_index_name, S_IFDIR | S_IRUGO | + S_IWUSR | S_IXUGO, &fid); + if (rc < 0) + RETURN(rc); + + d = dt_locate(env, mdd->mdd_child, &fid); + if (IS_ERR(d)) + RETURN(PTR_ERR(d)); + LASSERT(lu_object_exists(&d->do_lu)); + if (!dt_try_as_dir(env, d)) { + CERROR("%s: \"%s\" is not an index: rc = %d\n", + mdd2obd_dev(mdd)->obd_name, orph_index_name, rc); + lu_object_put(env, &d->do_lu); + RETURN(-ENOTDIR); + } + mdd->mdd_orphans = d; + RETURN(0); } void orph_index_fini(const struct lu_env *env, struct mdd_device *mdd)