[Ocfs2-tools-commits] smushran commits r552 - in trunk: libocfs2
libocfs2/include listuuid tunefs.ocfs2
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jan 13 15:04:04 CST 2005
Author: smushran
Date: 2005-01-13 15:04:02 -0600 (Thu, 13 Jan 2005)
New Revision: 552
Modified:
trunk/libocfs2/alloc.c
trunk/libocfs2/chainalloc.c
trunk/libocfs2/checkhb.c
trunk/libocfs2/include/ocfs2_fs.h
trunk/listuuid/listuuid.c
trunk/tunefs.ocfs2/Makefile
trunk/tunefs.ocfs2/tunefs.c
Log:
o reduced OCFS2_MAX_NODES from 256 to 255
o ocfs2_new_system_inode calls ocfs2_chain_add_group when out of space
o fixed chaining in ocfs2_chain_add_group
o tunefs skips system files already present during add_nodes
Modified: trunk/libocfs2/alloc.c
===================================================================
--- trunk/libocfs2/alloc.c 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/libocfs2/alloc.c 2005-01-13 21:04:02 UTC (rev 552)
@@ -200,8 +200,15 @@
ret = ocfs2_chain_alloc_with_io(fs, fs->fs_system_inode_alloc,
&gd_blkno, ino);
- if (ret)
- goto out;
+ if (ret == OCFS2_ET_BIT_NOT_FOUND) {
+ ret = ocfs2_chain_add_group(fs, fs->fs_system_inode_alloc);
+ if (ret)
+ goto out;
+ ret = ocfs2_chain_alloc_with_io(fs, fs->fs_system_inode_alloc,
+ &gd_blkno, ino);
+ if (ret)
+ goto out;
+ }
memset(buf, 0, fs->fs_blocksize);
di = (ocfs2_dinode *)buf;
Modified: trunk/libocfs2/chainalloc.c
===================================================================
--- trunk/libocfs2/chainalloc.c 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/libocfs2/chainalloc.c 2005-01-13 21:04:02 UTC (rev 552)
@@ -482,15 +482,17 @@
cinode->ci_inode->id2.i_chain.cl_cpg *
cinode->ci_inode->id2.i_chain.cl_bpc, 0);
+ rec = &cinode->ci_inode->id2.i_chain.cl_recs[0];
+ old_blkno = rec->c_blkno;
+ gd->bg_next_group = old_blkno;
+
ret = ocfs2_write_group_desc(fs, blkno, (char *)gd);
if (ret)
goto out;
/* XXX could be a helper? */
- rec = &cinode->ci_inode->id2.i_chain.cl_recs[0];
rec->c_free += gd->bg_free_bits_count;
rec->c_total += gd->bg_bits;
- old_blkno = rec->c_blkno;
rec->c_blkno = blkno;
cinode->ci_inode->i_clusters += cinode->ci_inode->id2.i_chain.cl_cpg;
Modified: trunk/libocfs2/checkhb.c
===================================================================
--- trunk/libocfs2/checkhb.c 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/libocfs2/checkhb.c 2005-01-13 21:04:02 UTC (rev 552)
@@ -485,6 +485,7 @@
return ret;
}
+#endif /* 0 */
/*
* ocfs2_get_ocfs1_label()
@@ -515,4 +516,3 @@
close(fd);
return ret;
}
-#endif /* 0 */
Modified: trunk/libocfs2/include/ocfs2_fs.h
===================================================================
--- trunk/libocfs2/include/ocfs2_fs.h 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/libocfs2/include/ocfs2_fs.h 2005-01-13 21:04:02 UTC (rev 552)
@@ -110,7 +110,7 @@
#define OCFS2_MAX_FILENAME_LENGTH 255
/* Limit of node map bits in ocfs2_disk_lock */
-#define OCFS2_MAX_NODES 256
+#define OCFS2_MAX_NODES 255
#define MAX_VOL_ID_LENGTH 16
#define MAX_VOL_LABEL_LEN 64
Modified: trunk/listuuid/listuuid.c
===================================================================
--- trunk/listuuid/listuuid.c 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/listuuid/listuuid.c 2005-01-13 21:04:02 UTC (rev 552)
@@ -104,7 +104,7 @@
char *p;
int i;
- printf("%-20s %7s %-32s\n", "Device", "maj,min", "UUID");
+ printf("%-20s %7s %-5s %-32s %-s\n", "Device", "maj,min", "FS", "UUID", "Label");
list_for_each(pos, dev_list) {
dev = list_entry(pos, ocfs2_devices, list);
if (dev->fs_type == 0)
@@ -115,7 +115,8 @@
sprintf(p, "%02X", dev->uuid[i]);
sprintf(devstr, "%3d,%-d", dev->maj_num, dev->min_num);
- printf("%-20s %-7s %-32s\n", dev->dev_name, devstr, uuid);
+ printf("%-20s %-7s %-5s %-32s %s\n", dev->dev_name, devstr,
+ (dev->fs_type == 2 ? "ocfs2" : "ocfs"), uuid, dev->label);
}
return ;
@@ -158,20 +159,33 @@
fs = NULL;
ret = ocfs2_open(dev_name, OCFS2_FLAG_RO, 0, 0, &fs);
if (ret) {
- dev->fs_type = 0;
- ret = 0;
- continue;
+ if (ret == OCFS2_ET_OCFS_REV)
+ dev->fs_type = 1;
+ else {
+ ret = 0;
+ continue;
+ }
} else
dev->fs_type = 2;
/* get uuid for ocfs2 */
if (dev->fs_type == 2) {
+ memcpy(dev->label, OCFS2_RAW_SB(fs->fs_super)->s_label,
+ sizeof(dev->label));
memcpy(dev->uuid, OCFS2_RAW_SB(fs->fs_super)->s_uuid,
sizeof(dev->uuid));
+ } else {
+ if (ocfs2_get_ocfs1_label(dev->dev_name,
+ dev->label, sizeof(dev->label),
+ dev->uuid, sizeof(dev->uuid))) {
+ dev->label[0] = '\0';
+ memset(dev->uuid, 0, sizeof(dev->uuid));
+ }
}
/* close fs */
- ocfs2_close(fs);
+ if (fs)
+ ocfs2_close(fs);
}
ocfs2_print_uuids(&dev_list);
Modified: trunk/tunefs.ocfs2/Makefile
===================================================================
--- trunk/tunefs.ocfs2/Makefile 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/tunefs.ocfs2/Makefile 2005-01-13 21:04:02 UTC (rev 552)
@@ -18,7 +18,7 @@
SBIN_PROGRAMS = tunefs.ocfs2
-INCLUDES = -I$(TOPDIR)/libocfs2/include
+INCLUDES = -I$(TOPDIR)/libocfs2/include $(GLIB_CFLAGS)
DEFINES = -DOCFS2_FLAT_INCLUDES -DVERSION=\"$(VERSION)\"
ifeq ($(OCFS_PROCESSOR),x86_64)
@@ -38,6 +38,6 @@
DIST_FILES = $(CFILES)
tunefs.ocfs2: $(OBJS) $(LIBOCFS2_DEPS)
- $(LINK) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS)
+ $(LINK) $(LIBOCFS2_LIBS) $(GLIB_LIBS) $(COM_ERR_LIBS)
include $(TOPDIR)/Postamble.make
Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c 2005-01-13 19:46:00 UTC (rev 551)
+++ trunk/tunefs.ocfs2/tunefs.c 2005-01-13 21:04:02 UTC (rev 552)
@@ -43,6 +43,7 @@
#include <netinet/in.h>
#include <inttypes.h>
#include <ctype.h>
+#include <glib.h>
#include <ocfs2.h>
#include <ocfs2_fs.h>
@@ -72,7 +73,7 @@
*/
static void usage(const char *progname)
{
- fprintf(stderr, "Usage: %s [-L volume-label] [-n number-of-nodes]\n"
+ fprintf(stderr, "usage: %s [-L volume-label] [-n number-of-nodes]\n"
"\t\t[-j journal-size] [-S volume-size] [-qvV] device\n",
progname);
exit(0);
@@ -268,37 +269,57 @@
char fname[SYSTEM_FILE_NAME_MAX];
uint64_t blkno;
int i, j;
+ char *display_str = NULL;
for (i = OCFS2_LAST_GLOBAL_SYSTEM_INODE + 1; i < NUM_SYSTEM_INODES; ++i) {
for (j = old_num; j < opts.num_nodes; ++j) {
sprintf(fname, ocfs2_system_inodes[i].si_name, j);
- printf("Adding %s... ", fname);
+ display_str = g_strdup_printf("Adding %s...", fname);
+ printf("%s", display_str);
+ fflush(stdout);
+ /* Goto next if file already exists */
+ ret = ocfs2_lookup(fs, fs->fs_sysdir_blkno, fname,
+ strlen(fname), NULL, &blkno);
+ if (!ret)
+ goto next_file;
+
/* create inode for system file */
- ret = ocfs2_new_system_inode(fs, &blkno, ocfs2_system_inodes[i].si_mode,
+ ret = ocfs2_new_system_inode(fs, &blkno,
+ ocfs2_system_inodes[i].si_mode,
ocfs2_system_inodes[i].si_flags);
if (ret)
goto bail;
/* Add the inode to the system dir */
- ret = ocfs2_link(fs, fs->fs_sysdir_blkno, fname,
- blkno, OCFS2_FT_REG_FILE);
- if (ret) {
- if (ret == OCFS2_ET_DIR_NO_SPACE) {
- ret = ocfs2_expand_dir(fs, fs->fs_sysdir_blkno, fs->fs_sysdir_blkno);
- if (!ret)
- ret = ocfs2_link(fs, fs->fs_sysdir_blkno,
- fname, blkno, OCFS2_FT_REG_FILE);
- }
- if (ret)
- goto bail;
+ ret = ocfs2_link(fs, fs->fs_sysdir_blkno, fname, blkno,
+ OCFS2_FT_REG_FILE);
+ if (!ret)
+ goto next_file;
+ if (ret == OCFS2_ET_DIR_NO_SPACE) {
+ ret = ocfs2_expand_dir(fs, fs->fs_sysdir_blkno,
+ fs->fs_sysdir_blkno);
+ if (!ret)
+ ret = ocfs2_link(fs, fs->fs_sysdir_blkno,
+ fname, blkno,
+ OCFS2_FT_REG_FILE);
+ } else
+ goto bail;
+next_file:
+ if (display_str) {
+ memset(display_str, ' ', strlen(display_str));
+ printf("\r%s\r", display_str);
+ fflush(stdout);
+ free(display_str);
+ display_str = NULL;
}
- printf("\r \r");
}
}
bail:
- if (ret)
+ if (display_str) {
+ free(display_str);
printf("\n");
+ }
return ret;
}
@@ -385,7 +406,7 @@
uint64_t blkno;
int i;
uint16_t max_nodes = OCFS2_RAW_SB(fs->fs_super)->s_max_nodes;
- uint64_t num_clusters;
+ uint32_t num_clusters;
char *buf = NULL;
ocfs2_dinode *di;
@@ -483,11 +504,7 @@
ret = ocfs2_open(opts.device, OCFS2_FLAG_RW, 0, 0, &fs);
if (ret) {
- if (ret == OCFS2_ET_OCFS_REV)
- printf("ERROR: %s is an ocfs (and not ocfs2) volume. ", opts.device);
- else
- printf("ERROR: %s is not an ocfs2 volume. ", opts.device);
- printf("Aborting.\n");
+ com_err(argv[0], ret, " ");
goto bail;
}
More information about the Ocfs2-tools-commits
mailing list