X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Flov%2Flov_dev.c;h=4dce6a68754105447f8b37bb0e39efa4f480df24;hb=20b3c42dfca56b79b891cb290768b2c9ace80d0b;hp=cab0e3bbd97160db818eabd14ed9683f08fcdc32;hpb=b401ba0c214b184424146dda994470aa3c4356c9;p=fs%2Flustre-release.git diff --git a/lustre/lov/lov_dev.c b/lustre/lov/lov_dev.c index cab0e3b..4dce6a6 100644 --- a/lustre/lov/lov_dev.c +++ b/lustre/lov/lov_dev.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/ @@ -45,14 +45,12 @@ #include "lov_cl_internal.h" -cfs_mem_cache_t *lov_page_kmem; cfs_mem_cache_t *lov_lock_kmem; cfs_mem_cache_t *lov_object_kmem; cfs_mem_cache_t *lov_thread_kmem; cfs_mem_cache_t *lov_session_kmem; cfs_mem_cache_t *lov_req_kmem; -cfs_mem_cache_t *lovsub_page_kmem; cfs_mem_cache_t *lovsub_lock_kmem; cfs_mem_cache_t *lovsub_object_kmem; cfs_mem_cache_t *lovsub_req_kmem; @@ -64,11 +62,6 @@ struct lock_class_key cl_lov_device_mutex_class; struct lu_kmem_descr lov_caches[] = { { - .ckd_cache = &lov_page_kmem, - .ckd_name = "lov_page_kmem", - .ckd_size = sizeof (struct lov_page) - }, - { .ckd_cache = &lov_lock_kmem, .ckd_name = "lov_lock_kmem", .ckd_size = sizeof (struct lov_lock) @@ -94,11 +87,6 @@ struct lu_kmem_descr lov_caches[] = { .ckd_size = sizeof (struct lov_req) }, { - .ckd_cache = &lovsub_page_kmem, - .ckd_name = "lovsub_page_kmem", - .ckd_size = sizeof (struct lovsub_page) - }, - { .ckd_cache = &lovsub_lock_kmem, .ckd_name = "lovsub_lock_kmem", .ckd_size = sizeof (struct lovsub_lock) @@ -167,7 +155,7 @@ static void lov_key_fini(const struct lu_context *ctx, struct lu_context_key *key, void *data) { struct lov_thread_info *info = data; - LINVRNT(list_empty(&info->lti_closure.clc_list)); + LINVRNT(cfs_list_empty(&info->lti_closure.clc_list)); OBD_SLAB_FREE_PTR(info, lov_thread_kmem); } @@ -243,18 +231,19 @@ static int lov_device_init(const struct lu_env *env, struct lu_device *d, struct lov_tgt_desc *desc; desc = ld->ld_lov->lov_tgts[i]; - if (desc->ltd_active) { - cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, - desc->ltd_exp->exp_obd->obd_lu_dev); - if (IS_ERR(cl)) { - rc = PTR_ERR(cl); - break; - } - lsd = cl2lovsub_dev(cl); - lsd->acid_idx = i; - lsd->acid_super = ld; - ld->ld_target[i] = lsd; + if (desc == NULL) + continue; + + cl = cl_type_setup(env, d->ld_site, &lovsub_device_type, + desc->ltd_obd->obd_lu_dev); + if (IS_ERR(cl)) { + rc = PTR_ERR(cl); + break; } + lsd = cl2lovsub_dev(cl); + lsd->acid_idx = i; + lsd->acid_super = ld; + ld->ld_target[i] = lsd; } if (rc) @@ -342,16 +331,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr) return ERR_PTR(-ENOMEM); for (result = i = 0; i < nr && result == 0; i++) { struct lov_device_emerg *em; - void *cookie; OBD_ALLOC_PTR(em); if (em != NULL) { emerg[i] = em; cl_page_list_init(&em->emrg_page_list); - cookie = cl_env_reenter(); em->emrg_env = cl_env_alloc(&em->emrg_refcheck, LCT_REMEMBER|LCT_NOREF); - cl_env_reexit(cookie); if (!IS_ERR(em->emrg_env)) em->emrg_env->le_ctx.lc_cookie = 0x2; else { @@ -389,7 +375,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) OBD_ALLOC(newd, tgt_size * sz); if (newd != NULL) { - mutex_lock(&dev->ld_mutex); + mutex_lock(&dev->ld_mutex); if (sub_size > 0) { memcpy(newd, dev->ld_target, sub_size * sz); OBD_FREE(dev->ld_target, sub_size * sz); @@ -400,7 +386,7 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev) if (dev->ld_emrg != NULL) lov_emerg_free(dev->ld_emrg, sub_size); dev->ld_emrg = emerg; - mutex_unlock(&dev->ld_mutex); + mutex_unlock(&dev->ld_mutex); } else { lov_emerg_free(emerg, tgt_size); result = -ENOMEM; @@ -420,16 +406,23 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, int rc; ENTRY; - lov_getref(obd); + obd_getref(obd); tgt = obd->u.lov.lov_tgts[index]; LASSERT(tgt != NULL); + LASSERT(tgt->ltd_obd != NULL); + + if (!tgt->ltd_obd->obd_set_up) { + CERROR("Target %s not set up\n", obd_uuid2str(&tgt->ltd_uuid)); + RETURN(-EINVAL); + } rc = lov_expand_targets(env, ld); if (rc == 0 && ld->ld_flags & LOV_DEV_INITIALIZED) { LASSERT(dev->ld_site != NULL); + cl = cl_type_setup(env, dev->ld_site, &lovsub_device_type, - tgt->ltd_exp->exp_obd->obd_lu_dev); + tgt->ltd_obd->obd_lu_dev); if (!IS_ERR(cl)) { lsd = cl2lovsub_dev(cl); lsd->acid_idx = index; @@ -442,7 +435,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, rc = PTR_ERR(cl); } } - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -455,7 +448,7 @@ static int lov_process_config(const struct lu_env *env, int gen; __u32 index; - lov_getref(obd); + obd_getref(obd); cmd = cfg->lcfg_command; rc = lov_process_config_base(d->ld_obd, cfg, &index, &gen); @@ -472,7 +465,7 @@ static int lov_process_config(const struct lu_env *env, break; } } - lov_putref(obd); + obd_putref(obd); RETURN(rc); } @@ -499,8 +492,8 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env, d->ld_ops = &lov_lu_ops; ld->ld_cl.cd_ops = &lov_cl_ops; - mutex_init(&ld->ld_mutex); - lockdep_set_class(&ld->ld_mutex, &cl_lov_device_mutex_class); + mutex_init(&ld->ld_mutex); + lockdep_set_class(&ld->ld_mutex, &cl_lov_device_mutex_class); /* setup the LOV OBD */ obd = class_name2obd(lustre_cfg_string(cfg, 0));