X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;ds=sidebyside;f=lustre%2Fcmm%2Fmdc_device.c;h=58f72f09ea0bd8e59f9f1621cdf3fa434bf9e62c;hb=e2af7fb3c91dfb13d34d8e1b2f2df8c09621f768;hp=2b04e872c7b147c9ae2cd8a251aa8984d2e010cc;hpb=0521288fde9ed5862c1a01b0a884e91b8ad9841f;p=fs%2Flustre-release.git diff --git a/lustre/cmm/mdc_device.c b/lustre/cmm/mdc_device.c index 2b04e87..58f72f0 100644 --- a/lustre/cmm/mdc_device.c +++ b/lustre/cmm/mdc_device.c @@ -1,34 +1,45 @@ -/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*- - * vim:expandtab:shiftwidth=8:tabstop=8: +/* + * GPL HEADER START * - * lustre/cmm/cmm_mdc.c - * Lustre Metadata Client (mdc) + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright (c) 2006 Cluster File Systems, Inc. - * Author: Mike Pershin + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 only, + * as published by the Free Software Foundation. * - * This file is part of the Lustre file system, http://www.lustre.org - * Lustre is a trademark of Cluster File Systems, Inc. + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License version 2 for more details (a copy is included + * in the LICENSE file that accompanied this code). * - * You may have signed or agreed to another license before downloading - * this software. If so, you are bound by the terms and conditions - * of that agreement, and the following does not apply to you. See the - * LICENSE file included with this distribution for more information. + * You should have received a copy of the GNU General Public License + * version 2 along with this program; If not, see + * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf * - * If you did not agree to a different license, then this copy of Lustre - * is open source software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. * - * In either case, Lustre is distributed in the hope that it will be - * useful, but WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * license text for more details. + * GPL HEADER END + */ +/* + * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Use is subject to license terms. + * + * Copyright (c) 2011, Whamcloud, Inc. + */ +/* + * This file is part of Lustre, http://www.lustre.org/ + * Lustre is a trademark of Sun Microsystems, Inc. + * + * lustre/cmm/mdc_device.c + * + * Lustre Metadata Client (mdc) + * + * Author: Mike Pershin */ -#ifndef EXPORT_SYMTAB -# define EXPORT_SYMTAB -#endif #define DEBUG_SUBSYSTEM S_MDS #include @@ -38,19 +49,22 @@ #include "cmm_internal.h" #include "mdc_internal.h" -static struct lu_device_operations mdc_lu_ops; - -static inline int lu_device_is_mdc(struct lu_device *ld) -{ - return ergo(ld != NULL && ld->ld_ops != NULL, - ld->ld_ops == &mdc_lu_ops); -} - -static struct md_device_operations mdc_md_ops = { 0 }; +static const struct lu_device_operations mdc_lu_ops; +/** + * \addtogroup cmm_mdc + * @{ + */ +/** + * The md_device_operation for mdc. It is empty. + */ +static const struct md_device_operations mdc_md_ops = { 0 }; +/** + * Upcall handler in mdc. Analog of obd_device::o_notify(). + */ static int mdc_obd_update(struct obd_device *host, struct obd_device *watched, - enum obd_notify_event ev, void *owner) + enum obd_notify_event ev, void *owner, void *data) { struct mdc_device *mc = owner; int rc = 0; @@ -75,13 +89,17 @@ static int mdc_obd_update(struct obd_device *host, CDEBUG(D_INFO, "Update connect_flags: "LPX64"\n", conn_data->ocd_connect_flags); } - + RETURN(rc); } -/* MDC OBD is set up already and connected to the proper MDS +/** + * Add new mdc device. + * Invoked by configuration command LCFG_ADD_MDC. + * + * MDC OBD is set up already and connected to the proper MDS * mdc_add_obd() find that obd by uuid and connects to it. - * Local MDT uuid is used for connection - * */ + * Local MDT uuid is used for connection. + */ static int mdc_obd_add(const struct lu_env *env, struct mdc_device *mc, struct lustre_cfg *cfg) { @@ -90,7 +108,7 @@ static int mdc_obd_add(const struct lu_env *env, const char *uuid_str = lustre_cfg_string(cfg, 1); const char *index = lustre_cfg_string(cfg, 2); const char *mdc_uuid_str = lustre_cfg_string(cfg, 4); - struct lu_site *ls = mdc2lu_dev(mc)->ld_site; + struct md_site *ms = lu_site2md(mdc2lu_dev(mc)->ld_site); char *p; int rc = 0; @@ -116,7 +134,6 @@ static int mdc_obd_add(const struct lu_env *env, CERROR("target %s not set up\n", mdc->obd_name); rc = -EINVAL; } else { - struct lustre_handle *conn = &desc->cl_conn; struct obd_connect_data *ocd; CDEBUG(D_CONFIG, "connect to %s(%s)\n", @@ -132,22 +149,26 @@ static int mdc_obd_add(const struct lu_env *env, ocd->ocd_ibits_known = MDS_INODELOCK_UPDATE; ocd->ocd_connect_flags = OBD_CONNECT_VERSION | OBD_CONNECT_ACL | - OBD_CONNECT_LCL_CLIENT | + OBD_CONNECT_RMT_CLIENT | OBD_CONNECT_MDS_CAPA | - OBD_CONNECT_OSS_CAPA | + OBD_CONNECT_OSS_CAPA | OBD_CONNECT_IBITS | + OBD_CONNECT_BRW_SIZE | OBD_CONNECT_MDS_MDS | - OBD_CONNECT_FID; - rc = obd_connect(env, conn, mdc, &mdc->obd_uuid, ocd, NULL); + OBD_CONNECT_FID | + OBD_CONNECT_AT | + OBD_CONNECT_FULL20 | + OBD_CONNECT_64BITHASH; + ocd->ocd_brw_size = PTLRPC_MAX_BRW_SIZE; + rc = obd_connect(env, &desc->cl_exp, mdc, &mdc->obd_uuid, ocd, NULL); OBD_FREE_PTR(ocd); if (rc) { CERROR("target %s connect error %d\n", mdc->obd_name, rc); } else { - desc->cl_exp = class_conn2export(conn); /* set seq controller export for MDC0 if exists */ if (mc->mc_num == 0) - ls->ls_control_exp = + ms->ms_control_exp = class_export_get(desc->cl_exp); rc = obd_fid_init(desc->cl_exp); if (rc) @@ -158,7 +179,7 @@ static int mdc_obd_add(const struct lu_env *env, mdc->obd_upcall.onu_upcall = mdc_obd_update; } } - + if (rc) { obd_disconnect(desc->cl_exp); desc->cl_exp = NULL; @@ -168,6 +189,12 @@ static int mdc_obd_add(const struct lu_env *env, RETURN(rc); } +/** + * Delete mdc device. + * Called when configuration command LCFG_CLEANUP is issued. + * + * This disconnects MDC OBD and cleanup it. + */ static int mdc_obd_del(const struct lu_env *env, struct mdc_device *mc, struct lustre_cfg *cfg) { @@ -190,7 +217,7 @@ static int mdc_obd_del(const struct lu_env *env, struct mdc_device *mc, mdc_obd->obd_force = mdt_obd->obd_force; mdc_obd->obd_fail = 0; } - + rc = obd_fid_fini(desc->cl_exp); if (rc) CERROR("Fid fini error %d\n", rc); @@ -209,6 +236,10 @@ static int mdc_obd_del(const struct lu_env *env, struct mdc_device *mc, RETURN(0); } +/** + * Process config command. Passed to the mdc from mdt. + * Supports two commands only - LCFG_ADD_MDC and LCFG_CLEANUP + */ static int mdc_process_config(const struct lu_env *env, struct lu_device *ld, struct lustre_cfg *cfg) @@ -230,26 +261,34 @@ static int mdc_process_config(const struct lu_env *env, RETURN(rc); } -static struct lu_device_operations mdc_lu_ops = { - .ldo_object_alloc = mdc_object_alloc, +/** + * lu_device_operations instance for mdc. + */ +static const struct lu_device_operations mdc_lu_ops = { + .ldo_object_alloc = mdc_object_alloc, .ldo_process_config = mdc_process_config }; -void mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc, +/** + * Initialize proper easize and cookie size. + */ +void cmm_mdc_init_ea_size(const struct lu_env *env, struct mdc_device *mc, int max_mdsize, int max_cookiesize) { struct obd_device *obd = class_exp2obd(mc->mc_desc.cl_exp); - + obd->u.cli.cl_max_mds_easize = max_mdsize; obd->u.cli.cl_max_mds_cookiesize = max_cookiesize; } -static int mdc_device_init(const struct lu_env *env, struct lu_device *ld, +/** Start mdc device */ +static int mdc_device_init(const struct lu_env *env, struct lu_device *ld, const char *name, struct lu_device *next) { return 0; } +/** Stop mdc device. */ static struct lu_device *mdc_device_fini(const struct lu_env *env, struct lu_device *ld) { @@ -257,6 +296,7 @@ static struct lu_device *mdc_device_fini(const struct lu_env *env, RETURN (NULL); } +/** Allocate new mdc device */ static struct lu_device *mdc_device_alloc(const struct lu_env *env, struct lu_device_type *ldt, struct lustre_cfg *cfg) @@ -271,41 +311,44 @@ static struct lu_device *mdc_device_alloc(const struct lu_env *env, } else { md_device_init(&mc->mc_md_dev, ldt); mc->mc_md_dev.md_ops = &mdc_md_ops; - ld = mdc2lu_dev(mc); + ld = mdc2lu_dev(mc); ld->ld_ops = &mdc_lu_ops; - sema_init(&mc->mc_fid_sem, 1); - + cfs_sema_init(&mc->mc_fid_sem, 1); } RETURN (ld); } +/** Free mdc device */ static struct lu_device *mdc_device_free(const struct lu_env *env, struct lu_device *ld) { struct mdc_device *mc = lu2mdc_dev(ld); - LASSERTF(atomic_read(&ld->ld_ref) == 0, - "Refcount = %i\n", atomic_read(&ld->ld_ref)); - LASSERT(list_empty(&mc->mc_linkage)); + LASSERTF(cfs_atomic_read(&ld->ld_ref) == 0, + "Refcount = %d\n", cfs_atomic_read(&ld->ld_ref)); + LASSERT(cfs_list_empty(&mc->mc_linkage)); md_device_fini(&mc->mc_md_dev); OBD_FREE_PTR(mc); return NULL; } -/* context key constructor/destructor: mdc_key_init, mdc_key_fini */ +/** context key constructor/destructor: mdc_key_init, mdc_key_fini */ LU_KEY_INIT_FINI(mdc, struct mdc_thread_info); -/* context key: mdc_thread_key */ +/** context key: mdc_thread_key */ LU_CONTEXT_KEY_DEFINE(mdc, LCT_MD_THREAD|LCT_CL_THREAD); -/* type constructor/destructor: mdc_type_init, mdc_type_fini */ +/** type constructor/destructor: mdc_type_init, mdc_type_fini */ LU_TYPE_INIT_FINI(mdc, &mdc_thread_key); static struct lu_device_type_operations mdc_device_type_ops = { .ldto_init = mdc_type_init, .ldto_fini = mdc_type_fini, + .ldto_start = mdc_type_start, + .ldto_stop = mdc_type_stop, + .ldto_device_alloc = mdc_device_alloc, .ldto_device_free = mdc_device_free, @@ -319,4 +362,4 @@ struct lu_device_type mdc_device_type = { .ldt_ops = &mdc_device_type_ops, .ldt_ctx_tags = LCT_MD_THREAD|LCT_CL_THREAD }; - +/** @} */