? client ? nb.patch ? patch-2.6.23.1 ? tmp.conf ? doc/pvfs2-quickstart.tex.1 ? src/apps/admin/.pvfs2-validate.c.swp ? src/apps/admin/pvfs2-dspace-dump.c ? src/client/sysint/.mgmt-repair-file.sm.swp Index: include/pvfs2-mgmt.h =================================================================== RCS file: /projects/cvsroot/pvfs2/include/pvfs2-mgmt.h,v retrieving revision 1.60 diff -u -a -p -r1.60 pvfs2-mgmt.h --- include/pvfs2-mgmt.h 17 Aug 2007 04:04:23 -0000 1.60 +++ include/pvfs2-mgmt.h 7 Nov 2007 21:47:14 -0000 @@ -23,6 +23,7 @@ #ifndef __PVFS2_MGMT_H #define __PVFS2_MGMT_H +#include "pvfs2-sysint.h" #include "pvfs2-types.h" /* non-blocking mgmt operation handle */ @@ -361,6 +362,24 @@ int PVFS_mgmt_testsome( int PVFS_mgmt_cancel(PVFS_mgmt_op_id op_id); +PVFS_error PVFS_imgmt_repair_file( + char *object_name, + PVFS_object_ref parent_ref, + PVFS_sys_attr attr, + PVFS_credentials *credentials, + PVFS_handle handle, + PVFS_sysresp_create *resp, + PVFS_sys_op_id *op_id, + void *user_ptr); + +PVFS_error PVFS_mgmt_repair_file( + char *object_name, + PVFS_object_ref parent_ref, + PVFS_sys_attr attr, + PVFS_credentials *credentials, + PVFS_handle handle, + PVFS_sysresp_create *resp); + int PVFS_mgmt_get_config( const PVFS_fs_id* fsid, PVFS_BMI_addr_t* addr, Index: src/apps/admin/pvfs2-validate.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-validate.c,v retrieving revision 1.2 diff -u -a -p -r1.2 pvfs2-validate.c --- src/apps/admin/pvfs2-validate.c 2 Jan 2007 17:10:35 -0000 1.2 +++ src/apps/admin/pvfs2-validate.c 7 Nov 2007 21:47:14 -0000 @@ -104,6 +104,16 @@ int main(int argc, char **argv) return -1; } + if (fsck_options->repair_stranded_objects && + !fsck_options->check_stranded_objects) + { + fprintf(stderr, "Error: option to check for stranded objects (-c) "); + fprintf(stderr, "required with repair option (See -R option below).\n"); + usage(argc, argv); + free(fsck_options); + return -1; + } + ret = PVFS_util_init_defaults(); if (ret != 0) { @@ -235,7 +245,10 @@ int validate_pvfs_object( ret = PVFS_fsck_get_attributes(fsck_options, pref, creds, &attributes); if(ret < 0) { - fprintf(stderr, "Error: [%s] cannot retrieve attributes.\n", current_path); + fprintf(stderr, + "Error: [%s] cannot retrieve attributes for object: " + "handle=[%llu] fsid=[%d]\n", + current_path, llu(pref->handle), pref->fs_id); } else if (attributes.attr.objtype == PVFS_TYPE_METAFILE) { @@ -345,6 +358,8 @@ static void usage( fprintf(stderr, " -v \t print version and exit\n"); fprintf(stderr, " -a \t fix all problems found (NOT IMPLEMENTED)\n"); fprintf(stderr, " -r \t run in interactive mode (NOT IMPLEMENTED)\n"); + fprintf(stderr, " -R \t repair stranded objects (requires -c)\n"); + fprintf(stderr, " \t (requires that -d refer to the PVFS2 root directory)\n"); fprintf(stderr, "\n\n"); fprintf(stderr, " Return Codes:\n"); fprintf(stderr, @@ -359,6 +374,9 @@ static void usage( static struct PINT_fsck_options *parse_args(int argc, char **argv) { + /* getopt variables */ + char *optarg; + int opt = 0; int path_length = 0; @@ -369,7 +387,7 @@ static struct PINT_fsck_options *parse_a return NULL; } - while ((opt = getopt(argc, argv, "d:VvharsfcF")) != EOF) + while ((opt = getopt(argc, argv, "d:VvharsfcFR")) != EOF) { switch (opt) { @@ -391,6 +409,9 @@ static struct PINT_fsck_options *parse_a break; case 'c': opts->check_stranded_objects = 1; + break; + case 'R': + opts->repair_stranded_objects = 1; break; case 'a': opts->fix_errors = 1; Index: src/client/sysint/client-state-machine.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/client/sysint/client-state-machine.c,v retrieving revision 1.88 diff -u -a -p -r1.88 client-state-machine.c --- src/client/sysint/client-state-machine.c 30 Aug 2007 00:13:41 -0000 1.88 +++ src/client/sysint/client-state-machine.c 7 Nov 2007 21:47:14 -0000 @@ -232,7 +232,8 @@ struct PINT_client_op_entry_s PINT_clien {&pvfs2_client_mgmt_remove_object_sm}, {&pvfs2_client_mgmt_remove_dirent_sm}, {&pvfs2_client_mgmt_create_dirent_sm}, - {&pvfs2_client_mgmt_get_dirdata_handle_sm} + {&pvfs2_client_mgmt_get_dirdata_handle_sm}, + {&pvfs2_client_mgmt_repair_file_sm} }; @@ -854,6 +855,7 @@ const char *PINT_client_get_name_str(int { PVFS_MGMT_REMOVE_OBJECT, "PVFS_MGMT_REMOVE_OBJECT" }, { PVFS_MGMT_REMOVE_DIRENT, "PVFS_MGMT_REMOVE_DIRENT" }, { PVFS_MGMT_CREATE_DIRENT, "PVFS_MGMT_CREATE_DIRENT" }, + { PVFS_MGMT_REPAIR_FILE, "PVFS_MGMT_REPAIR_FILE" }, { PVFS_MGMT_GET_DIRDATA_HANDLE, "PVFS_MGMT_GET_DIRDATA_HANDLE" }, { PVFS_SYS_GETEATTR, "PVFS_SYS_GETEATTR" }, Index: src/client/sysint/client-state-machine.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/client/sysint/client-state-machine.h,v retrieving revision 1.170 diff -u -a -p -r1.170 client-state-machine.h --- src/client/sysint/client-state-machine.h 17 Aug 2007 04:04:24 -0000 1.170 +++ src/client/sysint/client-state-machine.h 7 Nov 2007 21:47:14 -0000 @@ -656,6 +656,7 @@ enum PVFS_MGMT_REMOVE_DIRENT = 78, PVFS_MGMT_CREATE_DIRENT = 79, PVFS_MGMT_GET_DIRDATA_HANDLE = 80, + PVFS_MGMT_REPAIR_FILE = 81, PVFS_SERVER_GET_CONFIG = 200, PVFS_SERVER_FETCH_CONFIG = 201, PVFS_CLIENT_JOB_TIMER = 300, @@ -798,6 +799,7 @@ extern struct PINT_state_machine_s pvfs2 extern struct PINT_state_machine_s pvfs2_client_mgmt_remove_dirent_sm; extern struct PINT_state_machine_s pvfs2_client_mgmt_create_dirent_sm; extern struct PINT_state_machine_s pvfs2_client_mgmt_get_dirdata_handle_sm; +extern struct PINT_state_machine_s pvfs2_client_mgmt_repair_file_sm; extern struct PINT_state_machine_s pvfs2_client_get_eattr_sm; extern struct PINT_state_machine_s pvfs2_client_set_eattr_sm; extern struct PINT_state_machine_s pvfs2_client_del_eattr_sm; Index: src/client/sysint/mgmt-repair-file.sm =================================================================== RCS file: src/client/sysint/mgmt-repair-file.sm diff -N src/client/sysint/mgmt-repair-file.sm --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/client/sysint/mgmt-repair-file.sm 7 Nov 2007 21:47:14 -0000 @@ -0,0 +1,307 @@ +/* + * (C) 2007 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +/** \file + * \ingroup sysint + * + * PVFS2 system interface routines for repairing files. + */ + +#include +#include + +#include "client-state-machine.h" +#include "pvfs2-debug.h" +#include "pvfs2-dist-simple-stripe.h" +#include "job.h" +#include "gossip.h" +#include "str-utils.h" +#include "pint-cached-config.h" +#include "pint-distribution.h" +#include "PINT-reqproto-encode.h" +#include "pint-util.h" +#include "pint-dist-utils.h" +#include "ncache.h" +#include "pvfs2-internal.h" +#include "sys-create.h" + +extern job_context_id pint_client_sm_context; + +%% + +machine pvfs2_client_mgmt_repair_file_sm +{ + state init + { + rung create_init; + default => parent_getattr; + } + + state parent_getattr + { + jump pvfs2_client_getattr_sm; + success => parent_getattr_inspect; + default => cleanup; + } + + state parent_getattr_inspect + { + rung create_parent_getattr_inspect; + success => dspace_create_setup_msgpair; + default => cleanup; + } + + state dspace_create_setup_msgpair + { + rung create_dspace_create_setup_msgpair; + success => dspace_create_xfer_msgpair; + default => dspace_create_failure; + } + + state dspace_create_xfer_msgpair + { + jump pvfs2_msgpairarray_sm; + success => create_setattr_setup_msgpair; + default => dspace_create_failure; + } + + state dspace_create_failure + { + run create_dspace_create_failure; + default => cleanup; + } + + state create_setattr_setup_msgpair + { + rung create_setattr_setup_msgpair; + success => create_setattr_xfer_msgpair; + default => cleanup; + } + + state create_setattr_xfer_msgpair + { + jump pvfs2_msgpairarray_sm; + success => crdirent_setup_msgpair; + default => create_setattr_failure; + } + + state create_setattr_failure + { + rung create_setattr_failure; + default => delete_handles_setup_msgpair_array; + } + + state crdirent_setup_msgpair + { + rung create_crdirent_setup_msgpair; + success => crdirent_xfer_msgpair; + default => crdirent_failure; + } + + state crdirent_xfer_msgpair + { + jump pvfs2_msgpairarray_sm; + success => cleanup; + default => crdirent_failure; + } + + state crdirent_failure + { + rung create_crdirent_failure; + default => delete_handles_setup_msgpair_array; + } + + state delete_handles_setup_msgpair_array + { + rung create_delete_handles_setup_msgpair_array; + success => delete_handles_xfer_msgpair_array; + default => cleanup; + } + + state delete_handles_xfer_msgpair_array + { + jump pvfs2_msgpairarray_sm; + default => cleanup; + } + + state cleanup + { + rung create_cleanup; + CREATE_RETRY => init; + default => terminate; + } +} + +%% + +/** Initiate creation of a file with a specified distribution. + */ +PVFS_error PVFS_imgmt_repair_file( + char *object_name, + PVFS_object_ref parent_ref, + PVFS_sys_attr attr, + PVFS_credentials *credentials, + PVFS_handle handle, /*Pull in handle of dfile to create*/ + PVFS_sysresp_create *resp, + PVFS_sys_op_id *op_id, + void *user_ptr) +{ + int num_dfiles_req = 0; + PVFS_error ret = -PVFS_EINVAL; + PINT_client_sm *sm_p = NULL; + PINT_smcb *smcb = NULL; + + gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_imgmt_repair_file entered\n"); + + if ((parent_ref.handle == PVFS_HANDLE_NULL) || + (parent_ref.fs_id == PVFS_FS_ID_NULL) || + (object_name == NULL) || (resp == NULL)) + { + gossip_err("invalid (NULL) required argument\n"); + return ret; + } + + if ((attr.mask & PVFS_ATTR_SYS_ALL_SETABLE) != + PVFS_ATTR_SYS_ALL_SETABLE) + { + gossip_lerr("PVFS_imgmt_repair_file() failure: invalid attributes " + "specified\n"); + return ret; + } + + if ((attr.mask & PVFS_ATTR_SYS_DFILE_COUNT) && + ((attr.dfile_count < 1) || + (attr.dfile_count > PVFS_REQ_LIMIT_DFILE_COUNT))) + { + gossip_err("Error: invalid number of datafiles (%d) specified " + "in PVFS_mgmt_repair_file().\n", (int)attr.dfile_count); + return ret; + } + + if ((strlen(object_name) + 1) > PVFS_REQ_LIMIT_SEGMENT_BYTES) + { + return -PVFS_ENAMETOOLONG; + } + + PINT_smcb_alloc(&smcb, PVFS_MGMT_REPAIR_FILE, + sizeof(struct PINT_client_sm), + client_op_state_get_machine, + client_state_machine_terminate, + pint_client_sm_context); + if(smcb == NULL) + { + return -PVFS_ENOMEM; + } + sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); + + sm_p->u.create.datafile_handles = (PVFS_handle *)malloc( + sizeof(PVFS_handle)); + if (sm_p->u.create.datafile_handles == NULL) + { + gossip_err("create: Failed to allocate data handle array\n"); + return -PVFS_ENOMEM; + } + memset(sm_p->u.create.datafile_handles, 0,sizeof(PVFS_handle)); + + PINT_init_msgarray_params(&sm_p->msgarray_params, parent_ref.fs_id); + PINT_init_sysint_credentials(sm_p->cred_p, credentials); + sm_p->u.create.object_name = object_name; + sm_p->u.create.create_resp = resp; + sm_p->u.create.datafile_handles[0] = handle; /*Assign handle pulled in here*/ + PVFS_util_copy_sys_attr(&sm_p->u.create.sys_attr, &attr); + sm_p->u.create.stored_error_code = 0; + sm_p->u.create.retry_count = 0; + + sm_p->object_ref = parent_ref; + + /* use the basic_dist distribution to keep all on one server */ + sm_p->u.create.dist = PINT_dist_create("basic_dist"); + if (!sm_p->u.create.dist) + { + free(sm_p); + return -PVFS_ENOMEM; + } + + /*Set requested number of dfiles to 1*/ + num_dfiles_req = 1; + + /* Determine the number of dfiles, passing in desired value of 1 */ + ret = PINT_cached_config_get_num_dfiles(sm_p->object_ref.fs_id, + sm_p->u.create.dist, + num_dfiles_req, + &sm_p->u.create.num_data_files); + if (ret < 0) + { + gossip_err("Failed to get number of data servers\n"); + free(sm_p); + return ret; + } + + gossip_debug( + GOSSIP_CLIENT_DEBUG, "Creating file %s under %llu, %d\n", + object_name, llu(parent_ref.handle), parent_ref.fs_id); + + return PINT_client_state_machine_post( + smcb, op_id, user_ptr); +} + +/** Create a file with a specified distribution. + */ +PVFS_error PVFS_mgmt_repair_file( + char *object_name, + PVFS_object_ref parent_ref, + PVFS_sys_attr attr, + PVFS_credentials *credentials, + PVFS_handle handle, + PVFS_sysresp_create *resp) +{ + PVFS_error ret = -PVFS_EINVAL, error = 0; + PVFS_sys_op_id op_id; + + gossip_debug(GOSSIP_CLIENT_DEBUG, "PVFS_mgmt_repair_file entered\n"); + + ret = PVFS_imgmt_repair_file(object_name, parent_ref, attr, credentials, + handle, resp, &op_id, NULL); + if (ret) + { + PVFS_perror_gossip("PVFS_imgmt_repair_file call", ret); + error = ret; + } + else + { + ret = PVFS_sys_wait(op_id, "create", &error); + if (ret) + { + PVFS_perror_gossip("PVFS_sys_wait call", ret); + error = ret; + } + } + + PINT_sys_release(op_id); + return error; +} + +static PINT_sm_action create_dspace_create_failure( + struct PINT_smcb *smcb, job_status_s *js_p) +{ + PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); + sm_p->u.create.stored_error_code = js_p->error_code; + + gossip_debug(GOSSIP_CLIENT_DEBUG, + "create state: dspace_create_failure\n"); + return 1; +} + + +/* + * Local variables: + * mode: c + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ft=c ts=8 sts=4 sw=4 expandtab + */ Index: src/client/sysint/module.mk.in =================================================================== RCS file: /projects/cvsroot/pvfs2/src/client/sysint/module.mk.in,v retrieving revision 1.85 diff -u -a -p -r1.85 module.mk.in --- src/client/sysint/module.mk.in 13 Apr 2007 05:14:16 -0000 1.85 +++ src/client/sysint/module.mk.in 7 Nov 2007 21:47:14 -0000 @@ -50,6 +50,7 @@ CLIENT_SMCGEN := \ $(DIR)/mgmt-remove-object.c \ $(DIR)/mgmt-remove-dirent.c \ $(DIR)/mgmt-create-dirent.c \ + $(DIR)/mgmt-repair-file.c \ $(DIR)/mgmt-get-dirdata-handle.c # track generated .c files that need to be removed during dist clean, etc. Index: src/client/sysint/sys-create.h =================================================================== RCS file: src/client/sysint/sys-create.h diff -N src/client/sysint/sys-create.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/client/sysint/sys-create.h 7 Nov 2007 21:47:14 -0000 @@ -0,0 +1,43 @@ +/* + * (C) 2007 Clemson University and The University of Chicago + * + * See COPYING in top-level directory. + */ + +enum +{ + CREATE_RETRY = 170 +}; + +/* state function prototypes */ +PINT_sm_action create_init( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_dspace_create_setup_msgpair( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_datafiles_setup_msgpair_array( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_datafiles_failure( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_setattr_setup_msgpair( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_setattr_failure( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_crdirent_setup_msgpair( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_crdirent_failure( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_delete_handles_setup_msgpair_array( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_cleanup( + PINT_smcb *smcb, job_status_s *js_p); +PINT_sm_action create_parent_getattr_inspect( + PINT_smcb *smcb, job_status_s *js_p); +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 + * End: + * + * vim: ts=8 sts=4 sw=4 expandtab + */ + Index: src/client/sysint/sys-create.sm =================================================================== RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-create.sm,v retrieving revision 1.111 diff -u -a -p -r1.111 sys-create.sm --- src/client/sysint/sys-create.sm 30 Aug 2007 00:13:41 -0000 1.111 +++ src/client/sysint/sys-create.sm 7 Nov 2007 21:47:14 -0000 @@ -26,14 +26,10 @@ #include "pint-dist-utils.h" #include "ncache.h" #include "pvfs2-internal.h" +#include "sys-create.h" extern job_context_id pint_client_sm_context; -enum -{ - CREATE_RETRY = 170 -}; - /* completion function prototypes */ static int create_create_comp_fn( void *v_p, struct PVFS_server_resp *resp_p, int index); @@ -55,7 +51,7 @@ machine pvfs2_client_create_sm { state init { - run create_init; + rung create_init; default => parent_getattr; } @@ -68,14 +64,14 @@ machine pvfs2_client_create_sm state parent_getattr_inspect { - run create_parent_getattr_inspect; + rung create_parent_getattr_inspect; success => dspace_create_setup_msgpair; default => cleanup; } state dspace_create_setup_msgpair { - run create_dspace_create_setup_msgpair; + rung create_dspace_create_setup_msgpair; success => dspace_create_xfer_msgpair; default => cleanup; } @@ -89,7 +85,7 @@ machine pvfs2_client_create_sm state datafiles_setup_msgpair_array { - run create_datafiles_setup_msgpair_array; + rung create_datafiles_setup_msgpair_array; success => datafiles_xfer_msgpair_array; default => cleanup; } @@ -103,13 +99,13 @@ machine pvfs2_client_create_sm state datafiles_failure { - run create_datafiles_failure; + rung create_datafiles_failure; default => delete_handles_setup_msgpair_array; } state create_setattr_setup_msgpair { - run create_setattr_setup_msgpair; + rung create_setattr_setup_msgpair; success => create_setattr_xfer_msgpair; default => cleanup; } @@ -123,13 +119,13 @@ machine pvfs2_client_create_sm state create_setattr_failure { - run create_setattr_failure; + rung create_setattr_failure; default => delete_handles_setup_msgpair_array; } state crdirent_setup_msgpair { - run create_crdirent_setup_msgpair; + rung create_crdirent_setup_msgpair; success => crdirent_xfer_msgpair; default => crdirent_failure; } @@ -143,13 +139,13 @@ machine pvfs2_client_create_sm state crdirent_failure { - run create_crdirent_failure; + rung create_crdirent_failure; default => delete_handles_setup_msgpair_array; } state delete_handles_setup_msgpair_array { - run create_delete_handles_setup_msgpair_array; + rung create_delete_handles_setup_msgpair_array; success => delete_handles_xfer_msgpair_array; default => cleanup; } @@ -162,7 +158,7 @@ machine pvfs2_client_create_sm state cleanup { - run create_cleanup; + rung create_cleanup; CREATE_RETRY => init; default => terminate; } @@ -377,7 +373,7 @@ PVFS_error PVFS_sys_create( /****************************************************************/ -static PINT_sm_action create_init( +PINT_sm_action create_init( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -531,7 +527,7 @@ static int create_delete_handles_comp_fn return resp_p->status; } -static PINT_sm_action create_dspace_create_setup_msgpair( +PINT_sm_action create_dspace_create_setup_msgpair( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -590,7 +586,7 @@ static PINT_sm_action create_dspace_crea return SM_ACTION_COMPLETE; } -static PINT_sm_action create_datafiles_setup_msgpair_array( +PINT_sm_action create_datafiles_setup_msgpair_array( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -701,7 +697,7 @@ static PINT_sm_action create_datafiles_s return SM_ACTION_COMPLETE; } -static PINT_sm_action create_datafiles_failure( +PINT_sm_action create_datafiles_failure( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -712,7 +708,7 @@ static PINT_sm_action create_datafiles_f return SM_ACTION_COMPLETE; } -static PINT_sm_action create_setattr_setup_msgpair( +PINT_sm_action create_setattr_setup_msgpair( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -762,7 +758,7 @@ static PINT_sm_action create_setattr_set return SM_ACTION_COMPLETE; } -static PINT_sm_action create_setattr_failure( +PINT_sm_action create_setattr_failure( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -773,7 +769,7 @@ static PINT_sm_action create_setattr_fai return SM_ACTION_COMPLETE; } -static PINT_sm_action create_crdirent_setup_msgpair( +PINT_sm_action create_crdirent_setup_msgpair( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -819,7 +815,7 @@ static PINT_sm_action create_crdirent_se return SM_ACTION_COMPLETE; } -static PINT_sm_action create_crdirent_failure( +PINT_sm_action create_crdirent_failure( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -836,7 +832,7 @@ static PINT_sm_action create_crdirent_fa } /* delete the newly created meta and data handles */ -static PINT_sm_action create_delete_handles_setup_msgpair_array( +PINT_sm_action create_delete_handles_setup_msgpair_array( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -944,7 +940,7 @@ static PINT_sm_action create_delete_hand return SM_ACTION_COMPLETE; } -static PINT_sm_action create_cleanup( +PINT_sm_action create_cleanup( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); @@ -1044,7 +1040,7 @@ static PINT_sm_action create_cleanup( /** looks at the attributes of the parent directory and decides if it impacts * the file creation in any way */ -static PINT_sm_action create_parent_getattr_inspect( +PINT_sm_action create_parent_getattr_inspect( struct PINT_smcb *smcb, job_status_s *js_p) { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); Index: src/common/misc/fsck-utils.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/misc/fsck-utils.c,v retrieving revision 1.5 diff -u -a -p -r1.5 fsck-utils.c --- src/common/misc/fsck-utils.c 18 Oct 2007 18:42:24 -0000 1.5 +++ src/common/misc/fsck-utils.c 7 Nov 2007 21:47:14 -0000 @@ -11,6 +11,7 @@ #include #include "fsck-utils.h" +#include "client-state-machine.h" #define HANDLE_BATCH 1000 #define MAX_DIR_ENTS 64 @@ -62,13 +63,15 @@ struct PINT_handle_wrangler_handlelist PVFS_BMI_addr_t *addr_array; } PINT_handle_wrangler_handlelist; -#if 0 -/* not used yet */ static int PINT_handle_wrangler_get_stranded_handles( const PVFS_fs_id * cur_fs, int *num_stranded_handles, PVFS_handle ** stranded_handles); -#endif + +static int PINT_handle_wrangler_repair_stranded_handles( + const struct PINT_fsck_options *fsck_options, + const PVFS_fs_id * cur_fs, + const PVFS_credentials * creds); static int PINT_handle_wrangler_display_stranded_handles( const struct PINT_fsck_options *fsck_options, @@ -1046,6 +1049,13 @@ int PVFS_fsck_finalize( creds); } + /* repair leftover handles */ + if (fsck_options->repair_stranded_objects) + { + PINT_handle_wrangler_repair_stranded_handles(fsck_options, cur_fs, + creds); + } + return(0); } @@ -1413,14 +1423,14 @@ static int PINT_handle_wrangler_remove_h return ret; } -#if 0 /** * Returns the handles left over from the fsck */ static int PINT_handle_wrangler_get_stranded_handles( const PVFS_fs_id * cur_fs, /**< filesystem id */ int *num_stranded_handles, /**< number of handles in array of handles returned */ - PVFS_handle ** stranded_handles) /**< array of stranded handles on fs cur_fs */ + PVFS_handle ** stranded_handles) /**< array of stranded handles on fs cur_fs, + allocated here. Must be freed by the caller. */ { int ret = 0; int i = 0; @@ -1456,7 +1466,177 @@ static int PINT_handle_wrangler_get_stra return ret; } -#endif + +/** + * Repairs the handles left over from the fsck + * + * \retval 0 on success + * \retval -PVFS_error on failure + */ +static int PINT_handle_wrangler_repair_stranded_handles( + const struct PINT_fsck_options *fsck_options, /**< populated fsck options */ + const PVFS_fs_id * cur_fs, /**< filesystem id */ + const PVFS_credentials * creds) /**< populated credentials structure */ +{ + int i = 0; + int ret = 0; + int num_stranded_handles = 0; + PVFS_handle * stranded_handles = NULL; + PVFS_credentials credentials; + PVFS_sys_attr attr; + PVFS_sysresp_getattr attributes; + PVFS_sysresp_mkdir mkdir_resp; + PVFS_sysresp_create repair_resp; + PVFS_sysresp_lookup lookup_resp; + PVFS_object_ref parent_ref; + + memset(&credentials, 0, sizeof(credentials)); + memset(&attr, 0, sizeof(attr)); + memset(&attributes, 0, sizeof(attributes)); + memset(&mkdir_resp, 0, sizeof(mkdir_resp)); + memset(&repair_resp, 0, sizeof(repair_resp)); + memset(&lookup_resp, 0, sizeof(lookup_resp)); + memset(&parent_ref, 0, sizeof(parent_ref)); + + char cur_time[20]; + size_t num_chars; + struct tm cur_time_s; + time_t now; + now = time(NULL); + cur_time_s = *(localtime(&now)); + num_chars = strftime(cur_time,20,"%Y.%m.%d_%H.%M.%S",&cur_time_s); + if(num_chars == 0) + { + gossip_err("Error: could not get current time.\n"); + return(-PVFS_EINVAL); + } + + PVFS_util_gen_credentials(&credentials); + attr.owner = credentials.uid; + attr.group = credentials.gid; + attr.perms = 0700; /*owner (root) only*/ + attr.atime = attr.mtime = attr.ctime = 0; /*Set to "now"*/ + attr.mask = PVFS_ATTR_SYS_ALL_SETABLE; /*requires 'at lest' this*/ + + /*Set to dir in lost+found.*/ + /*look up the handle for lost+found*/ + char * parent_name = "/lost+found"; + ret = PVFS_sys_lookup(*cur_fs, parent_name, &credentials, &lookup_resp, + PVFS2_LOOKUP_LINK_NO_FOLLOW); + if (ret < 0) + { + gossip_err(" *** lookup failed on [%s] directory\n",parent_name); + return ret; + } + + ret = PVFS_sys_mkdir(cur_time, lookup_resp.ref, attr, &credentials, + &mkdir_resp); + if (ret < 0 && ret != -PVFS_EEXIST) + { + gossip_err(" *** mkdir failed on directory [/lost+found/%s]\n",cur_time); + return ret; + } + + parent_ref = mkdir_resp.ref; + + PINT_handle_wrangler_get_stranded_handles(cur_fs, + &num_stranded_handles, + &stranded_handles); + if(num_stranded_handles > 0) + { + printf("Repaired Objects:\n"); + printf("[ Handle ] [ FSID ] [ Size ] "); + printf("[ PVFS2 Server ] [ Filename ]\n"); + } + for(i = 0;i < num_stranded_handles; i++) + { + char name[PATH_MAX] = ""; + PVFS_object_ref dfile; + sprintf(name,"%d.dfile",i); + + /* get this objects attributes */ + dfile.handle = stranded_handles[i]; + dfile.fs_id = parent_ref.fs_id; + ret = PVFS_fsck_get_attributes(fsck_options, &dfile, + creds, &attributes); + + /* If get attributes fails skip to next, Only try to rescue dfiles */ + if(ret || attributes.attr.objtype != PVFS_TYPE_DATAFILE) + { + continue; + } + + ret = PVFS_mgmt_repair_file(name,parent_ref,attr,&credentials, + stranded_handles[i],&repair_resp); + if(ret < 0) + { + gossip_err("Unable to repair stranded handle [%llu]", + llu(stranded_handles[i])); + } + else + { + const char * server_name = NULL; + int j = 0; + int server_type = 0; + struct server_configuration_s *config; + PVFS_BMI_addr_t server_addr; + + /* get this objects attributes */ + ret = PVFS_fsck_get_attributes(fsck_options, &dfile, + creds, &attributes); + if(ret < 0) + { + PVFS_perror_gossip("PVFS_fsck_get_attributes", ret); + gossip_err("Error: unable to retrieve attributes for handle "); + gossip_err("[%llu]\n", llu(repair_resp.ref.handle)); + return(ret); + } + + /*Get the pretty server name */ + config = PINT_get_server_config_struct(*cur_fs); + /* find which server the handle is on */ + ret = PINT_cached_config_map_to_server(&server_addr, + stranded_handles[i], + *cur_fs); + if(ret < 0) + { + PVFS_perror_gossip("PINT_cached_config_map_to_server", ret); + gossip_err("Error: could not resolve handle [%llu] to server\n", + llu(stranded_handles[i])); + /* release mutex on server config */ + PINT_put_server_config_struct(config); + return(ret); + } + /* get the index of the server this handle is located on */ + for(j = 0; j < PINT_handle_wrangler_handlelist.num_servers; j++) + { + if(PINT_handle_wrangler_handlelist.addr_array[j] == server_addr) + { + /* retrieve the server name */ + server_name = PINT_cached_config_map_addr( + config, + *cur_fs, + PINT_handle_wrangler_handlelist. + addr_array[j], + &server_type); + break; + } + } + + /* release mutex on server config */ + PINT_put_server_config_struct(config); + + printf("%12llu %10d ",llu(stranded_handles[i]),repair_resp.ref.fs_id); + printf("%13lld ", lld(attributes.attr.size)); + printf(" %10s ", server_name); + printf(" %10s\n", name); + } + } + + free(stranded_handles); + + return ret; +} /** * Displays the handles left over from the fsck Index: src/common/misc/fsck-utils.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/misc/fsck-utils.h,v retrieving revision 1.1 diff -u -a -p -r1.1 fsck-utils.h --- src/common/misc/fsck-utils.h 6 Dec 2006 17:22:13 -0000 1.1 +++ src/common/misc/fsck-utils.h 7 Nov 2007 21:47:14 -0000 @@ -45,6 +45,7 @@ struct PINT_fsck_options { unsigned int fix_errors; /**< fix errors found */ + unsigned int repair_stranded_objects; /**< check for stranded objects */ unsigned int check_stranded_objects; /**< check for stranded objects */ unsigned int check_symlink_target; /**< checks symlink target for bad practice */ unsigned int check_dir_entry_names; /**< checks dirent names for bad practice */ Index: src/common/misc/state-machine.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/misc/state-machine.h,v retrieving revision 1.16 diff -u -a -p -r1.16 state-machine.h --- src/common/misc/state-machine.h 30 Aug 2007 00:13:43 -0000 1.16 +++ src/common/misc/state-machine.h 7 Nov 2007 21:47:14 -0000 @@ -57,6 +57,16 @@ enum PINT_state_code { */ #define PINT_STATE_STACK_SIZE 8 +/* All state action functions return this type which controls state + * machine action + */ +typedef enum { + SM_ACTION_DEFERRED = 0, + SM_ACTION_COMPLETE = 1, + SM_ACTION_TERMINATE = 2, + SM_ERROR = -1 /* this is a catastrophic error */ +} PINT_sm_action; + /* State machine control block - one per running instance of a state * machine */ @@ -100,7 +110,7 @@ struct PINT_state_s enum PINT_state_code flag; union { - int (*func)(struct PINT_smcb *, job_status_s *); + PINT_sm_action (*func)(struct PINT_smcb *, job_status_s *); struct PINT_state_machine_s *nested; } action; struct PINT_pjmp_tbl_s *pjtbl; @@ -120,16 +130,6 @@ struct PINT_tran_tbl_s enum PINT_state_code flag; struct PINT_state_s *next_state; }; - -/* All state action functions return this type which controls state - * machine action - */ -typedef enum { - SM_ACTION_DEFERRED = 0, - SM_ACTION_COMPLETE = 1, - SM_ACTION_TERMINATE = 2, - SM_ERROR = -1 /* this is a catastrophic error */ -} PINT_sm_action; extern char * PINT_sm_action_string[]; #define SM_ACTION_STRING(action) \ Index: src/common/statecomp/codegen.c =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/statecomp/codegen.c,v retrieving revision 1.26 diff -u -a -p -r1.26 codegen.c --- src/common/statecomp/codegen.c 30 Aug 2007 00:13:43 -0000 1.26 +++ src/common/statecomp/codegen.c 7 Nov 2007 21:47:14 -0000 @@ -196,6 +196,7 @@ void gen_state_action(enum state_action { switch (action) { case ACTION_RUN: + case ACTION_RUNG: fprintf(out_file, "\t .flag = SM_RUN ,\n"); fprintf(out_file, "\t .action.func = %s ,\n", run_func); fprintf(out_file,"\t .pjtbl = NULL ,\n"); Index: src/common/statecomp/parser.y =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/statecomp/parser.y,v retrieving revision 1.32 diff -u -a -p -r1.32 parser.y --- src/common/statecomp/parser.y 13 Apr 2007 05:14:23 -0000 1.32 +++ src/common/statecomp/parser.y 7 Nov 2007 21:47:14 -0000 @@ -61,6 +61,7 @@ extern int yylex(void); %token NESTED %token STATE %token RUN +%token RUNG %token PJMP %token JUMP %token STATE_RETURN @@ -115,6 +116,11 @@ state_body : state_action transition_l state_action : RUN identifier SEMICOLON { cur_state->action = ACTION_RUN; + cur_state->function_or_machine = $2; + } + | RUNG identifier SEMICOLON + { + cur_state->action = ACTION_RUNG; cur_state->function_or_machine = $2; } | JUMP identifier SEMICOLON Index: src/common/statecomp/scanner.l =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/statecomp/scanner.l,v retrieving revision 1.22 diff -u -a -p -r1.22 scanner.l --- src/common/statecomp/scanner.l 30 Aug 2007 00:13:43 -0000 1.22 +++ src/common/statecomp/scanner.l 7 Nov 2007 21:47:14 -0000 @@ -87,6 +87,7 @@ id [_a-zA-Z][_0-9a-zA-Z]* "nested" {RETURNVAL(NESTED);} "state" {RETURNVAL(STATE);} "run" {RETURNVAL(RUN);} +"rung" {RETURNVAL(RUNG);} "pjmp" {RETURNVAL(PJMP);} "jump" {RETURNVAL(JUMP);} "return" {RETURNVAL(STATE_RETURN);} Index: src/common/statecomp/statecomp.h =================================================================== RCS file: /projects/cvsroot/pvfs2/src/common/statecomp/statecomp.h,v retrieving revision 1.3 diff -u -a -p -r1.3 statecomp.h --- src/common/statecomp/statecomp.h 13 Apr 2007 05:14:23 -0000 1.3 +++ src/common/statecomp/statecomp.h 7 Nov 2007 21:47:14 -0000 @@ -21,6 +21,7 @@ enum transition_type enum state_action { ACTION_RUN, + ACTION_RUNG, ACTION_JUMP, ACTION_PJMP };