* Number of existing device type instances.
*/
atomic_t ldt_device_nr;
- /**
- * Linkage into a global list of all device types.
- *
- * \see lu_device_types.
- */
- struct list_head ldt_linkage;
};
/**
#define OBD_STATFS_FOR_MDT0 0x0004 /* The statfs is only for retrieving
* information from MDT0. */
-/* OBD Device Declarations */
-extern struct obd_device *obd_devs[MAX_OBD_DEVICES];
-extern struct list_head obd_types;
-extern spinlock_t obd_types_lock;
extern rwlock_t obd_dev_lock;
/* OBD Operations Declarations */
typedef int (*llog_cb_t)(const struct lu_env *, struct llog_handle *,
struct llog_rec_hdr *, void *);
-extern atomic_t obd_stale_export_num;
-extern struct list_head obd_stale_exports;
-extern spinlock_t obd_stale_export_lock;
-
struct obd_export *obd_stale_export_get(void);
void obd_stale_export_put(struct obd_export *exp);
void obd_stale_export_adjust(struct obd_export *exp);
struct llog_handle *handle,
struct llog_rec_hdr *rec, void *data);
int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
-int class_add_uuid(const char *uuid, __u64 nid);
#define CFG_F_START 0x01 /* Set when we start updating from a log */
#define CFG_F_MARKER 0x02 /* We are within a maker */
int class_add_uuid(const char *uuid, __u64 nid);
int class_del_uuid (const char *uuid);
int class_check_uuid(struct obd_uuid *uuid, __u64 nid);
-void class_init_uuidlist(void);
-void class_exit_uuidlist(void);
/* class_obd.c */
extern char obd_jobid_node[];
#include <lustre_ioctl.h>
#include "llog_internal.h"
-struct obd_device *obd_devs[MAX_OBD_DEVICES];
-struct list_head obd_types;
-DEFINE_RWLOCK(obd_dev_lock);
-
#ifdef CONFIG_PROC_FS
static __u64 obd_max_alloc;
#else
static int __init obdclass_init(void)
{
- int i, err;
-
- spin_lock_init(&obd_stale_export_lock);
- INIT_LIST_HEAD(&obd_stale_exports);
- atomic_set(&obd_stale_export_num, 0);
+ int err;
LCONSOLE_INFO("Lustre: Build Version: "LUSTRE_VERSION_STRING"\n");
- spin_lock_init(&obd_types_lock);
- obd_zombie_impexp_init();
+ err = obd_init_checks();
+ if (err == -EOVERFLOW)
+ return err;
+
#ifdef CONFIG_PROC_FS
obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
LPROCFS_STATS_FLAG_NONE |
LPROCFS_STATS_FLAG_IRQ_SAFE);
if (obd_memory == NULL) {
CERROR("kmalloc of 'obd_memory' failed\n");
- err = -ENOMEM;
- goto cleanup_zombie_impexp;
+ return -ENOMEM;
}
lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
LPROCFS_CNTR_AVGMINMAX,
"memused", "bytes");
#endif
- err = obd_init_checks();
- if (err == -EOVERFLOW)
- goto cleanup_zombie_impexp;
+ err = obd_zombie_impexp_init();
+ if (err)
+ goto cleanup_obd_memory;
- class_init_uuidlist();
err = class_handle_init();
if (err)
- goto cleanup_uuidlist;
-
- INIT_LIST_HEAD(&obd_types);
+ goto cleanup_zombie_impexp;
err = misc_register(&obd_psdev);
if (err) {
goto cleanup_class_handle;
}
- /* This struct is already zeroed for us (static global) */
- for (i = 0; i < class_devno_max(); i++)
- obd_devs[i] = NULL;
-
/* Default the dirty page cache cap to 1/2 of system memory.
* For clients with less memory, a larger fraction is needed
* for other purposes (mostly for BGL). */
if (err)
goto cleanup_llog_info;
- goto out_success;
+ return 0;
cleanup_llog_info:
llog_info_fini();
cleanup_class_handle:
class_handle_cleanup();
-cleanup_uuidlist:
- class_exit_uuidlist();
-
cleanup_zombie_impexp:
obd_zombie_impexp_stop();
-out_success:
+cleanup_obd_memory:
+#ifdef CONFIG_PROC_FS
+ lprocfs_free_stats(&obd_memory);
+#endif
+
return err;
}
static void __exit obdclass_exit(void)
{
+#ifdef CONFIG_PROC_FS
__u64 memory_leaked;
__u64 memory_max;
+#endif /* CONFIG_PROC_FS */
ENTRY;
lustre_unregister_fs();
class_procfs_clean();
class_handle_cleanup();
- class_exit_uuidlist();
+ class_del_uuid(NULL); /* Delete all UUIDs. */
obd_zombie_impexp_stop();
- LASSERT(list_empty(&obd_stale_exports));
-
- memory_leaked = obd_memory_sum();
- memory_max = obd_memory_max();
+#ifdef CONFIG_PROC_FS
+ memory_leaked = obd_memory_sum();
+ memory_max = obd_memory_max();
- lprocfs_free_stats(&obd_memory);
- CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
+ lprocfs_free_stats(&obd_memory);
+ CDEBUG((memory_leaked) ? D_ERROR : D_INFO,
"obd_memory max: %llu, leaked: %llu\n",
- memory_max, memory_leaked);
+ memory_max, memory_leaked);
+#endif /* CONFIG_PROC_FS */
- EXIT;
+ EXIT;
}
MODULE_AUTHOR("OpenSFS, Inc. <http://www.lustre.org/>");
#include <lustre_disk.h>
#include <lustre_kernelcomm.h>
-spinlock_t obd_types_lock;
+static DEFINE_SPINLOCK(obd_types_lock);
+static LIST_HEAD(obd_types);
+DEFINE_RWLOCK(obd_dev_lock);
+static struct obd_device *obd_devs[MAX_OBD_DEVICES];
static struct kmem_cache *obd_device_cachep;
struct kmem_cache *obdo_cachep;
EXPORT_SYMBOL(obdo_cachep);
static struct kmem_cache *import_cachep;
-static struct list_head obd_zombie_imports;
-static struct list_head obd_zombie_exports;
-static spinlock_t obd_zombie_impexp_lock;
+static LIST_HEAD(obd_zombie_imports);
+static LIST_HEAD(obd_zombie_exports);
+static DEFINE_SPINLOCK(obd_zombie_impexp_lock);
static void obd_zombie_impexp_notify(void);
static void obd_zombie_export_add(struct obd_export *exp);
static void print_export_data(struct obd_export *exp,
const char *status, int locks, int debug_level);
-struct list_head obd_stale_exports;
-spinlock_t obd_stale_export_lock;
-atomic_t obd_stale_export_num;
+static LIST_HEAD(obd_stale_exports);
+static DEFINE_SPINLOCK(obd_stale_export_lock);
+static atomic_t obd_stale_export_num = ATOMIC_INIT(0);
int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
EXPORT_SYMBOL(ptlrpc_put_connection_superhack);
EXIT;
}
-static struct completion obd_zombie_start;
-static struct completion obd_zombie_stop;
-static unsigned long obd_zombie_flags;
-static wait_queue_head_t obd_zombie_waitq;
-static pid_t obd_zombie_pid;
+static DECLARE_COMPLETION(obd_zombie_start);
+static DECLARE_COMPLETION(obd_zombie_stop);
+static unsigned long obd_zombie_flags;
+static DECLARE_WAIT_QUEUE_HEAD(obd_zombie_waitq);
+static pid_t obd_zombie_pid;
enum {
OBD_ZOMBIE_STOP = 0x0001,
{
struct task_struct *task;
- INIT_LIST_HEAD(&obd_zombie_imports);
-
- INIT_LIST_HEAD(&obd_zombie_exports);
- spin_lock_init(&obd_zombie_impexp_lock);
- init_completion(&obd_zombie_start);
- init_completion(&obd_zombie_stop);
- init_waitqueue_head(&obd_zombie_waitq);
- obd_zombie_pid = 0;
-
task = kthread_run(obd_zombie_impexp_thread, NULL, "obd_zombid");
if (IS_ERR(task))
RETURN(PTR_ERR(task));
set_bit(OBD_ZOMBIE_STOP, &obd_zombie_flags);
obd_zombie_impexp_notify();
wait_for_completion(&obd_zombie_stop);
+ LASSERT(list_empty(&obd_stale_exports));
}
/***** Kernel-userspace comm helpers *******/
#include "local_storage.h"
/* all initialized local storages on this node are linked on this */
-static struct list_head ls_list_head = LIST_HEAD_INIT(ls_list_head);
+static LIST_HEAD(ls_list_head);
static DEFINE_MUTEX(ls_list_mutex);
static int ls_object_init(const struct lu_env *env, struct lu_object *o,
}
EXPORT_SYMBOL(lu_object_find_slice);
-/**
- * Global list of all device types.
- */
-static struct list_head lu_device_types;
-
int lu_device_type_init(struct lu_device_type *ldt)
{
int result = 0;
atomic_set(&ldt->ldt_device_nr, 0);
- INIT_LIST_HEAD(&ldt->ldt_linkage);
if (ldt->ldt_ops->ldto_init)
result = ldt->ldt_ops->ldto_init(ldt);
- if (result == 0) {
- spin_lock(&obd_types_lock);
- list_add(&ldt->ldt_linkage, &lu_device_types);
- spin_unlock(&obd_types_lock);
- }
-
return result;
}
EXPORT_SYMBOL(lu_device_type_init);
void lu_device_type_fini(struct lu_device_type *ldt)
{
- spin_lock(&obd_types_lock);
- list_del_init(&ldt->ldt_linkage);
- spin_unlock(&obd_types_lock);
if (ldt->ldt_ops->ldto_fini)
ldt->ldt_ops->ldto_fini(ldt);
}
/**
* Global list of all sites on this node
*/
-static struct list_head lu_sites;
-static struct rw_semaphore lu_sites_guard;
+static LIST_HEAD(lu_sites);
+static DECLARE_RWSEM(lu_sites_guard);
/**
* Global environment used by site shrinker.
/**
* List of remembered contexts. XXX document me.
*/
-static struct list_head lu_context_remembered;
+static LIST_HEAD(lu_context_remembered);
/**
* Destroy \a key in all remembered contexts. This is used to destroy key
CDEBUG(D_INFO, "Lustre LU module (%p).\n", &lu_keys);
- INIT_LIST_HEAD(&lu_device_types);
- INIT_LIST_HEAD(&lu_context_remembered);
- INIT_LIST_HEAD(&lu_sites);
- init_rwsem(&lu_sites_guard);
-
result = lu_ref_global_init();
if (result != 0)
return result;
*
* Protected by lu_ref_refs_guard.
*/
-static struct list_head lu_ref_refs;
-static spinlock_t lu_ref_refs_guard;
+static LIST_HEAD(lu_ref_refs);
+static DEFINE_SPINLOCK(lu_ref_refs_guard);
static struct lu_ref lu_ref_marker = {
.lf_guard = __SPIN_LOCK_UNLOCKED(lu_ref_marker.lf_guard),
.lf_list = LIST_HEAD_INIT(lu_ref_marker.lf_list),
CDEBUG(D_CONSOLE,
"lu_ref tracking is enabled. Performance isn't.\n");
- INIT_LIST_HEAD(&lu_ref_refs);
- spin_lock_init(&lu_ref_refs_guard);
result = lu_kmem_init(lu_ref_caches);
#ifdef CONFIG_PROC_FS
static __u64 handle_base;
#define HANDLE_INCR 7
-static spinlock_t handle_base_lock;
+static DEFINE_SPINLOCK(handle_base_lock);
static struct handle_bucket {
spinlock_t lock;
if (handle_hash == NULL)
return -ENOMEM;
- spin_lock_init(&handle_base_lock);
for (bucket = handle_hash + HANDLE_HASH_SIZE - 1; bucket >= handle_hash;
bucket--) {
INIT_LIST_HEAD(&bucket->head);
};
/* FIXME: This should probably become more elegant than a global linked list */
-static struct list_head g_uuid_list;
-static spinlock_t g_uuid_lock;
-
-void class_init_uuidlist(void)
-{
- INIT_LIST_HEAD(&g_uuid_list);
- spin_lock_init(&g_uuid_lock);
-}
-
-void class_exit_uuidlist(void)
-{
- /* delete all */
- class_del_uuid(NULL);
-}
+static LIST_HEAD(g_uuid_list);
+static DEFINE_SPINLOCK(g_uuid_lock);
int lustre_uuid_to_peer(const char *uuid, lnet_nid_t *peer_nid, int index)
{
RETURN(rc);
}
-static struct list_head lustre_profile_list =
- LIST_HEAD_INIT(lustre_profile_list);
+static LIST_HEAD(lustre_profile_list);
static DEFINE_SPINLOCK(lustre_profile_list_lock);
struct lustre_profile *class_get_profile(const char * prof)
/*********** mount lookup *********/
static DEFINE_MUTEX(lustre_mount_info_lock);
-static struct list_head server_mount_info_list =
- LIST_HEAD_INIT(server_mount_info_list);
+static LIST_HEAD(server_mount_info_list);
static struct lustre_mount_info *server_find_mount(const char *name)
{
}
EXPORT_SYMBOL(tgt_name2lwp_name);
-static struct list_head lwp_register_list =
- LIST_HEAD_INIT(lwp_register_list);
+static LIST_HEAD(lwp_register_list);
static DEFINE_SPINLOCK(lwp_register_list_lock);
static void lustre_put_lwp_item(struct lwp_register_item *lri)