0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "protocol.h"
0012 #include "orangefs-kernel.h"
0013 #include "orangefs-debugfs.h"
0014 #include "orangefs-sysfs.h"
0015
0016
0017 #ifndef ORANGEFS_VERSION
0018 #define ORANGEFS_VERSION "upstream"
0019 #endif
0020
0021
0022
0023
0024
0025 struct orangefs_stats orangefs_stats;
0026
0027
0028 int hash_table_size = 509;
0029
0030 static ulong module_parm_debug_mask;
0031 __u64 orangefs_gossip_debug_mask;
0032 int op_timeout_secs = ORANGEFS_DEFAULT_OP_TIMEOUT_SECS;
0033 int slot_timeout_secs = ORANGEFS_DEFAULT_SLOT_TIMEOUT_SECS;
0034 int orangefs_cache_timeout_msecs = 500;
0035 int orangefs_dcache_timeout_msecs = 50;
0036 int orangefs_getattr_timeout_msecs = 50;
0037
0038 MODULE_LICENSE("GPL");
0039 MODULE_AUTHOR("ORANGEFS Development Team");
0040 MODULE_DESCRIPTION("The Linux Kernel VFS interface to ORANGEFS");
0041 MODULE_PARM_DESC(module_parm_debug_mask, "debugging level (see orangefs-debug.h for values)");
0042 MODULE_PARM_DESC(op_timeout_secs, "Operation timeout in seconds");
0043 MODULE_PARM_DESC(slot_timeout_secs, "Slot timeout in seconds");
0044 MODULE_PARM_DESC(hash_table_size,
0045 "size of hash table for operations in progress");
0046
0047 static struct file_system_type orangefs_fs_type = {
0048 .name = "pvfs2",
0049 .mount = orangefs_mount,
0050 .kill_sb = orangefs_kill_sb,
0051 .owner = THIS_MODULE,
0052 };
0053
0054 module_param(hash_table_size, int, 0);
0055 module_param(module_parm_debug_mask, ulong, 0644);
0056 module_param(op_timeout_secs, int, 0);
0057 module_param(slot_timeout_secs, int, 0);
0058
0059
0060
0061
0062
0063
0064
0065 DEFINE_MUTEX(orangefs_request_mutex);
0066
0067
0068 struct list_head *orangefs_htable_ops_in_progress;
0069 DEFINE_SPINLOCK(orangefs_htable_ops_in_progress_lock);
0070
0071
0072 LIST_HEAD(orangefs_request_list);
0073
0074
0075 DEFINE_SPINLOCK(orangefs_request_list_lock);
0076
0077
0078 DECLARE_WAIT_QUEUE_HEAD(orangefs_request_list_waitq);
0079
0080 static int __init orangefs_init(void)
0081 {
0082 int ret;
0083 __u32 i = 0;
0084
0085 if (op_timeout_secs < 0)
0086 op_timeout_secs = 0;
0087
0088 if (slot_timeout_secs < 0)
0089 slot_timeout_secs = 0;
0090
0091
0092 ret = op_cache_initialize();
0093 if (ret < 0)
0094 goto out;
0095
0096 ret = orangefs_inode_cache_initialize();
0097 if (ret < 0)
0098 goto cleanup_op;
0099
0100 orangefs_htable_ops_in_progress =
0101 kcalloc(hash_table_size, sizeof(struct list_head), GFP_KERNEL);
0102 if (!orangefs_htable_ops_in_progress) {
0103 ret = -ENOMEM;
0104 goto cleanup_inode;
0105 }
0106
0107
0108 for (i = 0; i < hash_table_size; i++)
0109 INIT_LIST_HEAD(&orangefs_htable_ops_in_progress[i]);
0110
0111 ret = fsid_key_table_initialize();
0112 if (ret < 0)
0113 goto cleanup_progress_table;
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128 ret = orangefs_prepare_debugfs_help_string(1);
0129 if (ret)
0130 goto cleanup_key_table;
0131
0132 orangefs_debugfs_init(module_parm_debug_mask);
0133
0134 ret = orangefs_sysfs_init();
0135 if (ret)
0136 goto sysfs_init_failed;
0137
0138
0139 ret = orangefs_dev_init();
0140 if (ret < 0) {
0141 gossip_err("%s: could not initialize device subsystem %d!\n",
0142 __func__,
0143 ret);
0144 goto cleanup_device;
0145 }
0146
0147 ret = register_filesystem(&orangefs_fs_type);
0148 if (ret == 0) {
0149 pr_info("%s: module version %s loaded\n",
0150 __func__,
0151 ORANGEFS_VERSION);
0152 goto out;
0153 }
0154
0155 orangefs_sysfs_exit();
0156
0157 cleanup_device:
0158 orangefs_dev_cleanup();
0159
0160 sysfs_init_failed:
0161 orangefs_debugfs_cleanup();
0162
0163 cleanup_key_table:
0164 fsid_key_table_finalize();
0165
0166 cleanup_progress_table:
0167 kfree(orangefs_htable_ops_in_progress);
0168
0169 cleanup_inode:
0170 orangefs_inode_cache_finalize();
0171
0172 cleanup_op:
0173 op_cache_finalize();
0174
0175 out:
0176 return ret;
0177 }
0178
0179 static void __exit orangefs_exit(void)
0180 {
0181 int i = 0;
0182 gossip_debug(GOSSIP_INIT_DEBUG, "orangefs: orangefs_exit called\n");
0183
0184 unregister_filesystem(&orangefs_fs_type);
0185 orangefs_debugfs_cleanup();
0186 orangefs_sysfs_exit();
0187 fsid_key_table_finalize();
0188 orangefs_dev_cleanup();
0189 BUG_ON(!list_empty(&orangefs_request_list));
0190 for (i = 0; i < hash_table_size; i++)
0191 BUG_ON(!list_empty(&orangefs_htable_ops_in_progress[i]));
0192
0193 orangefs_inode_cache_finalize();
0194 op_cache_finalize();
0195
0196 kfree(orangefs_htable_ops_in_progress);
0197
0198 pr_info("orangefs: module version %s unloaded\n", ORANGEFS_VERSION);
0199 }
0200
0201
0202
0203
0204
0205 void purge_inprogress_ops(void)
0206 {
0207 int i;
0208
0209 for (i = 0; i < hash_table_size; i++) {
0210 struct orangefs_kernel_op_s *op;
0211 struct orangefs_kernel_op_s *next;
0212
0213 spin_lock(&orangefs_htable_ops_in_progress_lock);
0214 list_for_each_entry_safe(op,
0215 next,
0216 &orangefs_htable_ops_in_progress[i],
0217 list) {
0218 set_op_state_purged(op);
0219 gossip_debug(GOSSIP_DEV_DEBUG,
0220 "%s: op:%s: op_state:%d: process:%s:\n",
0221 __func__,
0222 get_opname_string(op),
0223 op->op_state,
0224 current->comm);
0225 }
0226 spin_unlock(&orangefs_htable_ops_in_progress_lock);
0227 }
0228 }
0229
0230 module_init(orangefs_init);
0231 module_exit(orangefs_exit);