[Ocfs-tools-commits]
smushran commits r73 - in trunk/ocfs: bugfix debugocfs format
format/inc fsck libocfs libocfs/Common/inc
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Jun 17 18:52:22 CDT 2004
Author: smushran
Date: 2004-06-17 17:52:20 -0500 (Thu, 17 Jun 2004)
New Revision: 73
Modified:
trunk/ocfs/bugfix/
trunk/ocfs/bugfix/bug3016598.c
trunk/ocfs/debugocfs/
trunk/ocfs/format/
trunk/ocfs/format/format.c
trunk/ocfs/format/inc/format.h
trunk/ocfs/format/system.c
trunk/ocfs/fsck/
trunk/ocfs/fsck/Cscope.make
trunk/ocfs/fsck/blked.c
trunk/ocfs/fsck/class_rw.c
trunk/ocfs/fsck/fsck.c
trunk/ocfs/fsck/fsck.h
trunk/ocfs/fsck/layout.h
trunk/ocfs/fsck/sig.c
trunk/ocfs/fsck/utils.c
trunk/ocfs/fsck/verify.c
trunk/ocfs/fsck/verify.h
trunk/ocfs/libocfs/
trunk/ocfs/libocfs/Common/inc/ocfsconst.h
trunk/ocfs/libocfs/Common/inc/ocfsdef.h
trunk/ocfs/libocfs/Common/inc/ocfsdisk.h
Log:
format accepts -S size
fsck displays list of files involved in global bitmap corruption
fsck displays list of files involved incase of unset bits found in the gbl btmp
fsck error messages made concise
Property changes on: trunk/ocfs/bugfix
___________________________________________________________________
Name: svn:ignore
+ bug3123542
stamp-md5
bug3016598
Modified: trunk/ocfs/bugfix/bug3016598.c
===================================================================
--- trunk/ocfs/bugfix/bug3016598.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/bugfix/bug3016598.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -95,7 +95,7 @@
/* check the undeletable dir bug, BUG #3016598 */
for (i=0, deleted_files=0; i < dir->num_ent_used; i++) {
- if ((FILEENT(dir, i))->sync_flags & OCFS_SYNC_FLAG_MARK_FOR_DELETION)
+ if (IS_FE_DELETED((FILEENT(dir, i))->sync_flags))
deleted_files++;
}
if (dir->num_ent_used && dir->num_ent_used == deleted_files) {
Property changes on: trunk/ocfs/debugocfs
___________________________________________________________________
Name: svn:ignore
+ debugocfs
ocfsextfinder
debugocfs.8
libdebugocfs.a
stamp-md5
cscope*
Property changes on: trunk/ocfs/format
___________________________________________________________________
Name: svn:ignore
+ cscope.out
tuneocfs
mkfs.ocfs
tuneocfs.8
mkfs.ocfs.8
mounted.ocfs
stamp-md5
cscope.files
Modified: trunk/ocfs/format/format.c
===================================================================
--- trunk/ocfs/format/format.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/format/format.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -148,11 +148,20 @@
if (!(GetDiskGeometry(file, &vol_size, §_size)))
goto bail;
+ if (opts.device_size) {
+ if (opts.device_size > vol_size) {
+ fprintf(stderr, "Error: Size specified is larger "
+ "than the device size.\nAborting.\n");
+ goto bail;
+ } else
+ vol_size = opts.device_size;
+ }
+
if (vol_size < OCFS_MIN_VOL_SIZE) {
fprintf(stderr, "Error: %s at %lluMB is smaller than %uMB.\n"
"Aborting.\n", opts.device, (vol_size/(1024*1024)),
(OCFS_MIN_VOL_SIZE/(1024*1024)));
- goto bail;
+ goto bail;
}
/* close and reopen after binding to raw */
@@ -655,6 +664,9 @@
{
int i;
int ret = 1;
+ char *p;
+ __u64 fac = 1;
+ long double size;
if (argc < 2) {
version(argv[0]);
@@ -748,6 +760,20 @@
opts.quiet = true;
break;
+ case 'S': /* device size */
+ ++i;
+ if (i < argc && argv[i]) {
+ size = strtold(argv[i], &p);
+ if (p)
+ MULT_FACTOR(*p, fac);
+ opts.device_size = (__u64)(size * fac);
+ } else {
+ fprintf(stderr,"Invalid size.\n"
+ "Aborting.\n");
+ ret = 0;
+ }
+ break;
+
case 'u': /* uid */
++i;
if (i < argc && argv[i])
Modified: trunk/ocfs/format/inc/format.h
===================================================================
--- trunk/ocfs/format/inc/format.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/format/inc/format.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -207,6 +207,6 @@
__u32 ocfs_alloc_from_global_bitmap (__u64 file_size, ocfs_vol_disk_hdr *volhdr);
int ocfs_update_bm_lock_stats(int file);
int ocfs_init_global_alloc_bm (__u32 num_bits, int file, ocfs_vol_disk_hdr *volhdr);
-void ocfs_init_dirnode(ocfs_dir_node *dir, __u64 disk_off, __u32 bit_off);
+void ocfs_init_dirnode(ocfs_dir_node *dir, __u64 disk_off);
#endif /* _FORMAT_H_ */
Modified: trunk/ocfs/format/system.c
===================================================================
--- trunk/ocfs/format/system.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/format/system.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -1,3 +1,30 @@
+
+/*
+ * system.c
+ *
+ * creates system files and root dir during format
+ *
+ * Copyright (C) 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.
+ *
+ * Authors: Kurt Hackel
+ *
+ */
+
#include <format.h>
#include <signal.h>
#include <libgen.h>
@@ -156,7 +183,7 @@
goto bail;
volhdr->root_off = (root_bit * volhdr->cluster_size) + volhdr->data_start_off;
- ocfs_init_dirnode(dir, volhdr->root_off, root_bit);
+ ocfs_init_dirnode(dir, volhdr->root_off);
dir->dir_node_flags |= DIR_NODE_FLAG_ROOT;
if (!SetSeek(file, volhdr->root_off))
@@ -303,13 +330,13 @@
}
-void ocfs_init_dirnode(ocfs_dir_node *dir, __u64 disk_off, __u32 bit_off)
+void ocfs_init_dirnode(ocfs_dir_node *dir, __u64 disk_off)
{
memset(dir, 0, OCFS_DEFAULT_DIR_NODE_SIZE);
strcpy (dir->signature, OCFS_DIR_NODE_SIGNATURE);
dir->num_ents = 254;
dir->node_disk_off = disk_off;
- dir->alloc_file_off = bit_off;
+ dir->alloc_file_off = disk_off;
dir->alloc_node = OCFS_INVALID_NODE_NUM;
dir->free_node_ptr = INVALID_NODE_POINTER;
dir->next_node_ptr = INVALID_NODE_POINTER;
@@ -328,7 +355,7 @@
char *filename;
ocfs_local_alloc *alloc;
__u64 off;
- __u32 orphan_bit;
+// __u32 orphan_bit;
ocfs_dir_node *orphan_dir = NULL;
__u8 next_free_ext = 0;
@@ -382,8 +409,8 @@
orphan_dir = (ocfs_dir_node *) MemAlloc(OCFS_DEFAULT_DIR_NODE_SIZE);
if (orphan_dir == NULL)
return 0;
- orphan_bit = (__u32)((data - volhdr->data_start_off) / volhdr->cluster_size);
- ocfs_init_dirnode(orphan_dir, data, orphan_bit);
+// orphan_bit = (__u32)((data - volhdr->data_start_off) / volhdr->cluster_size);
+ ocfs_init_dirnode(orphan_dir, data);
DISK_LOCK_CURRENT_MASTER (orphan_dir) = file_id - OCFS_ORPHAN_DIR;
DISK_LOCK_FILE_LOCK (orphan_dir) = OCFS_DLM_ENABLE_CACHE_LOCK;
orphan_dir->dir_node_flags |= DIR_NODE_FLAG_ORPHAN;
Property changes on: trunk/ocfs/fsck
___________________________________________________________________
Name: svn:ignore
+ fsck.ocfs.8
stamp-md5
parse
blked.ocfs
fsck.ocfs
cscope.out
cscope.files
classes.c
Modified: trunk/ocfs/fsck/Cscope.make
===================================================================
--- trunk/ocfs/fsck/Cscope.make 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/Cscope.make 2004-06-17 22:52:20 UTC (rev 73)
@@ -6,4 +6,5 @@
find . -name '*.c' -print >>cscope.files
find . -name '*.h' -print >>cscope.files
find ../libocfs -name '*.h' -print >>cscope.files
+ find ../libocfs -name '*.c' -print >>cscope.files
cscope -b
Modified: trunk/ocfs/fsck/blked.c
===================================================================
--- trunk/ocfs/fsck/blked.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/blked.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -44,6 +44,8 @@
bool never_mounted = false;
__u32 fs_version = 0;
+__u32 fs_num;
+
ocfs_global_ctxt OcfsGlobalCtxt;
ocfsck_context ctxt;
extern void version(char *progname);
Modified: trunk/ocfs/fsck/class_rw.c
===================================================================
--- trunk/ocfs/fsck/class_rw.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/class_rw.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -784,11 +784,11 @@
int _string_to_fileflag_u32(char *newval, void *top, typeinfo *info)
{
int ret = -1;
- char **arr;
+ char **arr, **p;
__u32 flag;
flag = 0;
- arr = g_strsplit(newval, " ", 0);
+ p = arr = g_strsplit(newval, " ", 0);
while (*arr!=NULL)
{
@@ -826,7 +826,7 @@
}
G_STRUCT_MEMBER(__u32, top, info->off) = flag;
ret = 0;
- g_strfreev(arr);
+ g_strfreev(p);
return ret;
}
@@ -1315,9 +1315,9 @@
{
__u32 sync = 0;
int ret = -1;
- char **arr;
+ char **arr, **p;
- arr = g_strsplit(newval, " ", 0);
+ p = arr = g_strsplit(newval, " ", 0);
while (*arr != NULL)
{
@@ -1338,7 +1338,7 @@
G_STRUCT_MEMBER(__u32, top, info->off) = sync;
ret = 0;
bail:
- g_strfreev(arr);
+ g_strfreev(p);
return ret;
}
@@ -1373,10 +1373,10 @@
{
__u8 sync = 0;
int ret = -1;
- char **arr;
+ char **arr, **p;
sync = 0;
- arr = g_strsplit(newval, " ", 0);
+ p = arr = g_strsplit(newval, " ", 0);
while (*arr != NULL)
{
@@ -1397,7 +1397,7 @@
G_STRUCT_MEMBER(__u8, top, info->off) = sync;
ret = 0;
bail:
- g_strfreev(arr);
+ g_strfreev(p);
return ret;
}
Modified: trunk/ocfs/fsck/fsck.c
===================================================================
--- trunk/ocfs/fsck/fsck.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/fsck.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -41,6 +41,8 @@
bool never_mounted = false;
__u32 fs_version = 0;
+__u32 fs_num = 0;
+
ocfs_global_ctxt OcfsGlobalCtxt;
ocfsck_context ctxt;
extern void version(char *progname);
@@ -120,7 +122,7 @@
ctxt.no_hb_chk = false;
if (ctxt.dev_is_file)
- ctxt.no_hb_chk = false;
+ ctxt.no_hb_chk = true;
ret = 0;
bail:
@@ -184,7 +186,7 @@
break;
}
- // show current value and default value
+ /* show current value and default value */
m = &(cls->members[fld]);
if (m->to_string(&cur, buf, &(m->type))==-1) {
ret = -1;
@@ -202,7 +204,7 @@
cur ? cur->str : "",
dflt ? dflt->str : "");
- // get new value and validate it
+ /* get new value and validate it */
if (fgets(newval, USER_INPUT_MAX, stdin) == NULL) {
ret = -1;
break;
@@ -270,12 +272,14 @@
else
ctxt.flags = O_RDONLY | O_LARGEFILE;
- if (bind_raw(ctxt.device, &ctxt.raw_minor, ctxt.raw_device, sizeof(ctxt.raw_device)))
- goto bail;
+ if (!ctxt.dev_is_file) {
+ if (bind_raw(ctxt.device, &ctxt.raw_minor, ctxt.raw_device, sizeof(ctxt.raw_device)))
+ goto bail;
+ if (ctxt.verbose)
+ CLEAR_AND_PRINT("Bound %s to %s", ctxt.device, ctxt.raw_device);
+ } else
+ strncpy(ctxt.raw_device, ctxt.device, sizeof(ctxt.raw_device));
- if (ctxt.verbose)
- CLEAR_AND_PRINT("Bound %s to %s", ctxt.device, ctxt.raw_device);
-
if ((fd = myopen(ctxt.raw_device, ctxt.flags)) == -1) {
LOG_ERROR("Error opening %s.\n%s.", ctxt.raw_device,
strerror(errno));
@@ -320,6 +324,7 @@
ctxt.vol_bm_data = g_array_new(false, true, sizeof(bitmap_data));
ctxt.dir_bm_data = g_array_new(false, true, sizeof(bitmap_data));
ctxt.ext_bm_data = g_array_new(false, true, sizeof(bitmap_data));
+ ctxt.filenames = g_array_new(false, true, sizeof(str_data));
ret = 0;
@@ -343,7 +348,7 @@
ocfs_layout_t *l;
int j;
GHashTable *bad = NULL;
- int changed = 0;
+ str_data *fn;
memset(&ctxt, 0, sizeof(ctxt));
init_global_context();
@@ -412,6 +417,7 @@
break;
if (ret != -1 && !ctxt.modify_all)
continue;
+#if 0
while (ctxt.write_changes) {
changed = 0;
if (edit_structure(s, buf, j, &changed, &option) != -1)
@@ -425,6 +431,7 @@
break;
}
+#endif
if (bad)
g_hash_table_destroy(bad);
@@ -500,6 +507,14 @@
if (ctxt.ext_bm_data)
g_array_free(ctxt.ext_bm_data, true);
+ if (ctxt.filenames) {
+ for (i = 0; i < ctxt.filenames->len; ++i) {
+ fn = &(g_array_index(ctxt.filenames, str_data, i));
+ safefree(fn->str);
+ }
+ g_array_free(ctxt.filenames, true);
+ }
+
for (i = 0; i < OCFS_MAXIMUM_NODES; ++i)
free_aligned(ctxt.dir_bm[i]);
Modified: trunk/ocfs/fsck/fsck.h
===================================================================
--- trunk/ocfs/fsck/fsck.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/fsck.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -169,8 +169,10 @@
GHashTable **bad);
void *mem_alloc(int len);
int fsck_initialize(char **buf);
-int qsort_compare(const void *q1, const void *q2);
-void print_free_bits(GArray *bits, char *str);
+int comp_nums(const void *q1, const void *q2);
+int comp_bits(const void *q1, const void *q2);
+void find_unset_bits(__u8 *vol_bm, char *bitmap);
+void find_set_bits(__u8 *vol_bm, char *bitmap);
int check_global_bitmap(int fd);
int check_node_bitmaps(int fd, GArray *bm_data, __u8 **node_bm,
__u32 *node_bm_sz, char *str);
@@ -178,7 +180,7 @@
int handle_leaf_extents (int fd, ocfs_alloc_ext *arr, int num, __u32 node,
__u64 parent_offset);
void traverse_dir_nodes(int fd, __u64 offset, char *path);
-void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset,
+void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset, int slot,
bool systemfile, char *path);
void traverse_extent(int fd, ocfs_extent_group * exthdr, int flag, void *buf,
int *indx);
@@ -192,6 +194,9 @@
int get_node_names(int file, ocfs_vol_disk_hdr *volhdr, char **node_names,
__u32 sect_size);
void print_node_names(char **node_names, __u32 nodemap);
+void print_gbl_alloc_errs(void);
+void print_bit_ranges(GArray *bits, char *str1, char *str2);
+void print_filenames(GArray *files);
////////////////////////
void ocfs_extent_map_init (ocfs_extent_map * map);
@@ -219,7 +224,8 @@
bm_extent,
bm_dir,
bm_symlink,
- bm_filedata
+ bm_filedata,
+ bm_global
};
typedef struct _bitmap_data
@@ -228,8 +234,15 @@
__s32 alloc_node;
__u64 fss_off; /* file system structure offset */
__u64 parent_off; /* offset of the fs structure housing the extent */
+ __u32 fnum;
} bitmap_data;
+typedef struct _str_data
+{
+ __u32 num;
+ char *str;
+} str_data;
+
typedef struct _ocfsck_context
{
char device[OCFS_MAX_FILENAME_LENGTH];
@@ -256,6 +269,7 @@
GArray *vol_bm_data;
GArray *dir_bm_data;
GArray *ext_bm_data;
+ GArray *filenames;
} ocfsck_context;
//int ocfs_lookup_file_allocation (ocfs_super * osb, ocfs_inode * oin,
@@ -281,6 +295,7 @@
int print_class(char *buf, ocfs_class *cl, FILE *out, GHashTable *ht);
bitmap_data * add_bm_data(__u64 start, __u64 len, __s32 alloc_node,
__u64 parent_offset, int type);
+int add_str_data(GArray *sd, __u32 num, char *str);
int read_one_sector(int fd, char *buf, __u64 offset, int idx);
int write_one_sector(int fd, char *buf, __u64 offset, int idx);
@@ -289,5 +304,9 @@
int read_volume_bitmap (int fd, char *buf, __u64 offset, int idx);
int write_volume_bitmap (int fd, char *buf, __u64 offset, int idx);
+int check_dir_index (char *dirbuf, __u64 dir_offset);
+int check_num_del (char *dirbuf, __u64 dir_offset);
+int fix_num_del (char *dirbuf, __u64 dir_offset);
+int fix_fe_offsets(char *dirbuf, __u64 dir_offset);
#endif /* FSCK_H */
Modified: trunk/ocfs/fsck/layout.h
===================================================================
--- trunk/ocfs/fsck/layout.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/layout.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -101,7 +101,7 @@
int (*sig_match) (char *buf, int idx);
int (*read) (int fd, char *buf, __u64 offset, int idx);
int (*write) (int fd, char *buf, __u64 offset, int idx);
- int (*verify) (int fd, char *buf, int idx, GHashTable **bad);
+ int (*verify) (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
int (*output) (char *buf, int idx, GHashTable *bad, FILE *f);
int (*defaults) (char *buf, GString **out, int idx, int fld);
};
Modified: trunk/ocfs/fsck/sig.c
===================================================================
--- trunk/ocfs/fsck/sig.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/sig.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -31,9 +31,6 @@
ocfs_node_config_hdr *hdr = (ocfs_node_config_hdr *)buf;
if (!strncmp (hdr->signature, NODE_CONFIG_HDR_SIGN, NODE_CONFIG_SIGN_LEN))
return 0;
-// LOG_ERROR("invalid signature '%*s' found in autoconfig header",
-// NODE_CONFIG_SIGN_LEN, hdr->signature);
-// strcpy (hdr->signature, NODE_CONFIG_HDR_SIGN);
return -EINVAL;
}
@@ -58,9 +55,6 @@
if (memcmp (hdr->signature, OCFS_VOLUME_SIGNATURE,
strlen (OCFS_VOLUME_SIGNATURE)) == 0)
return 0;
-// LOG_ERROR("invalid signature '%*s' found in volume header",
-// strlen(OCFS_VOLUME_SIGNATURE), hdr->signature);
-// strcpy (hdr->signature, OCFS_VOLUME_SIGNATURE);
return -EINVAL;
}
@@ -109,9 +103,6 @@
ocfs_dir_node *dir = (ocfs_dir_node *)buf;
if (IS_VALID_DIR_NODE(dir))
return 0;
-// LOG_ERROR("invalid signature '%*s' found in directory",
-// strlen(OCFS_DIR_NODE_SIGNATURE), dir->signature);
-// strcpy (dir->signature, OCFS_DIR_NODE_SIGNATURE);
return -EINVAL;
}
@@ -120,9 +111,6 @@
ocfs_file_entry *fe = (ocfs_file_entry *)buf;
if (IS_VALID_FILE_ENTRY(fe))
return 0;
-// LOG_ERROR("invalid signature '%*s' found in file entry",
-// strlen(OCFS_FILE_ENTRY_SIGNATURE), fe->signature);
-// strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
return -EINVAL;
}
@@ -131,9 +119,6 @@
ocfs_extent_group *ext = (ocfs_extent_group *)buf;
if (IS_VALID_EXTENT_HEADER(ext))
return 0;
-// LOG_ERROR("invalid signature '%*s' found in extent header",
-// strlen(OCFS_EXTENT_HEADER_SIGNATURE), ext->signature);
-// strcpy (ext->signature, OCFS_EXTENT_HEADER_SIGNATURE);
return -EINVAL;
}
@@ -142,8 +127,5 @@
ocfs_extent_group *ext = (ocfs_extent_group *)buf;
if (IS_VALID_EXTENT_DATA(ext))
return 0;
-// LOG_ERROR("invalid signature '%*s' found in extent data",
-// strlen(OCFS_EXTENT_DATA_SIGNATURE), ext->signature);
-// strcpy (ext->signature, OCFS_EXTENT_DATA_SIGNATURE);
return -EINVAL;
}
Modified: trunk/ocfs/fsck/utils.c
===================================================================
--- trunk/ocfs/fsck/utils.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/utils.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -35,6 +35,8 @@
extern bool int_err;
extern bool prn_err;
+extern __u32 fs_num;
+
/*
* usage()
*
@@ -104,11 +106,13 @@
*loc = '\0';
if (strcasecmp(yesno, "yes")==0 || strcasecmp(yesno, "y")==0) {
- if (s->write(fd, buf, off, idx)==-1)
- LOG_ERROR("failed to write data to disk");
+ if ((ret = s->write(fd, buf, off, idx)) == -1) {
+ LOG_INTERNAL();
+ goto bail;
+ }
else {
GHashTable *tmp = NULL;
- ret = s->verify(fd, buf, idx, &tmp);
+ ret = s->verify(fd, buf, off, idx, &tmp);
if (tmp != NULL)
g_hash_table_destroy(tmp);
}
@@ -146,20 +150,10 @@
if (s->sig_match(buf, idx)==-EINVAL) {
LOG_ERROR("Bad signature found");
ret = -1;
- if (ctxt.write_changes) {
- if (!*bad)
- *bad = g_hash_table_new(g_direct_hash, g_direct_equal);
- ret = confirm_changes(off, s, buf, idx, *bad);
- LOG_PRINT("Fixed");
- } else
- LOG_PRINT("To fix, rerun with -w");
- /* restore the original if the new one was not written */
- if (ret == -1)
- memcpy(buf, saved_block, 512);
}
}
- if (s->verify(fd, buf, idx, bad)==-1) {
+ if (s->verify(fd, buf, off, idx, bad)==-1) {
LOG_ERROR("structure failed verification");
ret = -1;
}
@@ -194,11 +188,15 @@
ctxt.device_size = buf.st_size;
goto finito;
} else if (S_ISCHR(buf.st_mode)) {
- char *junk;
+ char *junk = NULL;
__u64 hi, lo, new, delta, last;
int ret;
junk = malloc_aligned(512);
+ if (!junk) {
+ LOG_INTERNAL();
+ goto bail;
+ }
hi = 0xfffffffffffffd00;
lo = 0ULL;
new = hi >> 1;
@@ -209,14 +207,14 @@
myseek64(fd, new, SEEK_SET);
ret = read(fd, junk, 512);
if (ret == 512) {
- // go higher
+ /* go higher */
ctxt.device_size = (new + 512);
lo = new;
delta = (hi - lo) >> 1;
new = hi - delta;
new &= 0xfffffffffffffd00;
} else {
- // go lower
+ /* go lower */
hi = new;
delta = (hi - lo) >> 1;
new = lo + delta;
@@ -233,6 +231,7 @@
ret = read(fd, junk, 512);
new += 512;
}
+ free_aligned(junk);
goto finito;
} else {
if (ioctl(fd, BLKGETSIZE, &numblks) == -1) {
@@ -455,27 +454,145 @@
} /* print_node_names */
/*
- * print_free_bits()
+ * print_gbl_alloc_errs()
*
*/
-void print_free_bits(GArray *bits, char *str)
+void print_gbl_alloc_errs(void)
{
+ bitmap_data *bm1;
+ bitmap_data *bm2;
+ str_data *s1;
+ str_data *s2;
+ GArray *cbl = NULL;
__u32 i, j, k;
+ GArray *files = NULL;
+ GString *gs = NULL;
+ char *newstr = NULL;
+
+ files = g_array_new(false, true, sizeof(__u32));
+ cbl = g_array_new(false, true, sizeof(str_data));
+ gs = g_string_new (NULL);
+
+ /* walk the list and check for any duplicates */
+ for (i = 0; i < ctxt.vol_bm_data->len;) {
+ bm1 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
+ for (k = 0, j = i + 1; j < ctxt.vol_bm_data->len; ++j, ++k) {
+ bm2 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, j));
+ if (bm2->bitnum == bm1->bitnum) {
+ if (!ctxt.verbose)
+ g_array_append_val(files, bm2->fnum);
+ else {
+ newstr = g_strdup_printf(", %u.%u",
+ HILO(bm2->parent_off));
+ g_string_append (gs, newstr);
+ safefree(newstr);
+ }
+ continue;
+ } else
+ break;
+ }
+ if (k) {
+ if (!ctxt.verbose)
+ g_array_append_val(files, bm1->fnum);
+ else {
+ newstr = g_strdup_printf("%u.%u", HILO(bm1->parent_off));
+ g_string_prepend(gs, newstr);
+ add_str_data(cbl, bm1->bitnum, gs->str);
+ safefree(newstr);
+ if (gs) {
+ g_string_free(gs, true);
+ gs = g_string_new (NULL);
+ }
+ }
+ }
+ i += k + 1;
+ }
+
+ if (files->len || cbl->len)
+ LOG_ERROR("Global bitmap corruption detected");
+ else
+ goto bail;
+
+ if (ctxt.verbose) {
+ for (i = 0; i < cbl->len;) {
+ s1 = &(g_array_index(cbl, str_data, i));
+ for (k = 0, j = i + 1; j < cbl->len; ++k, ++j) {
+ s2 = &(g_array_index(cbl, str_data, j));
+ if (s1->num + k + 1 != s2->num)
+ break;
+ if (strncmp(s1->str, s2->str, sizeof(s1->str)))
+ break;
+ }
+ if (k)
+ LOG_PRINT("Bits# %u-%u allocated to objects %s", s1->num, s1->num+k, s1->str);
+ else
+ LOG_PRINT("Bit# %u allocated to objects %s", s1->num, s1->str);
+ i += k + 1;
+ }
+ goto bail;
+ }
+
+ /* concise output */
+ LOG_PRINT("Global bitmap corruption involves the following objects:");
+ print_filenames(files);
+
+bail:
+ if (files)
+ g_array_free(files, true);
+ if (gs)
+ g_string_free(gs, true);
+ if (cbl) {
+ for (i = 0; i < cbl->len; ++i) {
+ s1 = &(g_array_index(cbl, str_data, i));
+ safefree(s1->str);
+ }
+ g_array_free(cbl, true);
+ }
+
+ return ;
+} /* print_gbl_alloc_errs */
+
+/*
+ * print_filenames()
+ *
+ */
+void print_filenames(GArray *files)
+{
+ str_data *fs;
+ __u32 num, oldnum;
+ __u32 i;
+
+ qsort(files->data, files->len, sizeof(__u32), &comp_nums);
+
+ num = oldnum = ULONG_MAX;
+ for (i = 0; i < files->len; ++i) {
+ num = g_array_index(files, __u32, i);
+ if (num != oldnum) {
+ fs = &(g_array_index(ctxt.filenames, str_data, num));
+ LOG_PRINT("%s", fs->str);
+ oldnum = num;
+ }
+ }
+} /* print_filenames */
+
+/*
+ * print_bit_ranges()
+ *
+ */
+void print_bit_ranges(GArray *bits, char *str1, char *str2)
+{
+ __u32 i, j, k;
__u32 bit1, bit2;
+ GString *gs = NULL;
+ char comma[3];
+ gchar newstr[50];
if (!bits)
goto bail;
-#if 0
- for (i = 0; i < bits->len; ++i) {
- bit1 = g_array_index(bits, __u32, i);
- if (i == 0)
- printf("\nbits: ");
- printf("%d, ", bit1);
- }
- printf("\n");
-#endif
+ gs = g_string_new (NULL);
+ *comma = '\0';
for (i = 0; i < bits->len;) {
bit1 = g_array_index(bits, __u32, i);
for (k = 0, j = i + 1; j < bits->len; ++k, ++j) {
@@ -484,60 +601,120 @@
break;
}
if (k)
- LOG_ERROR("Bits %u-%u are unset in the %s bitmap",
- bit1, bit1 + k, str);
+ sprintf(newstr, "%s%u-%u", comma, bit1, bit1 + k);
else
- LOG_ERROR("Bit %u is unset in the %s bitmap", bit1, str);
+ sprintf(newstr, "%s%u", comma, bit1);
+ g_string_append (gs, newstr);
+ if (!i)
+ strcpy(comma, ", ");
i += k + 1;
}
+ LOG_PRINT("List of %s bits in the %s bitmap: %s", str1, str2, gs->str);
+
bail:
+ if (gs)
+ g_string_free(gs, true);
return ;
-} /* print_free_bits */
+} /* print_bit_ranges */
/*
+ * find_unset_bits()
+ *
+ */
+void find_unset_bits(__u8 *vol_bm, char *bitmap)
+{
+ __u32 i, j;
+ bitmap_data *bm;
+ GArray *bits = NULL;
+ GArray *files = NULL;
+ __u32 bitnum;
+ bitmap_data kbm;
+
+ bits = g_array_new(false, true, sizeof(__u32));
+ files = g_array_new(false, true, sizeof(__u32));
+
+ /* clearing all the allocated bits in the global bitmap */
+ for (i = 0; i < ctxt.vol_bm_data->len; ++i) {
+ bm = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
+ j = __test_and_clear_bit(bm->bitnum, (unsigned long *)vol_bm);
+ if (!j) {
+ if (!test_bit(bm->bitnum, (unsigned long *)ctxt.vol_bm))
+ g_array_append_val(bits, bm->bitnum);
+ }
+ }
+
+ if (!bits->len)
+ goto bail;
+
+ LOG_WARNING("Global bitmap has unset bits");
+ print_bit_ranges(bits, "unset", bitmap);
+
+ for (i = 0; i < bits->len; ++i) {
+ bitnum = g_array_index(bits, __u32, i);
+
+ memset (&kbm, 0, sizeof(bitmap_data));
+ kbm.bitnum = bitnum;
+ kbm.alloc_node = OCFS_INVALID_NODE_NUM;
+ bm = bsearch(&kbm, ctxt.vol_bm_data->data, ctxt.vol_bm_data->len,
+ sizeof(bitmap_data), &comp_bits);
+ g_array_append_val(files, bm->fnum);
+ }
+
+ LOG_PRINT("List of files affected by the unset bits:");
+ print_filenames(files);
+
+bail:
+ if (bits)
+ g_array_free(bits, true);
+ if (files)
+ g_array_free(files, true);
+ return ;
+} /* find_unset_bits */
+
+/*
+ * find_set_bits()
+ *
+ */
+void find_set_bits(__u8 *vol_bm, char *bitmap)
+{
+ __u32 i, j;
+ GArray *bits = NULL;
+
+ bits = g_array_new(false, true, sizeof(__u32));
+
+ /* The first 1MB in the bitmap is for the system fe's */
+ j = VOL_BITMAP_BYTES / ctxt.hdr->cluster_size;
+
+ for (i = j; i < ctxt.hdr->num_clusters; ++i) {
+ if (test_bit(i, vol_bm))
+ g_array_append_val(bits, i);
+ }
+
+ if (bits) {
+ LOG_WARNING("Unused bits (wasted space) detected in the global bitmap.");
+ print_bit_ranges(bits, "unused", bitmap);
+ }
+
+ if (bits)
+ g_array_free(bits, true);
+ return ;
+} /* find_set_bits */
+
+/*
* check_global_bitmap()
*
*/
int check_global_bitmap(int fd)
{
int ret = -1;
- bitmap_data *bm1;
- bitmap_data *bm2;
__u8 *vol_bm = NULL;
- __u32 i;
- __u32 j;
- GArray *bits = NULL;
- bits = g_array_new(false, true, sizeof(__u32));
-
/* sorting the global bitmap data on alloc_node and bit_num */
qsort(ctxt.vol_bm_data->data, ctxt.vol_bm_data->len,
- sizeof(bitmap_data), &qsort_compare);
-#if 0
- for (i = 0; i < ctxt.vol_bm_data->len; ++i) {
- bm1 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
- printf("BOO: bit=%u, num=%u, blk=%u.%u, fe=%u.%u\n", bm1->bitnum,
- bm1->num, HILO(bm1->fss_off), HILO(bm1->parent_off));
- }
-#endif
+ sizeof(bitmap_data), &comp_bits);
- /* walk the list and check for any duplicates */
- for (i = 0; i < ctxt.vol_bm_data->len; ++i) {
- bm1 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
- for (j = i + 1; j < ctxt.vol_bm_data->len; ++j) {
- bm2 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, j));
- if (bm2->bitnum == bm1->bitnum) {
- LOG_ERROR("Block %u.%u (bit# %u) allocated "
- "to File Entries %u.%u and %u.%u",
- HILO(bm1->fss_off), bm1->bitnum,
- HILO(bm1->parent_off),
- HILO(bm2->parent_off));
- continue;
- } else
- break;
- }
- }
+ print_gbl_alloc_errs();
/* make a temp copy of the volume bitmap */
if ((vol_bm = malloc_aligned(VOL_BITMAP_BYTES)) == NULL) {
@@ -546,33 +723,15 @@
} else
memcpy(vol_bm, ctxt.vol_bm, VOL_BITMAP_BYTES);
- /* clearing all the allocated bits in the global bitmap */
- for (i = 0; i < ctxt.vol_bm_data->len; ++i) {
- bm1 = &(g_array_index(ctxt.vol_bm_data, bitmap_data, i));
- j = __test_and_clear_bit(bm1->bitnum, (unsigned long *)vol_bm);
- if (!j) {
- if (!test_bit(bm1->bitnum, (unsigned long *)ctxt.vol_bm))
- g_array_append_val(bits, bm1->bitnum);
- }
- }
+ find_unset_bits(vol_bm, "global");
- print_free_bits(bits, "global");
-
-#ifdef STILL_DEBUGGING
+//#ifdef STILL_DEBUGGING
/* cross check... ensure no bit in the global bitmap is set */
- /* The first 1MB in the bitmap is for the system fe's */
- j = VOL_BITMAP_BYTES / ctxt.hdr->cluster_size;
- for (i = j; i < ctxt.hdr->num_clusters; ++i) {
- if (test_bit(i, vol_bm))
- LOG_ERROR("Bit %u in the global bitmap is "
- "unaccounted", i);
- }
-#endif
+ find_set_bits(vol_bm, "global");
+//#endif
ret = 0;
bail:
- if (bits)
- g_array_free(bits, true);
free_aligned(vol_bm);
return ret;
} /* check_global_bitmap */
@@ -595,7 +754,7 @@
__u32 j;
/* sorting the node bitmap data on alloc_node and bit_num */
- qsort(bm_data->data, bm_data->len, sizeof(bitmap_data), &qsort_compare);
+ qsort(bm_data->data, bm_data->len, sizeof(bitmap_data), &comp_bits);
#ifdef STILL_DEBUGGING
for (i = 0; i < bm_data->len; ++i) {
bm1 = &(g_array_index(bm_data, bitmap_data, i));
@@ -671,12 +830,25 @@
return ret;
} /* check_node_bitmaps */
+/*
+ * comp_nums()
+ *
+ */
+int comp_nums(const void *q1, const void *q2)
+{
+ __u32 *num1 = (__u32 *)q1;
+ __u32 *num2 = (__u32 *)q2;
+ return *num1 - *num2;
+} /* comp_nums */
+
+
+
/*
- * qsort_compare()
+ * comp_bits()
*
*/
-int qsort_compare(const void *q1, const void *q2)
+int comp_bits(const void *q1, const void *q2)
{
bitmap_data *bm1 = (bitmap_data *)q1;
bitmap_data *bm2 = (bitmap_data *)q2;
@@ -687,7 +859,7 @@
ret = bm1->bitnum - bm2->bitnum;
return ret;
-} /* qsort_compare */
+} /* comp_bits */
static int fe_compare_func(const void *m1, const void *m2);
@@ -740,18 +912,11 @@
ocfs_disk_structure *fest;
GHashTable *bad;
ocfs_dir_node *dir;
- __u8 *index = NULL;
- int deleted_files;
dirst = &dirnode_t;
fest = &fileent_t;
bad = NULL;
- if ((index = malloc(256)) == NULL) {
- LOG_INTERNAL();
- goto bail;
- }
-
if ((dirbuf = malloc_aligned(DIR_NODE_SIZE)) == NULL) {
LOG_INTERNAL();
goto bail;
@@ -779,67 +944,11 @@
goto bail;
}
- /* check the dir->index integrity */
- globaldir = dir;
- memcpy(index, dir->index, dir->num_ent_used);
- qsort(index, dir->num_ent_used, sizeof(__u8), fe_compare_func);
-
- if (memcmp(index, dir->index, dir->num_ent_used) != 0) {
- __u8 *idxtmp = NULL;
-
- LOG_ERROR("Bad dir index found");
- printf("\n");
- for (i=0; i<254; ++i) {
- if (dir->index[i] != index[i]) {
- ocfs_file_entry *f1, *f2;
- f1 = (ocfs_file_entry *)((char *)dirbuf + 512 + (dir->index[i]*512));
- f2 = (ocfs_file_entry *)((char *)dirbuf + 512 + (index[i]*512));
- printf("%d, %s: %d, %s\n", dir->index[i], f1->filename, index[i], f2->filename);
- }
- }
- if (ctxt.write_changes) {
- if ((idxtmp = malloc(256)) == NULL) {
- LOG_INTERNAL();
- goto bail;
- }
- memcpy(idxtmp, dir->index, 256);
- memcpy(dir->index, index, dir->num_ent_used);
- if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
- LOG_ERROR("failed to write at offset %u.%u",
- HILO(dir_offset));
- memcpy(dir->index, idxtmp, 256);
- }
- safefree(idxtmp);
- LOG_PRINT("Fixed");
- } else
- LOG_PRINT("To fix, rerun with -w");
- }
-
- /* check the undeletable dir bug, BUG #3016598 */
- for (i=0, deleted_files=0; i < dir->num_ent_used; i++) {
- if (IS_FE_DELETED((FILEENT(dir, i))->sync_flags))
- deleted_files++;
- }
- if (dir->num_ent_used && dir->num_ent_used == deleted_files) {
- /* we hit the bug... fix by zeroing num_ent_used */
- LOG_ERROR("Undeletable directory found");
- if (ctxt.write_changes) {
- dir->num_ent_used = 0;
- if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0)==-1) {
- LOG_ERROR("failed to write at offset %u/%u", dir_offset);
- dir->num_ent_used = 1;
- }
- LOG_PRINT("Fixed");
- } else
- LOG_PRINT("To fix, rerun with -w");
- }
-
/* Add bitmap entry for the dirnode itself */
add_bm_data(dir->alloc_file_off, 1, dir->alloc_node,
dir_offset,
- (dir->alloc_node == OCFS_INVALID_NODE_NUM ? bm_filedata : bm_dir));
+ (dir->alloc_node == OCFS_INVALID_NODE_NUM ? bm_global : bm_dir));
- // TODO: add in directory editing here
for (i = 0; i < dir->num_ent_used; i++) {
off = dir_offset;
off += OCFS_SECTOR_SIZE; /* move past the dirnode header */
@@ -854,23 +963,20 @@
continue;
}
- // TODO: add in file entry editing here
-
if (!IS_FE_DELETED(febuf->sync_flags))
- check_file_entry(fd, febuf, off, false, dirpath);
+ check_file_entry(fd, febuf, off, dir->index[i], false, dirpath);
}
/* is there another directory chained off of this one? */
if (dir->next_node_ptr == -1)
- break; // nope, we're done
+ break; /* nope, we're done */
else
- dir_offset = dir->next_node_ptr; // keep going
+ dir_offset = dir->next_node_ptr; /* keep going */
}
bail:
free_aligned(dirbuf);
free_aligned(febuf);
- safefree(index);
} /* traverse_dir_nodes */
/*
@@ -886,7 +992,7 @@
* check_file_entry()
*
*/
-void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset,
+void check_file_entry(int fd, ocfs_file_entry *fe, __u64 offset, int slot,
bool systemfile, char *dirpath)
{
void *buf = NULL;
@@ -932,7 +1038,14 @@
break;
case 3:
+ add_str_data(ctxt.filenames, ++fs_num, path);
+
+ if (ctxt.verbose) {
+ safefree(path);
+ path = g_strdup_printf("%s%s\t(%d)", dirpath, fe->filename, slot);
+ }
CLEAR_AND_PRINT(path);
+
if (fe->local_ext)
handle_leaf_extents(fd, fe->extents,
OCFS_MAX_FILE_ENTRY_EXTENTS,
@@ -976,11 +1089,13 @@
void *buf = NULL;
void *p;
int i;
+ __u32 fnum = 0;
switch (type) {
case bm_extent:
bitnum = start >> OCFS_LOG_SECTOR_SIZE;
num = len;
+ fnum = fs_num - 1;
break;
case bm_dir:
@@ -991,10 +1106,12 @@
case bm_symlink:
break;
+ case bm_global:
case bm_filedata:
bitnum = (start - ctxt.hdr->data_start_off) >>
ctxt.cluster_size_bits;
num = len >> ctxt.cluster_size_bits;
+ fnum = fs_num - 1;
break;
default:
@@ -1004,6 +1121,9 @@
if (num == 0)
goto bail;
+ if (type == bm_global)
+ fnum = ULONG_MAX;
+
if ((buf = malloc(sizeof(bitmap_data) * num)) == NULL) {
LOG_INTERNAL();
goto bail;
@@ -1015,6 +1135,7 @@
bm->fss_off = start;
bm->alloc_node = alloc_node;
bm->parent_off = parent_offset;
+ bm->fnum = fnum;
p += sizeof(bitmap_data);
}
@@ -1029,6 +1150,7 @@
g_array_append_vals(ctxt.ext_bm_data, bm, num);
break;
+ case bm_global:
case bm_filedata:
g_array_append_vals(ctxt.vol_bm_data, bm, num);
break;
@@ -1041,7 +1163,27 @@
return bm;
} /* add_bm_data */
+/*
+ * add_str_data()
+ *
+ */
+int add_str_data(GArray *sd, __u32 num, char *str)
+{
+ str_data *f;
+
+ f = malloc(sizeof(str_data));
+ if (!f) {
+ LOG_INTERNAL();
+ return -1;
+ }
+ f->num = num;
+ f->str = strdup(str);
+ g_array_append_vals(sd, f, 1);
+
+ return 0;
+} /* add_str_data */
+
/*
* handle_leaf_extents()
*
@@ -1109,8 +1251,6 @@
goto bail;
}
- // TODO: add in extent editing here
-
/* check up_hdr_node_ptr */
if (exthdr->this_ext != ext->up_hdr_node_ptr) {
LOG_ERROR("up_hdr_node_ptr %u.%u in extent %u.%u "
@@ -1197,7 +1337,6 @@
goto bail;
}
- // TODO: add in extent editing here
if (fe->this_sector != ext->up_hdr_node_ptr) {
LOG_ERROR("up_hdr_node_ptr %u.%u in extent %u.%u "
"should be %u.%u", HILO(ext->up_hdr_node_ptr),
@@ -1294,3 +1433,267 @@
return ret;
} /* check_fe_last_data_ext */
+
+/*
+ * check_dir_index()
+ *
+ */
+int check_dir_index (char *dirbuf, __u64 dir_offset)
+{
+ ocfs_file_entry *fe = NULL;
+ ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+ int ret = 0;
+ __u8 i;
+ __u8 j;
+ __u8 offset;
+ __u8 ind1[256];
+ __u8 ind2[256];
+ ocfs_disk_structure *dirst = &dirnode_t;
+
+ memset(ind1, 0, 256);
+ memset(ind2, 0, 256);
+
+ /* Any erroneous/duplicates/deleted files in the index */
+ for (i = 0, j = 0; i < dirnode->num_ent_used; ++i) {
+ offset = dirnode->index[i];
+
+ /* erroneous */
+ if (offset > 253)
+ continue;
+
+ /* duplicates */
+ if (ind1[offset] == 0)
+ ind1[offset] = 1;
+ else
+ continue;
+
+ /* deleted */
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirbuf) +
+ (offset * OCFS_SECTOR_SIZE));
+ if (IS_FE_DELETED(fe->sync_flags))
+ continue;
+
+ /* good ones in ind2 */
+ ind2[j++] = offset;
+ }
+
+ /* Use new num_ents_used */
+ if (j != dirnode->num_ent_used) {
+ LOG_ERROR("Incorrect number of entries found in dirnode");
+ if (ctxt.write_changes) {
+ globaldir = dirnode;
+ qsort(ind2, j, sizeof(__u8), fe_compare_func);
+ memcpy(dirnode->index, ind2, 256);
+ dirnode->num_ent_used = j;
+
+ if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
+ LOG_INTERNAL();
+ exit(1);
+ } else
+ LOG_PRINT("Fixed");
+ } else
+ LOG_PRINT("To fix, rerun with -w");
+ goto bail;
+ }
+
+ /* Is the index in sorted order */
+ globaldir = dirnode;
+ memset(ind1, 0, 256);
+ memcpy(ind1, dirnode->index, dirnode->num_ent_used);
+ qsort(ind1, dirnode->num_ent_used, sizeof(__u8), fe_compare_func);
+
+ if (memcmp(ind1, dirnode->index, dirnode->num_ent_used) != 0) {
+ LOG_ERROR("Bad dir index found");
+ if (ctxt.write_changes) {
+ memcpy(dirnode->index, ind1, dirnode->num_ent_used);
+
+ if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
+ LOG_INTERNAL();
+ exit(1);
+ } else
+ LOG_PRINT("Fixed");
+ } else
+ LOG_PRINT("To fix, rerun with -w");
+ }
+bail:
+ return ret;
+} /* check_dir_index */
+
+
+/*
+ * check_num_del()
+ *
+ */
+int check_num_del (char *dirbuf, __u64 dir_offset)
+{
+ ocfs_file_entry *fe = NULL;
+ ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+ int i;
+ int j;
+ int ret = 0;
+ __u8 offset;
+ __u8 ind[256];
+
+ if (dirnode->num_del == 0 && dirnode->num_ent_used == 0)
+ goto bail;
+
+ if (dirnode->num_del == 0 && dirnode->num_ent_used > 0) {
+ memset(ind, 0, 256);
+ for (i = 0; i < dirnode->num_ent_used; ++i) {
+ if (dirnode->index[i] >= dirnode->num_ent_used) {
+ ret = -1;
+ break;
+ }
+ }
+ goto bail;
+ }
+
+ /* num_del > 0 && dirnode->num_ents_used > 0 */
+ memset(ind, 0, 256);
+
+ offset = dirnode->first_del;
+ for (i = 0; i < dirnode->num_del; ++i) {
+ if (offset > 253) {
+ ret = -1;
+ break;
+ }
+
+ /* check if offset is in index and hence invalid */
+ for (j = 0; j < dirnode->num_ent_used; ++j) {
+ if (dirnode->index[j] == offset) {
+ ret = -1;
+ break;
+ }
+ }
+
+ /* check for circular list */
+ if (ind[offset]) {
+ ret = -1;
+ break;
+ } else
+ ind[offset] = 1;
+
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+ (offset * OCFS_SECTOR_SIZE));
+
+ /* file has to be deleted to be in the list */
+ if (fe->sync_flags) {
+ ret = -1;
+ break;
+ }
+
+ offset = (__u8)fe->next_del;
+ }
+
+bail:
+ return ret;
+} /* check_num_del */
+
+
+/*
+ * fix_num_del()
+ * Should be called after check_num_del()
+ */
+int fix_num_del (char *dirbuf, __u64 dir_offset)
+{
+ ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+ ocfs_file_entry *fe = NULL;
+ int i;
+ int j;
+ int num_del;
+ __u8 largest_off = 0;
+ __u8 ind[256];
+ __u8 offset;
+ __u64 feoff;
+ ocfs_disk_structure *dirst = &dirnode_t;
+ ocfs_disk_structure *fest = &fileent_t;
+
+ memset (ind, 0xFF, 256);
+
+ /* largest offset in index */
+ for (i = 0; i < dirnode->num_ent_used; ++i)
+ largest_off = max(largest_off, dirnode->index[i]);
+
+ num_del = largest_off - dirnode->num_ent_used + 1;
+
+ if (!num_del)
+ goto bail;
+
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode));
+
+ for (i = 0, j = 0; i < largest_off; ++i) {
+ if (IS_FE_DELETED(fe->sync_flags))
+ ind[j++] = i;
+ fe = (ocfs_file_entry *)((char *)fe + OCFS_SECTOR_SIZE);
+ }
+
+ if (j != num_del) {
+ LOG_ERROR("while fixing num_del");
+ exit(1);
+ }
+
+ /* write dirnode */
+ dirnode->num_del = num_del;
+ dirnode->first_del = ind[0];
+ if (dirst->write(ctxt.fd, dirbuf, dir_offset, 0) == -1) {
+ LOG_INTERNAL();
+ exit(1);
+ }
+
+ for (i = 0; i < j; ++i) {
+ offset = ind[i];
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+ (offset * OCFS_SECTOR_SIZE));
+ feoff = dir_offset + ((1 + offset) * OCFS_SECTOR_SIZE);
+ fe->next_del = ind[i+1];
+ /* write fe */
+ if (fest->write(ctxt.fd, (char *)fe, feoff, 0) == -1) {
+ LOG_INTERNAL();
+ exit(1);
+ }
+ }
+
+bail:
+ return 0;
+} /* fix_num_del */
+
+/*
+ * fix_fe_offsets()
+ *
+ */
+int fix_fe_offsets(char *dirbuf, __u64 dir_offset)
+{
+ ocfs_dir_node *dirnode = (ocfs_dir_node *)dirbuf;
+ ocfs_disk_structure *fest = &fileent_t;
+ ocfs_file_entry *fe;
+ __u64 feoff;
+ __u8 off;
+ int i;
+
+ for (i = 0; i < dirnode->num_ent_used; ++i) {
+ off = dirnode->index[i];
+ fe = (ocfs_file_entry *) (FIRST_FILE_ENTRY (dirnode) +
+ (off * OCFS_SECTOR_SIZE));
+ feoff = dir_offset + ((1 + off) * OCFS_SECTOR_SIZE);
+
+ if (IS_FE_DELETED(fe->sync_flags)) {
+ LOG_INTERNAL();
+ exit(1);
+ }
+
+ if (fe->this_sector != feoff ||
+ fe->dir_node_ptr != dir_offset) {
+ if (ctxt.write_changes) {
+ fe->this_sector = feoff;
+ fe->dir_node_ptr = dir_offset;
+ /* write fe */
+ if (fest->write(ctxt.fd, (char *)fe, feoff, 0) == -1) {
+ LOG_INTERNAL();
+ exit(1);
+ }
+ }
+ }
+ }
+
+ return 0;
+} /* fix_fe_offsets */
Modified: trunk/ocfs/fsck/verify.c
===================================================================
--- trunk/ocfs/fsck/verify.c 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/verify.c 2004-06-17 22:52:20 UTC (rev 73)
@@ -68,7 +68,7 @@
* __u32 last_node;
* __u64 cfg_seq_num;
*/
-int verify_nodecfghdr (int fd, char *buf, int idx, GHashTable **bad)
+int verify_nodecfghdr (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int ret = 0;
ocfs_node_config_hdr *hdr;
@@ -85,7 +85,7 @@
if (check_outside_bounds(buf, sizeof(ocfs_node_config_hdr)) == -1)
LOG_WARNING("nonzero bytes after the disk structure");
- ret = verify_disk_lock (fd, buf, idx, bad);
+ ret = verify_disk_lock (fd, buf, offset, idx, bad);
if (hdr->version != NODE_CONFIG_VER) {
mbr = find_class_member(cl, "version", &i);
@@ -110,7 +110,7 @@
* ocfs_guid guid;
* ocfs_ipc_config_info ipc_config;
*/
-int verify_nodecfginfo (int fd, char *buf, int idx, GHashTable **bad)
+int verify_nodecfginfo (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int ret = 0;
ocfs_disk_node_config_info *node;
@@ -125,7 +125,7 @@
if (check_outside_bounds(buf, sizeof(ocfs_disk_node_config_info)) == -1)
LOG_WARNING("nonzero bytes after the disk structure");
- ret = verify_disk_lock (fd, buf, idx, bad);
+ ret = verify_disk_lock (fd, buf, offset, idx, bad);
if (g_hash_table_size(*bad) == 0)
ret = 0;
@@ -137,17 +137,18 @@
* verify_system_file_entry()
*
*/
-int verify_system_file_entry (int fd, char *buf, int idx, GHashTable **bad, char *fname, int type)
+int verify_system_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad, char *fname, int type)
{
int ret, i;
ocfs_file_entry *fe;
ocfs_class_member *mbr;
ocfs_class *cl;
+ int slot;
cl = &ocfs_file_entry_class;
fe = (ocfs_file_entry *)buf;
- ret = verify_file_entry (fd, buf, idx, bad);
+ ret = verify_file_entry (fd, buf, offset, idx, bad);
if (strncmp(fe->filename, fname, strlen(fname)) != 0)
{
@@ -156,7 +157,8 @@
ret = -1;
}
- check_file_entry(fd, fe, fe->this_sector, true, "$");
+ slot = (((fe->this_sector - ctxt.hdr->data_start_off) / 512) % 32);
+ check_file_entry(fd, fe, fe->this_sector, slot, true, "$");
if (fe->disk_lock.curr_master != ((type+idx) % OCFS_MAXIMUM_NODES) &&
fe->disk_lock.curr_master != OCFS_INVALID_NODE_NUM &&
@@ -251,97 +253,97 @@
* verify_dir_alloc_bitmap()
*
*/
-int verify_dir_alloc_bitmap (int fd, char *buf, int idx, GHashTable **bad)
+int verify_dir_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s%d", "DirBitMapFile", idx+OCFS_FILE_DIR_ALLOC_BITMAP);
load_sysfile_bitmap(fd, buf, idx, true);
- return verify_system_file_entry (fd, buf, idx, bad, fname, OCFS_FILE_DIR_ALLOC_BITMAP);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_DIR_ALLOC_BITMAP);
} /* verify_dir_alloc_bitmap */
/*
* verify_file_alloc_bitmap()
*
*/
-int verify_file_alloc_bitmap (int fd, char *buf, int idx, GHashTable **bad)
+int verify_file_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s%d", "ExtentBitMapFile", idx+OCFS_FILE_FILE_ALLOC_BITMAP);
load_sysfile_bitmap(fd, buf, idx, false);
- return verify_system_file_entry (fd, buf, idx, bad, fname, OCFS_FILE_FILE_ALLOC_BITMAP);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_FILE_ALLOC_BITMAP);
} /* verify_file_alloc_bitmap */
/*
* verify_dir_alloc()
*
*/
-int verify_dir_alloc (int fd, char *buf, int idx, GHashTable **bad)
+int verify_dir_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s%d", "DirFile", idx+OCFS_FILE_DIR_ALLOC);
- return verify_system_file_entry (fd, buf, idx, bad, fname, OCFS_FILE_DIR_ALLOC);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_DIR_ALLOC);
} /* verify_dir_alloc */
/*
* verify_file_alloc()
*
*/
-int verify_file_alloc (int fd, char *buf, int idx, GHashTable **bad)
+int verify_file_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s%d", "ExtentFile", idx+OCFS_FILE_FILE_ALLOC);
- return verify_system_file_entry (fd, buf, idx, bad, fname, OCFS_FILE_FILE_ALLOC);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_FILE_ALLOC);
} /* verify_file_alloc */
/*
* verify_vol_metadata()
*
*/
-int verify_vol_metadata (int fd, char *buf, int idx, GHashTable **bad)
+int verify_vol_metadata (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s", "VolMetaDataFile"); // no file #
- return verify_system_file_entry (fd, buf, idx, bad, fname, OCFS_FILE_VOL_META_DATA);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_VOL_META_DATA);
} /* verify_vol_metadata */
/*
* verify_vol_metadata_log()
*
*/
-int verify_vol_metadata_log (int fd, char *buf, int idx, GHashTable **bad)
+int verify_vol_metadata_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s", "VolMetaDataLogFile"); // no file #
- return verify_system_file_entry (fd, buf, idx, bad, fname, OCFS_FILE_VOL_LOG_FILE);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, OCFS_FILE_VOL_LOG_FILE);
} /* verify_vol_metadata_log */
/*
* verify_cleanup_log()
*
*/
-int verify_cleanup_log (int fd, char *buf, int idx, GHashTable **bad)
+int verify_cleanup_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s%d", "CleanUpLogFile", idx+CLEANUP_FILE_BASE_ID);
- return verify_system_file_entry (fd, buf, idx, bad, fname, CLEANUP_FILE_BASE_ID);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, CLEANUP_FILE_BASE_ID);
} /* verify_cleanup_log */
/*
* verify_recover_log()
*
*/
-int verify_recover_log (int fd, char *buf, int idx, GHashTable **bad)
+int verify_recover_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
char fname[30];
sprintf(fname, "%s%d", "RecoverLogFile", idx+LOG_FILE_BASE_ID);
- return verify_system_file_entry (fd, buf, idx, bad, fname, LOG_FILE_BASE_ID);
+ return verify_system_file_entry (fd, buf, offset, idx, bad, fname, LOG_FILE_BASE_ID);
} /* verify_recover_log */
/*
* verify_volume_bitmap()
*
*/
-int verify_volume_bitmap (int fd, char *buf, int idx, GHashTable **bad)
+int verify_volume_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
return 0;
} /* verify_volume_bitmap */
@@ -350,7 +352,7 @@
* verify_publish_sector()
*
*/
-int verify_publish_sector (int fd, char *buf, int idx, GHashTable **bad)
+int verify_publish_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int i;
ocfs_publish *pub;
@@ -386,7 +388,7 @@
* verify_vote_sector()
*
*/
-int verify_vote_sector (int fd, char *buf, int idx, GHashTable **bad)
+int verify_vote_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int i;
ocfs_vote *vote;
@@ -414,17 +416,10 @@
* verify_dir_node()
*
*/
-int verify_dir_node (int fd, char *buf, int idx, GHashTable **bad)
+int verify_dir_node (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int ret = 0;
-// ocfs_dir_node *dir;
ocfs_class *cl;
-// int i;
-// ocfs_class_member *mbr;
-// int j;
-// __u64 size = 0;
-// __u64 off = 0;
-// char tmpstr[255];
cl = &ocfs_dir_node_class;
*bad = g_hash_table_new(g_direct_hash, g_direct_equal);
@@ -433,7 +428,7 @@
LOG_WARNING("nonzero bytes after the disk structure");
/* ocfs_disk_lock disk_lock; */
- ret = verify_disk_lock (fd, buf, idx, bad);
+ ret = verify_disk_lock (fd, buf, offset, idx, bad);
/* __u64 alloc_file_off; */
/* __u32 alloc_node; */
@@ -443,20 +438,36 @@
/* __s64 indx_node_ptr; */
/* __s64 next_del_ent_node; */
/* __s64 head_del_ent_node; */
+
+ /* __u8 index[256]; */
+ check_dir_index(buf, offset);
+
/* __u8 first_del; */
/* __u8 num_del; */
+ ret = check_num_del(buf, offset);
+ if (ret) {
+ LOG_ERROR("Bad list of deleted entries found");
+ if (ctxt.write_changes) {
+ fix_num_del(buf, offset);
+ LOG_PRINT("Fixed");
+ } else
+ LOG_PRINT("To fix, rerun with -w");
+ ret = 0;
+ }
+
/* __u8 num_ents; */
/* __u8 depth; */
/* __u8 num_ent_used; */
/* __u8 dir_node_flags; */
/* __u8 sync_flags; */
- /* __u8 index[256]; */
/* __u8 index_dirty; */
/* __u8 bad_off; */
/* __u64 num_tot_files; */
/* __u8 reserved[119]; */
/* __u8 file_ent[1]; */
+ fix_fe_offsets(buf, offset);
+
if (g_hash_table_size(*bad) == 0)
ret = 0;
@@ -467,7 +478,7 @@
* verify_file_entry()
*
*/
-int verify_file_entry (int fd, char *buf, int idx, GHashTable **bad)
+int verify_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int ret = 0;
ocfs_file_entry *fe;
@@ -487,7 +498,7 @@
LOG_WARNING("nonzero bytes after the disk structure");
/* ocfs_disk_lock disk_lock; */
- ret = verify_disk_lock (fd, buf, idx, bad);
+ ret = verify_disk_lock (fd, buf, offset, idx, bad);
/* bool local_ext; */
/* __s32 granularity; */
@@ -505,7 +516,8 @@
g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
}
- /* __s8 next_del; */
+ /* __s8 next_del; fix_fe_offset */
+
/* __u8 filename[OCFS_MAX_FILENAME_LENGTH]; */
/* __u16 filename_len; */
@@ -547,9 +559,9 @@
}
}
- /* __u64 dir_node_ptr; */
+ /* __u64 dir_node_ptr; fix_fe_offset */
- /* __u64 this_sector; */
+ /* __u64 this_sector; fix_fe_offset */
if (!fe->this_sector) {
mbr = find_class_member(cl, "this_sector", &i);
g_hash_table_insert(*bad, GINT_TO_POINTER(i), GINT_TO_POINTER(1));
@@ -580,7 +592,7 @@
* verify_extent_group()
*
*/
-int verify_extent_group (int fd, char *buf, int idx, GHashTable **bad, int type, __u64 up_ptr)
+int verify_extent_group (int fd, char *buf, __u64 offset, int idx, GHashTable **bad, int type, __u64 up_ptr)
{
ocfs_extent_group *ext;
ocfs_class *cl;
@@ -662,18 +674,18 @@
* verify_extent_header()
*
*/
-int verify_extent_header (int fd, char *buf, int idx, GHashTable **bad)
+int verify_extent_header (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
- return verify_extent_group(fd, buf, idx, bad, OCFS_EXTENT_HEADER, 0ULL);
+ return verify_extent_group(fd, buf, offset, idx, bad, OCFS_EXTENT_HEADER, 0ULL);
} /* verify_extent_header */
/*
* verify_extent_data()
*
*/
-int verify_extent_data (int fd, char *buf, int idx, GHashTable **bad)
+int verify_extent_data (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
- return verify_extent_group(fd, buf, idx, bad, OCFS_EXTENT_DATA, 0ULL);
+ return verify_extent_group(fd, buf, offset, idx, bad, OCFS_EXTENT_DATA, 0ULL);
} /* verify_extent_data */
@@ -704,7 +716,6 @@
goto bail;
}
-// if (myread(ctxt.fd, ctxt.vol_bm, (ctxt.hdr->num_clusters + 7 / 8)) == -1) {
if (myread(ctxt.fd, ctxt.vol_bm, VOL_BITMAP_BYTES) == -1) {
LOG_INTERNAL();
goto bail;
@@ -725,7 +736,7 @@
* verify_vol_disk_header()
*
*/
-int verify_vol_disk_header(int fd, char *buf, int idx, GHashTable **bad)
+int verify_vol_disk_header(int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
int len, ret = -1;
__u64 j;
@@ -925,7 +936,7 @@
* verify_vol_label()
*
*/
-int verify_vol_label (int fd, char *buf, int idx, GHashTable **bad)
+int verify_vol_label (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
ocfs_vol_label *lbl;
@@ -935,14 +946,14 @@
LOG_WARNING("nonzero bytes after the volume label structure");
}
- return verify_disk_lock (fd, buf, idx, bad);
+ return verify_disk_lock (fd, buf, offset, idx, bad);
} /* verify_vol_label */
/*
* verify_disk_lock()
*
*/
-int verify_disk_lock (int fd, char *buf, int idx, GHashTable **bad)
+int verify_disk_lock (int fd, char *buf, __u64 offset, int idx, GHashTable **bad)
{
ocfs_disk_lock *lock;
ocfs_class *cl;
Modified: trunk/ocfs/fsck/verify.h
===================================================================
--- trunk/ocfs/fsck/verify.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/fsck/verify.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -28,29 +28,29 @@
int test_member_range(ocfs_class *cl, const char *name, char *buf);
int check_outside_bounds(char *buf, int structsize);
-int verify_vol_disk_header (int fd, char *buf, int idx, GHashTable **bad);
-int verify_disk_lock (int fd, char *buf, int idx, GHashTable **bad);
-int verify_vol_label (int fd, char *buf, int idx, GHashTable **bad);
-int verify_nodecfghdr (int fd, char *buf, int idx, GHashTable **bad);
-int verify_nodecfginfo (int fd, char *buf, int idx, GHashTable **bad);
-int verify_cleanup_log (int fd, char *buf, int idx, GHashTable **bad);
-int verify_dir_alloc (int fd, char *buf, int idx, GHashTable **bad);
-int verify_dir_alloc_bitmap (int fd, char *buf, int idx, GHashTable **bad);
-int verify_file_alloc (int fd, char *buf, int idx, GHashTable **bad);
-int verify_file_alloc_bitmap (int fd, char *buf, int idx, GHashTable **bad);
-int verify_publish_sector (int fd, char *buf, int idx, GHashTable **bad);
-int verify_recover_log (int fd, char *buf, int idx, GHashTable **bad);
-int verify_vol_metadata (int fd, char *buf, int idx, GHashTable **bad);
-int verify_vol_metadata_log (int fd, char *buf, int idx, GHashTable **bad);
-int verify_volume_bitmap (int fd, char *buf, int idx, GHashTable **bad);
-int verify_vote_sector (int fd, char *buf, int idx, GHashTable **bad);
-int verify_dir_node (int fd, char *buf, int idx, GHashTable **bad);
-int verify_file_entry (int fd, char *buf, int idx, GHashTable **bad);
-int verify_extent_group (int fd, char *buf, int idx, GHashTable **bad,
+int verify_vol_disk_header (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_disk_lock (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_vol_label (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_nodecfghdr (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_nodecfginfo (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_cleanup_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_dir_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_dir_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_file_alloc (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_file_alloc_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_publish_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_recover_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_vol_metadata (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_vol_metadata_log (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_volume_bitmap (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_vote_sector (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_dir_node (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_extent_group (int fd, char *buf, __u64 offset, int idx, GHashTable **bad,
int type, __u64 up_ptr);
-int verify_extent_header (int fd, char *buf, int idx, GHashTable **bad);
-int verify_extent_data (int fd, char *buf, int idx, GHashTable **bad);
-int verify_system_file_entry (int fd, char *buf, int idx, GHashTable **bad,
+int verify_extent_header (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_extent_data (int fd, char *buf, __u64 offset, int idx, GHashTable **bad);
+int verify_system_file_entry (int fd, char *buf, __u64 offset, int idx, GHashTable **bad,
char *fname, int type);
int load_volume_bitmap(void);
Property changes on: trunk/ocfs/libocfs
___________________________________________________________________
Name: svn:ignore
+ libocfs.a
Modified: trunk/ocfs/libocfs/Common/inc/ocfsconst.h
===================================================================
--- trunk/ocfs/libocfs/Common/inc/ocfsconst.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/libocfs/Common/inc/ocfsconst.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -38,6 +38,12 @@
#define MISS_COUNT_VALUE 40
#define MIN_MISS_COUNT_VALUE 5
+/* values are in ms */
+#define OCFS_MIN_DISKHB 500
+#define OCFS_MAX_DISKHB 5000
+#define OCFS_MIN_HBTIMEO 10000
+#define OCFS_MAX_HBTIMEO 60000
+
#define OCFS_DEFAULT_DIR_NODE_SIZE (1024 * 128)
#define OCFS_DEFAULT_FILE_NODE_SIZE (512)
@@ -107,6 +113,8 @@
/* change this to some other sector, change format TODO */
#define OCFS_BITMAP_LOCK_OFFSET (OCFS_SECTOR_SIZE * 2)
+#define OCFS_MAX_BITMAP_SIZE 1024 * 1024
+
#define HEARTBEAT_METHOD_DISK (1)
#define HEARTBEAT_METHOD_IPC (2)
Modified: trunk/ocfs/libocfs/Common/inc/ocfsdef.h
===================================================================
--- trunk/ocfs/libocfs/Common/inc/ocfsdef.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/libocfs/Common/inc/ocfsdef.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -52,8 +52,8 @@
#define IS_VALID_OSB(_osb) ((_osb)->obj_id.type == OCFS_TYPE_OSB)
-#define IS_VALID_DISKHB(_hb) ((_hb) >= 500 && (_hb) <= 5000)
-#define IS_VALID_HBTIMEO(_to) ((_to) >= 10000 && (_to) <= 60000)
+#define IS_VALID_DISKHB(_hb) ((_hb) >= OCFS_MIN_DISKHB && (_hb) <= OCFS_MAX_DISKHB)
+#define IS_VALID_HBTIMEO(_to) ((_to) >= OCFS_MIN_HBTIMEO && (_to) <= OCFS_MAX_HBTIMEO)
#define OCFS_GET_EXTENT(vbo, extent, k) \
do { \
Modified: trunk/ocfs/libocfs/Common/inc/ocfsdisk.h
===================================================================
--- trunk/ocfs/libocfs/Common/inc/ocfsdisk.h 2004-06-17 02:02:11 UTC (rev 72)
+++ trunk/ocfs/libocfs/Common/inc/ocfsdisk.h 2004-06-17 22:52:20 UTC (rev 73)
@@ -133,7 +133,7 @@
ocfs_disk_lock disk_lock; // DISKLOCK
__u8 signature[8]; // CHAR[8]
__u64 alloc_file_off; // NUMBER RANGE(0,ULONG_LONG_MAX)
- __u32 alloc_node; // NUMBER RANGE(0,31)
+ __u32 alloc_node; // NODENUM
__u64 free_node_ptr; // DISKPTR
__u64 node_disk_off; // DISKPTR
__s64 next_node_ptr; // DISKPTR
More information about the Ocfs-tools-commits
mailing list