1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
/*
* Berkeley Lab Checkpoint/Restart (BLCR) for Linux is Copyright (c)
* 2003, The Regents of the University of California, through Lawrence
* Berkeley National Laboratory (subject to receipt of any required
* approvals from the U.S. Dept. of Energy). All rights reserved.
*
* Portions may be copyrighted by others, as may be noted in specific
* copyright notices within specific files.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Id: cr_module.c,v 1.51.4.1 2012/12/25 03:27:28 phargrov Exp $
*/
#include "cr_module.h"
#include <linux/init.h>
#include <linux/moduleparam.h>
/* Find some always-exported symbols needed to validate System.map */
#include <linux/unistd.h> /* for __NR_close */
MODULE_AUTHOR("Lawrence Berkeley National Lab " PACKAGE_BUGREPORT);
MODULE_DESCRIPTION("Berkeley Lab Checkpoint/Restart (BLCR) kernel module");
MODULE_LICENSE("GPL");
#if CR_KERNEL_TRACING
module_param(cr_ktrace_mask, uint, 0644);
MODULE_PARM_DESC(cr_ktrace_mask,
"Mask of ORed tracing flags: see cr_ktrace.h for list");
#endif
#if CRI_DEBUG
extern unsigned int cr_read_fault_rate;
extern unsigned int cr_write_fault_rate;
module_param(cr_read_fault_rate, uint, 0644);
module_param(cr_write_fault_rate, uint, 0644);
MODULE_PARM_DESC(cr_read_fault_rate,
"Injection rate (1-in-value) of artificial read faults");
MODULE_PARM_DESC(cr_write_fault_rate,
"Injection rate (1-in-value) of artificial write faults");
#endif
extern unsigned long cr_io_max, cr_io_max_mask;
module_param(cr_io_max, ulong, 0644);
MODULE_PARM_DESC(cr_io_max, "Maximum size of an I/O request (must be a power of 2)");
cr_kmem_cache_ptr cr_pdata_cachep = NULL;
cr_kmem_cache_ptr cr_task_cachep = NULL;
cr_kmem_cache_ptr cr_chkpt_req_cachep = NULL;
cr_kmem_cache_ptr cr_chkpt_proc_req_cachep = NULL;
cr_kmem_cache_ptr cr_rstrt_req_cachep = NULL;
cr_kmem_cache_ptr cr_rstrt_proc_req_cachep = NULL;
static int __init cr_init_module(void)
{
int err;
err = vmadump_init_module();
if (err) return err;
CR_INFO("Berkeley Lab Checkpoint/Restart (BLCR) module version " PACKAGE_VERSION ".");
#if CR_KERNEL_TRACING
CR_INFO(" Tracing enabled (trace_mask=0x%x)", cr_ktrace_mask);
#endif
CR_INFO(" Parameter cr_io_max = 0x%lx", cr_io_max);
#if CRI_DEBUG
CR_INFO(" Parameter cr_read_fault_rate = %d", cr_read_fault_rate);
CR_INFO(" Parameter cr_write_fault_rate = %d", cr_write_fault_rate);
#endif
CR_INFO(" Supports kernel interface version " CR_MODULE_VERSION ".");
#if CR_CONTEXT_VERSION == CR_CONTEXT_VERSION_MIN
CR_INFO(" Supports context file format version %d.", CR_CONTEXT_VERSION);
#else
CR_INFO(" Supports context file format versions %d though %d.",
CR_CONTEXT_VERSION_MIN, CR_CONTEXT_VERSION);
#endif
CR_INFO(PACKAGE_BUGREPORT);
/* Check for correct blcr_imports */
if (strcmp(blcr_config_timestamp, BLCR_CONFIG_TIMESTAMP)) {
CR_ERR("Module blcr_imports timestamp (%s) does not match that of blcr (" BLCR_CONFIG_TIMESTAMP ").", blcr_config_timestamp);
return -EINVAL;
}
/* validate/setup for I/O max */
if (cr_io_max & (cr_io_max - 1)) {
CR_ERR("Module parameter cr_io_max must be a power of 2");
return -EINVAL;
}
cr_io_max_mask = ~(cr_io_max - 1);
err = cr_proc_init();
if (err) {
goto bad_proc_init;
}
#ifdef CR_ENABLE_BOGUS_FOPS
err = cr_fs_init();
if (err) {
goto bad_fs_init;
}
#endif
#if defined(CONFIG_COMPAT) && !defined(HAVE_COMPAT_IOCTL)
err = cr_init_ioctl32();
if (err) {
goto bad_ioctl32;
}
#endif
err = cr_rstrt_init();
if (err) {
goto bad_rstrt_init;
}
err = cr_object_init();
if (err) {
goto bad_object_init;
}
err = -ENOMEM;
cr_pdata_cachep = CR_KMEM_CACHE(cr_pdata_s);
if (!cr_pdata_cachep) goto no_pdata_cachep;
cr_task_cachep = CR_KMEM_CACHE(cr_task_s);
if (!cr_task_cachep) goto no_task_cachep;
cr_chkpt_req_cachep = CR_KMEM_CACHE(cr_chkpt_req_s);
if (!cr_chkpt_req_cachep) goto no_chkpt_req_cachep;
cr_chkpt_proc_req_cachep = CR_KMEM_CACHE(cr_chkpt_preq_s);
if (!cr_chkpt_proc_req_cachep) goto no_chkpt_proc_req_cachep;
cr_rstrt_req_cachep = CR_KMEM_CACHE(cr_rstrt_req_s);
if (!cr_rstrt_req_cachep) goto no_rstrt_req_cachep;
cr_rstrt_proc_req_cachep = CR_KMEM_CACHE(cr_rstrt_preq_s);
if (!cr_rstrt_proc_req_cachep) goto no_rstrt_proc_req_cachep;
return 0;
no_rstrt_proc_req_cachep:
kmem_cache_destroy(cr_rstrt_req_cachep);
no_rstrt_req_cachep:
kmem_cache_destroy(cr_chkpt_proc_req_cachep);
no_chkpt_proc_req_cachep:
kmem_cache_destroy(cr_chkpt_req_cachep);
no_chkpt_req_cachep:
kmem_cache_destroy(cr_task_cachep);
no_task_cachep:
kmem_cache_destroy(cr_pdata_cachep);
no_pdata_cachep:
cr_object_cleanup();
bad_object_init:
cr_rstrt_cleanup();
bad_rstrt_init:
#if defined(CONFIG_COMPAT) && !defined(HAVE_COMPAT_IOCTL)
cr_cleanup_ioctl32();
bad_ioctl32:
#endif
#ifdef CR_ENABLE_BOGUS_FOPS
cr_fs_cleanup();
bad_fs_init:
#endif
cr_proc_cleanup();
bad_proc_init:
return err;
}
static void __exit cr_cleanup_module(void)
{
#if defined(CONFIG_COMPAT) && !defined(HAVE_COMPAT_IOCTL)
cr_cleanup_ioctl32();
#endif
#ifdef CR_ENABLE_BOGUS_FOPS
cr_fs_cleanup();
#endif
cr_proc_cleanup();
cr_wd_flush();
cr_object_cleanup();
cr_rstrt_cleanup();
kmem_cache_destroy(cr_rstrt_proc_req_cachep);
kmem_cache_destroy(cr_rstrt_req_cachep);
kmem_cache_destroy(cr_chkpt_proc_req_cachep);
kmem_cache_destroy(cr_chkpt_req_cachep);
kmem_cache_destroy(cr_task_cachep);
kmem_cache_destroy(cr_pdata_cachep);
CR_INFO("Checkpoint/Restart module removed");
vmadump_cleanup_module();
}
module_init(cr_init_module);
module_exit(cr_cleanup_module);
|