[Pvfs2-cvs] commit by shuangy in pvfs2/src/apps/admin: pvfs2-fsck.c
pvfs2-fsck.h
CVS commit program
cvs at parl.clemson.edu
Thu Dec 2 18:16:42 EST 2010
Update of /projects/cvsroot/pvfs2/src/apps/admin
In directory parlweb1:/tmp/cvs-serv18284/src/apps/admin
Modified Files:
Tag: Orange-Elaine-Distr-Dir-Branch
pvfs2-fsck.c pvfs2-fsck.h
Log Message:
fixed pvfs2-fsck.
Index: pvfs2-fsck.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-fsck.c,v
diff -p -u -r1.27 -r1.27.36.1
--- pvfs2-fsck.c 20 Nov 2008 01:16:44 -0000 1.27
+++ pvfs2-fsck.c 2 Dec 2010 23:16:42 -0000 1.27.36.1
@@ -553,6 +553,7 @@ int traverse_directory_tree(PVFS_fs_id c
ret = match_dirdata(hl,
NULL /* optional second handle list */,
pref,
+ getattr_resp.attr.dirdata_count,
creds);
if (ret != 0) {
assert(0);
@@ -566,37 +567,85 @@ int traverse_directory_tree(PVFS_fs_id c
int match_dirdata(struct handlelist *hl,
struct handlelist *alt_hl,
PVFS_object_ref dir_ref,
+ int dh_count,
PVFS_credentials *creds)
{
- int ret, idx;
- PVFS_handle dirdata_handle;
+ int ret, i, server_idx = 0, error = 0;
+ PVFS_handle *dh_handles;
+
+ dh_handles = (PVFS_handle *) malloc(dh_count * sizeof(PVFS_handle));
+ if (dh_handles == NULL)
+ {
+ assert(0);
+ }
- printf("# looking for dirdata match to %llu.\n",
+/*
+ printf("# looking for dirdata array for %llu.\n",
llu(dir_ref.handle));
+*/
- ret = PVFS_mgmt_get_dirdata_handle(dir_ref,
- &dirdata_handle,
- creds, NULL);
+ ret = PVFS_mgmt_get_dirdata_array(dir_ref, creds, dh_handles, dh_count, NULL);
if (ret != 0)
{
PVFS_perror("match_dirdata", ret);
+ free(dh_handles);
return -1;
}
- printf("# mgmt_get_dirdata returned %llu.\n", llu(dirdata_handle));
-
- if (handlelist_find_handle(hl, dirdata_handle, &idx) == 0)
+ for (i = 0; i < dh_count; i++)
{
- handlelist_remove_handle(hl, dirdata_handle, idx);
- return 0;
+ int in_main_list = 0, in_alt_list = 0;
+
+ if (handlelist_find_handle(hl, dh_handles[i], &server_idx) == 0)
+ {
+ in_main_list = 1;
+ }
+ else if (alt_hl &&
+ (handlelist_find_handle(alt_hl,
+ dh_handles[i],
+ &server_idx) == 0))
+ {
+ in_alt_list = 1;
+ }
+
+ if ((!in_main_list) && (!in_alt_list))
+ {
+ printf("# dirdata handle %llu missing from list\n",
+ llu(dh_handles[i]));
+ /* if possible, rebuild the dirdata handle. */
+ /* otherwise delete dirdata, return error to get
+ * directory and dirent removed.
+ */
+ dh_handles[i] = PVFS_HANDLE_NULL;
+ error++;
+ }
+
}
- if (alt_hl && handlelist_find_handle(alt_hl, dirdata_handle, &idx) == 0)
+
+ for (i = 0; i < dh_count; i++)
{
- handlelist_remove_handle(alt_hl, dirdata_handle, idx);
- return 0;
+ if (dh_handles[i] != PVFS_HANDLE_NULL) {
+ /* TODO: THIS IS A HACK; NEED BETTER WAY TO REMOVE FROM
+ * ONE OF TWO LISTS...
+ */
+
+ if (handlelist_find_handle(hl, dh_handles[i], &server_idx) == 0)
+ {
+ handlelist_remove_handle(hl,
+ dh_handles[i],
+ server_idx);
+ }
+ else {
+ handlelist_remove_handle(alt_hl,
+ dh_handles[i],
+ server_idx);
+ }
+ }
}
- return -1;
+ free(dh_handles);
+ return (error) ? -1 : 0;
+
}
int descend(PVFS_fs_id cur_fs,
@@ -703,6 +752,7 @@ int descend(PVFS_fs_id cur_fs,
ret = match_dirdata(hl,
alt_hl,
entry_ref,
+ getattr_resp.attr.dirdata_count,
creds);
if (ret != 0)
{
@@ -906,7 +956,7 @@ struct handlelist *find_sub_trees(PVFS_f
break;
case PVFS_TYPE_DIRECTORY:
/* add to directory list */
- printf("# looking for dirdata match to %llu.\n", llu(handle));
+ printf("# looking for dirdata array for %llu.\n", llu(handle));
descend(cur_fs,
hl_all,
@@ -1012,6 +1062,7 @@ struct handlelist *fill_lost_and_found(P
if (match_dirdata(hl_all,
alt_hl,
handle_ref,
+ getattr_resp.attr.dirdata_count,
creds) != 0)
{
ret = remove_object(handle_ref,
Index: pvfs2-fsck.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-fsck.h,v
diff -p -u -r1.5 -r1.5.82.1
--- pvfs2-fsck.h 20 May 2006 00:20:26 -0000 1.5
+++ pvfs2-fsck.h 2 Dec 2010 23:16:42 -0000 1.5.82.1
@@ -27,6 +27,7 @@ int traverse_directory_tree(PVFS_fs_id c
int match_dirdata(struct handlelist *hl,
struct handlelist *alt_hl,
PVFS_object_ref dir_ref,
+ int dh_count,
PVFS_credentials *creds);
int descend(PVFS_fs_id cur_fs,
More information about the Pvfs2-cvs
mailing list