[Ocfs2-commits] mfasheh commits r1599 - branches/dlm-glue/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Oct 28 16:28:20 CDT 2004
Author: mfasheh
Date: 2004-10-28 16:28:18 -0500 (Thu, 28 Oct 2004)
New Revision: 1599
Removed:
branches/dlm-glue/src/volcfg.c
branches/dlm-glue/src/volcfg.h
Modified:
branches/dlm-glue/src/Makefile
branches/dlm-glue/src/ocfs.h
branches/dlm-glue/src/proc.c
branches/dlm-glue/src/super.c
Log:
* more and more
Modified: branches/dlm-glue/src/Makefile
===================================================================
--- branches/dlm-glue/src/Makefile 2004-10-28 20:36:58 UTC (rev 1598)
+++ branches/dlm-glue/src/Makefile 2004-10-28 21:28:18 UTC (rev 1599)
@@ -86,7 +86,6 @@
sysfile.c \
util.c \
ver.c \
- volcfg.c \
HFILES = \
ocfs2_fs.h \
@@ -117,7 +116,6 @@
sysfile.h \
util.h \
ver.h \
- volcfg.h \
VERSION_FILES = $(CFILES) $(HFILES)
VERSION_SRC = ver.c
Modified: branches/dlm-glue/src/ocfs.h
===================================================================
--- branches/dlm-glue/src/ocfs.h 2004-10-28 20:36:58 UTC (rev 1598)
+++ branches/dlm-glue/src/ocfs.h 2004-10-28 21:28:18 UTC (rev 1599)
@@ -63,10 +63,6 @@
}
ocfs_alloc_bm;
-#define OCFS_MAX_DLM_PKT_SIZE 256
-#define OCFS_DLM_MAX_MSG_SIZE 256
-#define OCFS_DLM_MSG_MAGIC 0x79677083
-
/* convenience macro */
#define OCFS_ASSERT(x) do { if (!(x)) BUG(); } while (0)
@@ -95,10 +91,6 @@
#define OCFS_MAX_OSB_ID 65536
-
-#define HEARTBEAT_METHOD_DISK (1)
-#define HEARTBEAT_METHOD_IPC (2)
-
#define OCFS_INVALID_NODE_NUM -1
/* osb->osb_flags flags */
@@ -111,25 +103,6 @@
#define OCFS_FLAG_MEM_LISTS_INITIALIZED (0x00000002)
#define OCFS_FLAG_SHUTDOWN_VOL_THREAD (0x00000004)
-/*
-** Information on Publish sector of each node
-*/
-#define DISK_HBEAT_COMM_ON 20 /* in the order of 5 secs */
-#define DISK_HBEAT_NO_COMM 4 /* in the order of 1 sec */
-#define DISK_HBEAT_INVALID 0 /* in the order of 100ms */
-
-
-/*
-** Information on Vote sector of each node
-*/
-// VOTEFLAG MASK
-#define FLAG_VOTE_NODE 0x1
-#define FLAG_VOTE_OIN_UPDATED 0x2
-#define FLAG_VOTE_OIN_ALREADY_INUSE 0x4
-#define FLAG_VOTE_UPDATE_RETRY 0x8
-#define FLAG_VOTE_FILE_DEL 0x10
-
-
#define SHUTDOWN_SIGS (sigmask(SIGKILL) | sigmask(SIGHUP) | \
sigmask(SIGINT) | sigmask(SIGQUIT))
@@ -190,28 +163,10 @@
#define OCFS_SB(sb) ((ocfs_super *)OCFS_GENERIC_SB_MEMBER(sb))
#define OCFS2_SB(sb) ((ocfs_super *)OCFS_GENERIC_SB_MEMBER(sb))
-#define OCFS_IPC_DEFAULT_PORT 7001
-
-
-#define OCFS_IPC_DLM_VERSION 0x0201
-
-
-/* =========================================================== */
-
/* This totally sucks that we have to include these here
* FIXME: Make them seperately includable. */
#include "ocfs2_fs.h"
-#include "ocfs2_disk_dlm.h"
-typedef struct _BARF_BARF_BARF
-{
- char node_name[MAX_NODE_NAME_LENGTH];
- ocfs_guid guid;
- ocfs_ipc_config_info ipc_config;
-}
-BARF_BARF_BARF;
-
-
typedef struct _ocfs_super ocfs_super;
typedef struct _ocfs_lock_res ocfs_lock_res;
@@ -453,11 +408,6 @@
u64 system_dir_blkno;
u64 bitmap_blkno;
u32 bitmap_blocks;
- u64 autoconfig_blkno;
- u32 autoconfig_blocks;
- u64 new_autoconfig_blkno;
- u32 new_autoconfig_blocks;
- u32 total_autoconfig_blocks;
u8 *uuid;
u8 *vol_label;
@@ -468,12 +418,7 @@
spinlock_t s_next_gen_lock;
u32 s_next_generation;
- struct semaphore cfg_lock;
- BARF_BARF_BARF **node_cfg_info;
- __u64 cfg_seq_num;
- int cfg_initialized;
u16 max_nodes;
- u16 num_cfg_nodes;
u16 num_nodes;
s16 node_num;
int reclaim_id; /* reclaim the original node number*/
@@ -489,15 +434,6 @@
struct semaphore recovery_lock;
int disable_recovery;
atomic_t num_recovery_threads;
- struct timer_list lock_timer;
- atomic_t lock_stop;
- wait_queue_head_t lock_event;
- atomic_t lock_event_woken;
- atomic_t nm_init;
- wait_queue_head_t nm_init_event;
- __u32 prealloc_lock;
- struct buffer_head **autoconfig_bhs;
- atomic_t node_req_vote; /* set when node's vote req pending */
wait_queue_head_t flush_event;
atomic_t flush_event_woken;
struct _ocfs_journal *journal;
@@ -505,7 +441,6 @@
spinlock_t clean_buffer_lock;
int have_local_alloc;
struct buffer_head *local_alloc_bh;
- __u8 check_mounted; /* tell nm to check mounted flag, protected by publish_lock*/
ocfs_dlm_stats net_reqst_stats; /* stats of netdlm vote requests */
ocfs_dlm_stats net_reply_stats; /* stats of netdlm vote reponses */
ocfs_alloc_stats alloc_stats;
@@ -529,16 +464,6 @@
struct completion vote_event_init;
};
-typedef struct _ocfs_comm_info
-{
- u16 ip_version; /* IP version in NBO */
- u16 ip_port; /* IP port in NBO */
- union {
- __u32 ip_addr4; /* IPv4 address in NBO */
- __u32 ip_addr6[4]; /* IPv6 address in NBO */
- } addr_u;
-} ocfs_comm_info;
-
typedef struct _ocfs_global_ctxt
{
struct semaphore global_res;
@@ -547,10 +472,8 @@
kmem_cache_t *lock_cache;
__u32 flags;
__s16 pref_node_num; /* preferred... osb has the real one */
- ocfs_guid guid; /* uniquely identifies a node */
char *node_name; /* human readable node identification */
char *cluster_name; /* unused */
- ocfs_comm_info comm_info; /* ip address, etc for listener */
int comm_info_read; /* ipc info loaded from config file */
spinlock_t comm_seq_lock; /* protects comm_seq_num */
__u64 comm_seq_num; /* local node seq num used in ipcdlm */
@@ -565,23 +488,6 @@
*/
extern ocfs_global_ctxt OcfsGlobalCtxt;
-typedef struct _ocfs_cfg_task
-{
- struct work_struct cfg_wq;
- ocfs_super *osb;
- __u64 lock_off;
- __u8 *buffer;
- struct buffer_head *bh;
-}
-ocfs_cfg_task;
-
-typedef enum _ocfs_volcfg_op
-{
- OCFS_VOLCFG_ADD,
- OCFS_VOLCFG_UPD
-}
-ocfs_volcfg_op;
-
struct ocfs_ioc
{
char name[255]; /* "OCFS" */
Modified: branches/dlm-glue/src/proc.c
===================================================================
--- branches/dlm-glue/src/proc.c 2004-10-28 20:36:58 UTC (rev 1598)
+++ branches/dlm-glue/src/proc.c 2004-10-28 21:28:18 UTC (rev 1599)
@@ -48,7 +48,6 @@
#define OCFS2_PROC_BASENAME "fs/ocfs2"
-static int ocfs_proc_globalctxt(char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_dlm_stats(char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_version (char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_nodenum (char *page, char **start, off_t off, int count, int *eof, void *data);
@@ -58,7 +57,6 @@
static int ocfs_proc_device (char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_nodes (char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_alloc_stat(char *page, char **start, off_t off, int count, int *eof, void *data);
-static int ocfs_proc_guid (char *page, char **start, off_t off, int count, int *eof, void *data);
static int ocfs_proc_label (char *page, char **start, off_t off, int count, int *eof, void *data);
typedef struct _ocfs_proc_list
@@ -71,7 +69,6 @@
ocfs_proc_list top_dir[] = {
{ "version", NULL, ocfs_proc_version },
{ "nodename", NULL, ocfs_proc_nodename },
- { "globalctxt", NULL, ocfs_proc_globalctxt },
{ "lockstat", NULL, ocfs_proc_dlm_stats },
{ NULL } };
@@ -83,7 +80,6 @@
{ "device", NULL, ocfs_proc_device },
{ "nodes", NULL, ocfs_proc_nodes },
{ "allocstat", NULL, ocfs_proc_alloc_stat },
- { "guid", NULL, ocfs_proc_guid },
{ "label", NULL, ocfs_proc_label },
{ NULL } };
@@ -157,35 +153,7 @@
return len;
} /* ocfs_proc_calc_metrics */
-
/*
- * ocfs_proc_globalctxt()
- *
- */
-static int ocfs_proc_globalctxt(char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len = 0;
- int ret;
-
- LOG_ENTRY ();
-
- len += sprintf(page + len, "ip addr/port : 0x%08u/%u\n",
- ntohl(OcfsGlobalCtxt.comm_info.addr_u.ip_addr4),
- ntohs(OcfsGlobalCtxt.comm_info.ip_port));
- len += sprintf(page + len, "guid : ");
- strncat(page + len, OcfsGlobalCtxt.guid.guid, OCFS2_GUID_LEN);
- len += OCFS2_GUID_LEN;
- strncat(page + len, "\n", 1);
- len++;
-
- ret = ocfs_proc_calc_metrics(page, start, off, count, eof, len);
-
- LOG_EXIT_INT (ret);
- return ret;
-} /* ocfs_proc_version */
-
-/*
* ocfs_proc_dlm_stats()
*
*/
@@ -514,7 +482,6 @@
int i;
int ret;
ocfs_super *osb;
- BARF_BARF_BARF *node;
char mount;
LOG_ENTRY ();
@@ -522,23 +489,10 @@
osb = data;
if (osb) {
- down (&(osb->cfg_lock));
for (i = 0; i < osb->max_nodes; i++) {
- node = osb->node_cfg_info[i];
- if (!node)
- continue;
mount = ocfs_node_map_test_bit(osb, &osb->node_map, i) ? 'M' : ' ';
- len += sprintf (page + len,
- "%2d %c %-32s 0x%08u %-6u ",
- i, mount, node->node_name,
- ntohl(node->ipc_config.addr_u.ip_addr4),
- ntohs(node->ipc_config.ip_port));
- strncat(page + len, node->guid.guid,
- OCFS2_GUID_LEN);
- len += OCFS2_GUID_LEN;
- len += sprintf (page + len, "\n");
+ len += sprintf(page + len, "%2d %c\n", i, mount);
}
- up (&(osb->cfg_lock));
}
ret = ocfs_proc_calc_metrics (page, start, off, count, eof, len);
@@ -548,36 +502,6 @@
} /* ocfs_proc_nodes */
/*
- * ocfs_proc_guid()
- *
- */
-static int ocfs_proc_guid (char *page, char **start, off_t off,
- int count, int *eof, void *data)
-{
- int len;
- int ret;
- ocfs_super *osb;
- char *p;
- int i;
-
- LOG_ENTRY ();
-
- osb = (ocfs_super *) data;
-
- for (i = 0, p = page; i < MAX_VOL_ID_LENGTH; i++, p += 2)
- sprintf(p, "%02X", osb->uuid[i]);
- *p = '\n'; ++p; *p = '\0';
-
- len = strlen (page);
-
- ret = ocfs_proc_calc_metrics (page, start, off, count, eof, len);
-
- LOG_EXIT_INT (ret);
- return ret;
-} /* ocfs_proc_guid */
-
-
-/*
* ocfs_proc_label()
*
*/
Modified: branches/dlm-glue/src/super.c
===================================================================
--- branches/dlm-glue/src/super.c 2004-10-28 20:36:58 UTC (rev 1598)
+++ branches/dlm-glue/src/super.c 2004-10-28 21:28:18 UTC (rev 1599)
@@ -42,6 +42,10 @@
#include <linux/socket.h>
#include <linux/inet.h>
+#include <dlmutil.h>
+#include <dlmcommon.h>
+#include <dlmnm.h>
+
#include "ocfs_log.h"
#include "ocfs.h"
#include "ocfs2.h"
@@ -62,7 +66,6 @@
#include "sysfile.h"
#include "util.h"
#include "ver.h"
-#include "volcfg.h"
#include "ocfs_journal.h"
#include "buffer_head_io.h"
@@ -83,7 +86,6 @@
__u32 debug_exclude = 0;
char *ip_address = NULL;
__u32 ip_port_v2 = 0;
-char *guid = NULL;
__u32 cs = 0;
char *ocfs_hostname;
@@ -133,7 +135,6 @@
module_param (debug_exclude, uint, 0);
module_param (ip_address, charp, 0);
module_param (ip_port_v2, uint, 0);
-module_param (guid, charp, 0);
module_param (cs, uint, 0);
#else /* 2.6.x kernel */
MODULE_PARM (node_name, "s");
@@ -150,8 +151,6 @@
MODULE_PARM_DESC(ip_address, "IP address for the network dlm on this node");
MODULE_PARM (ip_port_v2, "i");
MODULE_PARM_DESC(ip_port_v2, "Port number for the network dlm on this node");
-MODULE_PARM (guid, "s");
-MODULE_PARM_DESC(guid, "GUID for this machine");
MODULE_PARM (cs, "i");
MODULE_PARM_DESC(cs, "Checksum");
#endif /* Linux 2.4 stuff */
@@ -390,7 +389,7 @@
printk ("ocfs2: Mounting device (%u,%u) on %s (node %d)\n",
MAJOR(sb->s_dev), MINOR(sb->s_dev),
- osb->node_cfg_info[osb->node_num]->node_name, osb->node_num);
+ OcfsGlobalCtxt.node_name, osb->node_num);
atomic_set(&osb->vol_state, VOLUME_MOUNTED);
LOG_EXIT_STATUS(status);
@@ -595,8 +594,6 @@
static int ocfs_read_params(void)
{
int status = 0;
- __u32 check_sum = 0;
- int i;
/* Read remaining insmod params */
if (node_number != OCFS_INVALID_NODE_NUM) {
@@ -605,19 +602,6 @@
LOG_TRACE_ARGS("Preferred node number: %d\n", node_number);
}
- if (ip_port_v2 == 0)
- OcfsGlobalCtxt.comm_info.ip_port =
- htons(OCFS_IPC_DEFAULT_PORT);
- else if (ip_port_v2 & 0xFFFF0000) {
- status = -EINVAL;
- LOG_ERROR_STR("'ip_port_v2' is too large'");
- }
- else
- OcfsGlobalCtxt.comm_info.ip_port =
- htons((u16)ip_port_v2);
- LOG_TRACE_ARGS("IP port: %d\n",
- ntohs(OcfsGlobalCtxt.comm_info.ip_port));
-
if (node_name && strlen(node_name) < MAX_NODE_NAME_LENGTH) {
OcfsGlobalCtxt.node_name = node_name;
LOG_TRACE_ARGS ("Node name: %s\n", OcfsGlobalCtxt.node_name);
@@ -626,36 +610,6 @@
LOG_ERROR_STR ("'node_name' not set or too long");
}
-#define MAX_IPv4_ADDR_STR_LEN 15 /* 4x '255' + 3x '.' */
- if (ip_address && strlen (ip_address) <= MAX_IPv4_ADDR_STR_LEN) {
- OcfsGlobalCtxt.comm_info.addr_u.ip_addr4 =
- in_aton(ip_address);
- LOG_TRACE_ARGS ("IP address: %s\n", ip_address);
- } else {
- status = -EINVAL;
- LOG_ERROR_STR ("'ip_address' not set or too long");
- }
-
- if (guid && strlen (guid) == OCFS2_GUID_LEN) {
- memcpy(&OcfsGlobalCtxt.guid.guid, guid, OCFS2_GUID_LEN);
- LOG_TRACE_ARGS ("Node guid: %s\n", guid);
- } else {
- status = -EINVAL;
- LOG_ERROR_STR ("'guid' not set correctly");
- }
-
- if (status == 0) {
- for (i = 0; i < OCFS2_GUID_LEN; ++i)
- check_sum += (__u32) guid[i];
- if (cs != check_sum) {
- status = -EINVAL;
- LOG_ERROR_STR ("load module using load_ocfs2");
- }
- }
-
- /* hardcoding... not used yet */
- OcfsGlobalCtxt.comm_info.ip_version = htons(4);
-
return status;
} /* ocfs_read_params */
@@ -1033,7 +987,6 @@
static void ocfs_dismount_volume (struct super_block *sb)
{
ocfs_super *osb = NULL;
- int i;
LOG_ENTRY_ARGS ("(0x%p)\n", sb);
@@ -1072,17 +1025,8 @@
printk ("ocfs2: Unmounting device (%u,%u) on %s (node %d)\n",
MAJOR(osb->sb->s_dev), MINOR(osb->sb->s_dev),
- osb->node_cfg_info[osb->node_num]->node_name, osb->node_num);
+ OcfsGlobalCtxt.node_name, osb->node_num);
- /* Free all nodecfgs */
- for (i = 0; i < osb->max_nodes; ++i) {
- BARF_BARF_BARF *p;
-
- p = osb->node_cfg_info[i];
- if (p)
- kfree(p);
- }
-
ocfs_release_system_inodes(osb);
ocfs_delete_osb (osb);
@@ -1109,13 +1053,13 @@
if (!osb->vol_label) {
LOG_ERROR_STR("unable to alloc vol label");
status = -ENOMEM;
- goto finally;
+ goto bail;
}
osb->uuid = kmalloc(MAX_VOL_ID_LENGTH, GFP_KERNEL);
if (!osb->uuid) {
LOG_ERROR_STR("unable to alloc uuid");
status = -ENOMEM;
- goto finally;
+ goto bail;
}
/* this needs to be done before most other initializations */
@@ -1125,7 +1069,7 @@
LOG_ERROR_ARGS("Invalid number of nodes (%u)\n",
osb->max_nodes);
status = -EINVAL;
- goto finally;
+ goto bail;
}
printk("max_nodes for this device: %u\n", osb->max_nodes);
@@ -1139,14 +1083,14 @@
if ((i = OCFS2_HAS_INCOMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_INCOMPAT_SUPP))) {
LOG_ERROR_ARGS("couldn't mount because of unsupported "
"optional features (%x).\n", i);
- goto finally;
+ goto bail;
}
if (!(osb->sb->s_flags & MS_RDONLY) &&
(i = OCFS2_HAS_RO_COMPAT_FEATURE(osb->sb, ~OCFS2_FEATURE_RO_COMPAT_SUPP))) {
LOG_ERROR_ARGS("couldn't mount RDWR because of "
"unsupported optional features (%x).\n",
i);
- goto finally;
+ goto bail;
}
init_waitqueue_head(&osb->recovery_event);
@@ -1172,16 +1116,9 @@
if (!osb->journal) {
LOG_ERROR_STR("unable to alloc journal");
status = -ENOMEM;
- goto finally;
- }
- memset(osb->journal, 0, sizeof(ocfs_journal));
-
- osb->node_cfg_info = kmalloc(sizeof(BARF_BARF_BARF *) * osb->max_nodes, GFP_KERNEL);
- if (!osb->node_cfg_info) {
- LOG_ERROR_STATUS(status = -ENOMEM);
goto bail;
}
- memset(osb->node_cfg_info, 0, sizeof(BARF_BARF_BARF *) * osb->max_nodes);
+ memset(osb->journal, 0, sizeof(ocfs_journal));
ocfs2_init_node_maps(osb);
@@ -1194,19 +1131,12 @@
init_MUTEX (&(osb->recovery_lock));
init_MUTEX (&(osb->orphan_recovery_lock));
- init_MUTEX (&(osb->cfg_lock));
-
osb->needs_flush = 0;
osb->disable_recovery = 0;
- atomic_set (&osb->node_req_vote, 0);
-
atomic_set (&osb->num_recovery_threads, 0);
- init_waitqueue_head (&osb->nm_init_event);
- atomic_set (&osb->nm_init, 0);
-
init_waitqueue_head (&osb->flush_event);
atomic_set (&osb->flush_event_woken, 0);
atomic_set (&osb->clean_buffer_seq, 1);
@@ -1298,29 +1228,7 @@
goto bail;
}
- osb->autoconfig_blkno = p_blkno;
- osb->autoconfig_blocks = OCFS_VOLCFG_HDR_SECTORS + osb->max_nodes;
-
- osb->new_autoconfig_blkno = osb->autoconfig_blkno + osb->autoconfig_blocks;
- osb->new_autoconfig_blocks = OCFS_VOLCFG_NEWCFG_SECTORS;
- osb->total_autoconfig_blocks = OCFS_VOLCFG_NEWCFG_SECTORS + osb->max_nodes;
-
- printk("autoconfig: blkno=%llu, blocks=%u newblkno=%llu newblocks=%u\n",
- osb->autoconfig_blkno, osb->autoconfig_blocks,
- osb->new_autoconfig_blkno, osb->new_autoconfig_blocks);
-
- osb->autoconfig_bhs = ocfs_malloc (osb->total_autoconfig_blocks
- * sizeof(struct buffer_head *));
- if (!osb->autoconfig_bhs) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto bail;
- }
- memset(osb->autoconfig_bhs, 0,
- osb->total_autoconfig_blocks * sizeof(struct buffer_head *));
-
iput(inode);
-
-
/*
* global bitmap
@@ -1363,16 +1271,6 @@
}
iput(inode);
-
- osb->prealloc_lock = 0;
-
-
- status = ocfs_get_config (osb);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
/* load all node-local system inodes */
status = ocfs_init_local_system_inodes(osb);
if (status < 0) {
@@ -1404,16 +1302,7 @@
}
spin_unlock (&osb_id_lock);
-
- /* skip the frees which happen on error only */
- goto finally;
-
bail:
- if (osb->autoconfig_bhs)
- kfree(osb->autoconfig_bhs);
- if (osb->node_cfg_info)
- kfree(osb->node_cfg_info);
-finally:
LOG_EXIT_STATUS (status);
return status;
} /* ocfs_initialize_osb */
@@ -1567,7 +1456,6 @@
*/
static void ocfs_delete_osb (ocfs_super * osb)
{
- int i;
LOG_ENTRY ();
/* This function assumes that the caller has the main osb resource */
@@ -1579,15 +1467,6 @@
list_del (&(osb->osb_next));
up (&(OcfsGlobalCtxt.global_res));
- for(i = 0; i < osb->total_autoconfig_blocks; i++)
- if (osb->autoconfig_bhs[i])
- brelse(osb->autoconfig_bhs[i]);
-
- if (osb->autoconfig_bhs)
- kfree(osb->autoconfig_bhs);
- if (osb->node_cfg_info)
- kfree(osb->node_cfg_info);
-
/* FIXME
* This belongs in journal shutdown, but because we have to
* allocate osb->journal at the start of ocfs_initalize_osb(),
Deleted: branches/dlm-glue/src/volcfg.c
===================================================================
--- branches/dlm-glue/src/volcfg.c 2004-10-28 20:36:58 UTC (rev 1598)
+++ branches/dlm-glue/src/volcfg.c 2004-10-28 21:28:18 UTC (rev 1599)
@@ -1,970 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * volcfg.c
- *
- * Auto configuration, namely, node number.
- *
- * Copyright (C) 2002, 2004 Oracle. All rights reserved.
- *
- * 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 021110-1307, USA.
- */
-
-#include "ocfs_compat.h"
-
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-
-#include "ocfs_log.h"
-#include "ocfs.h"
-
-#include "util.h"
-#include "volcfg.h"
-
-#include "buffer_head_io.h"
-
-/* Tracing */
-#define OCFS_DEBUG_CONTEXT OCFS_DEBUG_CONTEXT_VOLCFG
-
-static void ocfs_worker (void *arg);
-static void ocfs_assert_lock_owned (unsigned long arg);
-static int ocfs_add_to_disk_config (ocfs_super * osb, __s16 pref_node_num, ocfs_node_config_info * new_disk_node);
-static int ocfs_write_volcfg_header (ocfs_super * osb, ocfs_volcfg_op op);
-static int ocfs_update_disk_config (ocfs_super * osb, __u32 node_num, ocfs_node_config_info * disk);
-static int ocfs_release_disk_lock (ocfs_super * osb, __u64 lock_off);
-static int ocfs_add_node_to_config (ocfs_super * osb);
-static int ocfs_has_node_config_changed (ocfs_super * osb);
-static int ocfs_refresh_node_config (ocfs_super * osb);
-static void ocfs_show_all_node_cfgs (ocfs_super * osb);
-static int ocfs_disknode_to_node (BARF_BARF_BARF ** node, ocfs_node_config_info * disk);
-static void ocfs_volcfg_gblctxt_to_node(BARF_BARF_BARF *node);
-static void ocfs_volcfg_gblctxt_to_disknode(ocfs_node_config_info *disk);
-
-/*
- * ocfs_worker()
- *
- * This function reiterates the lock on the disk from this node once
- * it has obtained it.
- */
-static void ocfs_worker (void *arg)
-{
- __u32 length;
- int status;
- ocfs_super *osb;
- __u64 offset;
- ocfs_cfg_task *cfg_task;
- struct buffer_head *bh;
-
- LOG_ENTRY ();
-
- cfg_task = arg;
-
- /* Obtain the volume for which we need to reiterate the lock */
- osb = cfg_task->osb;
- bh = cfg_task->bh;
- length = osb->sb->s_blocksize;
- offset = cfg_task->lock_off;
-
- /* Write the sector back */
- status = ocfs_write_block(osb, bh, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- /* deliberate no exit jump here */
- }
-
- if (atomic_read (&osb->lock_stop)) {
- LOG_TRACE_ARGS ("Last Lock written : %lu\n", jiffies);
- atomic_set (&osb->lock_event_woken, 1);
- brelse(bh);
- wake_up (&osb->lock_event);
- } else {
- LOG_TRACE_ARGS ("Lock written : %lu\n", jiffies);
- mod_timer (&osb->lock_timer, jiffies + OCFS_VOLCFG_LOCK_ITERATE);
- }
-
- LOG_EXIT ();
- return;
-} /* ocfs_worker */
-
-/*
- * ocfs_assert_lock_owned()
- *
- * Routine called by a timer to reiterate the disk lock.
- */
-static void ocfs_assert_lock_owned (unsigned long arg)
-{
- ocfs_cfg_task *cfg_task;
-
- LOG_ENTRY ();
-
- cfg_task = (ocfs_cfg_task *) arg;
-
- /* initialize the task and submit it */
- INIT_WORK(&cfg_task->cfg_wq, ocfs_worker, cfg_task);
- schedule_work(&cfg_task->cfg_wq);
-
- LOG_EXIT ();
- return ;
-} /* ocfs_assert_lock_owned */
-
-/*
- * ocfs_add_to_disk_config()
- *
- */
-static int ocfs_add_to_disk_config (ocfs_super * osb, __s16 pref_node_num, ocfs_node_config_info * new_disk_node)
-{
- int status = 0;
- int i;
- ocfs_node_config_info *disk_node = NULL;
- __s16 node_num;
- struct buffer_head **cfg_bhs = NULL;
-
- LOG_ENTRY ();
-
- cfg_bhs = kmalloc(sizeof(struct buffer_head *) * osb->max_nodes, GFP_KERNEL);
- if (cfg_bhs == NULL) {
- LOG_ERROR_STATUS(status = -ENOMEM);
- goto finally;
- }
- memset(cfg_bhs, 0, osb->max_nodes * sizeof(struct buffer_head *));
-
- /* Read the nodecfg info for all nodes from disk */
- status = ocfs_read_blocks(osb,
- (osb->autoconfig_blkno + OCFS_VOLCFG_HDR_SECTORS),
- (osb->autoconfig_blocks - OCFS_VOLCFG_HDR_SECTORS),
- cfg_bhs, 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
- /* Check if preferred node num is available */
- node_num = OCFS_INVALID_NODE_NUM;
- if (pref_node_num < osb->max_nodes) {
- disk_node = (ocfs_node_config_info *) cfg_bhs[pref_node_num]->b_data;
- if (disk_node->node_name[0] == '\0')
- node_num = pref_node_num;
- }
-
- /* if not, find the first available empty slot */
- if (node_num == OCFS_INVALID_NODE_NUM) {
- for (node_num = 0; node_num < osb->max_nodes; node_num++) {
- disk_node = (ocfs_node_config_info *) cfg_bhs[node_num]->b_data;
- if (disk_node->node_name[0] == '\0')
- break;
- }
- }
-
- /* If no free slots, error out */
- if (node_num >= osb->max_nodes) {
- LOG_ERROR_STR ("Unable to allocate node number as no slots " \
- "are available");
- status = -ENOSPC;
- goto finally;
- }
-
- /* Copy the new nodecfg into the memory buffer */
- memcpy (cfg_bhs[node_num]->b_data, new_disk_node, osb->sb->s_blocksize);
-
- /* Write the new node details on disk */
- status = ocfs_write_block(osb, cfg_bhs[node_num], NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
- /* Update the nodecfg hdr on disk */
- status = ocfs_write_volcfg_header (osb, OCFS_VOLCFG_ADD);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
-finally:
- for (i = 0; i < osb->max_nodes; i++)
- if (cfg_bhs[i])
- brelse(cfg_bhs[i]);
- if (cfg_bhs)
- kfree(cfg_bhs);
-
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_add_to_disk_config */
-
-/*
- * ocfs_write_volcfg_header()
- *
- */
-static int ocfs_write_volcfg_header (ocfs_super * osb, ocfs_volcfg_op op)
-{
- int status = 0;
- ocfs_node_config_hdr *hdr, *hdr_copy;
- struct buffer_head *node_cfg_bhs[2];
-
- LOG_ENTRY ();
-
- node_cfg_bhs[0] = node_cfg_bhs[1] = NULL;
- /* Read the nodecfg header */
- status = ocfs_read_block(osb, osb->autoconfig_blkno, &node_cfg_bhs[0],
- 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
-
- status = ocfs_read_block(osb, (osb->new_autoconfig_blkno + 1),
- &node_cfg_bhs[1], 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
-
- hdr = (ocfs_node_config_hdr *) node_cfg_bhs[0]->b_data;
- hdr_copy = (ocfs_node_config_hdr *) node_cfg_bhs[1]->b_data;
-
- if (op == OCFS_VOLCFG_ADD)
- hdr->num_nodes++;
-
- /* Increment the seq# to trigger other nodes to re-read node cfg */
- hdr->cfg_seq_num++;
-
- memcpy(hdr_copy, hdr, osb->sb->s_blocksize);
- /* Write the nodecfg header */
- /* Write the nodecfg hdr into the second sector of newcfg also. */
- /* We do so so that we can read the nodecfg hdr easily when we */
- /* read the publish sector, for e.g. in ocfs_nm_thread() */
- status = ocfs_write_blocks(osb, node_cfg_bhs, 2, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
- brelse(node_cfg_bhs[0]);
- brelse(node_cfg_bhs[1]);
- node_cfg_bhs[0] = node_cfg_bhs[1] = NULL;
-
-bail:
- if (node_cfg_bhs[0])
- brelse(node_cfg_bhs[0]);
- if (node_cfg_bhs[1])
- brelse(node_cfg_bhs[1]);
-
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_write_volcfg_header */
-
-/*
- * ocfs_config_with_disk_lock()
- *
- * This function tries to obtain the lock on the disk for the volume
- * specified. The logic for obtaining a disk lock is as follows :
- *
- * Read the volcfg lock sector. If it is not locked, lock it by stamping
- * ones node number. Read the same sector after OCFS_VOLCFG_LOCK_TIME.
- * If the contents have not been modified, the lock is ours. Retain the
- * lock by reiterating the lock write operation every OCFS_VOLCFG_ITERATE_TIME.
- *
- * If the volcfg lock sector is owned by someone else, wait for
- * OCFS_VOLCFG_LOCK_TIME and read the lock sector again. If the lock sector
- * is owned by the same node as before attempt to break the lock as the
- * node may have died. If however, the lock sector is now owned by someone
- * else, wait for OCFS_VOLCFG_LOCK_TIME before repeating the entire exercise
- * again.
- *
- * Returns 0 if success, < 0 if error.
- */
-static int ocfs_config_with_disk_lock (ocfs_super * osb, __u64 lock_off, __u8 * cfg_buf, __s16 node_num, ocfs_volcfg_op op)
-{
- int status = 0;
- char *lock_buf;
- int tried_acq = 0;
- int break_lock = 0;
- ocfs2_disk_lock *disk_lock;
- ocfs_cfg_task *cfg_task;
- __s16 lock_node_num = OCFS_INVALID_NODE_NUM;
- struct buffer_head *bh = NULL;
- int i;
-
- LOG_ENTRY ();
-
- cfg_task = ocfs_malloc (sizeof (ocfs_cfg_task));
- if (cfg_task == NULL)
- {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto finito;
- }
-
- /* initialize cfg_task with info reqd to reiterate the volcfg lock */
- cfg_task->osb = osb;
- cfg_task->lock_off = lock_off;
-
- /* Initialize the kernel timer */
- init_timer(&osb->lock_timer);
- osb->lock_timer.function = ocfs_assert_lock_owned;
- osb->lock_timer.expires = 0;
- osb->lock_timer.data = (unsigned long) cfg_task;
-
- init_waitqueue_head (&osb->lock_event);
- atomic_set (&osb->lock_event_woken, 0);
- atomic_set (&osb->lock_stop, 0);
-
- status = ocfs_read_block(osb, lock_off >> osb->sb->s_blocksize_bits,
- &bh, 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finito;
- }
- cfg_task->bh = bh;
-
- for (i = 0; i < 50; i++) {
- /* Read the volcfg lock sector */
- status = ocfs_read_block(osb,
- lock_off >> osb->sb->s_blocksize_bits,
- &bh, 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finito;
- }
-
- disk_lock = (ocfs2_disk_lock *) bh->b_data;
- lock_node_num = disk_lock->dl_master;
-
- if (disk_lock->dl_level == 0 || break_lock) {
- if (disk_lock->dl_level != 0)
- LOG_TRACE_STR ("Try to break node config lock");
- else
- LOG_TRACE_STR ("Lock node config");
-
- /* Attempt to lock volcfg */
- memcpy(disk_lock, cfg_buf, osb->sb->s_blocksize);
-
- disk_lock->dl_master = osb->node_num;
- disk_lock->dl_level = 1;
- memcpy(cfg_buf, disk_lock, osb->sb->s_blocksize);
-
- /* Write into volcfg lock sector... */
- status = ocfs_write_block(osb, bh, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finito;
- }
- tried_acq = 1;
- }
-
- ocfs_sleep (OCFS_VOLCFG_LOCK_TIME);
-
- /* Read the volcfg lock sector again... */
- status = ocfs_read_block(osb,
- lock_off >> osb->sb->s_blocksize_bits,
- &bh, 0, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finito;
- }
-
- lock_buf = bh->b_data;
-
- /* If we tried to acquire and we still own it we take it... */
- if ((tried_acq) && (memcmp (lock_buf, cfg_buf, osb->sb->s_blocksize) == 0)) {
- memcpy (lock_buf, cfg_buf, osb->sb->s_blocksize);
-
- /* Set timer to reiterate lock every few jiffies */
- LOG_TRACE_ARGS ("Start Timer: %lu\n", jiffies);
- osb->lock_timer.expires = jiffies +
- OCFS_VOLCFG_LOCK_ITERATE;
- /* we get_bh here because we brelse later in
- * this function, and so does the timer routine. */
- get_bh(bh);
- add_timer(&osb->lock_timer);
-
- /* Write the config info into the disk */
- disk_lock = (ocfs2_disk_lock *)cfg_buf;
- disk_lock->dl_master = OCFS_INVALID_NODE_NUM;
- disk_lock->dl_level = 0;
-
- if (op == OCFS_VOLCFG_ADD)
- status = ocfs_add_to_disk_config (osb, node_num,
- (ocfs_node_config_info *) cfg_buf);
- else if (op == OCFS_VOLCFG_UPD)
- status = ocfs_update_disk_config(osb, node_num,
- (ocfs_node_config_info *) cfg_buf);
- else
- status = -EINVAL;
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finito;
- }
- break;
- } else {
- disk_lock = (ocfs2_disk_lock *)lock_buf;
- if (disk_lock->dl_master == lock_node_num)
- break_lock = 1;
- else {
- LOG_TRACE_ARGS ("Node config locked by node: %d\n",
- disk_lock->dl_master);
- ocfs_sleep (OCFS_VOLCFG_LOCK_TIME);
- }
- }
-
- }
- if (i >= 50)
- status = -EINVAL;
-
-finito:
- ocfs_release_disk_lock (osb, lock_off);
-
- if (cfg_task)
- kfree(cfg_task);
- if (bh)
- brelse(bh);
-
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_config_with_disk_lock */
-
-/*
- * ocfs_release_disk_lock()
- *
- * This function Cancels the timer to reiterate we own the disk lock and
- * then frees it by writing the sector for the disk lock.
- *
- * Returns 0 if success, < 0 if error.
- */
-static int ocfs_release_disk_lock (ocfs_super * osb, __u64 lock_off)
-{
- int status = 0;
- struct buffer_head *bh;
- struct super_block *sb;
- __u64 blocknum;
-
- LOG_ENTRY ();
-
- sb = osb->sb;
-
- blocknum = lock_off >> sb->s_blocksize_bits;
- bh = sb_getblk(sb, blocknum);
- if (bh == NULL) {
- LOG_ERROR_STATUS (status = -EIO);
- goto finally;
- }
-
- /* reset lock... */
- memset (bh->b_data, 0, osb->sb->s_blocksize);
-
- /* Release the lock */
- status = ocfs_write_block(osb, bh, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
- /* Cancel the timer so that we don't reiterate the lock anymore */
- LOG_TRACE_STR ("Waiting for osb->lock_event");
- atomic_set (&osb->lock_stop, 1);
- ocfs_wait (osb->lock_event, atomic_read (&osb->lock_event_woken), 0);
- atomic_set (&osb->lock_event_woken, 0);
- del_timer_sync(&osb->lock_timer);
-
- /* reset lock... */
- memset (bh->b_data, 0, osb->sb->s_blocksize);
-
- /* Release the lock */
- status = ocfs_write_block(osb, bh, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
-finally:
- if (bh)
- brelse(bh);
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_release_disk_lock */
-
-/*
- * ocfs_add_node_to_config()
- *
- */
-static int ocfs_add_node_to_config (ocfs_super * osb)
-{
- int status;
- ocfs_node_config_info *disk;
- void *buffer;
- __u64 offset;
-
- LOG_ENTRY ();
-
- buffer = ocfs_malloc (osb->sb->s_blocksize);
- if (buffer == NULL) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto bail;
- }
- memset (buffer, 0, osb->sb->s_blocksize);
-
- disk = buffer;
-
- /* populate the disknodecfg info from global context */
- ocfs_volcfg_gblctxt_to_disknode (disk);
-
- /* Write this nodes config onto disk */
- offset = (osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits);
- status = ocfs_config_with_disk_lock (osb, offset, (__u8 *) disk,
- OcfsGlobalCtxt.pref_node_num,
- OCFS_VOLCFG_ADD);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
-
- status = ocfs_chk_update_config (osb);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
-
-bail:
- if (buffer)
- kfree(buffer);
-
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_add_node_to_config */
-
-/*
- * ocfs_disknode_to_node()
- *
- */
-static int ocfs_disknode_to_node (BARF_BARF_BARF ** node, ocfs_node_config_info * disk)
-{
- int status = 0;
-
- LOG_ENTRY ();
-
- if (*node == NULL) {
- if ((*node = (BARF_BARF_BARF *)
- ocfs_malloc (sizeof (BARF_BARF_BARF))) == NULL) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto bail;
- }
- memset (*node, 0, sizeof (BARF_BARF_BARF));
- }
-
- strncpy ((*node)->node_name, disk->node_name, MAX_NODE_NAME_LENGTH);
-
- memcpy((*node)->guid.guid, disk->guid.guid, OCFS2_GUID_LEN);
-
- (*node)->ipc_config.ip_port = disk->ipc_config.ip_port;
- (*node)->ipc_config.addr_u.ip_addr4 =
- disk->ipc_config.addr_u.ip_addr4;
- (*node)->ipc_config.ip_version = disk->ipc_config.ip_version;
-
-bail:
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_disknode_to_node */
-
-/*
- * ocfs_update_disk_config()
- *
- */
-static int ocfs_update_disk_config (ocfs_super * osb, __u32 node_num, ocfs_node_config_info * disk)
-{
- int status = 0;
- __u32 blocknum;
- struct buffer_head *bh = NULL;
- struct super_block *sb = NULL;
-
- LOG_ENTRY ();
-
- sb = osb->sb;
- /* Write the node details */
- blocknum = osb->autoconfig_blkno + OCFS_VOLCFG_HDR_SECTORS + node_num;
-
- bh = sb_getblk(sb, blocknum);
- if (bh == NULL) {
- status = -EIO;
- LOG_ERROR_STATUS(status);
- goto finally;
- }
-
- memcpy(bh->b_data, disk, osb->sb->s_blocksize);
-
- status = ocfs_write_block(osb, bh, NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
- status = ocfs_write_volcfg_header (osb, OCFS_VOLCFG_UPD);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
-finally:
- if (bh)
- brelse(bh);
-
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_update_disk_config */
-
-/*
- * ocfs_volcfg_gblctxt_to_disknode()
- *
- */
-static void ocfs_volcfg_gblctxt_to_disknode(ocfs_node_config_info *disk)
-{
- ocfs_ipc_config_info *ipc;
- ocfs_comm_info *g_ipc;
-
- LOG_ENTRY ();
-
- ipc = &(disk->ipc_config);
- g_ipc = &(OcfsGlobalCtxt.comm_info);
-
- if (OcfsGlobalCtxt.node_name)
- strncpy (disk->node_name, OcfsGlobalCtxt.node_name,
- MAX_NODE_NAME_LENGTH);
-
- memcpy(disk->guid.guid, OcfsGlobalCtxt.guid.guid,
- OCFS2_GUID_LEN);
-
- ipc->ip_port = g_ipc->ip_port;
- ipc->ip_version = g_ipc->ip_version;
- ipc->addr_u.ip_addr4 = g_ipc->addr_u.ip_addr4;
-
- LOG_EXIT ();
- return ;
-} /* ocfs_volcfg_gblctxt_to_disknode */
-
-/*
- * ocfs_volcfg_gblctxt_to_node()
- *
- */
-static void ocfs_volcfg_gblctxt_to_node(BARF_BARF_BARF *node)
-{
- ocfs_ipc_config_info *ipc;
- ocfs_comm_info *g_ipc;
-
- LOG_ENTRY ();
-
- ipc = &(node->ipc_config);
- g_ipc = &(OcfsGlobalCtxt.comm_info);
-
- if (OcfsGlobalCtxt.node_name)
- strncpy (node->node_name, OcfsGlobalCtxt.node_name,
- MAX_NODE_NAME_LENGTH);
-
- memcpy(node->guid.guid, OcfsGlobalCtxt.guid.guid,
- OCFS2_GUID_LEN);
-
- ipc->ip_port = g_ipc->ip_port;
- ipc->ip_version = g_ipc->ip_version;
- ipc->addr_u.ip_addr4 = g_ipc->addr_u.ip_addr4;
-
- LOG_EXIT ();
- return ;
-} /* ocfs_volcfg_gblctxt_to_node */
-
-/*
- * ocfs_chk_update_config()
- *
- */
-int ocfs_chk_update_config (ocfs_super * osb)
-{
- int status = 0;
- ocfs_node_config_hdr *hdr = NULL;
- ocfs_node_config_info *disk = NULL;
- __s32 i;
- struct buffer_head **cfg_bhs = NULL;
-
- LOG_ENTRY ();
-
- /* Read in the config on the disk */
- cfg_bhs = ocfs_malloc(osb->autoconfig_blocks *
- sizeof(*cfg_bhs));
- if (cfg_bhs == NULL) {
- status = -ENOMEM;
- LOG_ERROR_STATUS(status);
- goto finally;
- }
- memset(cfg_bhs, 0, osb->autoconfig_blocks * sizeof(*cfg_bhs));
-
- status = ocfs_read_blocks(osb, osb->autoconfig_blkno,
- (osb->autoconfig_blocks), cfg_bhs, 0,
- NULL);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
- /* 1st block in buffer is the NodeCfgHdr */
- hdr = (ocfs_node_config_hdr *) cfg_bhs[0]->b_data;
-
- if (strncmp (hdr->signature, OCFS2_NODE_CONFIG_HDR_SIGN,
- OCFS2_NODE_CONFIG_SIGN_LEN)) {
- LOG_ERROR_STR ("Invalid node config signature");
- status = -EINVAL;
- goto finally;
- }
-
- if (hdr->version < OCFS2_NODE_MIN_SUPPORTED_VER ||
- hdr->version > OCFS2_NODE_CONFIG_VER) {
- LOG_ERROR_ARGS ("Node config version mismatch, (%d) < minimum" \
- " (%d) or > current (%d)", hdr->version,
- OCFS2_NODE_MIN_SUPPORTED_VER, OCFS2_NODE_CONFIG_VER);
- status = -EINVAL;
- goto finally;
- }
-
- /* Exit if nodecfg on disk has remained unchanged... */
- if ((osb->cfg_initialized) && (osb->cfg_seq_num == hdr->cfg_seq_num) &&
- (osb->num_cfg_nodes == hdr->num_nodes))
- goto finally;
-
- /* ... else refresh nodecfg in memory */
-
- /* Read the nodecfg for all possible nodes as there may be holes */
- /* i.e., node numbers need not be dolled out in sequence */
- for (i = 0; i < osb->max_nodes; i++) {
- int which;
- which = i + OCFS_VOLCFG_HDR_SECTORS;
- disk = (ocfs_node_config_info *) cfg_bhs[which]->b_data;
-
- if (disk->node_name[0] == '\0')
- continue;
-
- status = ocfs_disknode_to_node (&osb->node_cfg_info[i], disk);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto finally;
- }
-
- /* If nodenum is set, goto next node */
- if (osb->node_num != OCFS_INVALID_NODE_NUM)
- continue;
-
- /*
- * If node num is not set, set it if guid matches.
- * If guid does not match and the hostid also does not
- * match, goto next slot.
- * However if the guid does not natch but the hostid
- * matches, it means that the user re-ran ocfs_uid_gen
- * with the -r option to reclaim its node number. In
- * this case, allow the reclaim only if the user mounts
- * the volume with the reclaimid option. Else, error.
- */
- if (!memcmp(&OcfsGlobalCtxt.guid.guid, disk->guid.guid,
- OCFS2_GUID_LEN)) {
- osb->node_num = i;
- continue;
- }
-
- /* If the hostid does not match, goto next... */
- if (memcmp(&OcfsGlobalCtxt.guid.id.host_id,
- disk->guid.id.host_id,
- OCFS2_GUID_HOSTID_LEN))
- continue;
-
- /* ...else allow node to reclaim the number if reclaimid set */
- if (osb->reclaim_id) {
- osb->node_num = i;
- /* Write this node's cfg with the new guid on disk */
- status = ocfs_refresh_node_config (osb);
- if (status < 0) {
- LOG_ERROR_STATUS(status);
- goto finally;
- }
- }
- else {
- LOG_ERROR_STR("Re-mount volume with the reclaimid " \
- "option to reclaim the node number");
- status = -EBUSY;
- goto finally;
- }
- }
-
- osb->cfg_initialized = 1;
- osb->cfg_seq_num = hdr->cfg_seq_num;
- osb->num_cfg_nodes = hdr->num_nodes;
- LOG_TRACE_ARGS ("Num of configured nodes (%u)\n", osb->num_cfg_nodes);
- IF_TRACE(ocfs_show_all_node_cfgs (osb));
-
-finally:
- if (cfg_bhs) {
- for (i = 0; i < osb->autoconfig_blocks; i++)
- if (cfg_bhs[i])
- brelse(cfg_bhs[i]);
- kfree(cfg_bhs);
- }
-
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_chk_update_config */
-
-/*
- * ocfs_get_config()
- *
- */
-int ocfs_get_config (ocfs_super * osb)
-{
- int status = 0;
-
- LOG_ENTRY ();
-
- /* Update our config info for this volume from the disk */
- status = ocfs_chk_update_config (osb);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
-
- if (osb->node_num == OCFS_INVALID_NODE_NUM) {
- if (osb->reclaim_id) {
- LOG_ERROR_STR ("unable to reclaim id");
- status = -EINVAL;
- goto bail;
- }
- status = ocfs_add_node_to_config (osb);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
- } else {
- if (ocfs_has_node_config_changed (osb)) {
- status = ocfs_refresh_node_config (osb);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
- }
- }
-
- LOG_TRACE_ARGS ("Node Num: %d\n", osb->node_num);
-
-bail:
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_get_config */
-
-/*
- * ocfs_has_node_config_changed()
- *
- */
-static int ocfs_has_node_config_changed (ocfs_super * osb)
-{
- BARF_BARF_BARF *node;
- ocfs_ipc_config_info *ipc;
- ocfs_comm_info *g_ipc;
- int chg = 0;
-
- LOG_ENTRY ();
-
- node = osb->node_cfg_info[osb->node_num];
- ipc = &(node->ipc_config);
- g_ipc = &(OcfsGlobalCtxt.comm_info);
-
- if (OcfsGlobalCtxt.node_name &&
- strncmp (node->node_name, OcfsGlobalCtxt.node_name,
- MAX_NODE_NAME_LENGTH))
- chg = 1;
-
- if (!chg && (ipc->ip_version != g_ipc->ip_version))
- chg = 1;
-
- if (!chg && (ipc->ip_port != g_ipc->ip_port))
- chg = 1;
-
- if (!chg && (ipc->addr_u.ip_addr4 != g_ipc->addr_u.ip_addr4))
- chg = 1;
-
- LOG_EXIT_INT (chg);
- return chg;
-} /* ocfs_has_node_config_changed */
-
-/*
- * ocfs_refresh_node_config()
- *
- */
-static int ocfs_refresh_node_config (ocfs_super * osb)
-{
- BARF_BARF_BARF *node;
- ocfs_node_config_info *disk;
- __u64 offset;
- __u8 *buffer;
- int status;
-
- LOG_ENTRY ();
-
- buffer = ocfs_malloc (osb->sb->s_blocksize);
- if (buffer == NULL) {
- LOG_ERROR_STATUS (status = -ENOMEM);
- goto bail;
- }
-
- memset (buffer, 0, osb->sb->s_blocksize);
- disk = (ocfs_node_config_info *) buffer;
-
- /* populate the nodecfg info in disk from global context */
- ocfs_volcfg_gblctxt_to_disknode (disk);
-
- /* populate the nodecfg info in mem from global context */
- node = osb->node_cfg_info[osb->node_num];
- ocfs_volcfg_gblctxt_to_node (node);
-
- /* Update the nodecfg on disk with the new info */
- offset = (osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits);
- status = ocfs_config_with_disk_lock (osb, offset, (__u8 *) disk,
- osb->node_num, OCFS_VOLCFG_UPD);
- if (status < 0) {
- LOG_ERROR_STATUS (status);
- goto bail;
- }
-
-bail:
- if (buffer)
- kfree(buffer);
- LOG_EXIT_STATUS (status);
- return status;
-} /* ocfs_refresh_node_config */
-
-/*
- * ocfs_show_all_node_cfgs()
- *
- */
-static void ocfs_show_all_node_cfgs (ocfs_super * osb)
-{
- BARF_BARF_BARF *node;
- __u32 i;
-
- for (i = 0; i < osb->max_nodes; i++) {
- node = osb->node_cfg_info[i];
-
- if (!node || node->node_name[0] == '\0')
- continue;
-
- LOG_TRACE_ARGS ("Node (%u) is (%s)\n", i,
- node->node_name);
- LOG_TRACE_ARGS ("ip=0x%08u, port=%d\n",
- ntohl(node->ipc_config.addr_u.ip_addr4),
- ntohs(node->ipc_config.ip_port));
- }
-
- return;
-} /* ocfs_show_all_node_cfgs */
Deleted: branches/dlm-glue/src/volcfg.h
===================================================================
--- branches/dlm-glue/src/volcfg.h 2004-10-28 20:36:58 UTC (rev 1598)
+++ branches/dlm-glue/src/volcfg.h 2004-10-28 21:28:18 UTC (rev 1599)
@@ -1,32 +0,0 @@
-/* -*- mode: c; c-basic-offset: 8; -*-
- * vim: noexpandtab sw=8 ts=8 sts=0:
- *
- * volcfg.h
- *
- * Function prototypes
- *
- * Copyright (C) 2002, 2004 Oracle. All rights reserved.
- *
- * 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 021110-1307, USA.
- */
-
-#ifndef OCFS2_VOLCFG_H
-#define OCFS2_VOLCFG_H
-
-int ocfs_chk_update_config(ocfs_super *osb);
-int ocfs_get_config(ocfs_super *osb);
-
-#endif /* OCFS2_VOLCFG_H */
More information about the Ocfs2-commits
mailing list