[Ocfs2-tools-commits] jlbec commits r671 - trunk/mount.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Fri Mar 18 00:43:01 CST 2005
Author: jlbec
Signed-off-by: mfasheh
Date: 2005-03-18 00:43:00 -0600 (Fri, 18 Mar 2005)
New Revision: 671
Modified:
trunk/mount.ocfs2/mount.ocfs2.c
Log:
o Remove dead group code.
Signed-off-by: mfasheh
Modified: trunk/mount.ocfs2/mount.ocfs2.c
===================================================================
--- trunk/mount.ocfs2/mount.ocfs2.c 2005-03-18 06:06:10 UTC (rev 670)
+++ trunk/mount.ocfs2/mount.ocfs2.c 2005-03-18 06:43:00 UTC (rev 671)
@@ -29,8 +29,6 @@
static int nomtab = 0;
-static char op_buf[PAGE_SIZE];
-
struct mount_options {
char *dev;
char *dir;
@@ -185,196 +183,6 @@
my_free(mnt.mnt_dir);
}
-static int get_my_nodenum(uint8_t *nodenum)
-{
-#if 0
- FILE *file;
- int ret = -EINVAL;
- int retval=-EINVAL, num;
- nm_op *op = (nm_op *)op_buf;
-
- memset(op_buf, 0, PAGE_SIZE);
- op->magic = NM_OP_MAGIC;
- op->opcode = NM_OP_GET_GLOBAL_NODE_NUM;
-
- *nodenum = 255;
-
- file = fopen(CLUSTER_FILE, "r+");
- if (!file)
- return -errno;
- if (fwrite((char *)op, sizeof(nm_op), 1, file) != 1)
- goto done;
- if (fscanf(file, "%d: %d", &retval, &num) != 2 ||
- retval != 0 || num < 0 || num > 255) {
- ret = -EINVAL;
- goto done;
- }
- *nodenum = num;
- ret = 0;
-done:
- fclose(file);
- return ret;
-#else
- return 0;
-#endif
-}
-
-static int create_group(char *uuid, uint8_t *group_num)
-{
-#if 0
- FILE *file;
- int ret = -EINVAL, retval;
- int groupnum = NM_INVALID_SLOT_NUM;
- nm_op *op = (nm_op *)op_buf;
- struct stat st;
- char fname[100];
-
- if (strlen(uuid) != CLUSTER_DISK_UUID_LEN)
- return -EINVAL;
-
- sprintf(fname, "/proc/cluster/nm/%s", uuid);
- if (stat(fname, &st) == 0) {
- *group_num = st.st_ino - NM_GROUP_INODE_START;
- return -EEXIST;
- }
-
- *group_num = NM_INVALID_SLOT_NUM;
-
- memset(op_buf, 0, PAGE_SIZE);
- op->magic = NM_OP_MAGIC;
- op->opcode = NM_OP_CREATE_GROUP;
-
- op->arg_u.gc.group_num = NM_INVALID_SLOT_NUM;
- strcpy(op->arg_u.gc.name, uuid);
- strcpy(op->arg_u.gc.disk_uuid, uuid);
-
- file = fopen(CLUSTER_FILE, "r+");
- if (!file)
- return -errno;
-
- if (fwrite((char *)op, sizeof(nm_op), 1, file) != 1)
- goto done;
-
- if (fscanf(file, "%d: group %d", &retval, &groupnum) != 2) {
- ret = -EINVAL;
- goto done;
- }
- ret = retval;
- if ((ret == 0 || ret == -EEXIST) &&
- groupnum >= 0 && groupnum < NM_INVALID_SLOT_NUM)
- *group_num = groupnum;
-
-done:
- fclose(file);
- return ret;
-#else
- return 0;
-#endif
-}
-
-
-static int add_to_local_group(char *uuid, uint8_t group_num, uint8_t node_num)
-{
-#if 0
- FILE *file;
- int ret = -EINVAL, retval;
- nm_op *op = (nm_op *)op_buf;
- char fname[100];
- DIR *dir;
- struct dirent *de;
-
- if (strlen(uuid) != CLUSTER_DISK_UUID_LEN)
- return -EINVAL;
-
- sprintf(fname, "/proc/cluster/nm/%s", uuid);
- dir = opendir(fname);
- if (dir) {
- while ((de = readdir(dir)) != NULL) {
- if (de->d_ino - NM_NODE_INODE_START == node_num) {
- closedir(dir);
- return -EEXIST;
- }
- }
- closedir(dir);
- }
-
- memset(op_buf, 0, PAGE_SIZE);
- op->magic = NM_OP_MAGIC;
- op->opcode = NM_OP_ADD_GROUP_NODE;
- op->arg_u.gc.group_num = group_num;
- op->arg_u.gc.node_num = node_num;
- op->arg_u.gc.slot_num = node_num;
-
- file = fopen(GROUP_FILE, "r+");
- if (!file)
- return -errno;
-
- if (fwrite((char *)op, sizeof(nm_op), 1, file) != 1)
- goto done;
-
- if (fscanf(file, "%d: node", &retval) != 1) {
- ret = -EINVAL;
- goto done;
- }
- ret = retval;
-
-done:
- fclose(file);
- return ret;
-#else
- return 0;
-#endif
-}
-
-static int activate_group(char *group_name, char *group_dev, uint8_t group_num,
- uint32_t block_bits, uint64_t num_blocks, uint64_t start_block)
-{
-#if 0
- int dev_fd = -1;
- int ret = -EINVAL, retval;
- FILE *file;
- hb_op *op;
-
- if (verbose)
- printf("starting disk heartbeat...\n");
-
- memset(op_buf, 0, PAGE_SIZE);
- op = (hb_op *)op_buf;
- op->magic = HB_OP_MAGIC;
- op->opcode = HB_OP_START_DISK_HEARTBEAT;
- op->group_num = group_num;
- strcpy(op->disk_uuid, group_name);
- op->bits = block_bits;
- op->blocks = num_blocks;
- op->start = start_block;
-
- dev_fd = open(group_dev, O_RDWR);
- if (dev_fd == -1)
- return -errno;
- op->fd = dev_fd;
-
- file = fopen(HEARTBEAT_DISK_FILE, "r+");
- if (!file)
- return -errno;
-
- if (fwrite((char *)op, sizeof(hb_op), 1, file) != 1)
- goto done;
-
- if (fscanf(file, "%d: ", &retval) != 1) {
- ret = -EINVAL;
- goto done;
- }
- ret = 0;
-done:
- /* hb will keep its own ref */
- if (dev_fd != -1)
- close(dev_fd);
-
- fclose(file);
-#endif
- return 0;
-}
-
static int get_ocfs2_disk_hb_params(char *group_dev, uint32_t *block_bits, uint32_t *cluster_bits,
uint64_t *start_block, uint32_t *num_clusters)
{
@@ -435,247 +243,6 @@
return status;
}
-static int get_node_map(uint8_t group_num, char *bitmap)
-{
-#if 0
- FILE *file = NULL;
- hb_op *op;
- int ret = -EINVAL;
- int retval;
- uint8_t bytemap[NM_MAX_NODES];
- int i;
-
- if (verbose)
- printf("getting node map...\n");
-
- memset(op_buf, 0, PAGE_SIZE);
- op = (hb_op *)op_buf;
- op->magic = HB_OP_MAGIC;
- op->opcode = HB_OP_GET_NODE_MAP;
- op->group_num = group_num;
-
- file = fopen(HEARTBEAT_DISK_FILE, "r+");
- if (!file)
- return -errno;
-
- if (fwrite((char *)op, sizeof(hb_op), 1, file) != 1)
- goto done;
-
- if (fscanf(file, "%d: ", &retval) != 1) {
- ret = -EINVAL;
- goto done;
- }
- if (retval != 0) {
- ret = retval;
- goto done;
- }
- if (fread(bytemap, 1, NM_MAX_NODES, file) < NM_MAX_NODES) {
- ret = -EINVAL;
- goto done;
- }
-
- for (i = 0; i < NM_MAX_NODES; ++i) {
- if (bytemap[i])
- ocfs2_set_bit(i, bitmap);
- }
-
- ret = 0;
-done:
- fclose(file);
- return ret;
-#else
- return 0;
-#endif
-}
-
-static int get_raw_node_map(uint8_t groupnum, char *groupdev,
- uint32_t block_bits, uint32_t num_blocks,
- uint64_t start_block, char *bitmap)
-{
-#if 0
- int i;
- int ret = -EINVAL;
- char *buf = NULL, *tmpbuf;
- hb_disk_heartbeat_block *times = NULL;
- errcode_t err;
- io_channel *channel;
-
- if (verbose)
- printf("getting raw node map...\n");
-
- times = malloc(sizeof(hb_disk_heartbeat_block) * NM_MAX_NODES);
- if (!times) {
- ret = -ENOMEM;
- goto done;
- }
-
- err = io_open(groupdev, OCFS2_FLAG_RO, &channel);
- if (err) {
- ret = -EINVAL;
- goto done;
- }
-
- err = io_set_blksize(channel, 1 << block_bits);
- if (err) {
- ret = -EINVAL;
- goto done;
- }
-
- err = ocfs2_malloc_blocks(channel, (int)NM_MAX_NODES, &buf);
- if (err) {
- ret = -ENOMEM;
- goto done;
- }
-
- err = io_read_block(channel, start_block, (int)NM_MAX_NODES, buf);
- if (err) {
- ret = -EIO;
- if (err == OCFS2_ET_SHORT_READ)
- ret = -EINVAL;
- goto done;
- }
-
- tmpbuf = buf;
- for (i=0; i<NM_MAX_NODES; i++) {
- times[i].time = ((hb_disk_heartbeat_block *)tmpbuf)->time;
- tmpbuf += (1 << block_bits);
- }
-
- /* TODO: how long? */
- sleep(4);
-
- err = io_read_block(channel, start_block, (int)NM_MAX_NODES, buf);
- if (err) {
- ret = -EIO;
- if (err == OCFS2_ET_SHORT_READ)
- ret = -EINVAL;
- goto done;
- }
-
- tmpbuf = buf;
- for (i=0; i<NM_MAX_NODES; i++) {
- if (verbose)
- printf("node: %d: before=%"PRIu64", after=%"PRIu64"\n",
- i, times[i].time, ((hb_disk_heartbeat_block *)tmpbuf)->time);
- if (times[i].time != ((hb_disk_heartbeat_block *)tmpbuf)->time) {
- if (verbose)
- printf(" >>>>> aha node %d seems to be up!\n", i);
- ocfs2_set_bit(i, bitmap);
- }
- tmpbuf += (1 << block_bits);
- }
-
- ret = 0;
-done:
-
- if (buf)
- ocfs2_free(&buf);
- io_close(channel);
- if (times)
- free(times);
- return ret;
-#else
- return 0;
-#endif
-}
-
-static int create_remote_group(char *group_name, uint8_t node)
-{
-#if 0
- int ret, fd = -1, remote_node = -1;
- gsd_ioc ioc;
- char fname[100];
- DIR *dir = NULL;
- struct dirent *de = NULL;
-
- if (verbose)
- printf("create_remote_group: name=%s, remote node=%u\n", group_name, node);
-
- /* NOTE: this is a bit of a hack. we actually normally would not
- * know which "global" node corresponds to this "group relative" node.
- * but for now, they directly match up. */
- // sprintf(fname, "/proc/cluster/nm/%s/%03u", group_name, node);
-
- dir = opendir("/proc/cluster/nm");
- if (!dir) {
- ret = -EINVAL;
- goto leave;
- }
-
- fname[0]=0;
- while ((de = readdir(dir)) != NULL) {
- if (de->d_ino - NM_NODE_INODE_START == node) {
- sprintf(fname, "/proc/cluster/nm/%s", de->d_name);
- break;
- }
- }
- closedir(dir);
- if (!fname[0]) {
- ret = -EINVAL;
- goto leave;
- }
- if (verbose)
- printf("found file %s corresponding to node %u\n", fname, node);
-
- /* open a file descriptor to the node we want to talk to */
- remote_node = open(fname, O_RDONLY);
- if (remote_node == -1) {
- ret = -errno;
- goto leave;
- }
- if (verbose)
- printf("fd for remote node=%d\n", remote_node);
-
- /* TODO: move this over to a transaction file on the inode, eliminate the ioctl */
- fd = open("/proc/cluster/net", O_RDONLY);
- if (fd == -1) {
- ret = -errno;
- goto leave;
- }
-
- if (verbose)
- printf("fd for net ioctl file=%d\n", fd);
-
- /* call an ioctl to create the group over there */
- memset(&ioc, 0, sizeof(gsd_ioc));
- ioc.fd = remote_node;
- ioc.namelen = strlen(group_name);
- memcpy(ioc.name, group_name, ioc.namelen);
- if (ioctl(fd, GSD_IOC_CREATE_GROUP, &ioc) < 0) {
- ret = -errno;
- goto leave;
- }
- ret = ioc.status;
- if (verbose)
- printf("create group ioctl returned ret=%d\n", ret);
-
- if (ret != 0 && ret != -EEXIST)
- goto leave;
-
- /* call an ioctl to add this node to the group over there */
- memset(&ioc, 0, sizeof(gsd_ioc));
- ioc.fd = remote_node;
- ioc.namelen = strlen(group_name);
- memcpy(ioc.name, group_name, ioc.namelen);
- if (ioctl(fd, GSD_IOC_ADD_GROUP_NODE, &ioc) < 0) {
- ret = -errno;
- goto leave;
- }
- ret = ioc.status;
- if (verbose)
- printf("add node ioctl returned ret=%d\n", ret);
-
-leave:
- if (fd != -1)
- close(fd);
- if (remote_node != -1)
- close(remote_node);
- return ret;
-#else
- return 0;
-#endif
-}
-
static int start_heartbeat(char *hbuuid, char *device)
{
int ret;
More information about the Ocfs2-tools-commits
mailing list