Whamcloud - gitweb
Remove depricated ptlrpc_free_req() function.
[fs/lustre-release.git] / lustre / cmm / cmm_device.c
index 3dee060..aef1da6 100644 (file)
@@ -1,29 +1,43 @@
 /* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
  * vim:expandtab:shiftwidth=8:tabstop=8:
  *
- *  lustre/cmm/cmm_device.c
- *  Lustre Cluster Metadata Manager (cmm)
+ * GPL HEADER START
  *
- *  Copyright (c) 2006 Cluster File Systems, Inc.
- *   Author: Mike Pershin <tappro@clusterfs.com>
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
- *   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 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.
  *
- *   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.
+ * 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).
  *
- *   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.
+ * 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
  *
- *   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.
+ * 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.
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright  2008 Sun Microsystems, Inc. All rights reserved
+ * Use is subject to license terms.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/cmm/cmm_device.c
+ *
+ * Lustre Cluster Metadata Manager (cmm)
+ *
+ * Author: Mike Pershin <tappro@clusterfs.com>
  */
 
 #ifndef EXPORT_SYMTAB
@@ -138,7 +152,7 @@ static int cmm_post_init_mdc(const struct lu_env *env,
         spin_lock(&cmm->cmm_tgt_guard);
         list_for_each_entry_safe(mc, tmp, &cmm->cmm_targets,
                                  mc_linkage) {
-                mdc_init_ea_size(env, mc, max_mdsize, max_cookiesize);
+                cmm_mdc_init_ea_size(env, mc, max_mdsize, max_cookiesize);
         }
         spin_unlock(&cmm->cmm_tgt_guard);
         RETURN(rc);
@@ -176,17 +190,23 @@ static int cmm_add_mdc(const struct lu_env *env,
         }
         spin_unlock(&cm->cmm_tgt_guard);
         ld = ldt->ldt_ops->ldto_device_alloc(env, ldt, cfg);
+        if (IS_ERR(ld))
+                RETURN(PTR_ERR(ld));
+
         ld->ld_site = cmm2lu_dev(cm)->ld_site;
 
         rc = ldt->ldt_ops->ldto_device_init(env, ld, NULL, NULL);
         if (rc) {
                 ldt->ldt_ops->ldto_device_free(env, ld);
-                RETURN (rc);
+                RETURN(rc);
         }
         /* pass config to the just created MDC */
         rc = ld->ld_ops->ldo_process_config(env, ld, cfg);
-        if (rc)
+        if (rc) {
+                ldt->ldt_ops->ldto_device_fini(env, ld);
+                ldt->ldt_ops->ldto_device_free(env, ld);
                 RETURN(rc);
+        }
 
         spin_lock(&cm->cmm_tgt_guard);
         list_for_each_entry_safe(mc, tmp, &cm->cmm_targets,
@@ -368,9 +388,12 @@ out_free_cmm:
         return l;
 }
 
-static void cmm_device_free(const struct lu_env *env, struct lu_device *d)
+static struct lu_device *cmm_device_free(const struct lu_env *env,
+                                         struct lu_device *d)
 {
         struct cmm_device *m = lu2cmm_dev(d);
+        struct lu_device  *next = md2lu_dev(m->cmm_child);
+        ENTRY;
 
         LASSERT(m->cmm_tgt_count == 0);
         LASSERT(list_empty(&m->cmm_targets));
@@ -378,13 +401,15 @@ static void cmm_device_free(const struct lu_env *env, struct lu_device *d)
                 OBD_FREE_PTR(m->cmm_fld);
                 m->cmm_fld = NULL;
         }
-       md_device_fini(&m->cmm_md_dev);
+        md_device_fini(&m->cmm_md_dev);
         OBD_FREE_PTR(m);
+        RETURN(next);
 }
 
-/* context key constructor/destructor */
+/* context key constructor/destructor: cmm_key_init, cmm_key_fini */
 LU_KEY_INIT_FINI(cmm, struct cmm_thread_info);
 
+/* context key: cmm_thread_key */
 LU_CONTEXT_KEY_DEFINE(cmm, LCT_MD_THREAD);
 
 struct cmm_thread_info *cmm_env_info(const struct lu_env *env)
@@ -396,6 +421,7 @@ struct cmm_thread_info *cmm_env_info(const struct lu_env *env)
         return info;
 }
 
+/* type constructor/destructor: cmm_type_init/cmm_type_fini */
 LU_TYPE_INIT_FINI(cmm, &cmm_thread_key);
 
 static int cmm_device_init(const struct lu_env *env, struct lu_device *d,
@@ -407,7 +433,7 @@ static int cmm_device_init(const struct lu_env *env, struct lu_device *d,
         ENTRY;
 
         spin_lock_init(&m->cmm_tgt_guard);
-        INIT_LIST_HEAD(&m->cmm_targets);
+        CFS_INIT_LIST_HEAD(&m->cmm_targets);
         m->cmm_tgt_count = 0;
         m->cmm_child = lu2md_dev(next);
 
@@ -481,13 +507,17 @@ struct lprocfs_vars lprocfs_cmm_module_vars[] = {
         { 0 }
 };
 
-LPROCFS_INIT_VARS(cmm, lprocfs_cmm_module_vars, lprocfs_cmm_obd_vars);
+static void lprocfs_cmm_init_vars(struct lprocfs_static_vars *lvars)
+{
+    lvars->module_vars  = lprocfs_cmm_module_vars;
+    lvars->obd_vars     = lprocfs_cmm_obd_vars;
+}
 
 static int __init cmm_mod_init(void)
 {
         struct lprocfs_static_vars lvars;
 
-        lprocfs_init_vars(cmm, &lvars);
+        lprocfs_cmm_init_vars(&lvars);
         return class_register_type(&cmm_obd_device_ops, NULL, lvars.module_vars,
                                    LUSTRE_CMM_NAME, &cmm_device_type);
 }
@@ -497,7 +527,7 @@ static void __exit cmm_mod_exit(void)
         class_unregister_type(LUSTRE_CMM_NAME);
 }
 
-MODULE_AUTHOR("Cluster File Systems, Inc. <info@clusterfs.com>");
+MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
 MODULE_DESCRIPTION("Lustre Clustered Metadata Manager ("LUSTRE_CMM_NAME")");
 MODULE_LICENSE("GPL");