X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=lustre%2Fobdclass%2Fmd_local_object.c;h=7f235f44a3ddf891869b198d5bf56a2bd49e696a;hb=f7a81d4797933d179f9955bb0821779d3ac9a8fe;hp=919c2840fd194930bdf4c6206c57a4491e08e78f;hpb=90d8e7fd28746a572c8de488222f5312fe927fc3;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/md_local_object.c b/lustre/obdclass/md_local_object.c index 919c284..7f235f4 100644 --- a/lustre/obdclass/md_local_object.c +++ b/lustre/obdclass/md_local_object.c @@ -1,6 +1,4 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: - * +/* * GPL HEADER START * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -26,8 +24,10 @@ * GPL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved + * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. * Use is subject to license terms. + * + * Copyright (c) 2012, Intel Corporation. */ /* * This file is part of Lustre, http://www.lustre.org/ @@ -43,9 +43,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #include #include @@ -56,10 +53,10 @@ /** List head to hold list of objects to be created. */ -static struct list_head llo_lobj_list; +static cfs_list_t llo_lobj_list; /** Lock to protect list manipulations */ -static struct mutex llo_lock; +static struct mutex llo_lock; /** * Structure used to maintain state of path parsing. @@ -91,7 +88,7 @@ LU_KEY_INIT(llod_global, struct llo_thread_info); LU_KEY_FINI(llod_global, struct llo_thread_info); static struct lu_context_key llod_key = { - .lct_tags = LCT_MD_THREAD | LCT_DT_THREAD, + .lct_tags = LCT_MD_THREAD, .lct_init = llod_global_key_init, .lct_fini = llod_global_key_fini }; @@ -135,9 +132,8 @@ static int llo_lookup(const struct lu_env *env, spec->sp_feat = NULL; spec->sp_cr_flags = 0; - spec->sp_cr_lookup = 1; + spec->sp_cr_lookup = 0; spec->sp_cr_mode = 0; - spec->sp_ck_split = 0; lname->ln_name = name; lname->ln_namelen = strlen(name); @@ -148,6 +144,10 @@ static int llo_lookup(const struct lu_env *env, /** * Function to look up path component, this is passed to parsing * function. \see llo_store_resolve + * + * \retval rc returns error code for lookup or locate operation + * + * pointer to object is returned in data (lfh->lfh_pobj) */ static int llo_find_entry(const struct lu_env *env, const char *name, void *data) @@ -205,7 +205,7 @@ struct md_object *llo_store_resolve(const struct lu_env *env, struct llo_thread_info *info = llo_env_info(env); struct llo_find_hint *lfh = &info->lti_lfh; char *local = info->lti_buf; - struct md_object *obj = lfh->lfh_pobj; + struct md_object *obj; int result; strncpy(local, path, DT_MAX_PATH); @@ -224,6 +224,8 @@ struct md_object *llo_store_resolve(const struct lu_env *env, result = dt_path_parser(env, local, llo_find_entry, lfh); if (result != 0) obj = ERR_PTR(result); + else + obj = lfh->lfh_pobj; } } else { obj = ERR_PTR(result); @@ -283,10 +285,9 @@ static struct md_object *llo_create_obj(const struct lu_env *env, spec->sp_cr_flags = 0; spec->sp_cr_lookup = 1; spec->sp_cr_mode = 0; - spec->sp_ck_split = 0; if (feat == &dt_directory_features) - la->la_mode = S_IFDIR; + la->la_mode = S_IFDIR | S_IXUGO; else la->la_mode = S_IFREG; @@ -312,7 +313,7 @@ static struct md_object *llo_create_obj(const struct lu_env *env, * special index defined by \a feat in \a directory. * * \param md device - * \param dir parent directory + * \param dirname parent directory * \param objname file name * \param fid object fid * \param feat index features required for directory create @@ -347,7 +348,7 @@ EXPORT_SYMBOL(llo_store_create_index); * Create md object for regular file in \a directory. * * \param md device - * \param dir parent directory + * \param dirname parent directory * \param objname file name * \param fid object fid. */ @@ -367,19 +368,27 @@ EXPORT_SYMBOL(llo_store_create); /** * Register object for 'create on first mount' facility. + * objects are created in order of registration. */ -int llo_local_obj_register(struct lu_local_obj_desc *llod) +void llo_local_obj_register(struct lu_local_obj_desc *llod) { - mutex_lock(&llo_lock); - list_add(&llod->llod_linkage, &llo_lobj_list); - mutex_unlock(&llo_lock); - - return 0; + mutex_lock(&llo_lock); + cfs_list_add_tail(&llod->llod_linkage, &llo_lobj_list); + mutex_unlock(&llo_lock); } EXPORT_SYMBOL(llo_local_obj_register); +void llo_local_obj_unregister(struct lu_local_obj_desc *llod) +{ + mutex_lock(&llo_lock); + cfs_list_del(&llod->llod_linkage); + mutex_unlock(&llo_lock); +} + +EXPORT_SYMBOL(llo_local_obj_unregister); + /** * Created registed objects. */ @@ -392,24 +401,26 @@ int llo_local_objects_setup(const struct lu_env *env, struct lu_fid *fid; struct lu_local_obj_desc *scan; struct md_object *mdo; + const char *dir; int rc = 0; fid = &info->lti_cfid; + mutex_lock(&llo_lock); - mutex_lock(&llo_lock); - - list_for_each_entry(scan, &llo_lobj_list, llod_linkage) { - + cfs_list_for_each_entry(scan, &llo_lobj_list, llod_linkage) { lu_local_obj_fid(fid, scan->llod_oid); + dir = ""; + if (scan->llod_dir) + dir = scan->llod_dir; if (scan->llod_is_index) mdo = llo_store_create_index(env, md, dt , - "", scan->llod_name, + dir, scan->llod_name, fid, scan->llod_feat); else mdo = llo_store_create(env, md, dt, - "", scan->llod_name, + dir, scan->llod_name, fid); if (IS_ERR(mdo) && PTR_ERR(mdo) != -EEXIST) { rc = PTR_ERR(mdo); @@ -423,7 +434,7 @@ int llo_local_objects_setup(const struct lu_env *env, } out: - mutex_unlock(&llo_lock); + mutex_unlock(&llo_lock); return rc; } @@ -434,7 +445,7 @@ int llo_global_init(void) int result; CFS_INIT_LIST_HEAD(&llo_lobj_list); - mutex_init(&llo_lock); + mutex_init(&llo_lock); LU_CONTEXT_KEY_INIT(&llod_key); result = lu_context_key_register(&llod_key); @@ -444,4 +455,5 @@ int llo_global_init(void) void llo_global_fini(void) { lu_context_key_degister(&llod_key); + LASSERT(cfs_list_empty(&llo_lobj_list)); }