[Pvfs2-cvs] commit by aching in pvfs2-1/src/apps/admin:
pvfs2-change-fsid.c pvfs2-check-server.c pvfs2-config-convert
pvfs2-drop-caches.c pvfs2-lsplus.c pvfs2-validate.c
pvfs2-xattr.c module.mk.in pvfs2-config.in pvfs2-cp.c
pvfs2-fsck.c pvfs2-genconfig pvfs2-ln.c pvfs2-ls.c
pvfs2-migrate-collection.c pvfs2-mkdir.c pvfs2-mkspace.c
pvfs2-perror.c pvfs2-ping.c pvfs2-remove-object.c pvfs2-rm.c
pvfs2-set-debugmask.c pvfs2-set-sync.c pvfs2-showcoll.c
pvfs2-stat.c pvfs2-touch.c pvfs2-viewdist.c
CVS commit program
cvs at parl.clemson.edu
Mon Jul 21 14:19:48 EDT 2008
Update of /projects/cvsroot/pvfs2-1/src/apps/admin
In directory parlweb1:/tmp/cvs-serv19729/apps/admin
Modified Files:
Tag: locking-branch
module.mk.in pvfs2-config.in pvfs2-cp.c pvfs2-fsck.c
pvfs2-genconfig pvfs2-ln.c pvfs2-ls.c
pvfs2-migrate-collection.c pvfs2-mkdir.c pvfs2-mkspace.c
pvfs2-perror.c pvfs2-ping.c pvfs2-remove-object.c pvfs2-rm.c
pvfs2-set-debugmask.c pvfs2-set-sync.c pvfs2-showcoll.c
pvfs2-stat.c pvfs2-touch.c pvfs2-viewdist.c
Added Files:
Tag: locking-branch
pvfs2-change-fsid.c pvfs2-check-server.c pvfs2-config-convert
pvfs2-drop-caches.c pvfs2-lsplus.c pvfs2-validate.c
pvfs2-xattr.c
Log Message:
Reverse merged and ported to HEAD.
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-change-fsid.c 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,637 @@
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+/** \file
+ * Update utility for updating fsid in PVFS2 collections
+ */
+
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <getopt.h>
+#include <limits.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <dirent.h>
+#include <limits.h>
+#include <inttypes.h>
+#include <time.h>
+
+#include <db.h>
+
+#include "pvfs2-config.h"
+#include "pvfs2.h"
+#include "pvfs2-internal.h"
+#include "trove.h"
+#include "mkspace.h"
+#include "pint-distribution.h"
+#include "pint-dist-utils.h"
+
+
+typedef struct
+{
+ char db_path[PATH_MAX];
+ char fs_conf[PATH_MAX];
+ char fs_name[PATH_MAX];
+ char storage_path[PATH_MAX];
+ int32_t old_fsid;
+ int32_t new_fsid;
+ char old_fsid_hex[9];
+ char new_fsid_hex[9];
+ int verbose;
+ int view_only;
+ int hex_dir_exists;
+} options_t;
+
+
+int update_fs_conf(void);
+int update_fsid_in_collections_db(void);
+int get_old_fsid_from_conf(void);
+int move_hex_dir(void);
+int process_args(int argc, char ** argv);
+int setup(int argc, char ** argv);
+void print_help(char * progname);
+
+static options_t opts;
+
+int main(int argc, char ** argv)
+{
+ int ret = 0;
+
+ ret = setup( argc, argv);
+ if(ret)
+ {
+ printf("Error in setup function\n");
+ return -1;
+ }
+
+ if(opts.old_fsid == opts.new_fsid)
+ {
+ if(opts.verbose)
+ {
+ printf("Nothing to do. Old/New fsids are the same.\n");
+ }
+ return 0;
+ }
+
+ /* Fix up the pvfs2-fs.conf file */
+ if(!opts.view_only)
+ {
+ ret = update_fs_conf();
+ if(ret)
+ {
+ fprintf(stderr,"Error updating %s\n", opts.fs_conf);
+ return -1;
+ }
+
+ if(opts.verbose)
+ {
+ printf("Successfully changed ID in [%s] from [%" PRId32 "] " \
+ "to [%" PRId32 "]\n",
+ opts.fs_conf,
+ opts.old_fsid,
+ opts.new_fsid);
+ }
+ }
+
+ /* Move the hex dir in the storage space */
+ ret = move_hex_dir();
+ if(ret)
+ {
+ fprintf(stderr,"Error moving hex directory in storage space.\n");
+ return -1;
+ }
+
+ if(opts.view_only)
+ {
+ printf("ID field in [%s] is dec=[%" PRId32 "] hex=[%s]\n",
+ opts.fs_conf,
+ opts.old_fsid,
+ opts.old_fsid_hex);
+ if(opts.hex_dir_exists)
+ {
+ printf("Found directory [%s] in storage space.\n",
+ opts.old_fsid_hex);
+ }
+ else
+ {
+ printf("Directory [%s] was NOT found in storage space.\n",
+ opts.old_fsid_hex);
+ }
+ }
+
+ /* Fix up the collections.db file */
+ ret = update_fsid_in_collections_db();
+ if(ret)
+ {
+ fprintf(stderr,"Error updating collections.db file\n");
+ return -1;
+ }
+
+ return 0;
+}
+
+int setup( int argc, char ** argv)
+{
+ int ret = 0;
+
+ /* Process command line args */
+ ret = process_args( argc, argv);
+ if(ret)
+ {
+ fprintf(stderr,"Error processing arguments\n");
+ return -1;
+ }
+
+
+ /* If no old_fsid provided, look it up in the conf file */
+ /* OR if view_only is specified, look it up */
+ if(!opts.old_fsid || opts.view_only)
+ {
+ ret = get_old_fsid_from_conf();
+ if(ret)
+ {
+ fprintf(stderr,"Error getting fsid.\n");
+ return -1;
+ }
+ }
+
+ /* If no new_fsid provided, generate one */
+ if(!opts.new_fsid && !opts.view_only)
+ {
+ srand( time(NULL) );
+ /* This number came from genconfig */
+ opts.new_fsid = (int32_t)abs(rand() * 2147483647);
+ sprintf(opts.new_fsid_hex,"%08" PRIx32, opts.new_fsid);
+ if(opts.verbose)
+ {
+ printf("Generated new fsid of %" PRId32 "\n", opts.new_fsid);
+ }
+ }
+
+ if(opts.verbose)
+ {
+ printf("Moving from fsid dec=[%" PRId32 "] hex=[%s] " \
+ "to fsid dec=[%" PRId32 "] hex=[%s]\n",
+ opts.old_fsid,
+ opts.old_fsid_hex,
+ opts.new_fsid,
+ opts.new_fsid_hex);
+ }
+
+ return 0;
+}
+
+int update_fs_conf(void)
+{
+ FILE * fptr = NULL;
+ char command[PATH_MAX];
+ char output[PATH_MAX];
+ char file[512][512];
+ struct stat buf;
+ int ret = 0, i = 0, j = 0;
+
+ /* See if fs_conf file exists */
+ ret = stat(opts.fs_conf, &buf);
+ if(ret)
+ {
+ fprintf(stderr,
+ "Error checking for file's existance. [%s]",
+ opts.fs_conf);
+ return -1;
+ }
+
+ memset(command,0,sizeof(command));
+ memset(output,0,sizeof(output));
+
+ /* See if old_fsid is in the file provided */
+ sprintf(command,
+ "grep ID %s | grep %" PRId32,
+ opts.fs_conf,
+ opts.old_fsid);
+ fptr = popen(command, "r");
+ if(fptr == NULL)
+ {
+ fprintf(stderr,"Error opening pipe. errno=%d",errno);
+ exit(-1);
+ }
+ fscanf(fptr, "%s", output);
+ if(!strncmp(output,"",PATH_MAX))
+ {
+ printf("fsid [%" PRId32 "] not found in file\n",opts.old_fsid);
+ return -1;
+ }
+ pclose(fptr);
+
+ memset(output,0,sizeof(output));
+
+ /* Replace old_fsid with new_fsid and write file back out */
+ sprintf(command,
+ "sed s/%" PRId32 "/%" PRId32 "/ %s",
+ opts.old_fsid,
+ opts.new_fsid,
+ opts.fs_conf);
+ fptr = popen(command, "r");
+ if(fptr == NULL)
+ {
+ fprintf(stderr,"Error opening pipe. errno=%d",errno);
+ exit(-1);
+ }
+
+ i = 0;
+ while( fgets(output, sizeof(output), fptr) )
+ {
+ strncpy(file[i],output,512);
+ i++;
+ }
+ pclose(fptr);
+
+ fptr = fopen(opts.fs_conf,"w");
+ for(j = 0; j < i; j++)
+ {
+ fprintf(fptr,"%s",file[j]);
+ }
+ fclose(fptr);
+
+ return 0;
+}
+
+int get_old_fsid_from_conf(void)
+{
+ FILE * fptr = NULL;
+ int i = 0;
+ char buffer[512][512];
+ int32_t read_fsid = 0;
+
+ memset(buffer, 0, sizeof(buffer));
+
+ fptr = fopen(opts.fs_conf,"r+");
+ if(fptr == NULL)
+ {
+ fprintf(stderr,"Error opening %s\n",opts.fs_conf);
+ return -1;
+ }
+
+ /* Read in file */
+ while(!feof(fptr))
+ {
+ fscanf(fptr,"%s",buffer[i]);
+ i++;
+ }
+ fclose(fptr);
+
+ /* Search for ID field */
+ i = 0;
+ while(strncmp(buffer[i],"ID",2))
+ {
+ i++;
+ }
+
+ /* Read in ID */
+ sscanf(buffer[++i],"%" SCNd32, &read_fsid);
+ if(!read_fsid)
+ {
+ fprintf(stderr,"Error: fsid not found.\n");
+ return -1;
+ }
+
+ opts.old_fsid = read_fsid;
+ sprintf(opts.old_fsid_hex,"%08" PRIx32,opts.old_fsid);
+
+ return 0;
+}
+
+int move_hex_dir(void)
+{
+ FILE * fptr = NULL;
+ char command[PATH_MAX];
+ char output[PATH_MAX];
+ struct stat buf;
+ char path[PATH_MAX];
+ char new_path[PATH_MAX];
+ int ret = 0;
+
+ memset(path,0,sizeof(path));
+ sprintf(path,"%s/%s", opts.storage_path, opts.old_fsid_hex);
+
+ /* See if directory exists */
+ ret = stat(path, &buf);
+ if(ret)
+ {
+ fprintf(stderr,
+ "Error checking for directory's existance. [%s]\n",
+ path);
+ return -1;
+ }
+
+ opts.hex_dir_exists = 1;
+
+ if(opts.view_only)
+ {
+ return 0;
+ }
+
+ memset(command,0,sizeof(command));
+ memset(output,0,sizeof(output));
+ memset(new_path,0,sizeof(new_path));
+
+ /* Move the directory */
+ sprintf(new_path, "%s/%s", opts.storage_path, opts.new_fsid_hex);
+ sprintf(command, "mv %s %s", path, new_path);
+
+ fptr = popen(command, "r");
+ if(fptr == NULL)
+ {
+ fprintf(stderr,"Error opening pipe. errno=%d",errno);
+ exit(-1);
+ }
+ fscanf(fptr, "%s", output);
+ if(strncmp(output,"",PATH_MAX))
+ {
+ printf("mv from [%s] to [%s] failed.\n", path, new_path);
+ return -1;
+ }
+ pclose(fptr);
+
+ if(opts.verbose)
+ {
+ printf("Successful dir move from [%s] to [%s]\n", path, new_path);
+ }
+
+ return 0;
+}
+
+int update_fsid_in_collections_db(void)
+{
+ int ret = -1;
+ DB * dbp;
+ DBT key, data;
+ DBC * dbc_p = NULL;
+ TROVE_coll_id coll_id;
+
+ ret = db_create(&dbp, NULL, 0);
+ if(ret != 0)
+ {
+ fprintf(stderr, "Error: db_create: %s.\n", db_strerror(ret));
+ return(-1);
+ }
+
+ /* open collections.db */
+ ret = dbp->open(dbp,
+ #ifdef HAVE_TXNID_PARAMETER_TO_DB_OPEN
+ NULL,
+ #endif
+ opts.db_path,
+ NULL,
+ DB_UNKNOWN,
+ 0,
+ 0);
+ if(ret != 0)
+ {
+ fprintf(stderr,"Error:dbp->open:%s.\n", db_strerror(ret));
+ return(-1);
+ }
+
+ ret = dbp->cursor(dbp, NULL, &dbc_p, 0);
+ if (ret != 0)
+ {
+ fprintf(stderr, "Error: dbp->cursor: %s.\n", db_strerror(ret));
+ dbp->close(dbp, 0);
+ return(-1);
+ }
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+
+ key.data = opts.fs_name;
+ key.size = strlen(opts.fs_name) + 1;
+ data.data = &coll_id;
+ data.ulen = sizeof(coll_id);
+ data.flags = DB_DBT_USERMEM;
+
+ ret = dbp->get(dbp, NULL, &key, &data, 0);
+ if (ret != 0)
+ {
+ fprintf(stderr, "Error: dbp->get: %s\n", db_strerror(ret));
+ return -1;
+ }
+
+ if(opts.view_only)
+ {
+ printf("DB entry in [%s] for key [%s] is dec=[%" PRId32 "] " \
+ "hex=[%08" PRIx32 "]\n",
+ opts.db_path,
+ opts.fs_name,
+ (int32_t)coll_id,
+ (int32_t)coll_id);
+ return 0;
+ }
+
+ if(opts.verbose)
+ {
+ printf("Retrieved key [%s] from db. Old value is [%" PRId32 "]\n",
+ (char *)key.data,
+ (int32_t)coll_id);
+ }
+
+ if(coll_id != opts.old_fsid)
+ {
+ fprintf(stderr, "Error: fsid retrieved does not equal old " \
+ "fsid provided! Found:[%" PRId32 "] " \
+ "Provided:[%" PRId32 "]\n",
+ (int32_t)coll_id,
+ opts.old_fsid);
+ return -1;
+ }
+
+ /* At this point the fsid (or coll_id) has been retrieved and checked */
+ /* against the user provided fsid (old) */
+ /* Replace old fsid with new fsid */
+
+ data.data = &(opts.new_fsid);
+ data.ulen = sizeof(opts.new_fsid);
+ data.flags = DB_DBT_USERMEM;
+
+ ret = dbp->put(dbp, NULL, &key, &data, 0);
+ if (ret != 0)
+ {
+ fprintf(stderr, "Error: dbp->get: %s\n", db_strerror(ret));
+ return -1;
+ }
+
+ /* At this point the new fsid should be properly inserted into the db */
+ /* Sanity check by retrieving again, and comparing to the new fsid */
+
+ data.data = &coll_id;
+ data.ulen = sizeof(coll_id);
+ data.flags = DB_DBT_USERMEM;
+
+ ret = dbp->get(dbp, NULL, &key, &data, 0);
+ if (ret != 0)
+ {
+ fprintf(stderr, "Error: dbp->get: %s\n", db_strerror(ret));
+ return -1;
+ }
+
+ if(coll_id != opts.new_fsid)
+ {
+ fprintf(stderr, "Error: fsid retrieved after the replace finished " \
+ "does not equal old fsid provided! "\
+ "Found:[%" PRId32 "] Provided:[%" PRId32 "]\n",
+ (int32_t)coll_id,
+ (int32_t)opts.old_fsid);
+ return -1;
+ }
+
+ if(opts.verbose)
+ {
+ printf("Retrieved key [%s] from db. New value is [%" PRId32 "]\n",
+ (char *)key.data, (int32_t)coll_id);
+ }
+
+ dbc_p->c_close(dbc_p);
+ dbp->close(dbp, 0);
+ return 0;
+}
+
+int process_args(int argc, char ** argv)
+{
+ int tmp_fsid = 0;
+ int ret = 0, option_index = 0;
+ static struct option long_opts[] =
+ {
+ {"help",0,0,0},
+ {"verbose",0,0,0},
+ {"oldfsid",1,0,0},
+ {"newfsid",1,0,0},
+ {"fsname",1,0,0},
+ {"dbpath",1,0,0},
+ {"fsconf",1,0,0},
+ {"storage",1,0,0},
+ {"view",0,0,0},
+ {0,0,0,0}
+ };
+
+ memset(&opts, 0, sizeof(options_t));
+ sprintf(opts.fs_name, "pvfs2-fs");
+
+ while ((ret = getopt_long(argc, argv, "",
+ long_opts, &option_index)) != -1)
+ {
+ switch (option_index)
+ {
+ case 0: /* help */
+ print_help(argv[0]);
+ exit(0);
+
+ case 1: /* verbose */
+ opts.verbose = 1;
+ break;
+
+ case 2: /* oldfsid */
+ tmp_fsid = atoi(optarg);
+ opts.old_fsid = (int32_t) tmp_fsid;
+ sprintf(opts.old_fsid_hex,"%08" PRIx32,opts.old_fsid);
+ break;
+
+ case 3: /* newfsid */
+ tmp_fsid = atoi(optarg);
+ opts.new_fsid = (int32_t) tmp_fsid;
+ sprintf(opts.new_fsid_hex,"%08" PRIx32,opts.new_fsid);
+ break;
+
+ case 4: /* fsname */
+ strncpy(opts.fs_name, optarg, PATH_MAX);
+ break;
+
+ case 5: /* dbpath */
+ strncpy(opts.db_path, optarg, PATH_MAX);
+ break;
+
+ case 6: /* fsconf */
+ strncpy(opts.fs_conf, optarg, PATH_MAX);
+ break;
+
+ case 7: /* storage */
+ strncpy(opts.storage_path, optarg, PATH_MAX);
+ break;
+
+ case 8: /* view */
+ opts.view_only = 1;
+ break;
+
+ default:
+ print_help(argv[0]);
+ return(-1);
+ }
+ option_index = 0;
+ }
+
+ /* db_path must be set */
+ if(!strncmp(opts.db_path,"",PATH_MAX))
+ {
+ fprintf(stderr,"Error: --dbpath option must be given.\n");
+ print_help(argv[0]);
+ return(-1);
+ }
+
+ /* fs_conf must be set */
+ if(!strncmp(opts.fs_conf,"",PATH_MAX))
+ {
+ fprintf(stderr,"Error: --fsconf option must be given.\n");
+ print_help(argv[0]);
+ return(-1);
+ }
+
+ /* storage_path must be set */
+ if(!strncmp(opts.storage_path,"",PATH_MAX))
+ {
+ fprintf(stderr,"Error: --storage option must be given.\n");
+ print_help(argv[0]);
+ return(-1);
+ }
+
+ return 0;
+}
+
+void print_help(char * progname)
+{
+ fprintf(stderr,"\nThis utility will update the fsid for a filesystem.\n");
+ fprintf(stderr,"The following arguments are required:\n");
+ fprintf(stderr,"--------------\n");
+ fprintf(stderr," --dbpath=</path/to/collections.db> "
+ "The current file system ID.\n");
+ fprintf(stderr," --fsconf=</path/to/pvfs2-fs.conf> "
+ "Fs config file for the the file system being modified.\n");
+ fprintf(stderr," --storage=</path/to/pvfs2-storage-space> "
+ "Local storage space for the the file system being modified.\n");
+ fprintf(stderr, "\n");
+ fprintf(stderr,"The following arguments are optional:\n");
+ fprintf(stderr,"--------------\n");
+ fprintf(stderr," --oldfsid=<fs_id> "
+ "The current file system ID. Else looked up from fs conf.\n");
+ fprintf(stderr," --newfsid=<fs_id> "
+ "The desired file system ID. Else generated as in genconfig.\n");
+ fprintf(stderr," --verbose "
+ "Print verbose messages during execution.\n");
+ fprintf(stderr," --help "
+ "Show this help listing.\n");
+ fprintf(stderr, "\n");
+ return;
+}
+
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-check-server.c 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,219 @@
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdlib.h>
+
+#include "pvfs2.h"
+#include "pvfs2-mgmt.h"
+
+#ifndef PVFS2_VERSION
+#define PVFS2_VERSION "Unknown"
+#endif
+
+struct options
+{
+ char* hostname;
+ char* fsname;
+ int port;
+ char* network_proto;
+};
+
+static struct options* parse_args(int argc, char* argv[]);
+static void usage(int argc, char** argv);
+
+int main(int argc, char **argv)
+{
+ int ret = -1;
+ struct options* user_opts = NULL;
+ struct PVFS_sys_mntent* tmp_ent = NULL;
+ char config_server[256];
+
+ /* look at command line arguments */
+ user_opts = parse_args(argc, argv);
+ if(!user_opts)
+ {
+ fprintf(stderr, "Error: failed to parse command "
+ "line arguments.\n");
+ usage(argc, argv);
+ return(-1);
+ }
+
+ sprintf(config_server, "%.50s://%.150s:%d", user_opts->network_proto,
+ user_opts->hostname, user_opts->port);
+
+ /* build mnt entry */
+ tmp_ent = PVFS_util_gen_mntent(config_server, user_opts->fsname);
+ if(!tmp_ent)
+ {
+ fprintf(stderr, "Error: failed to build mnt entry.\n");
+ return(-1);
+ }
+
+ ret = PVFS_sys_initialize(GOSSIP_NO_DEBUG);
+ if(ret < 0)
+ {
+ fprintf(stderr, "Error: failed to initialize PVFS2 library.\n");
+ return(-1);
+ }
+
+ ret = PVFS_sys_fs_add(tmp_ent);
+ if(ret < 0)
+ {
+ PVFS_perror("Error: could not retrieve configuration from server", ret);
+ return(-1);
+ }
+
+ PVFS_sys_finalize();
+
+ PVFS_util_gen_mntent_release(tmp_ent);
+
+ return(ret);
+}
+
+
+/* parse_args()
+ *
+ * parses command line arguments
+ *
+ * returns pointer to options structure on success, NULL on failure
+ */
+static struct options* parse_args(int argc, char* argv[])
+{
+ /* getopt stuff */
+ char flags[] = "h:f:n:p:";
+ int one_opt = 0;
+ int len = 0;
+
+ struct options* tmp_opts = NULL;
+ int ret = -1;
+
+ /* create storage for the command line options */
+ tmp_opts = (struct options*)malloc(sizeof(struct options));
+ if(!tmp_opts){
+ return(NULL);
+ }
+ memset(tmp_opts, 0, sizeof(struct options));
+
+ /* look at command line arguments */
+ while((one_opt = getopt(argc, argv, flags)) != EOF){
+ switch(one_opt)
+ {
+ case('h'):
+ len = strlen(optarg)+1;
+ tmp_opts->hostname = (char*)malloc(len+1);
+ if(!tmp_opts->hostname)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+ memset(tmp_opts->hostname, 0, len+1);
+ ret = sscanf(optarg, "%s", tmp_opts->hostname);
+ if(ret < 1){
+ free(tmp_opts);
+ return(NULL);
+ }
+ break;
+ case('f'):
+ len = strlen(optarg)+1;
+ tmp_opts->fsname = (char*)malloc(len+1);
+ if(!tmp_opts->fsname)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+ memset(tmp_opts->fsname, 0, len+1);
+ ret = sscanf(optarg, "%s", tmp_opts->fsname);
+ if(ret < 1){
+ free(tmp_opts);
+ return(NULL);
+ }
+ break;
+ case('n'):
+ len = strlen(optarg)+1;
+ tmp_opts->network_proto = (char*)malloc(len+1);
+ if(!tmp_opts->network_proto)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+ memset(tmp_opts->network_proto, 0, len+1);
+ ret = sscanf(optarg, "%s", tmp_opts->network_proto);
+ if(ret < 1){
+ free(tmp_opts);
+ return(NULL);
+ }
+ break;
+ case('p'):
+ ret = sscanf(optarg, "%d", &tmp_opts->port);
+ if(ret < 1){
+ free(tmp_opts);
+ return(NULL);
+ }
+ break;
+ case('?'):
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if(!tmp_opts->hostname || !tmp_opts->fsname ||
+ !tmp_opts->network_proto || !tmp_opts->port)
+ {
+ if(tmp_opts->hostname)
+ free(tmp_opts->hostname);
+
+ if(tmp_opts->fsname)
+ free(tmp_opts->fsname);
+
+ if(tmp_opts->network_proto)
+ free(tmp_opts->network_proto);
+
+ free(tmp_opts);
+ return(NULL);
+ }
+
+ return(tmp_opts);
+}
+
+static void usage(int argc, char** argv)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Usage : %s -h <server> "
+ "-f <fsname> -n <proto> -p <port>\n", argv[0]);
+
+ fprintf(stderr, "Check to see if a server is responding.\n\n");
+
+ fprintf(stderr," -h <server> name of the server\n");
+ fprintf(stderr," -f <fsname> name of the exported"
+ " file system\n");
+ fprintf(stderr," -n <proto> name of the network"
+ " protocol to use\n");
+ fprintf(stderr," -p <port> port number on which"
+ " the pvfs2 server is listening\n");
+
+ fprintf(stderr, "Example: %s -h localhost -f pvfs2-fs -n tcp -p 7500\n",
+ argv[0]);
+ return;
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-config-convert 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,153 @@
+#!/usr/bin/perl -w
+#
+# (C) 2001 Clemson University and The University of Chicago
+#
+# See COPYING in top-level directory.
+#
+# convert old format pvfs2 config files to the new single config format.
+#
+use Term::ReadLine;
+use Getopt::Long;
+
+# turn on strictness
+use strict 'vars';
+
+my $opt_servers = '';
+my $show_help = '';
+
+sub usage
+{
+
+ print STDERR <<"THIS";
+Usage: pvfs2-config-convert [OPTIONS] <old-fs.conf> <old-server.conf> <new-fs.conf>
+
+ The pvfs2-config-convert utility converts old fs.conf and server.conf config
+ files to the new format, where only a single fs.conf is used. Each of the
+ options in the server.conf files will be added to the new fs.conf. Note that
+ this script does not support server.conf files generated for configurations where
+ multiple servers are run on the same node.
+
+ This script requires the following argument:
+
+ --servers <STRING> hostnames of all servers. Can be
+ <prefix>{#-#,#,#-#,...}
+
+The rest of the arguments are optional:
+
+ --help This message
+
+THIS
+
+}
+
+GetOptions('servers=s' => \$opt_servers,
+ 'help' => \$show_help)
+ or die "Could not parse arguments. See -h for help\n";
+
+if($show_help)
+{
+ usage();
+ exit;
+}
+
+if($opt_servers eq '')
+{
+ die "Bad arguments. See -h for help.\n";
+}
+
+if(@ARGV != 3)
+{
+ die "Bad arguments. See -h for help.\n";
+}
+
+my @servers = parse_hostlist($opt_servers);
+
+open(NEWFSCONF, ">", $ARGV[2]) or die "Failed to create new fs.conf: $ARGV[2]: $!\n";
+open(OLDFSCONF, "<", $ARGV[0]) or die "Failed to open old fs.conf: $ARGV[0]: $!\n";
+
+my $line = undef;
+
+while(defined($line = <OLDFSCONF>))
+{
+ print NEWFSCONF $line;
+}
+
+close(OLDFSCONF);
+
+foreach my $s (@servers)
+{
+ open(OLDSCONF, "<", $ARGV[1] . "-$s") or die "Failed to open old server.conf: $ARGV[1]-$s: $!\n";
+
+ print NEWFSCONF "<ServerOptions>\n\tServer $s\n";
+ while(defined($line = <OLDSCONF>))
+ {
+ if($line !~ /HostID/)
+ {
+ print NEWFSCONF "\t" . $line;
+ }
+ }
+
+ print NEWFSCONF "</ServerOptions>\n";
+ close(OLDSCONF);
+}
+
+close(NEWFSCONF);
+
+sub parse_hostlist
+{
+ my $inputline = shift;
+ my @components = ();
+ my @hosts = ();
+
+ # we want to split the string into components seperated by comma
+ # but we don't want split components that have curly brackets. For example,
+ # we need to be sure that "hosta{1-4,8-12},hostb,hostc{1,2,3}" splits to
+ # hosta{1-4,8-12}
+ # hostb
+ # hostc{1,2,3}
+ #
+ @components = $inputline =~ /(?:,?[ ]*([^{,]+(?:{[^}]+})?))/g;
+ foreach my $comp (@components)
+ {
+ # if we've got a component that has {..}, then expand.
+ # match the prefix (hostname) and curly brackets
+ if($comp =~ /([^{]+){([^}]+)}/)
+ {
+ my $prefix = $1;
+ my $ranges = $2;
+
+ # split the ranges string on the commas
+ foreach my $r (split(/,/, $ranges))
+ {
+ if($r !~ /-/)
+ {
+ # only one number, just push it on
+ }
+ else
+ {
+ # min and max in this range. Add each of the indexes
+ my ($s, $f) = $r =~ /([0-9]+)-([0-9]+)/;
+ for(my $i = $s; $i <= $f; ++$i)
+ {
+ push @hosts, "$prefix$i";
+ }
+ }
+ }
+ }
+ else {
+ push @hosts, $comp;
+ }
+ }
+ return @hosts;
+}
+
+
+
+# Local variables:
+# c-indent-level: 4
+# c-basic-offset: 4
+# End:
+#
+# vim: ts=8 sts=4 sw=4 expandtab
+
+
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-drop-caches.c 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,179 @@
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#include "pvfs2.h"
+#include "pvfs2-mgmt.h"
+
+#ifndef PVFS2_VERSION
+#define PVFS2_VERSION "Unknown"
+#endif
+
+struct options
+{
+ char* mnt_point;
+ int mnt_point_set;
+};
+
+static struct options* parse_args(int argc, char* argv[]);
+static void usage(int argc, char** argv);
+
+int main(int argc, char **argv)
+{
+ int ret = -1;
+ PVFS_fs_id cur_fs;
+ struct options* user_opts = NULL;
+ char pvfs_path[PVFS_NAME_MAX] = {0};
+ PVFS_credentials creds;
+
+ /* look at command line arguments */
+ user_opts = parse_args(argc, argv);
+ if(!user_opts)
+ {
+ fprintf(stderr, "Error: failed to parse command line arguments.\n");
+ usage(argc, argv);
+ return(-1);
+ }
+
+ ret = PVFS_util_init_defaults();
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_util_init_defaults", ret);
+ return(-1);
+ }
+
+ /* translate local path into pvfs2 relative path */
+ ret = PVFS_util_resolve(user_opts->mnt_point,
+ &cur_fs, pvfs_path, PVFS_NAME_MAX);
+ if(ret < 0)
+ {
+ fprintf(stderr, "Error: could not find filesystem for %s in pvfstab\n",
+ user_opts->mnt_point);
+ return(-1);
+ }
+
+ PVFS_util_gen_credentials(&creds);
+
+ ret = PVFS_mgmt_setparam_all(cur_fs,
+ &creds,
+ PVFS_SERV_PARAM_DROP_CACHES,
+ 0,
+ NULL,
+ NULL /* detailed errors */);
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_mgmt_setparam_all", ret);
+ return(-1);
+ }
+
+ PVFS_sys_finalize();
+
+ return(ret);
+}
+
+
+/* parse_args()
+ *
+ * parses command line arguments
+ *
+ * returns pointer to options structure on success, NULL on failure
+ */
+static struct options* parse_args(int argc, char* argv[])
+{
+ char flags[] = "vm:";
+ int one_opt = 0;
+ int len = 0;
+
+ struct options* tmp_opts = NULL;
+ int ret = -1;
+
+ /* create storage for the command line options */
+ tmp_opts = (struct options*)malloc(sizeof(struct options));
+ if(!tmp_opts){
+ return(NULL);
+ }
+ memset(tmp_opts, 0, sizeof(struct options));
+
+ /* look at command line arguments */
+ while((one_opt = getopt(argc, argv, flags)) != EOF){
+ switch(one_opt)
+ {
+ case('v'):
+ printf("%s\n", PVFS2_VERSION);
+ exit(0);
+ case('m'):
+ len = strlen(optarg)+1;
+ tmp_opts->mnt_point = (char*)malloc(len+1);
+ if(!tmp_opts->mnt_point)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+ memset(tmp_opts->mnt_point, 0, len+1);
+ ret = sscanf(optarg, "%s", tmp_opts->mnt_point);
+ if(ret < 1){
+ free(tmp_opts);
+ return(NULL);
+ }
+ /* TODO: dirty hack... fix later. The remove_dir_prefix()
+ * function expects some trailing segments or at least
+ * a slash off of the mount point
+ */
+ strcat(tmp_opts->mnt_point, "/");
+ tmp_opts->mnt_point_set = 1;
+ break;
+ case('?'):
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ if(optind < argc)
+ {
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+
+ if(!tmp_opts->mnt_point_set)
+ {
+ free(tmp_opts);
+ return(NULL);
+ }
+
+ return(tmp_opts);
+}
+
+
+static void usage(int argc, char** argv)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Usage : %s [-m fs_mount_point]\n",
+ argv[0]);
+ fprintf(stderr, "Request that the OS flush and drop all I/O caches on servers.\n");
+
+ return;
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-lsplus.c 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,895 @@
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <pwd.h>
+#include <grp.h>
+#include <assert.h>
+#include <getopt.h>
+
+#include "pvfs2.h"
+#include "str-utils.h"
+#include "pvfs2-internal.h"
+
+#ifndef PVFS2_VERSION
+#define PVFS2_VERSION "Unknown"
+#endif
+
+
+/* TODO: this can be larger after system interface readdir logic
+ * is in place to break up large readdirs into multiple operations
+ */
+#define MAX_NUM_DIRENTS 32
+
+/*
+ arbitrarily restrict the number of paths
+ that this ls version can take as arguments
+*/
+#define MAX_NUM_PATHS 8
+
+/* optional parameters, filled in by parse_args() */
+struct options
+{
+ int list_human_readable;
+ int list_long;
+ int list_verbose;
+ int list_numeric_uid_gid;
+ int list_directory;
+ int list_no_group;
+ int list_almost_all;
+ int list_all;
+ int list_no_owner;
+ int list_inode;
+ int list_use_si_units;
+ char *start[MAX_NUM_PATHS];
+ int num_starts;
+};
+
+static char *process_name = NULL;
+static int do_timing = 0;
+
+static struct options* parse_args(int argc, char* argv[]);
+
+static void usage(int argc, char** argv);
+
+static void print_entry(
+ char *entry_name,
+ PVFS_handle handle,
+ PVFS_fs_id fs_id,
+ PVFS_sys_attr *attr,
+ int attr_error,
+ struct options *opts);
+
+static int do_list(
+ char *start,
+ int fs_id,
+ struct options *opts);
+
+static void print_entry_attr(
+ PVFS_handle handle,
+ char *entry_name,
+ PVFS_sys_attr *attr,
+ struct options *opts);
+
+#define print_dot_and_dot_dot_info_if_required(refn) \
+do { \
+ if (opts->list_all && !opts->list_almost_all) { \
+ /* \
+ we have to fake access to the .. handle \
+ since our sysint lookup doesn't return that \
+ kind of intermediate information. we can get \
+ this value, by manually resolving it with lookups \
+ on base dirs, but I'm not sure it's worth it \
+ */ \
+ if (opts->list_inode && !opts->list_long) { \
+ printf("%llu .\n",llu(refn.handle)); \
+ printf("%llu .. (faked)\n",llu(refn.handle)); \
+ } \
+ else if (opts->list_long) { \
+ print_entry(".", refn.handle, \
+ refn.fs_id, NULL, 0, opts); \
+ print_entry(".. (faked)", refn.handle, \
+ refn.fs_id, NULL, 0, opts); \
+ } \
+ else { \
+ printf(".\n"); \
+ printf("..\n"); \
+ } \
+ } \
+} while(0)
+
+/*
+ build a string of a specified length that's either
+ left or right justified based on the src string;
+ caller must free ptr passed out as *out_str_p
+*/
+static inline void format_size_string(
+ char *src_str, int num_spaces_total, char **out_str_p,
+ int right_justified, int hard_limit)
+{
+ int len = 0;
+ int spaces_size_allowed = 0;
+ char *buf = NULL, *start = NULL, *src_start = NULL;
+
+ assert(src_str);
+ len = strlen(src_str);
+
+ if (hard_limit)
+ {
+ spaces_size_allowed = (num_spaces_total ? num_spaces_total : len);
+ }
+ else
+ {
+ spaces_size_allowed = len;
+ if (len < num_spaces_total)
+ {
+ spaces_size_allowed = num_spaces_total;
+ }
+ }
+
+ buf = (char *)malloc(spaces_size_allowed+1);
+ assert(buf);
+
+ memset(buf,0,spaces_size_allowed+1);
+
+ if ((len > 0) && (len <= spaces_size_allowed))
+ {
+ memset(buf,' ',(spaces_size_allowed));
+
+ src_start = src_str;
+
+ if (right_justified)
+ {
+ start = &buf[(spaces_size_allowed-(len))];
+ }
+ else
+ {
+ start = buf;
+ }
+
+ while(src_start && (*src_start))
+ {
+ *start++ = *src_start++;
+ }
+ *out_str_p = strdup(buf);
+ }
+ else if (len > 0)
+ {
+ /* if the string is too long, don't format it */
+ *out_str_p = strdup(src_str);
+ }
+ else if (len == 0)
+ {
+ *out_str_p = strdup("");
+ }
+ free(buf);
+}
+
+void print_entry_attr(
+ PVFS_handle handle,
+ char *entry_name,
+ PVFS_sys_attr *attr,
+ struct options *opts)
+{
+ char buf[128] = {0}, *formatted_size = NULL;
+ char *formatted_owner = NULL, *formatted_group = NULL;
+ struct group *grp = NULL;
+ struct passwd *pwd = NULL;
+ char *empty_str = "";
+ char *owner = empty_str, *group = empty_str;
+ char *inode = empty_str;
+ time_t mtime;
+ struct tm *time;
+ PVFS_size size = 0;
+ char scratch_owner[16] = {0}, scratch_group[16] = {0};
+ char scratch_size[16] = {0}, scratch_inode[16] = {0};
+ char f_type = '-';
+ char group_x_char = '-';
+
+ if (!opts->list_all && (entry_name[0] == '.'))
+ {
+ return;
+ }
+ if (attr == NULL)
+ {
+ return;
+ }
+ mtime = (time_t)attr->mtime;
+ time = localtime(&mtime);
+
+ snprintf(scratch_owner,16,"%d",(int)attr->owner);
+ snprintf(scratch_group,16,"%d",(int)attr->group);
+
+ if (opts->list_inode)
+ {
+ snprintf(scratch_inode,16,"%llu ",llu(handle));
+ inode = scratch_inode;
+ }
+
+ if ((attr->objtype == PVFS_TYPE_METAFILE) &&
+ (attr->mask & PVFS_ATTR_SYS_SIZE))
+ {
+ size = attr->size;
+ }
+ else if ((attr->objtype == PVFS_TYPE_SYMLINK) &&
+ (attr->link_target))
+ {
+ size = (PVFS_size)strlen(attr->link_target);
+ }
+ else if (attr->objtype == PVFS_TYPE_DIRECTORY)
+ {
+ size = (PVFS_size)4096;
+ }
+
+ if (opts->list_human_readable)
+ {
+ PVFS_util_make_size_human_readable(
+ size,scratch_size,16,opts->list_use_si_units);
+ }
+ else
+ {
+ snprintf(scratch_size,16, "%lld", lld(size));
+ }
+ format_size_string(scratch_size,11,&formatted_size,1,1);
+
+ if (!opts->list_no_owner)
+ {
+ owner = scratch_owner;
+ }
+ if (!opts->list_no_group)
+ {
+ group = scratch_group;
+ }
+
+ if (!opts->list_numeric_uid_gid)
+ {
+ if (!opts->list_no_owner)
+ {
+ pwd = getpwuid((uid_t)attr->owner);
+ owner = (pwd ? pwd->pw_name : scratch_owner);
+ }
+
+ if (!opts->list_no_group)
+ {
+ grp = getgrgid((gid_t)attr->group);
+ group = (grp ? grp->gr_name : scratch_group);
+ }
+ }
+
+ /* for owner and group allow the fields to grow larger than 8 if
+ * necessary (set hard_limit to 0), but pad anything smaller to
+ * take up 8 spaces.
+ */
+ format_size_string(owner,8,&formatted_owner,0,0);
+ format_size_string(group,8,&formatted_group,0,0);
+
+ if (attr->objtype == PVFS_TYPE_DIRECTORY)
+ {
+ f_type = 'd';
+ }
+ else if (attr->objtype == PVFS_TYPE_SYMLINK)
+ {
+ f_type = 'l';
+ }
+
+ /* special case to set setgid display for groups if needed */
+ if(attr->perms & PVFS_G_SGID)
+ {
+ group_x_char = ((attr->perms & PVFS_G_EXECUTE) ? 's' : 'S');
+ }
+ else
+ {
+ group_x_char = ((attr->perms & PVFS_G_EXECUTE) ? 'x' : '-');
+ }
+
+ snprintf(buf,128,"%s%c%c%c%c%c%c%c%c%c%c 1 %s %s %s "
+ "%.4d-%.2d-%.2d %.2d:%.2d %s",
+ inode,
+ f_type,
+ ((attr->perms & PVFS_U_READ) ? 'r' : '-'),
+ ((attr->perms & PVFS_U_WRITE) ? 'w' : '-'),
+ ((attr->perms & PVFS_U_EXECUTE) ? 'x' : '-'),
+ ((attr->perms & PVFS_G_READ) ? 'r' : '-'),
+ ((attr->perms & PVFS_G_WRITE) ? 'w' : '-'),
+ group_x_char,
+ ((attr->perms & PVFS_O_READ) ? 'r' : '-'),
+ ((attr->perms & PVFS_O_WRITE) ? 'w' : '-'),
+ ((attr->perms & PVFS_O_EXECUTE) ? 'x' : '-'),
+ formatted_owner,
+ formatted_group,
+ formatted_size,
+ (time->tm_year + 1900),
+ (time->tm_mon + 1),
+ time->tm_mday,
+ (time->tm_hour),
+ (time->tm_min),
+ entry_name);
+
+ if (formatted_size)
+ {
+ free(formatted_size);
+ }
+ if (formatted_owner)
+ {
+ free(formatted_owner);
+ }
+ if (formatted_group)
+ {
+ free(formatted_group);
+ }
+
+ if (attr->objtype == PVFS_TYPE_SYMLINK)
+ {
+ assert(attr->link_target);
+
+ if (opts->list_long)
+ {
+ printf("%s -> %s\n", buf, attr->link_target);
+ }
+ else
+ {
+ printf("%s\n",buf);
+ }
+ }
+ else
+ {
+ printf("%s\n",buf);
+ }
+}
+
+void print_entry(
+ char *entry_name,
+ PVFS_handle handle,
+ PVFS_fs_id fs_id,
+ PVFS_sys_attr *attr,
+ int attr_error,
+ struct options *opts)
+{
+ int ret = -1;
+ PVFS_object_ref ref;
+ PVFS_credentials credentials;
+ PVFS_sysresp_getattr getattr_response;
+
+ if (!opts->list_long)
+ {
+ if (opts->list_inode)
+ {
+ printf("%llu %s\n", llu(handle), entry_name);
+ }
+ else
+ {
+ printf("%s\n", entry_name);
+ }
+ return;
+ }
+
+ if (attr_error == 0)
+ {
+ if(!attr)
+ {
+ /* missing attributes (possibly for . or .. entries); get them
+ * the old fashioned way
+ */
+ ref.handle = handle;
+ ref.fs_id = fs_id;
+
+ memset(&getattr_response,0, sizeof(PVFS_sysresp_getattr));
+ PVFS_util_gen_credentials(&credentials);
+
+ ret = PVFS_sys_getattr(ref, PVFS_ATTR_SYS_ALL_NOHINT,
+ &credentials, &getattr_response);
+ if (ret)
+ {
+ fprintf(stderr,"Failed to get attributes on handle %llu,%d\n",
+ llu(handle),fs_id);
+ PVFS_perror("Getattr failure", ret);
+ return;
+ }
+ print_entry_attr(handle, entry_name, &getattr_response.attr, opts);
+ }
+ else
+ {
+ print_entry_attr(handle, entry_name, attr, opts);
+ }
+ }
+}
+
+static double Wtime(void)
+{
+ struct timeval t;
+ gettimeofday(&t, NULL);
+ return((double)t.tv_sec * 1e03 + (double)(t.tv_usec) * 1e-03);
+}
+
+int do_list(
+ char *start,
+ int fs_id,
+ struct options *opts)
+{
+ int i = 0, printed_dot_info = 0;
+ int ret = -1;
+ int pvfs_dirent_incount;
+ char *name = NULL, *cur_file = NULL;
+ PVFS_handle cur_handle;
+ PVFS_sysresp_lookup lk_response;
+ PVFS_sysresp_readdirplus rdplus_response;
+ PVFS_sysresp_getattr getattr_response;
+ PVFS_credentials credentials;
+ PVFS_object_ref ref;
+ PVFS_ds_position token;
+ uint64_t dir_version = 0;
+ double begin = 0., end;
+
+ name = start;
+
+ memset(&lk_response,0,sizeof(PVFS_sysresp_lookup));
+ PVFS_util_gen_credentials(&credentials);
+
+ ret = PVFS_sys_lookup(fs_id, name, &credentials,
+ &lk_response, PVFS2_LOOKUP_LINK_NO_FOLLOW);
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_sys_lookup", ret);
+ return -1;
+ }
+
+ ref.handle = lk_response.ref.handle;
+ ref.fs_id = fs_id;
+ pvfs_dirent_incount = MAX_NUM_DIRENTS;
+
+ memset(&getattr_response,0,sizeof(PVFS_sysresp_getattr));
+ if (PVFS_sys_getattr(ref, PVFS_ATTR_SYS_ALL,
+ &credentials, &getattr_response) == 0)
+ {
+ if ((getattr_response.attr.objtype == PVFS_TYPE_METAFILE) ||
+ (getattr_response.attr.objtype == PVFS_TYPE_SYMLINK) ||
+ ((getattr_response.attr.objtype == PVFS_TYPE_DIRECTORY) &&
+ (opts->list_directory)))
+ {
+ char segment[128] = {0};
+ PVFS_sysresp_getparent getparent_resp;
+ PINT_remove_base_dir(name, segment, 128);
+ if (strcmp(segment,"") == 0)
+ {
+ snprintf(segment,128,"/");
+ }
+
+ if (getattr_response.attr.objtype == PVFS_TYPE_DIRECTORY)
+ {
+ if (PVFS_sys_getparent(ref.fs_id, name, &credentials,
+ &getparent_resp) == 0)
+ {
+ print_dot_and_dot_dot_info_if_required(
+ getparent_resp.parent_ref);
+ }
+ }
+
+ if (opts->list_long)
+ {
+ print_entry_attr(ref.handle, segment,
+ &getattr_response.attr, opts);
+ }
+ else
+ {
+ print_entry(segment, ref.handle, ref.fs_id,
+ NULL,
+ 0,
+ opts);
+ }
+ return 0;
+ }
+ }
+
+ if (do_timing)
+ begin = Wtime();
+ token = 0;
+ do
+ {
+ memset(&rdplus_response, 0, sizeof(PVFS_sysresp_readdirplus));
+ ret = PVFS_sys_readdirplus(
+ ref, (!token ? PVFS_READDIR_START : token),
+ pvfs_dirent_incount, &credentials,
+ (opts->list_long) ? PVFS_ATTR_SYS_ALL : PVFS_ATTR_SYS_ALL_NOSIZE,
+ &rdplus_response);
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_sys_readdir", ret);
+ return -1;
+ }
+
+ if (dir_version == 0)
+ {
+ dir_version = rdplus_response.directory_version;
+ }
+ else if (opts->list_verbose)
+ {
+ if (dir_version != rdplus_response.directory_version)
+ {
+ fprintf(stderr, "*** directory changed! listing may "
+ "not be correct\n");
+ dir_version = rdplus_response.directory_version;
+ }
+ }
+
+ if (!printed_dot_info)
+ {
+ /*
+ the list_all option prints files starting with .;
+ the almost_all option skips the '.', '..' printing
+ */
+ print_dot_and_dot_dot_info_if_required(ref);
+ printed_dot_info = 1;
+ }
+
+ for(i = 0; i < rdplus_response.pvfs_dirent_outcount; i++)
+ {
+ cur_file = rdplus_response.dirent_array[i].d_name;
+ cur_handle = rdplus_response.dirent_array[i].handle;
+
+ print_entry(cur_file, cur_handle, fs_id,
+ &rdplus_response.attr_array[i],
+ rdplus_response.stat_err_array[i],
+ opts);
+ }
+ token += rdplus_response.pvfs_dirent_outcount;
+
+ if (rdplus_response.pvfs_dirent_outcount)
+ {
+ free(rdplus_response.dirent_array);
+ rdplus_response.dirent_array = NULL;
+ free(rdplus_response.stat_err_array);
+ rdplus_response.stat_err_array = NULL;
+ for (i = 0; i < rdplus_response.pvfs_dirent_outcount; i++) {
+ if (rdplus_response.attr_array)
+ {
+ PVFS_util_release_sys_attr(&rdplus_response.attr_array[i]);
+ }
+ }
+ free(rdplus_response.attr_array);
+ rdplus_response.attr_array = NULL;
+ }
+
+ } while(rdplus_response.pvfs_dirent_outcount == pvfs_dirent_incount);
+ if (do_timing) {
+ end = Wtime();
+ printf("PVFS_sys_readdirplus took %g msecs\n",
+ (end - begin));
+ }
+
+ if (rdplus_response.pvfs_dirent_outcount)
+ {
+ free(rdplus_response.dirent_array);
+ rdplus_response.dirent_array = NULL;
+ free(rdplus_response.stat_err_array);
+ rdplus_response.stat_err_array = NULL;
+ for (i = 0; i < rdplus_response.pvfs_dirent_outcount; i++) {
+ if (rdplus_response.attr_array)
+ {
+ PVFS_util_release_sys_attr(&rdplus_response.attr_array[i]);
+ }
+ }
+ free(rdplus_response.attr_array);
+ rdplus_response.attr_array = NULL;
+ }
+ return 0;
+}
+
+/* parse_args()
+ *
+ * parses command line arguments
+ *
+ * returns pointer to options structure on success, NULL on failure
+ */
+static struct options* parse_args(int argc, char* argv[])
+{
+ int i = 0, ret = 0, option_index = 0;
+ const char *cur_option = NULL;
+ struct options* tmp_opts = NULL;
+ static struct option long_opts[] =
+ {
+ {"help",0,0,0},
+ {"human-readable",0,0,0},
+ {"si",0,0,0},
+ {"version",0,0,0},
+ {"verbose",0,0,0},
+ {"numeric-uid-gid",0,0,0},
+ {"directory",0,0,0},
+ {"no-group",0,0,0},
+ {"almost-all",0,0,0},
+ {"all",0,0,0},
+ {"inode",0,0,0},
+ {"size",0,0,0},
+ {0,0,0,0}
+ };
+
+ tmp_opts = (struct options*)malloc(sizeof(struct options));
+ if (!tmp_opts)
+ {
+ return(NULL);
+ }
+ memset(tmp_opts, 0, sizeof(struct options));
+
+ while((ret = getopt_long(argc, argv, "hVndGoAaiglt",
+ long_opts, &option_index)) != -1)
+ {
+ switch(ret)
+ {
+ case 0:
+ cur_option = long_opts[option_index].name;
+
+ if (strcmp("help", cur_option) == 0)
+ {
+ usage(argc, argv);
+ exit(0);
+ }
+ else if (strcmp("human-readable", cur_option) == 0)
+ {
+ goto list_human_readable;
+ }
+ else if (strcmp("si", cur_option) == 0)
+ {
+ tmp_opts->list_use_si_units = 1;
+ break;
+ }
+ else if (strcmp("version", cur_option) == 0)
+ {
+ printf("%s\n", PVFS2_VERSION);
+ exit(0);
+ }
+ else if (strcmp("verbose", cur_option) == 0)
+ {
+ goto list_verbose;
+ }
+ else if (strcmp("numeric-uid-gid", cur_option) == 0)
+ {
+ goto list_numeric_uid_gid;
+ }
+ else if (strcmp("directory", cur_option) == 0)
+ {
+ goto list_directory;
+ }
+ else if (strcmp("no-group", cur_option) == 0)
+ {
+ goto list_no_group;
+ }
+ else if (strcmp("almost-all", cur_option) == 0)
+ {
+ goto list_almost_all;
+ }
+ else if (strcmp("all", cur_option) == 0)
+ {
+ goto list_all;
+ }
+ else if (strcmp("inode", cur_option) == 0)
+ {
+ goto list_inode;
+ }
+ else
+ {
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case 'h':
+ list_human_readable:
+ tmp_opts->list_human_readable = 1;
+ break;
+ case 'V':
+ list_verbose:
+ tmp_opts->list_verbose = 1;
+ break;
+ case 'l':
+ tmp_opts->list_long = 1;
+ break;
+ case 'n':
+ list_numeric_uid_gid:
+ tmp_opts->list_long = 1;
+ tmp_opts->list_numeric_uid_gid = 1;
+ break;
+ case 'd':
+ list_directory:
+ tmp_opts->list_directory = 1;
+ break;
+ case 'o':
+ list_no_group:
+ tmp_opts->list_long = 1;
+ tmp_opts->list_no_group = 1;
+ break;
+ case 'A':
+ list_almost_all:
+ tmp_opts->list_almost_all = 1;
+ break;
+ case 'a':
+ list_all:
+ tmp_opts->list_all = 1;
+ break;
+ case 'g':
+ tmp_opts->list_long = 1;
+ tmp_opts->list_no_owner = 1;
+ break;
+ case 'i':
+ list_inode:
+ tmp_opts->list_inode = 1;
+ break;
+ case 't':
+ do_timing = 1;
+ break;
+ case '?':
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+
+ for(i = optind; i < argc; i++)
+ {
+ if (tmp_opts->num_starts < MAX_NUM_PATHS)
+ {
+ tmp_opts->start[i-optind] = argv[i];
+ tmp_opts->num_starts++;
+ }
+ else
+ {
+ fprintf(stderr,"Ignoring path %s\n",argv[i]);
+ }
+ }
+ return tmp_opts;
+}
+
+static void usage(int argc, char** argv)
+{
+ fprintf(stderr, "Usage: %s [OPTION]... [FILE]...\n", argv[0]);
+ fprintf(stderr, "List information about the FILEs (the current "
+ "directory by default)\n\n");
+ fprintf(stderr," -a, --all "
+ "do not hide entries starting with .\n");
+ fprintf(stderr," -A, --almost-all do not list "
+ "implied . and ..\n");
+ fprintf(stderr," -d, --directory list directory "
+ "entries instead of contents\n");
+ fprintf(stderr," -g like -l, but do "
+ "not list owner\n");
+ fprintf(stderr," -G, --no-group inhibit display "
+ "of group information\n");
+ fprintf(stderr," -h, --human-readable print sizes in human "
+ "readable format\n\t\t\t\t(e.g. 1K 234M 2G)\n");
+ fprintf(stderr," --si likewise, but use powers "
+ "of 1000, not 1024\n");
+ fprintf(stderr," -i, --inode print index number "
+ "of each file\n");
+ fprintf(stderr," -l use a long listing "
+ "format\n");
+ fprintf(stderr," -n, --numeric-uid-gid like -l, but list "
+ "numeric UIDs and GIDs\n");
+ fprintf(stderr," -o like -l, but do not "
+ "list group information\n");
+ fprintf(stderr," --help display this help "
+ "and exit\n");
+ fprintf(stderr," -V, --verbose reports if the dir is "
+ "changing during listing\n");
+ fprintf(stderr," --version output version "
+ "information and exit\n");
+ return;
+}
+
+int main(int argc, char **argv)
+{
+ int ret = -1, i = 0;
+ char pvfs_path[MAX_NUM_PATHS][PVFS_NAME_MAX];
+ PVFS_fs_id fs_id_array[MAX_NUM_PATHS] = {0};
+ const PVFS_util_tab* tab;
+ struct options* user_opts = NULL;
+ char current_dir[PVFS_NAME_MAX] = {0};
+ int found_one = 0;
+
+ process_name = argv[0];
+
+ user_opts = parse_args(argc, argv);
+ if (!user_opts)
+ {
+ fprintf(stderr, "Error: failed to parse command line "
+ "arguments.\n");
+ usage(argc, argv);
+ return(-1);
+ }
+
+ tab = PVFS_util_parse_pvfstab(NULL);
+ if (!tab)
+ {
+ fprintf(stderr, "Error: failed to parse pvfstab.\n");
+ return(-1);
+ }
+
+ for(i = 0; i < MAX_NUM_PATHS; i++)
+ {
+ memset(pvfs_path[i],0,PVFS_NAME_MAX);
+ }
+
+ ret = PVFS_sys_initialize(GOSSIP_NO_DEBUG);
+ if (ret < 0)
+ {
+ PVFS_perror("PVFS_sys_initialize", ret);
+ return(-1);
+ }
+
+ /* initialize each file system that we found in the tab file */
+ for(i = 0; i < tab->mntent_count; i++)
+ {
+ ret = PVFS_sys_fs_add(&tab->mntent_array[i]);
+ if (ret == 0)
+ {
+ found_one = 1;
+ }
+ }
+
+ if (!found_one)
+ {
+ fprintf(stderr, "Error: could not initialize any file systems "
+ "from %s\n", tab->tabfile_name);
+ PVFS_sys_finalize();
+ return(-1);
+ }
+
+ if (user_opts->num_starts == 0)
+ {
+ snprintf(current_dir,PVFS_NAME_MAX,"%s/",
+ tab->mntent_array[0].mnt_dir);
+ user_opts->start[0] = current_dir;
+ user_opts->num_starts = 1;
+ }
+
+ for(i = 0; i < user_opts->num_starts; i++)
+ {
+ ret = PVFS_util_resolve(user_opts->start[i],
+ &fs_id_array[i], pvfs_path[i], PVFS_NAME_MAX);
+ if ((ret == 0) && (pvfs_path[i][0] == '\0'))
+ {
+ strcpy(pvfs_path[i], "/");
+ }
+
+ if (ret < 0)
+ {
+ fprintf(stderr, "Error: could not find file system "
+ "for %s in pvfstab\n", user_opts->start[i]);
+ return(-1);
+ }
+ }
+
+ for(i = 0; i < user_opts->num_starts; i++)
+ {
+ if (user_opts->num_starts > 1)
+ {
+ printf("%s:\n", pvfs_path[i]);
+ }
+
+ do_list(pvfs_path[i], fs_id_array[i], user_opts);
+
+ if (user_opts->num_starts > 1)
+ {
+ printf("\n");
+ }
+ }
+
+ PVFS_sys_finalize();
+ free(user_opts);
+
+ return(ret);
+}
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-validate.c 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,437 @@
+/*
+ * Copyright © Acxiom Corporation, 2006
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+
+#include "pvfs2.h"
+#include "pvfs2-internal.h"
+
+
+#include "fsck-utils.h"
+
+#define VERSION "0.1"
+/** \defgroup pvfs2validate PVFS2 Validate
+ *
+ * The pvfs2-validate implementation provides a client side utility to find and
+ * repair PVFS2 file system problems.
+ *
+ * @see fsckutils
+ *
+ * Before running pvfs2-validate, the following requirements must be met:
+ * - The PVFS2 servers must be running
+ * - No clients should be accssing the file system
+ * .
+ *
+ * TODO:
+ * - Need to design a way to kick off process on the pvfs2-server to check
+ * for orphaned bstreams (bstreams with no attributes and/or dfiles)
+ * - Needs to enter admin mode in beginning if needed, and leave at end.
+ * Shouldn't leave admin mode during operation.
+ * - Add ability to run pvfs2-validate on an unmounted filesytem, and on a system
+ * with no entries in tabfiles (pvfs2tab, /etc/mtab, /etc/fstab)
+ * - Force a sync on filesystem before beginning fsck
+ * .
+ *
+ * QUESTIONS:
+ * - Does the underlying filesystem fsck interfere with pvfs2-validate?
+ * - Should the underlying filesytem fsck be run in any conditions?
+ * - How/When to clean up lost+found directory?
+ * - What happens when lost+found directory has errors?
+ * - Can anyone with root access run pvfs2-validate? Do we need some sort of authorization?
+ * - Any known limits? (memory usage in pvfs2-validate, number of files)?
+ * - Should we enter admin mode if there is no chance of repairs on found objects?
+ * - Can pvfs2-validate be initiated automatically in some cases?
+ * - When pvfs2-validate runs, how does is affect performance (readonly/repair)?
+ * - Can the this be parallelized?
+ * - Can we have a "conditional admin mode", where admin mode only entered after
+ * a certain time condition where no file system activity takes place? This
+ * would keep servers from entering admin mode in the middle of operations.
+ * .
+ *
+ * @{
+ */
+
+/** \file
+ * Implementation of PVFS2 FSCK tool.
+ */
+
+/* Function Prototypes */
+static void usage(
+ int,
+ char **);
+
+int validate_pvfs_object(
+ const struct PINT_fsck_options *fsck_options,
+ const PVFS_object_ref * pref,
+ const PVFS_credentials * creds,
+ int *cur_fs,
+ char *current_path);
+
+static struct PINT_fsck_options *parse_args(
+ int argc,
+ char **argv);
+
+int main(int argc, char **argv)
+{
+ int ret = 0;
+ int cur_fs = 0;
+ char pvfs_path[PVFS_NAME_MAX] = { 0 };
+ PVFS_credentials creds;
+ PVFS_sysresp_lookup lookup_resp;
+ struct PINT_fsck_options *fsck_options = NULL;
+
+ memset(&creds, 0, sizeof(creds));
+ memset(&lookup_resp, 0, sizeof(lookup_resp));
+
+ fsck_options = parse_args(argc, argv);
+ if(!fsck_options)
+ {
+ fprintf(stderr, "Error: failed to parse arguments.\n");
+ usage(argc, argv);
+ return -1;
+ }
+
+ if (!fsck_options->start_path)
+ {
+ fprintf(stderr, "Error: no starting path specified (See -d option below).\n");
+ usage(argc, argv);
+ free(fsck_options);
+ return -1;
+ }
+
+ ret = PVFS_util_init_defaults();
+ if (ret != 0)
+ {
+ PVFS_perror("PVFS_util_init_defaults", ret);
+ free(fsck_options);
+ return -1;
+ }
+
+ /* translate local path into pvfs2 relative path */
+ ret = PVFS_util_resolve(
+ fsck_options->start_path,
+ &cur_fs, pvfs_path,
+ sizeof(pvfs_path));
+
+ if (ret != 0)
+ {
+ PVFS_perror("PVFS_util_resolve", ret);
+ PVFS_sys_finalize();
+ free(fsck_options);
+ return -1;
+ }
+
+ if (fsck_options->check_stranded_objects && (strcmp(pvfs_path, "/") != 0))
+ {
+ fprintf(stderr, "Error: -d must specify the pvfs2 root directory when utilizing the -c option.\n");
+ usage(argc, argv);
+ PVFS_sys_finalize();
+ free(fsck_options);
+ return -1;
+ }
+
+ PVFS_util_gen_credentials(&creds);
+
+ ret = PVFS_sys_lookup(
+ cur_fs, pvfs_path,
+ &creds,
+ &lookup_resp,
+ PVFS2_LOOKUP_LINK_NO_FOLLOW);
+
+ if (ret != 0)
+ {
+ fprintf(stderr, "Error: failed lookup on [%s]\n", pvfs_path);
+ PVFS_perror("PVFS_sys_lookup", ret);
+ PVFS_sys_finalize();
+ free(fsck_options);
+ return -1;
+ }
+
+ ret = PVFS_fsck_initialize(fsck_options, &creds, &cur_fs);
+ if (ret < 0)
+ {
+ PVFS_perror("PVFS_fsck_initialize", ret);
+ PVFS_sys_finalize();
+ free(fsck_options);
+ return(-1);
+ }
+
+ ret = PVFS_fsck_check_server_configs(fsck_options, &creds, &cur_fs);
+ if (ret < 0)
+ {
+ fprintf(stderr, "Error: a difference was detected while validating the server fs configs.\n");
+ PVFS_perror("PVFS_fsck_check_server_configs", ret);
+ PVFS_sys_finalize();
+ free(fsck_options);
+ return(-1);
+ }
+
+ /* stop right here if check_fs_configs option is enabled */
+ if (fsck_options->check_fs_configs)
+ {
+ printf("All PVFS2 servers have consistent fs configurations.\n");
+ free(fsck_options);
+ return 0;
+ }
+
+ printf("pvfs2-validate starting validation at object [%s]\n",
+ fsck_options->start_path);
+
+ /* validate the object */
+ ret = validate_pvfs_object(
+ fsck_options,
+ &lookup_resp.ref,
+ &creds,
+ &cur_fs,
+ fsck_options->start_path);
+
+ if (ret != 0)
+ {
+ printf("failed to validate object tree starting at [%s]. rc=[%d]\n",
+ fsck_options->start_path, ret);
+ }
+ else
+ {
+ printf("pvfs2-validate done validating object tree at [%s]\n",
+ fsck_options->start_path);
+ }
+
+ PVFS_fsck_finalize(fsck_options, &cur_fs, &creds);
+ PVFS_sys_finalize();
+ free(fsck_options);
+
+ return 0;
+}
+
+/**
+ * Validate a PVFS2 file, directory or symlink. Operates recursively to
+ * descend into directories.
+ *
+ * \retval 0 on success
+ * \retval -PVFS_EWARNING for non critical warnings
+ * \retval -PVFS_error on failure
+ */
+int validate_pvfs_object(
+ const struct PINT_fsck_options *fsck_options, /**< fsck options */
+ const PVFS_object_ref * pref, /**< object to validate */
+ const PVFS_credentials * creds, /**< caller's credentials */
+ int *cur_fs, /**< file system */
+ char *current_path) /**< path to object */
+{
+ int ret = 0;
+ int j = 0;
+ PVFS_sysresp_getattr attributes;
+ PVFS_dirent *directory_entries = NULL;
+ char* err_string = NULL;
+
+ memset(&attributes, 0, sizeof(attributes));
+
+ /* get this objects attributes */
+ ret = PVFS_fsck_get_attributes(fsck_options, pref, creds, &attributes);
+ if(ret < 0)
+ {
+ fprintf(stderr, "Error: [%s] cannot retrieve attributes.\n", current_path);
+ }
+ else if (attributes.attr.objtype == PVFS_TYPE_METAFILE)
+ {
+ /* metadata file */
+ ret = PVFS_fsck_validate_metafile(fsck_options, pref,
+ &attributes, creds);
+ }
+ else if (attributes.attr.objtype == PVFS_TYPE_DIRECTORY)
+ {
+ /* directory */
+ directory_entries = calloc(attributes.attr.dirent_count, sizeof(PVFS_dirent));
+ if (directory_entries == NULL)
+ {
+ perror("calloc");
+ return -PVFS_ENOMEM;
+ }
+
+ ret = PVFS_fsck_validate_dir(fsck_options, pref, &attributes, creds,
+ directory_entries);
+
+ if(ret == 0)
+ {
+ /* validate all directory entries recursively */
+ for (j = 0; j < attributes.attr.dirent_count; j++)
+ {
+ PVFS_object_ref obj_ref;
+ char new_path[PVFS_SEGMENT_MAX];
+
+ obj_ref.handle = directory_entries[j].handle;
+ obj_ref.fs_id = *cur_fs;
+
+ /* build full path name of the next object */
+ strcpy(new_path, current_path);
+ strcat(new_path, "/");
+ strcat(new_path, directory_entries[j].d_name);
+
+ /* recurse */
+ ret = validate_pvfs_object(fsck_options, &obj_ref, creds,
+ cur_fs, new_path);
+ }
+ }
+
+ free(directory_entries);
+ }
+ else if (attributes.attr.objtype == PVFS_TYPE_SYMLINK)
+ {
+ /* symbolic link */
+ ret = PVFS_fsck_validate_symlink(fsck_options, pref,
+ &attributes);
+ free(attributes.attr.link_target);
+ }
+ else
+ {
+ fprintf(stderr, "Error: [%s] is of an unknown object type: [%d]\n",
+ current_path, attributes.attr.objtype);
+ ret = -PVFS_EINVAL;
+ }
+
+ if (ret == 0)
+ {
+ if (fsck_options->verbose)
+ {
+ printf("validated [%s] object ret=[%d]\n", current_path, ret);
+ }
+ }
+ else
+ {
+ err_string = (char*)malloc(128*sizeof(char));
+ if(err_string)
+ {
+ PVFS_strerror_r(ret, err_string, 128);
+ fprintf(stderr, "Error: [%s] object is invalid (%s)\n",
+ current_path, err_string);
+ free(err_string);
+ }
+ else
+ {
+ fprintf(stderr, "Error: [%s] object is invalid (%d)\n",
+ current_path, ret);
+ }
+ }
+
+ /* Return 0, rather than "ret", too keep from propogating errors
+ * all the way back to the root object. We want to continue and show all
+ * problem rather than stopping on the first
+ */
+ return 0;
+}
+
+static void usage(
+ int argc,
+ char **argv)
+{
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Usage : %s [-Vvharsfc] -d pvfs2_directory\n", argv[0]);
+ fprintf(stderr, "Recursively checks a PVFS2 directory or file for problems.\n");
+ fprintf(stderr, " -h \t print this help screen\n");
+ fprintf(stderr, " -d \t path to a PVFS2 directory/file\n");
+ fprintf(stderr, " \t (specify mount point to check entire file system)\n");
+ fprintf(stderr, " -c \t check for stranded objects\n");
+ fprintf(stderr, " \t (requires that -d refer to the PVFS2 root directory)\n");
+ fprintf(stderr, " -s \t check for bad practice in symbolic links\n");
+ fprintf(stderr, " -f \t check for bad practice in directory/file names\n");
+ fprintf(stderr,
+ " -F \t stop after confirming consistent configuration of all servers\n");
+ fprintf(stderr, " -V \t run in verbose mode\n");
+ 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, "\n\n");
+ fprintf(stderr, " Return Codes:\n");
+ fprintf(stderr,
+ " \tThe exit code returned by %s is the sum of the following conditions:\n", argv[0]);
+ fprintf(stderr, " \t\t 0 - No errors\n");
+ fprintf(stderr, " \t\t 1 - File system errors corrected\n");
+ fprintf(stderr, " \t\t 2 - System should be rebooted\n");
+ fprintf(stderr, " \t\t 4 - File system errors left uncorrected\n\n");
+
+ fprintf(stderr, " Example: %s -d /mnt/pvfs2\n", argv[0]);
+}
+
+static struct PINT_fsck_options *parse_args(int argc, char **argv)
+{
+ int opt = 0;
+ int path_length = 0;
+
+ struct PINT_fsck_options *opts;
+ opts = calloc(1, sizeof(struct PINT_fsck_options));
+ if (opts == NULL)
+ {
+ return NULL;
+ }
+
+ while ((opt = getopt(argc, argv, "d:VvharsfcF")) != EOF)
+ {
+ switch (opt)
+ {
+ case 'd':
+ opts->start_path = optarg;
+ path_length = strlen(optarg);
+ /* remove trailing extraneous */
+ if (optarg[path_length - 1] == '/' && path_length > 1)
+ {
+ optarg[path_length - 1] = '\0';
+ }
+ break;
+ case 'V':
+ opts->verbose = 1;
+ break;
+ case 'v':
+ printf("pvfs2-fsck version %s\n", VERSION);
+ exit(0);
+ break;
+ case 'c':
+ opts->check_stranded_objects = 1;
+ break;
+ case 'a':
+ opts->fix_errors = 1;
+ printf("Error: file system repair not implemented\n");
+ usage(argc, argv);
+ exit(-PVFS_ENOSYS);
+ break;
+ case 'r':
+ printf("Error: interactive mode not implemented\n");
+ usage(argc, argv);
+ exit(-PVFS_ENOSYS);
+ break;
+ case 's':
+ opts->check_symlink_target = 1;
+ break;
+ case 'F':
+ opts->check_fs_configs = 1;
+ break;
+ case 'f':
+ opts->check_dir_entry_names = 1;
+ break;
+ case 'h':
+ usage(argc, argv);
+ exit(0);
+ break;
+ case '?':
+ usage(argc, argv); /* unknown option */
+ exit(3);
+ }
+ }
+
+ return opts;
+}
+
+/* @} */
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pvfs2-xattr.c 2008-07-21 14:19:48.000000000 -0400
@@ -0,0 +1,477 @@
+/*
+ * (C) 2004 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdlib.h>
+#include <getopt.h>
+
+#define __PINT_REQPROTO_ENCODE_FUNCS_C
+#include "pvfs2.h"
+#include "str-utils.h"
+#include "pint-sysint-utils.h"
+#include "pint-util.h"
+#include "pvfs2-internal.h"
+#include "pvfs2-req-proto.h"
+
+#include "xattr-utils.h"
+
+#define VALBUFSZ 1024
+
+/* extended attribute name spaces supported in PVFS2 */
+const char *PINT_eattr_namespaces[] =
+{
+ "system.",
+ "user.",
+ "trusted.",
+ "security.",
+ NULL
+};
+
+/* optional parameters, filled in by parse_args() */
+struct options
+{
+ PVFS_ds_keyval key;
+ PVFS_ds_keyval val;
+ char* srcfile;
+ int get, text;
+};
+
+enum object_type {
+ UNIX_FILE,
+ PVFS2_FILE
+};
+
+typedef struct pvfs2_file_object_s {
+ PVFS_fs_id fs_id;
+ PVFS_object_ref ref;
+ char pvfs2_path[PVFS_NAME_MAX];
+ char user_path[PVFS_NAME_MAX];
+ PVFS_sys_attr attr;
+ PVFS_permissions perms;
+} pvfs2_file_object;
+
+typedef struct unix_file_object_s {
+ int fd;
+ int mode;
+ char path[NAME_MAX];
+ PVFS_fs_id fs_id;
+} unix_file_object;
+
+typedef struct file_object_s {
+ int fs_type;
+ union {
+ unix_file_object ufs;
+ pvfs2_file_object pvfs2;
+ } u;
+} file_object;
+
+static struct options* parse_args(int argc, char* argv[]);
+static int generic_open(file_object *obj, PVFS_credentials *credentials);
+static int pvfs2_eattr(int get, file_object *, PVFS_ds_keyval *key_p,
+ PVFS_ds_keyval *val_p, PVFS_credentials *creds);
+static void usage(int argc, char** argv);
+static int resolve_filename(file_object *obj, char *filename);
+static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p);
+static int permit_set(PVFS_ds_keyval *key_p);
+static int eattr_is_prefixed(char* key_name);
+
+int main(int argc, char **argv)
+{
+ int ret = 0;
+ struct options* user_opts = NULL;
+ file_object src;
+ PVFS_credentials credentials;
+
+ memset(&src, 0, sizeof(src));
+ /* look at command line arguments */
+ user_opts = parse_args(argc, argv);
+ if(!user_opts)
+ {
+ fprintf(stderr, "Error: failed to parse "
+ "command line arguments.\n");
+ return(-1);
+ }
+
+ ret = PVFS_util_init_defaults();
+ if(ret < 0)
+ {
+ PVFS_perror("PVFS_util_init_defaults", ret);
+ return(-1);
+ }
+ resolve_filename(&src, user_opts->srcfile);
+
+ PVFS_util_gen_credentials(&credentials);
+ ret = generic_open(&src, &credentials);
+ if (ret < 0)
+ {
+ fprintf(stderr, "Could not open %s\n", user_opts->srcfile);
+ return -1;
+ }
+ if (!eattr_is_prefixed(user_opts->key.buffer))
+ {
+ fprintf(stderr, "extended attribute key is not prefixed %s\n", (char *) user_opts->key.buffer);
+ return -1;
+ }
+ if (!user_opts->get)
+ {
+ if (!permit_set(&user_opts->key))
+ {
+ fprintf(stderr, "Not permitted to set key %s\n", (char *) user_opts->key.buffer);
+ return -1;
+ }
+ if (modify_val(&user_opts->key, &user_opts->val) < 0)
+ {
+ fprintf(stderr, "Invalid value for user-settable hint %s, %s\n", (char *) user_opts->key.buffer, (char *) user_opts->val.buffer);
+ return -1;
+ }
+ }
+
+ ret = pvfs2_eattr(user_opts->get, &src, &user_opts->key, &user_opts->val, &credentials);
+ if (ret != 0)
+ {
+ return ret;
+ }
+ if (user_opts->get && user_opts->text)
+ {
+ if (strncmp(user_opts->key.buffer, "user.pvfs2.meta_hint", SPECIAL_METAFILE_HINT_KEYLEN) == 0) {
+ PVFS_metafile_hint *hint = (PVFS_metafile_hint *) user_opts->val.buffer;
+ printf("Metafile hints: ");
+ if (hint->flags & PVFS_IMMUTABLE_FL) {
+ printf("immutable file ");
+ }
+ if (hint->flags & PVFS_APPEND_FL) {
+ printf("Append-only file ");
+ }
+ if (hint->flags & PVFS_NOATIME_FL) {
+ printf("Atime updates disabled.");
+ }
+ printf("\n");
+ } else {
+ printf("key:%s Value:\n%s\n",
+ (char *)user_opts->key.buffer,
+ (char *)user_opts->val.buffer);
+ }
+ }
+ PVFS_sys_finalize();
+ return(ret);
+}
+
+static int modify_val(PVFS_ds_keyval *key_p, PVFS_ds_keyval *val_p)
+{
+ if (strncmp(key_p->buffer, "user.pvfs2.meta_hint", SPECIAL_METAFILE_HINT_KEYLEN) == 0)
+ {
+ PVFS_metafile_hint hint;
+ memset(&hint, 0, sizeof(hint));
+ if (strncmp(val_p->buffer, "+immutable", 10) == 0)
+ hint.flags |= PVFS_IMMUTABLE_FL;
+ else if (strncmp(val_p->buffer, "-immutable", 10) == 0)
+ hint.flags &= ~PVFS_IMMUTABLE_FL;
+ else if (strncmp(val_p->buffer, "+append", 7) == 0)
+ hint.flags |= PVFS_APPEND_FL;
+ else if (strncmp(val_p->buffer, "-append", 7) == 0)
+ hint.flags &= ~PVFS_APPEND_FL;
+ else if (strncmp(val_p->buffer, "+noatime", 8) == 0)
+ hint.flags |= PVFS_NOATIME_FL;
+ else if (strncmp(val_p->buffer, "-noatime", 8) == 0)
+ hint.flags &= ~PVFS_NOATIME_FL;
+ else
+ return -1;
+ memcpy(val_p->buffer, &hint, sizeof(hint));
+ val_p->buffer_sz = sizeof(hint);
+ }
+ return 0;
+}
+
+static int permit_set(PVFS_ds_keyval *key_p)
+{
+ if (strncmp(key_p->buffer, "system.", 7) == 0
+ || strncmp(key_p->buffer, "trusted.", 8) == 0
+ || strncmp(key_p->buffer, "security.", 9) == 0)
+ return 0;
+ return 1;
+}
+
+/* pvfs2_geteattr()
+ *
+ * changes the mode of the given file to the given permissions
+ *
+ * returns zero on success and negative one on failure
+ */
+static int pvfs2_eattr(int get, file_object *obj, PVFS_ds_keyval *key_p,
+ PVFS_ds_keyval *val_p, PVFS_credentials *creds)
+{
+ int ret = -1;
+
+ if (obj->fs_type == UNIX_FILE)
+ {
+ if (get == 1)
+ {
+#ifndef HAVE_FGETXATTR_EXTRA_ARGS
+ if ((ret = fgetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz)) < 0)
+#else
+ if ((ret = fgetxattr(obj->u.ufs.fd, key_p->buffer, val_p->buffer, val_p->buffer_sz, 0, 0)) < 0)
+#endif
+ {
+ perror("fgetxattr:");
+ return -1;
+ }
+ }
+ else
+ {
+#ifdef HAVE_FSETXATTR
+ if ((ret = fsetxattr(obj->u.ufs.fd, key_p->buffer,
+ val_p->buffer, val_p->buffer_sz, 0
+#ifdef HAVE_FSETXATTR_EXTRA_ARGS
+ ,0
+#endif
+ )) < 0)
+#else
+ errno = ENOSYS;
+#endif
+ {
+ perror("fsetxattr:");
+ return -1;
+ }
+ }
+ }
+ else
+ {
+ if (get == 1)
+ {
+ ret = PVFS_sys_geteattr(obj->u.pvfs2.ref, creds, key_p, val_p);
+ }
+ else {
+ ret = PVFS_sys_seteattr(obj->u.pvfs2.ref, creds, key_p, val_p, 0);
+ }
+
+ if (ret < 0)
+ {
+ PVFS_perror("PVFS_sys_geteattr", ret);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+
+/* parse_args()
+ *
+ * parses command line arguments
+ *
+ * returns pointer to options structure on success, NULL on failure
+ */
+static struct options* parse_args(int argc, char* argv[])
+{
+ char flags[] = "k:v:ts";
+ int one_opt = 0;
+
+ struct options* tmp_opts = NULL;
+
+ /* create storage for the command line options */
+ tmp_opts = (struct options*)malloc(sizeof(struct options));
+ if(!tmp_opts){
+ return(NULL);
+ }
+ memset(tmp_opts, 0, sizeof(struct options));
+
+ /* fill in defaults */
+ memset(&tmp_opts->key, 0, sizeof(PVFS_ds_keyval));
+ memset(&tmp_opts->val, 0, sizeof(PVFS_ds_keyval));
+ tmp_opts->srcfile = strdup(argv[argc-1]);
+ tmp_opts->get = 1;
+
+ /* look at command line arguments */
+ while((one_opt = getopt(argc, argv, flags)) != EOF)
+ {
+ switch(one_opt){
+ case 't':
+ tmp_opts->text = 1;
+ break;
+ case 's':
+ tmp_opts->get = 0;
+ break;
+ case 'k':
+ tmp_opts->key.buffer = strdup(optarg);
+ tmp_opts->key.buffer_sz = strlen(tmp_opts->key.buffer) + 1;
+ break;
+ case 'v':
+ tmp_opts->val.buffer = strdup(optarg);
+ tmp_opts->val.buffer_sz = strlen(tmp_opts->val.buffer) + 1;
+ break;
+ case('?'):
+ printf("?\n");
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (tmp_opts->get == 1)
+ {
+ tmp_opts->val.buffer = calloc(1, VALBUFSZ);
+ tmp_opts->val.buffer_sz = VALBUFSZ;
+ if (tmp_opts->val.buffer == NULL)
+ {
+ fprintf(stderr, "Could not allocate val\n");
+ exit(EXIT_FAILURE);
+ }
+ }
+ else {
+ if (tmp_opts->val.buffer == NULL)
+ {
+ fprintf(stderr, "Please specify value if setting extended attributes\n");
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ }
+ if (tmp_opts->key.buffer == NULL)
+ {
+ fprintf(stderr, "Please specify key if getting extended attributes\n");
+ usage(argc, argv);
+ exit(EXIT_FAILURE);
+ }
+ return(tmp_opts);
+}
+
+
+static void usage(int argc, char** argv)
+{
+ fprintf(stderr,"Usage: %s -s {set xattrs} -k <key> -v <val> -t {print attributes} filename\n",argv[0]);
+ return;
+}
+
+/* resolve_filename:
+ * given 'filename', find the PVFS2 fs_id and relative pvfs_path. In case of
+ * error, assume 'filename' is a unix file.
+ */
+static int resolve_filename(file_object *obj, char *filename)
+{
+ int ret;
+
+ ret = PVFS_util_resolve(filename, &(obj->u.pvfs2.fs_id),
+ obj->u.pvfs2.pvfs2_path, PVFS_NAME_MAX);
+ if (ret < 0)
+ {
+ obj->fs_type = UNIX_FILE;
+ strncpy(obj->u.ufs.path, filename, NAME_MAX);
+ } else {
+ obj->fs_type = PVFS2_FILE;
+ strncpy(obj->u.pvfs2.user_path, filename, PVFS_NAME_MAX);
+ }
+ return 0;
+}
+
+/* generic_open:
+ * given a file_object, perform the apropriate open calls.
+ */
+static int generic_open(file_object *obj, PVFS_credentials *credentials)
+{
+ struct stat stat_buf;
+ PVFS_sysresp_lookup resp_lookup;
+ PVFS_sysresp_getattr resp_getattr;
+ PVFS_object_ref ref;
+ int ret = -1;
+
+ if (obj->fs_type == UNIX_FILE)
+ {
+ PINT_statfs_t statfsbuf;
+ memset(&stat_buf, 0, sizeof(struct stat));
+
+ stat(obj->u.ufs.path, &stat_buf);
+ if (!S_ISREG(stat_buf.st_mode))
+ {
+ fprintf(stderr, "Not a file!\n");
+ return(-1);
+ }
+ obj->u.ufs.fd = open(obj->u.ufs.path, O_RDONLY);
+ obj->u.ufs.mode = (int)stat_buf.st_mode;
+ if (obj->u.ufs.fd < 0)
+ {
+ perror("open");
+ fprintf(stderr, "could not open %s\n", obj->u.ufs.path);
+ return (-1);
+ }
+ if (PINT_statfs_fd_lookup(obj->u.ufs.fd, &statfsbuf) < 0)
+ {
+ perror("fstatfs:");
+ fprintf(stderr, "could not fstatfs %s\n", obj->u.ufs.path);
+ }
+ memcpy(&obj->u.ufs.fs_id, &PINT_statfs_fsid(&statfsbuf),
+ sizeof(PINT_statfs_fsid(&statfsbuf)));
+ return 0;
+ }
+ else
+ {
+ memset(&resp_lookup, 0, sizeof(PVFS_sysresp_lookup));
+ ret = PVFS_sys_lookup(obj->u.pvfs2.fs_id,
+ (char *) obj->u.pvfs2.pvfs2_path,
+ credentials,
+ &resp_lookup,
+ PVFS2_LOOKUP_LINK_FOLLOW);
+ if (ret < 0)
+ {
+ PVFS_perror("PVFS_sys_lookup", ret);
+ return (-1);
+ }
+ ref.handle = resp_lookup.ref.handle;
+ ref.fs_id = resp_lookup.ref.fs_id;
+
+ memset(&resp_getattr, 0, sizeof(PVFS_sysresp_getattr));
+ ret = PVFS_sys_getattr(ref, PVFS_ATTR_SYS_ALL_NOHINT,
+ credentials, &resp_getattr);
+ if (ret)
+ {
+ fprintf(stderr, "Failed to do pvfs2 getattr on %s\n",
+ obj->u.pvfs2.pvfs2_path);
+ return -1;
+ }
+
+ if (resp_getattr.attr.objtype != PVFS_TYPE_METAFILE &&
+ resp_getattr.attr.objtype != PVFS_TYPE_DIRECTORY)
+ {
+ fprintf(stderr, "Not a meta file!\n");
+ return -1;
+ }
+ obj->u.pvfs2.perms = resp_getattr.attr.perms;
+ memcpy(&obj->u.pvfs2.attr, &resp_getattr.attr,
+ sizeof(PVFS_sys_attr));
+ obj->u.pvfs2.attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
+ obj->u.pvfs2.ref = ref;
+ }
+ return 0;
+}
+
+static int eattr_is_prefixed(char* key_name)
+{
+ int i = 0;
+ while(PINT_eattr_namespaces[i])
+ {
+ if(strncmp(PINT_eattr_namespaces[i], key_name,
+ strlen(PINT_eattr_namespaces[i])) == 0)
+ {
+ return(1);
+ }
+ i++;
+ }
+ return(0);
+}
+
+
+
+/*
+ * Local variables:
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ts=8 sts=4 sw=4 expandtab
+ */
+
Index: module.mk.in
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/module.mk.in,v
diff -p -u -r1.39 -r1.39.24.1
--- module.mk.in 4 Apr 2006 04:47:09 -0000 1.39
+++ module.mk.in 21 Jul 2008 18:19:47 -0000 1.39.24.1
@@ -7,6 +7,7 @@ ADMINSRC := \
$(DIR)/pvfs2-set-eventmask.c \
$(DIR)/pvfs2-set-sync.c \
$(DIR)/pvfs2-ls.c \
+ $(DIR)/pvfs2-lsplus.c \
$(DIR)/pvfs2-ping.c \
$(DIR)/pvfs2-rm.c \
$(DIR)/pvfs2-stat.c \
@@ -18,14 +19,19 @@ ADMINSRC := \
$(DIR)/pvfs2-chown.c \
$(DIR)/pvfs2-fs-dump.c\
$(DIR)/pvfs2-fsck.c\
+ $(DIR)/pvfs2-validate.c\
$(DIR)/pvfs2-cp.c \
$(DIR)/pvfs2-viewdist.c \
+ $(DIR)/pvfs2-xattr.c \
$(DIR)/pvfs2-touch.c \
$(DIR)/pvfs2-remove-object.c \
$(DIR)/pvfs2-ln.c \
- $(DIR)/pvfs2-perror.c
+ $(DIR)/pvfs2-perror.c \
+ $(DIR)/pvfs2-check-server.c \
+ $(DIR)/pvfs2-drop-caches.c
ADMINSRC_SERVER := \
$(DIR)/pvfs2-mkspace.c \
$(DIR)/pvfs2-migrate-collection.c \
+ $(DIR)/pvfs2-change-fsid.c \
$(DIR)/pvfs2-showcoll.c
Index: pvfs2-config.in
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-config.in,v
diff -p -u -r1.9 -r1.9.28.1
--- pvfs2-config.in 30 May 2006 20:26:26 -0000 1.9
+++ pvfs2-config.in 21 Jul 2008 18:19:47 -0000 1.9.28.1
@@ -47,7 +47,7 @@ while test $# -gt 0; do
--libs|--static-libs)
libflags="-L at libdir@ -lpvfs2 @LIBS@ @THREAD_LIB@"
if [ x"@BUILD_GM@" = x"1" ]; then
- libflags="$libflags -L at GM_HOME@/lib -lgm"
+ libflags="$libflags -L at GM_LIBDIR@ -lgm"
fi
if [ x"@BUILD_IB@" = x"1" ]; then
libflags="$libflags -L at IB_LIBDIR@ -lvapi -lmtl_common -lmosal -lmpga -lpthread -ldl"
@@ -55,6 +55,12 @@ while test $# -gt 0; do
if [ x"@BUILD_OPENIB@" = x"1" ]; then
libflags="$libflags -L at OPENIB_LIBDIR@ -libverbs"
fi
+ if [ x"@BUILD_MX@" = x"1" ]; then
+ libflags="$libflags -L at MX_LIBDIR@ -lmyriexpress -lpthread"
+ fi
+ if [ x"@BUILD_PORTALS@" = x"1" ]; then
+ libflags="$libflags @PORTALS_LIBS@"
+ fi
echo $libflags
;;
@@ -64,13 +70,19 @@ while test $# -gt 0; do
libflags="$libflags -lrt"
fi
if [ x"@BUILD_GM@" = x"1" ]; then
- libflags="$libflags -L at GM_HOME@/lib -lgm"
+ libflags="$libflags -L at GM_LIBDIR@ -lgm"
fi
if [ x"@BUILD_IB@" = x"1" ]; then
libflags="$libflags -L at IB_LIBDIR@ -lvapi -lmtl_common -lmosal -lmpga -lpthread -ldl"
fi
if [ x"@BUILD_OPENIB@" = x"1" ]; then
- libflags="$libflags -L at OEPNIB_LIBDIR@ -libverbs"
+ libflags="$libflags -L at OPENIB_LIBDIR@ -libverbs"
+ fi
+ if [ x"@BUILD_MX@" = x"1" ]; then
+ libflags="$libflags -L at MX_LIBDIR@ -lmyriexpress -lpthread"
+ fi
+ if [ x"@BUILD_PORTALS@" = x"1" ]; then
+ libflags="$libflags @PORTALS_LIBS@"
fi
echo $libflags
Index: pvfs2-cp.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-cp.c,v
diff -p -u -r1.21 -r1.21.4.1
--- pvfs2-cp.c 11 Sep 2006 20:22:01 -0000 1.21
+++ pvfs2-cp.c 21 Jul 2008 18:19:47 -0000 1.21.4.1
@@ -421,7 +421,7 @@ static int generic_open(file_object *obj
int ret = -1;
char *entry_name; /* name of the pvfs2 file */
char str_buf[PVFS_NAME_MAX]; /* basename of pvfs2 file */
-
+
if (obj->fs_type == UNIX_FILE)
{
memset(&stat_buf, 0, sizeof(struct stat));
@@ -628,7 +628,7 @@ static int generic_open(file_object *obj
ret = PVFS_sys_create(entry_name, parent_ref,
obj->u.pvfs2.attr, credentials,
- new_dist, &resp_create);
+ new_dist, NULL, &resp_create);
if (ret < 0)
{
PVFS_perror("PVFS_sys_create", ret);
@@ -682,7 +682,7 @@ void make_attribs(PVFS_sys_attr *attr, P
{
attr->owner = credentials->uid;
attr->group = credentials->gid;
- attr->perms = PVFS2_translate_mode(mode, 0);
+ attr->perms = PVFS_util_translate_mode(mode, 0);
attr->mask = (PVFS_ATTR_SYS_ALL_SETABLE);
attr->dfile_count = nr_datafiles;
Index: pvfs2-fsck.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-fsck.c,v
diff -p -u -r1.18 -r1.18.4.1
--- pvfs2-fsck.c 11 Sep 2006 20:22:01 -0000 1.18
+++ pvfs2-fsck.c 21 Jul 2008 18:19:47 -0000 1.18.4.1
@@ -434,7 +434,7 @@ int traverse_directory_tree(PVFS_fs_id c
int server_count,
PVFS_credentials *creds)
{
- int ret, server_idx;
+ int ret, server_idx = 0;
PVFS_sysresp_lookup lookup_resp;
PVFS_sysresp_getattr getattr_resp;
PVFS_object_ref pref;
@@ -454,7 +454,9 @@ int traverse_directory_tree(PVFS_fs_id c
&getattr_resp);
assert(getattr_resp.attr.objtype == PVFS_TYPE_DIRECTORY);
- assert(handlelist_find_handle(hl, pref.handle, &server_idx) == 0);
+
+ ret = handlelist_find_handle(hl, pref.handle, &server_idx);
+ assert(ret == 0);
handlelist_remove_handle(hl, pref.handle, server_idx);
@@ -517,7 +519,7 @@ int descend(PVFS_fs_id cur_fs,
PVFS_ds_position token;
PVFS_sysresp_readdir readdir_resp;
PVFS_sysresp_getattr getattr_resp;
- PVFS_object_ref entry_ref;
+ PVFS_object_ref entry_ref = {0, 0};
count = 64;
@@ -532,7 +534,7 @@ int descend(PVFS_fs_id cur_fs,
for (i = 0; i < readdir_resp.pvfs_dirent_outcount; i++)
{
- int server_idx, ret, in_main_list = 0, in_alt_list = 0;
+ int server_idx = 0, ret, in_main_list = 0, in_alt_list = 0;
char *cur_file;
PVFS_handle cur_handle;
@@ -696,7 +698,7 @@ int verify_datafiles(PVFS_fs_id cur_fs,
int df_count,
PVFS_credentials *creds)
{
- int ret, i, server_idx, error = 0;
+ int ret, i, server_idx = 0, error = 0;
PVFS_handle *df_handles;
df_handles = (PVFS_handle *) malloc(df_count * sizeof(PVFS_handle));
@@ -1034,7 +1036,7 @@ int create_lost_and_found(PVFS_fs_id cur
attr.owner = creds->uid;
attr.owner = creds->uid;
attr.group = creds->gid;
- attr.perms = PVFS2_translate_mode(0755, 0);
+ attr.perms = PVFS_util_translate_mode(0755, 0);
attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
ret = PVFS_sys_lookup(cur_fs,
Index: pvfs2-genconfig
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-genconfig,v
diff -p -u -r1.61 -r1.61.16.1
--- pvfs2-genconfig 14 Jun 2006 18:41:23 -0000 1.61
+++ pvfs2-genconfig 21 Jul 2008 18:19:47 -0000 1.61.16.1
@@ -8,6 +8,7 @@
#
use Term::ReadLine;
use Getopt::Long;
+use Math::BigInt;
# turn on strictness
use strict 'vars';
@@ -15,14 +16,19 @@ use strict 'vars';
# ugly global variables for option parsing
my $opt_protocol = '';
my $opt_port = '';
+my $opt_board = '';
my $opt_tcpport = '';
my $opt_gmport = '';
+my $opt_mxboard = '';
+my $opt_mxendpoint = '';
my $opt_ibport = '';
+my $opt_portal = '';
my $opt_ioservers = '';
my $opt_metaservers = '';
my $opt_logfile = '';
my $opt_storage = '';
my $opt_trovesync = '1';
+my $opt_trovemethod = '';
my $opt_quiet = '';
my $opt_logging = '';
my $opt_logstamp = '';
@@ -32,7 +38,10 @@ my $opt_first_handle = '';
my $opt_last_handle = '';
my $opt_root_handle = '';
my $opt_fsid = '';
+my $opt_fsname = '';
my $opt_default_num_dfiles = '';
+my $opt_default_flow_buffer_size = '';
+my $opt_default_flow_buffer_count = '';
my $opt_security = '0';
my $opt_trusted_port = '';
@@ -44,6 +53,13 @@ my $opt_metaspec = undef;
my %all_endpoints = ();
+my $default_storage = undef;
+my $default_logfile = undef;
+
+my $bmi_module = undef;
+
+my $opt_gen_key = 0;
+
my $META_ENDPOINT = 0x1;
my $IO_ENDPOINT = 0x2;
@@ -130,23 +146,23 @@ sub parse_hostlist
# hostb
# hostc{1,2,3}
#
- @components = $inputline =~ /(?:,?[ ]*([^{,]+(?:{[^}]+})?))/g;
+ @components = $inputline =~ /(?:,?[ ]*([^{,]+(?:{[^}]+})?[^,]*))/g;
foreach my $comp (@components)
{
# if we've got a component that has {..}, then expand.
# match the prefix (hostname) and curly brackets
- if($comp =~ /([^{]+){([^}]+)}/)
+ if($comp =~ /([^{]+){([^}]+)}(.*)$/)
{
my $prefix = $1;
my $ranges = $2;
-
+ my $suffix = $3;
+
# split the ranges string on the commas
foreach my $r (split(/,/, $ranges))
{
if($r !~ /-/)
{
# only one number, just push it on
- push @hosts, "$prefix$r";
}
else
{
@@ -154,7 +170,7 @@ sub parse_hostlist
my ($s, $f) = $r =~ /([0-9]+)-([0-9]+)/;
for(my $i = $s; $i <= $f; ++$i)
{
- push @hosts, "$prefix$i";
+ push @hosts, "$prefix$i$suffix";
}
}
}
@@ -173,18 +189,6 @@ sub emit_defaults
print $target "<Defaults>\n";
print $target "\tUnexpectedRequests $num_unexp\n";
-
- if(defined($logfile))
- {
- # remove quotes from logfile if any
- if ($logfile =~ /\".*\"/)
- {
- $logfile =~ s/\"//g;
- }
-
- print $target "\tLogFile $logfile\n";
- }
-
print $target "\tEventLogging $logging\n";
print $target "\tLogStamp $logstamp\n";
print $target "\tBMIModules $bmi_module\n";
@@ -197,6 +201,16 @@ sub emit_defaults
print $target "\tClientRetryLimit 5\n";
print $target "\tClientRetryDelayMilliSecs 2000\n";
+ if(defined($default_storage))
+ {
+ print $target "\n\tStorageSpace " . $default_storage . "\n";
+ }
+
+ if(defined($default_logfile))
+ {
+ print $target "\tLogFile " . $default_logfile . "\n";
+ }
+
print $target "</Defaults>\n";
}
@@ -227,16 +241,19 @@ sub emit_filesystem
{
my ($target, $name, $fs_id, $root_handle,
$last_handle, $first_handle, $count,
- $default_num_dfiles) = @_;
+ $default_num_dfiles, $default_flow_buffer_size, $default_flow_buffer_count) = @_;
- # divide handle range space equally among servers ((2^32)-1 for now)
+ # divide handle range space equally among servers ((2^63)-1 for now)
my($total_num_handles_available, $start, $end, $i, $step, $num_ranges);
$num_ranges = $count;
- $total_num_handles_available = $last_handle - $first_handle + 1;
+ $total_num_handles_available = $last_handle->copy();
+ $total_num_handles_available->bsub($first_handle);
+ $total_num_handles_available->binc();
# since meta and data handle ranges must be split, increment
# num nodes for calculation purposes below
- $step = sprintf("%lu",($total_num_handles_available / $num_ranges));
+ $step = $total_num_handles_available->copy();
+ $step->bdiv($num_ranges);
print $target "\n<Filesystem>\n";
print $target "\tName $name\n";
@@ -246,16 +263,19 @@ sub emit_filesystem
{
print $target "\tDefaultNumDFiles $default_num_dfiles\n";
}
- print $target "\t<MetaHandleRanges>\n";
- $start = $end = $first_handle - 1;
+ print $target "\t<MetaHandleRanges>\n";
+ $start = $end = $first_handle->copy();
+ $start->bdec();
+ $end->bdec();
my @meta_aliases = get_aliases($META_ENDPOINT);
@meta_aliases = sort @meta_aliases;
foreach my $ma (@meta_aliases)
{
- $start = $end + 1;
- $end += $step;
+ $start = $end->copy();
+ $start->binc();
+ $end->badd($step);
print $target "\t\tRange $ma $start-$end\n";
}
@@ -266,8 +286,9 @@ sub emit_filesystem
@io_aliases = sort @io_aliases;
foreach my $ia (@io_aliases)
{
- $start = $end + 1;
- $end += $step;
+ $start = $end->copy();
+ $start->binc();
+ $end->badd($step);
print $target "\t\tRange $ia $start-$end\n";
}
print $target "\t</DataHandleRanges>\n";
@@ -286,11 +307,51 @@ sub emit_filesystem
print $target "\t\tCoalescingLowWatermark 1\n";
}
+ if($opt_trovemethod ne "")
+ {
+ print $target "\t\tTroveMethod $opt_trovemethod\n";
+ }
+ else
+ {
+ print $target "\t\tTroveMethod alt-aio\n";
+ }
+
print $target "\t</StorageHints>\n";
+ if($opt_gen_key ne "0")
+ {
+ emit_fs_key($target);
+ }
+
+ if($default_flow_buffer_size > 0)
+ {
+ print $target "\tFlowBufferSizeBytes $default_flow_buffer_size\n";
+ }
+
+ if($default_flow_buffer_count > 0)
+ {
+ print $target "\tFlowBuffersPerFlow $default_flow_buffer_count\n";
+ }
+
print $target "</Filesystem>\n";
}
+sub emit_serveropts
+{
+ my $target = shift;
+
+ foreach my $alias (sort keys %all_endpoints)
+ {
+ my $endpoint = $all_endpoints{$alias};
+ print $target "\n<ServerOptions>\n";
+ print $target "\tServer $alias\n";
+ print $target "\tStorageSpace $endpoint->{STORAGE}\n";
+ print $target "\tLogFile $endpoint->{LOGFILE}\n";
+ print $target "</ServerOptions>\n";
+ }
+}
+
+
sub emit_server_conf
{
my($target, $node, $storage, $logfile) = @_;
@@ -300,6 +361,34 @@ sub emit_server_conf
print $target "LogFile $logfile\n";
}
+sub emit_fs_key
+{
+ my ($target, @path, $openssl_cmd, $b64_rand);
+
+ $target = $_[0];
+
+ $openssl_cmd = undef;
+
+ @path = split(/:/, $ENV{PATH});
+ for my $p (@path)
+ {
+ if( -x "$p/openssl" )
+ {
+ $openssl_cmd = "$p/openssl";
+ }
+ }
+
+ if(!defined($openssl_cmd))
+ {
+ print STDERR "\n\nFailed to find openssl executable in PATH\n\n";
+ exit 1;
+ }
+
+ $b64_rand = `$openssl_cmd rand -base64 20 2> /dev/null`;
+ chomp($b64_rand);
+ print $target "\tSecretKey $b64_rand\n";
+}
+
sub confirm
{
my($prompt, $char, $valid_char);
@@ -350,7 +439,7 @@ sub specusage
from the rest of the spec. While the protocols and ports are different, the
host for each uri must be the same. For example:
- --metaspec="[ib://myhosta:3335,gm://myhosta:6]:/psto,tcp://myhostb:3334"
+ --metaspec="[ib://myhosta:3335,gm://myhosta:6,mx://myhosta:0:3]:/psto,tcp://myhostb:3334"
This specifies that one endpoint is at myhosta with the infiniband and myrinet
protocols enabled, and the other endpoint is at myhostb with tcp enabled.
@@ -370,19 +459,15 @@ sub usage
# dump usage with a single HERE document rather than seperate print
# statements
print $OUT <<"THIS";
-Usage: pvfs2-genconfig [OPTIONS] <fs.conf> <server.conf>
+Usage: pvfs2-genconfig [OPTIONS] <fs.conf>
The pvfs2-genconfig utility creates configuration files for the
- PVFS2 file system. The <fs.conf> and <server.conf> arguments are
- manditory and specify the names of the configuration files that will
- be written. This utility will create one fs.conf file. It will also
- create a seperate server.conf file for each server in the file system.
- Each server.conf file will be appended with the host name of the server
- to which it belongs.
-
- EXAMPLE: 'pvfs2-genconfig /tmp/fs.conf /tmp/server.conf' will
- generate a file called /tmp/fs.conf and server specific files
- called /tmp/server.conf-host1, /tmp/server.conf-host2, etc.
+ PVFS2 file system. The <fs.conf> argument is
+ manditory and specify the name of the configuration file that will
+ be written. This utility will create the fs.conf file.
+
+ EXAMPLE: 'pvfs2-genconfig /tmp/fs.conf' will
+ generate a file called /tmp/fs.conf
NOTE: If pvfs2-genconfig is executed with a single argument of "-",
then all output is directed to stdout and no files are written.
@@ -390,23 +475,16 @@ Usage: pvfs2-genconfig [OPTIONS] <fs.con
arguments, then pvfs2-genconfig will prompt interactively for required
parameters.
- pvfs2-genconfig can also be executed non-interactively by providing,
- at a minimum, all of the following arguments:
-
- --logfile <STRING> logfile location
- --storage <STRING> storage space location
- --quiet run silently
-
- One of the two [] grouped options below must be chosen (for non-interactive):
+ pvfs2-genconfig can also be executed non-interactively with --quiet
+ and one of the two [] grouped options below:
[
- --protocol <PROTO>[,<PROTO>..] protocol(s) to use (tcp,gm,ib)
- --port <NUM> port to use (any single protocol)
- --ioservers <STRING> hostnames of data servers. Can be
+ --protocol <PROTO>[,<PROTO>..] protocol(s) to use (tcp,gm,mx,ib,portals)
+ --ioservers <STRING> hostnames of data servers. Can be
<prefix>{#-#,#,#-#,...}
--metaservers <STRING> hostnames of meta servers.
- ]
- or
+ ]
+ or
[
--iospec <STRING> endpoints of data servers. See --spec-usage
--metaspec <STRING> endpoints of meta servers. See --spec-usage
@@ -415,27 +493,38 @@ Usage: pvfs2-genconfig [OPTIONS] <fs.con
The following arguments are entirely optional, whether your intention is
to run pvfs2-genconfig in interactive or non-interactive mode:
- --tcpport <NUM> TCP port to use
- --gmport <NUM> GM port to use
- --ibport <NUM> IB port to use
+ --tcpport <NUM> TCP port to use (default: 3334)
+ --gmport <NUM> GM port to use (default: 6)
+ --mxboard <NUM> MX board to use (default is 0)
+ --mxendpoint <NUM> MX endpoint to use (default is 3)
+ --ibport <NUM> IB port to use (default is 3335)
+ --portal <NUM> Portals index for
+ listening server (default is 5)
--logging <STRING> debugging mask for log messages
--logstamp <STRING> timestamp type for log messages
('none','usec', or 'datetime' are valid)
+ --storage <STRING> path to pvfs storage directory.
+ --logfile <STRING> file to place server logging.
--notrovesync sync metadata only upon request
--server-job-timeout <NUM> server job timeout value (seconds)
--client-job-timeout <NUM> server job timeout value (seconds)
+ --trove-method <STRING> specify a trove method
--first-handle <NUM> first handle value to reserve
--last-handle <NUM> last handle value to reserve
--root-handle <NUM> handle value to reserve for root object
--fsid <NUM> fs identifier value
+ --fsname <STRING> fs name
--default-num-dfiles <NUM> number of datafiles to use per file
(defaults to number of I/O servers)
+ --flow-buffer-size <NUM> set flowbuffersize in bytes
+ --flow-buffer-count <NUM> set flow buffers per flow
--trusted <0|1> indicate whether trusted connection options need to be emitted
+ --genkey optionally generates a secret key for the
+ filesystem(s).
--help This message
--spec-usage Show the usage info for --iospec
and --metaspec options
-
THIS
}
@@ -468,8 +557,8 @@ You must enter the trusted port ranges t
This must be of the form <port1 - port2>
PORTLIST
;;
+ $type = prompt_word("Enter port list [Default is 0-65535]: ","0-65535");
}
- $type = prompt_word("Enter port list [Default is 0-65535]: ","0-65535");
return $type;
}
@@ -500,7 +589,7 @@ sub get_protocol
# get network type
print $OUT <<"PROTOCOL"
You must first select the network protocol that your file system will use.
-The only currently supported options are \"tcp\", \"gm\", and \"ib\".
+The only currently supported options are \"tcp\", \"gm\", \"mx\", \"ib\", and \"portals\".
(For multi-homed configurations, use e.g. \"ib,tcp\".)
PROTOCOL
;;
@@ -534,10 +623,14 @@ PROTOCOL
}
} elsif ($_ eq "gm") {
$port{'gm'} = gm_get_port();
+ } elsif ($_ eq "mx") {
+ $port{'mx'} = mx_get_endpoint();
} elsif ($_ eq "ib") {
$port{'ib'} = ib_get_port();
+ } elsif ($_ eq "portals") {
+ $port{'portals'} = portals_get_portal();
} else {
- die "Sorry. At this time, only the tcp, gm and ib protocols are available\nfor use with this configuration utility.\n";
+ die "Sorry. At this time, only the tcp, gm, mx, ib, and portals protocols are available\nfor use with this configuration utility.\n";
}
}
@@ -589,13 +682,24 @@ sub get_fsid
return $fsid;
}
+sub get_fsname
+{
+ my $fsname;
+ if ($opt_fsname) {
+ $fsname = $opt_fsname;
+ } else {
+ $fsname = "pvfs2-fs";
+ }
+ return $fsname;
+}
+
sub get_last_handle
{
my $last_handle;
if ($opt_last_handle) {
- $last_handle = $opt_last_handle;
+ $last_handle = Math::BigInt->new($opt_last_handle);
} else {
- $last_handle = 4294967297;
+ $last_handle = Math::BigInt->new('0x7FFFFFFFFFFFFFFF'); # 2^63
}
return $last_handle;
}
@@ -611,13 +715,35 @@ sub get_default_num_dfiles
return $default_num_dfiles;
}
+sub get_default_flow_buffer_size
+{
+ my $default_flow_buffer_size;
+ if($opt_default_flow_buffer_size ne '') {
+ $default_flow_buffer_size = $opt_default_flow_buffer_size;
+ } else {
+ $default_flow_buffer_size = -1;
+ }
+ return $default_flow_buffer_size;
+}
+
+sub get_default_flow_buffer_count
+{
+ my $default_flow_buffer_count;
+ if($opt_default_flow_buffer_count ne '') {
+ $default_flow_buffer_count = $opt_default_flow_buffer_count;
+ } else {
+ $default_flow_buffer_count = -1;
+ }
+ return $default_flow_buffer_count;
+}
+
sub get_first_handle
{
my $first_handle;
if ($opt_first_handle) {
- $first_handle = $opt_first_handle;
+ $first_handle = Math::BigInt->new($opt_first_handle);
} else {
- $first_handle = 4;
+ $first_handle = Math::BigInt->new(4);
}
return $first_handle;
}
@@ -646,28 +772,24 @@ sub get_client_job_timeout
sub get_logfile
{
- my $logfile;
+ my $logfile = "/tmp/pvfs2-server.log";
if ($opt_logfile) {
$logfile = $opt_logfile;
- } else {
- if (!$opt_quiet) {
+ } elsif (!$opt_quiet) {
print $OUT "Choose a file for each server to write log messages to.\n";
- }
- $logfile = prompt_word("Enter log file location [Default is /tmp/pvfs2-server.log]: ","/tmp/pvfs2-server.log");
+ $logfile = prompt_word("Enter log file location [Default is /tmp/pvfs2-server.log]: ","/tmp/pvfs2-server.log");
}
return $logfile;
}
sub get_storage
{
- my $storage;
+ my $storage = "/pvfs2-storage-space";
if ($opt_storage) {
$storage = $opt_storage;
- } else {
- if (!$opt_quiet) {
+ } elsif (!$opt_quiet) {
print $OUT "Choose a directory for each server to store data in.\n";
- }
- $storage = prompt_word("Enter directory name: [Default is /pvfs2-storage-space]: ","/pvfs2-storage-space");
+ $storage = prompt_word("Enter directory name: [Default is /pvfs2-storage-space]: ","/pvfs2-storage-space");
}
return $storage;
}
@@ -677,35 +799,30 @@ sub get_storage
# get host port
sub tcp_get_port
{
- my $port;
+ my $port = 3334;
if ($opt_tcpport) {
$port = $opt_tcpport;
- } elsif ($opt_port) {
- $port = $opt_port;
- $opt_port = '';
} elsif (!$opt_iospec) {
if (!$opt_quiet) {
print $OUT "Choose a TCP/IP port for the servers to listen on. Note that this\n";
print $OUT "script assumes that all servers will use the same port number.\n";
+ $port = prompt_num("Enter port number [Default is 3334]: ","3334");
}
- $port = prompt_num("Enter port number [Default is 3334]: ","3334");
}
return $port;
}
+
sub gm_get_port
{
- my $port;
+ my $port = 6;
if ($opt_gmport) {
$port = $opt_gmport;
- } elsif ($opt_port) {
- $port = $opt_port;
- $opt_port = '';
} elsif (!$opt_iospec) {
if (!$opt_quiet) {
print $OUT "Choose a GM port (in the range of 0 to 7) for the servers to listen on. \n";
print $OUT "This script assumes that all servers will use the same port number.\n";
+ $port = prompt_num("Enter port number [Default is 6]: ","6");
}
- $port = prompt_num("Enter port number [Default is 6]: ","6");
}
# every myrinet card i've seen has 8 ports. If myricom makes a card
# with more than that, we'll have to adapt
@@ -713,24 +830,72 @@ sub gm_get_port
return $port;
}
+
+sub mx_get_endpoint
+{
+ my $port = 3;
+ my $board = 0;
+
+ if ($opt_mxboard) {
+ $board = $opt_mxboard;
+ } elsif (!$opt_iospec) {
+ if (!$opt_quiet) {
+ print $OUT "Choose a MX board (in the range of 0 to 4) for the servers to listen on. \n";
+ print $OUT "This script assumes that all servers will use the same board number.\n";
+ $board = prompt_num("Enter board number [Default is 0]: ","0");
+ }
+ }
+ # The number of boards is only limited by the number of PCI-X or PCI-Express
+ # slots in the machine. This is reasonable maximum.
+ ($board < 8) or die "MX board must be in the range 0 to 7";
+
+ if ($opt_mxendpoint) {
+ $port = $opt_mxendpoint;
+ } elsif (!$opt_iospec) {
+ if (!$opt_quiet) {
+ print $OUT "Choose a MX endpoint (in the range of 0 to 7) for the servers to listen on. \n";
+ print $OUT "This script assumes that all servers will use the same port number.\n";
+ $port = prompt_num("Enter port number [Default is 3]: ","3");
+ }
+ }
+ # The number of endpoints in MX is configurable. The default value is 4
+ # but may be changing to 8. It can be higher, but this is reasonable.
+ ($port < 8) or die "MX endpoint must be in the range 0 to 7";
+
+ $port = $board . ":" . $port;
+ return $port;
+}
+
sub ib_get_port
{
- my $port;
+ my $port = 3335;
if ($opt_ibport) {
$port = $opt_ibport;
- } elsif ($opt_port) {
- $port = $opt_port;
- $opt_port = '';
} elsif(!$opt_iospec) {
if (!$opt_quiet) {
print $OUT "Choose a TCP/IP port for the servers to listen on for IB communications. Note that this\n";
print $OUT "script assumes that all servers will use the same port number.\n";
+ $port = prompt_num("Enter port number [Default is 3335]: ","3335");
}
- $port = prompt_num("Enter port number [Default is 3335]: ","3335");
}
return $port;
}
+sub portals_get_portal
+{
+ my $port = 5;
+ if ($opt_portal) {
+ $port = $opt_portal;
+ } elsif(!$opt_iospec) {
+ if (!$opt_quiet) {
+ print $OUT "Choose a portal index for the servers to listen on for communications. Note that this\n";
+ print $OUT "script assumes that all servers will use the same portal index.\n";
+ $port = prompt_num("Enter portal index [Default is 5]: ","5");
+ }
+ }
+ return $port;
+}
+
sub get_ionames
{
my $portmap = shift;
@@ -833,6 +998,7 @@ sub get_specs
my $proto = undef;
my $hostname = undef;
my $portn = undef;
+ my $boardn = undef;
if($ep =~ /^\[/)
{
# the string must have multiple protocols specified for the same
@@ -860,7 +1026,17 @@ sub get_specs
$prothost =~ /([a-z]+):\/\/([^:]+):([0-9]+)/;
$proto = $1;
my $hn = $2;
- $portn = $3;
+
+ # special casing for mx
+ if($proto =~ /mx/)
+ {
+ $boardn = $3;
+ $portn = $4;
+ }
+ else
+ {
+ $portn = $3;
+ }
if(!defined($hostname))
{
@@ -874,8 +1050,8 @@ sub get_specs
exit(1);
}
- $port{$proto} = $portn;
- $alias_suffix .= "_" . $proto . $portn;
+ $port{$proto} = "$boardn:$portn";
+ $alias_suffix .= "_" . $proto . $boardn . "_" . $portn;
}
my $alias = $hostname . $alias_suffix;
@@ -901,7 +1077,8 @@ sub get_specs
# match the storage and logfile respectively, with subgroups that
# put the actual strings into $4 and $5.
#
- $ep =~ /(?:([a-z]+):\/\/)?([^:]+):([^:]+)(?::([^:]+))?(?::([^:]+))?/;
+ my $count =
+ $ep =~ /(?:([a-z]+):\/\/)?([^:]+):([^:]+)(?::([^:]+))?(?::([^:]+))?(?::([^:]+))?/;
if(!defined($1))
{
# assume tcp for now
@@ -926,14 +1103,23 @@ sub get_specs
"requires a port number\n";
exit(1);
}
- my $ranges = $3;
- $stor = $4;
- $logf = $5;
+ my $branges = $3;
+ my $pranges = $4;
+ $stor = $5;
+ $logf = $6;
+
+ if($proto !~ /mx/)
+ {
+ $logf = $stor;
+ $stor = $pranges;
+ $pranges = $branges;
+ $branges = undef;
+ }
my ($s, $e);
- foreach my $r (split(/,/, $ranges))
+ foreach my $r (split(/,/, $pranges))
{
if($r !~ /-/)
{
@@ -951,22 +1137,86 @@ sub get_specs
for(my $i = $s; $i <= $e; ++$i)
{
- my $portmap = {$proto => $i};
- my $alias = $hostname . "_" . $proto . $i;
-
- if(exists $all_endpoints{$alias})
+ if($proto !~ /mx/)
{
- $all_endpoints{$alias}->{TYPE} |= $type;
+ my $portmap = {$proto => $i};
+ my $alias = $hostname . "_" . $proto . $i;
+
+ if(exists $all_endpoints{$alias})
+ {
+ $all_endpoints{$alias}->{TYPE} |= $type;
+ }
+ else
+ {
+ $all_endpoints{$alias} = {
+ ALIAS => $alias,
+ TYPE => $type,
+ HOSTNAME => $hostname,
+ PORTMAP => $portmap,
+ STORAGE => $stor,
+ LOGFILE => $logf};
+ }
}
else
{
- $all_endpoints{$alias} = {
- ALIAS => $alias,
- TYPE => $type,
- HOSTNAME => $hostname,
- PORTMAP => $portmap,
- STORAGE => $stor,
- LOGFILE => $logf};
+ if(!defined($branges))
+ {
+ my $portmap = {$proto => "$branges:$i"};
+ my $alias = $hostname . "_" . $proto . $branges . "_" . $i;
+ if(exists $all_endpoints{$alias})
+ {
+ $all_endpoints{$alias}->{TYPE} |= $type;
+ }
+ else
+ {
+ $all_endpoints{$alias} = {
+ ALIAS => $alias,
+ TYPE => $type,
+ HOSTNAME => $hostname,
+ PORTMAP => $portmap,
+ STORAGE => $stor,
+ LOGFILE => $logf};
+ }
+ }
+
+ my ($bs, $be);
+
+ foreach my $br (split(/,/, $branges))
+ {
+ if($br !~ /-/)
+ {
+ $bs = $br;
+ $be = $br;
+ }
+ else
+ {
+ if($br =~ /([0-9]+)-([0-9]+)/)
+ {
+ $bs = $1;
+ $be = $2;
+ }
+ }
+
+ for(my $bi = $bs; $bi <= $be; ++$bi)
+ {
+ my $portmap = {$proto => "$bi:$i"};
+ my $alias = $hostname . "_" . $proto . $bi . "_" . $i;
+ if(exists $all_endpoints{$alias})
+ {
+ $all_endpoints{$alias}->{TYPE} |= $type;
+ }
+ else
+ {
+ $all_endpoints{$alias} = {
+ ALIAS => $alias,
+ TYPE => $type,
+ HOSTNAME => $hostname,
+ PORTMAP => $portmap,
+ STORAGE => $stor,
+ LOGFILE => $logf};
+ }
+ }
+ }
}
}
}
@@ -1059,10 +1309,12 @@ my $show_specusage = '';
$opt_quiet = 0;
GetOptions('protocol=s' => \$opt_protocol,
- 'port=i' => \$opt_port,
'tcpport=i' => \$opt_tcpport,
'gmport=i' => \$opt_gmport,
+ 'mxboard=i' => \$opt_mxboard,
+ 'mxendpoint=i' => \$opt_mxendpoint,
'ibport=i' => \$opt_ibport,
+ 'portal=i' => \$opt_portal,
'ioservers=s' => \$opt_ioservers,
'metaservers=s' => \$opt_metaservers,
'logfile=s' => \$opt_logfile,
@@ -1071,8 +1323,11 @@ GetOptions('protocol=s' => \$opt_prot
'first-handle=i' => \$opt_first_handle,
'last-handle=i' => \$opt_last_handle,
'default-num-dfiles=i' => \$opt_default_num_dfiles,
+ 'flow-buffer-size=i' => \$opt_default_flow_buffer_size,
+ 'flow-buffer-count=i'=> \$opt_default_flow_buffer_count,
'root-handle=i' => \$opt_root_handle,
'fsid=i' => \$opt_fsid,
+ 'fsname=s' => \$opt_fsname,
'trusted=i' => \$opt_security,
'server-job-timeout=i' => \$opt_server_job_timeout,
'client-job-timeout=i' => \$opt_client_job_timeout,
@@ -1080,16 +1335,29 @@ GetOptions('protocol=s' => \$opt_prot
'help' => \$show_help,
'quiet!' => \$opt_quiet,
'trovesync!' => \$opt_trovesync,
+ 'trove-method=s' => \$opt_trovemethod,
'iospec=s' => \$opt_iospec,
'metaspec=s' => \$opt_metaspec,
'spec-usage!' => \$show_specusage,
+ 'genkey!' => \$opt_gen_key,
'-' => \$using_stdout)
or die "Could not parse arguments. See -h for help.\n";
-if(!((($opt_protocol && $opt_port && $opt_ioservers && $opt_metaservers) ||
- ($opt_iospec && $opt_metaspec)) &&
- $opt_quiet && $opt_logfile && $opt_storage))
+if($opt_quiet)
{
+ if(
+ !($opt_protocol && $opt_ioservers && $opt_metaservers)
+ &&
+ !($opt_iospec && $opt_metaspec)
+ )
+ {
+ # quiet requires full specification of server addresses somehow
+ die "Invalid arguments for --quiet usage. See -h for help\n";
+ }
+}
+else
+{
+
$term = new Term::ReadLine 'pvfs2-genconfig';
if(!defined($term))
{
@@ -1121,7 +1389,7 @@ my $output_target = undef;
if ($using_stdout) {
$output_target = \*STDOUT;
}
-elsif (@ARGV != 2)
+elsif (@ARGV != 1)
{
die "Bad arguments. See -h for help.\n";
}
@@ -1146,10 +1414,6 @@ if(defined($opt_metaspec) && !defined($o
print_welcome();
-my $default_storage = undef;
-my $default_logfile = undef;
-my $bmi_module = undef;
-
if($opt_metaspec)
{
get_specs($IO_ENDPOINT, $opt_iospec);
@@ -1244,8 +1508,11 @@ my $logstamp = get_logstamp();
my $first_handle = get_first_handle();
my $last_handle = get_last_handle();
my $default_num_dfiles = get_default_num_dfiles();
+my $default_flow_buffer_size = get_default_flow_buffer_size();
+my $default_flow_buffer_count = get_default_flow_buffer_count();
my $root_handle = get_root_handle();
my $fsid = get_fsid();
+my $fsname = get_fsname();
my $server_job_timeout = get_server_job_timeout();
my $client_job_timeout = get_client_job_timeout();
@@ -1258,10 +1525,6 @@ my $client_job_timeout = get_client_job_
if (!$opt_quiet) {
print $OUT "Writing fs config file... ";
- if ($using_stdout == 1)
- {
- print $OUT "\n";
- }
}
emit_defaults($output_target, $num_unexp_reqs,
@@ -1273,53 +1536,32 @@ if ($opt_security == 1)
$opt_trusted_network, $opt_trusted_netmask);
}
emit_aliases($output_target);
-emit_filesystem($output_target, "pvfs2-fs", $fsid, $root_handle,
- $last_handle, $first_handle, $count, $default_num_dfiles);
+emit_filesystem($output_target, $fsname , $fsid, $root_handle,
+ $last_handle, $first_handle, $meta_count + $io_count, $default_num_dfiles, $default_flow_buffer_size, $default_flow_buffer_count);
+
+if ($opt_metaspec) {
+ emit_serveropts($output_target);
+}
# close fs.conf
if ($using_stdout == 0)
{
close($output_target);
-}
-
-if (!$opt_quiet) {
- print $OUT "Done.\n";
-
- print $OUT "Writing ", $count, " server config file(s)... ";
- if ($using_stdout == 1)
- {
- print $OUT "\n";
- }
-}
-
-foreach my $ep (sort keys %all_endpoints)
-{
- my($filename);
-
- # and open server.conf files
- if ($using_stdout == 0)
- {
- $filename = "$ARGV[1]-" . $ep;
- unless (open(SERVEROUT, ">", $filename))
- {
- die "Can't open specified file $filename: $!\n";
- }
- $output_target = \*SERVEROUT;
- }
- emit_server_conf(
- $output_target, $ep,
- $all_endpoints{$ep}->{STORAGE},
- $all_endpoints{$ep}->{LOGFILE});
+ my $req_limit = 65536;
- if ($using_stdout == 0)
+ if(-s $ARGV[0] > $req_limit)
{
- close(SERVEROUT);
+ my $size = (-s $ARGV[0]);
+ print STDERR
+"Warning: Generated config file: " . $ARGV[0] . "\n" .
+"has size: $size, which is larger than the current PVFS request: $req_limit\n" .
+"Increase the value of PVFS_REQ_LIMIT_CONFIG_FILE_BYTES in src/proto/pvfs2-req-proto.h\n";
}
}
if (!$opt_quiet) {
- print $OUT "Done.\n";
+ print $OUT "done\n";
}
# Local variables:
Index: pvfs2-ln.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-ln.c,v
diff -p -u -r1.4 -r1.4.12.1
--- pvfs2-ln.c 1 Aug 2006 00:27:11 -0000 1.4
+++ pvfs2-ln.c 21 Jul 2008 18:19:47 -0000 1.4.12.1
@@ -131,7 +131,7 @@ static int make_link(PVFS_credentials
/* We need to change the PINT_remove_base_dir to an API call (pvfs_util),
* and we need to change this to use it
*/
- ret = PINT_remove_base_dir( (char *) pszPvfsPath,
+ ret = PINT_remove_base_dir( pszPvfsPath,
szBaseName,
sizeof(szBaseName));
@@ -209,7 +209,7 @@ static int parse_args(int argc, char** a
int ret = 0,
option_index = 0,
create_softlink = 0;
- char * cur_option = NULL;
+ const char * cur_option = NULL;
char flags[] = "hvVs"; /* Options available on command line */
static struct option long_opts[] =
@@ -225,7 +225,7 @@ static int parse_args(int argc, char** a
switch (ret)
{
case 0:
- cur_option = (char*)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if(strcmp("help", cur_option) == 0)
{
Index: pvfs2-ls.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-ls.c,v
diff -p -u -r1.65 -r1.65.16.1
--- pvfs2-ls.c 16 Jun 2006 21:01:11 -0000 1.65
+++ pvfs2-ls.c 21 Jul 2008 18:19:47 -0000 1.65.16.1
@@ -31,12 +31,6 @@
*/
#define MAX_NUM_DIRENTS 32
-/*
- arbitrarily restrict the number of paths
- that this ls version can take as arguments
-*/
-#define MAX_NUM_PATHS 8
-
/* optional parameters, filled in by parse_args() */
struct options
{
@@ -51,13 +45,14 @@ struct options
int list_no_owner;
int list_inode;
int list_use_si_units;
- char *start[MAX_NUM_PATHS];
+ char **start;
int num_starts;
};
static struct options* parse_args(int argc, char* argv[]);
static void usage(int argc, char** argv);
+static int do_timing = 0;
static void print_entry(
char *entry_name,
@@ -379,6 +374,13 @@ void print_entry(
print_entry_attr(handle, entry_name, &getattr_response.attr, opts);
}
+static double Wtime(void)
+{
+ struct timeval t;
+ gettimeofday(&t, NULL);
+ return((double)t.tv_sec * 1e03 + (double)(t.tv_usec) * 1e-03);
+}
+
int do_list(
char *start,
int fs_id,
@@ -396,6 +398,7 @@ int do_list(
PVFS_object_ref ref;
PVFS_ds_position token;
uint64_t dir_version = 0;
+ double begin = 0., end;
name = start;
@@ -415,8 +418,9 @@ int do_list(
pvfs_dirent_incount = MAX_NUM_DIRENTS;
memset(&getattr_response,0,sizeof(PVFS_sysresp_getattr));
- if (PVFS_sys_getattr(ref, PVFS_ATTR_SYS_ALL_NOHINT,
- &credentials, &getattr_response) == 0)
+ ret = PVFS_sys_getattr(ref, PVFS_ATTR_SYS_ALL_NOHINT,
+ &credentials, &getattr_response);
+ if(ret == 0)
{
if ((getattr_response.attr.objtype == PVFS_TYPE_METAFILE) ||
(getattr_response.attr.objtype == PVFS_TYPE_SYMLINK) ||
@@ -453,7 +457,14 @@ int do_list(
return 0;
}
}
+ else
+ {
+ PVFS_perror("PVFS_sys_getattr", ret);
+ return -1;
+ }
+ if (do_timing)
+ begin = Wtime();
token = 0;
do
{
@@ -507,6 +518,11 @@ int do_list(
}
} while(rd_response.pvfs_dirent_outcount == pvfs_dirent_incount);
+ if (do_timing) {
+ end = Wtime();
+ printf("PVFS_sys_readdir+sys_getattr took %g msecs\n",
+ (end - begin));
+ }
if (rd_response.pvfs_dirent_outcount)
{
@@ -525,7 +541,7 @@ int do_list(
static struct options* parse_args(int argc, char* argv[])
{
int i = 0, ret = 0, option_index = 0;
- char *cur_option = NULL;
+ const char *cur_option = NULL;
struct options* tmp_opts = NULL;
static struct option long_opts[] =
{
@@ -551,13 +567,13 @@ static struct options* parse_args(int ar
}
memset(tmp_opts, 0, sizeof(struct options));
- while((ret = getopt_long(argc, argv, "hVndGoAaigl",
+ while((ret = getopt_long(argc, argv, "hVndGoAaiglt",
long_opts, &option_index)) != -1)
{
switch(ret)
{
case 0:
- cur_option = (char *)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if (strcmp("help", cur_option) == 0)
{
@@ -620,6 +636,9 @@ static struct options* parse_args(int ar
list_verbose:
tmp_opts->list_verbose = 1;
break;
+ case 't':
+ do_timing = 1;
+ break;
case 'l':
tmp_opts->list_long = 1;
break;
@@ -658,19 +677,17 @@ static struct options* parse_args(int ar
exit(EXIT_FAILURE);
}
}
+ tmp_opts->start = (char **) calloc(1, (argc-optind+1) * sizeof(char *));
+ if (tmp_opts->start == NULL) {
+ exit(EXIT_FAILURE);
+ }
for(i = optind; i < argc; i++)
{
- if (tmp_opts->num_starts < MAX_NUM_PATHS)
- {
- tmp_opts->start[i-optind] = argv[i];
- tmp_opts->num_starts++;
- }
- else
- {
- fprintf(stderr,"Ignoring path %s\n",argv[i]);
- }
+ tmp_opts->start[i-optind] = argv[i];
+ tmp_opts->num_starts++;
}
+ assert(tmp_opts->num_starts < (argc - optind + 1));
return tmp_opts;
}
@@ -713,8 +730,8 @@ static void usage(int argc, char** argv)
int main(int argc, char **argv)
{
int ret = -1, i = 0;
- char pvfs_path[MAX_NUM_PATHS][PVFS_NAME_MAX];
- PVFS_fs_id fs_id_array[MAX_NUM_PATHS] = {0};
+ char **pvfs_path;
+ PVFS_fs_id *fs_id_array = NULL;
const PVFS_util_tab* tab;
struct options* user_opts = NULL;
char current_dir[PVFS_NAME_MAX] = {0};
@@ -736,12 +753,7 @@ int main(int argc, char **argv)
return(-1);
}
- for(i = 0; i < MAX_NUM_PATHS; i++)
- {
- memset(pvfs_path[i],0,PVFS_NAME_MAX);
- }
-
- ret = PVFS_sys_initialize(GOSSIP_NO_DEBUG);
+ ret = PVFS_sys_initialize(GOSSIP_NO_DEBUG);
if (ret < 0)
{
PVFS_perror("PVFS_sys_initialize", ret);
@@ -774,6 +786,28 @@ int main(int argc, char **argv)
user_opts->num_starts = 1;
}
+ pvfs_path = (char **) calloc(1, user_opts->num_starts * sizeof(char *));
+ if (!pvfs_path)
+ {
+ fprintf(stderr, "Could not alloc memory\n");
+ return -1;
+ }
+ for(i = 0; i < user_opts->num_starts; i++)
+ {
+ pvfs_path[i] = (char *) calloc(1, PVFS_NAME_MAX);
+ if (pvfs_path[i] == NULL)
+ {
+ fprintf(stderr, "Could not alloc memory\n");
+ return -1;
+ }
+ }
+ fs_id_array = (PVFS_fs_id *) calloc(1, user_opts->num_starts * sizeof(*fs_id_array));
+ if (fs_id_array == NULL)
+ {
+ fprintf(stderr, "Could not alloc memory\n");
+ return -1;
+ }
+
for(i = 0; i < user_opts->num_starts; i++)
{
ret = PVFS_util_resolve(user_opts->start[i],
@@ -805,8 +839,17 @@ int main(int argc, char **argv)
printf("\n");
}
}
+ for (i = 0; i < user_opts->num_starts; i++)
+ {
+ free(pvfs_path[i]);
+ }
+ free(user_opts->start);
+ free(pvfs_path);
+ free(fs_id_array);
PVFS_sys_finalize();
+ if (user_opts)
+ free(user_opts);
return(ret);
}
Index: pvfs2-migrate-collection.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-migrate-collection.c,v
diff -p -u -r1.17 -r1.17.12.1
--- pvfs2-migrate-collection.c 2 Aug 2006 20:13:18 -0000 1.17
+++ pvfs2-migrate-collection.c 21 Jul 2008 18:19:48 -0000 1.17.12.1
@@ -34,6 +34,7 @@
#include "mkspace.h"
#include "pint-distribution.h"
#include "pint-dist-utils.h"
+#include "pint-util.h"
#ifndef PVFS2_VERSION
#define PVFS2_VERSION "Unknown"
@@ -45,8 +46,9 @@ typedef struct
int fs_set;
int all_set;
int cleanup_set;
+ char alias[100];
+ int alias_set;
char fs_conf[PATH_MAX];
- char server_conf[PATH_MAX];
} options_t;
/** default size of buffers to use for reading old db keys */
@@ -137,9 +139,10 @@ int main(int argc, char **argv)
{
int ret = -1;
- /* all parameters read in from fs.conf and server.conf */
+ /* all parameters read in from fs.conf */
struct server_configuration_s server_config;
PINT_llist_p fs_configs;
+ char *server_alias;
/* make sure that the buffers we intend to use for reading keys and
* values is at least large enough to hold the maximum size of xattr keys
@@ -161,13 +164,31 @@ int main(int argc, char **argv)
return -1;
}
- ret = PINT_parse_config(&server_config, opts.fs_conf, opts.server_conf);
+ if(opts.alias_set)
+ {
+ server_alias = opts.alias;
+ }
+ else
+ {
+ server_alias = PINT_util_guess_alias();
+ }
+
+ ret = PINT_parse_config(&server_config, opts.fs_conf, server_alias);
if(ret < 0)
{
gossip_err("Error: Please check your config files.\n");
+ if(!opts.alias_set)
+ {
+ free(server_alias);
+ }
return -1;
}
+ if(!opts.alias_set)
+ {
+ free(server_alias);
+ }
+
if(opts.all_set)
{
/* get all the collection ids from the fs config */
@@ -390,6 +411,7 @@ static int parse_args(
{"version",0,0,0},
{"fs",1,0,0},
{"all",0,0,0},
+ {"alias",1,0,0},
{"cleanup",0,0,0},
{0,0,0,0}
};
@@ -422,7 +444,12 @@ static int parse_args(
opts->all_set = 1;
break;
- case 5: /* cleanup */
+ case 5: /* alias */
+ strncpy(opts->alias, optarg, 99);
+ opts->alias_set = 1;
+ break;
+
+ case 6: /* cleanup */
opts->cleanup_set = 1;
break;
default:
@@ -454,14 +481,6 @@ static int parse_args(
}
strcpy(opts->fs_conf, argv[optind++]);
- if(argc < optind)
- {
- /* missing server.conf */
- print_help(argv[0]);
- return(-1);
- }
- strcpy(opts->server_conf, argv[optind]);
-
return 0;
}
@@ -471,7 +490,7 @@ static int parse_args(
static void print_help(
char *progname) /**< executable name */
{
- fprintf(stderr,"\nusage: %s \\\n\t\t[OPTIONS] <global_config_file> <server_config_file>\n", progname);
+ fprintf(stderr,"\nusage: %s \\\n\t\t[OPTIONS] <global_config_file>\n", progname);
fprintf(stderr,"\nThis utility will migrate a PVFS2 collection from an old version\n"
"to the most recent version.\n\n");
fprintf(stderr,"One of the following arguments is required:\n");
@@ -485,6 +504,10 @@ static void print_help(
fprintf(stderr,"--------------\n");
fprintf(stderr," --cleanup "
"remove the old collection\n");
+ fprintf(stderr,
+ " --alias Specify the alias for this server.\n"
+ " The migration tool tries to guess the\n"
+ " alias based on the hostname if none is specified.\n");
fprintf(stderr," --verbose "
"print verbose messages during execution\n");
fprintf(stderr," --help "
@@ -615,7 +638,6 @@ static int translate_0_0_1(
* will create
*/
char handle_range[] = "4-64000000000";
- char* method_name = NULL;
TROVE_op_id op_id;
TROVE_context_id trove_context = -1;
char current_path[PATH_MAX];
@@ -681,7 +703,8 @@ static int translate_0_0_1(
}
/* initialize trove and lookup collection */
- ret = trove_initialize(storage_space, 0, &method_name, 0);
+ ret = trove_initialize(
+ TROVE_METHOD_DBPF, NULL, storage_space, 0);
if (ret < 0)
{
PVFS_perror("trove_initialize", ret);
@@ -689,7 +712,8 @@ static int translate_0_0_1(
pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
return(-1);
}
- ret = trove_collection_lookup(coll_name, &coll_id, NULL, &op_id);
+ ret = trove_collection_lookup(
+ TROVE_METHOD_DBPF, coll_name, &coll_id, NULL, &op_id);
if (ret != 1)
{
fprintf(stderr, "Error: failed to lookup new collection.\n");
@@ -740,7 +764,7 @@ static int translate_0_0_1(
/* at this point, we are done with the Trove API */
trove_close_context(coll_id, trove_context);
- trove_finalize();
+ trove_finalize(TROVE_METHOD_DBPF);
PINT_dist_finalize();
/* convert bstreams */
@@ -1249,28 +1273,28 @@ static int translate_keyval_key_0_0_1(TR
if(!strncmp(db_key->data, "root_handle", strlen("root_handle")))
{
keyval->buffer = ROOT_HANDLE_KEYSTR;
- keyval->buffer_sz = strlen(ROOT_HANDLE_KEYSTR);
+ keyval->buffer_sz = ROOT_HANDLE_KEYLEN;
}
else if(!strncmp(db_key->data, "dir_ent", strlen("dir_ent")))
{
keyval->buffer = DIRECTORY_ENTRY_KEYSTR;
- keyval->buffer_sz = strlen(DIRECTORY_ENTRY_KEYSTR);
+ keyval->buffer_sz = DIRECTORY_ENTRY_KEYLEN;
}
else if(!strncmp(db_key->data,
"datafile_handles", strlen("datafile_handles")))
{
keyval->buffer = DATAFILE_HANDLES_KEYSTR;
- keyval->buffer_sz = strlen(DATAFILE_HANDLES_KEYSTR);
+ keyval->buffer_sz = DATAFILE_HANDLES_KEYLEN;
}
else if(!strncmp(db_key->data, "metafile_dist", strlen("metafile_dist")))
{
keyval->buffer = METAFILE_DIST_KEYSTR;
- keyval->buffer_sz = strlen(METAFILE_DIST_KEYSTR);
+ keyval->buffer_sz = METAFILE_DIST_KEYLEN;
}
else if(!strncmp(db_key->data, "symlink_target", strlen("symlink_target")))
{
keyval->buffer = SYMLINK_TARGET_KEYSTR;
- keyval->buffer_sz = strlen(SYMLINK_TARGET_KEYSTR);
+ keyval->buffer_sz = SYMLINK_TARGET_KEYLEN;
}
else
{
@@ -1383,11 +1407,12 @@ static int translate_keyval_db_0_0_1(
/* assume its a component name of a directory entry */
t_key.buffer = key.data;
t_key.buffer_sz = key.size;
+ t_val.buffer = data.data;
+ t_val.buffer_sz = data.size;
trove_flags |= TROVE_KEYVAL_HANDLE_COUNT;
trove_flags |= TROVE_NOOVERWRITE;
}
-
- if(!strncmp(t_key.buffer, "md", 2)) /* metafile_dist */
+ else if(!strncmp(t_key.buffer, "md", 2)) /* metafile_dist */
{
PINT_dist *newdist;
newdist = data.data;
Index: pvfs2-mkdir.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-mkdir.c,v
diff -p -u -r1.10 -r1.10.4.1
--- pvfs2-mkdir.c 11 Sep 2006 20:22:01 -0000 1.10
+++ pvfs2-mkdir.c 21 Jul 2008 18:19:48 -0000 1.10.4.1
@@ -334,7 +334,7 @@ static int make_directory(PVFS_credentia
static int parse_args(int argc, char** argv, struct options * opts)
{
int i = 0, ret = 0,option_index = 0, mode_requested = 0;
- char * cur_option = NULL;
+ const char * cur_option = NULL;
char flags[] = "hm:pvV"; /* Options available on command line */
static struct option long_opts[] =
@@ -351,7 +351,7 @@ static int parse_args(int argc, char** a
switch (ret)
{
case 0:
- cur_option = (char*)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if(strcmp("help", cur_option) == 0)
{
@@ -456,7 +456,7 @@ static int parse_args(int argc, char** a
if(!mode_requested)
{
mode_t mode = S_IRWXO | S_IRWXG | S_IRWXU; /* 0777 */
- opts->mode = PVFS2_translate_mode(mode & ~PVFS_util_get_umask(), 0);
+ opts->mode = PVFS_util_translate_mode(mode & ~PVFS_util_get_umask(), 0);
}
/* Allocate memory to hold the filenames */
Index: pvfs2-mkspace.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-mkspace.c,v
diff -p -u -r1.19 -r1.19.30.1
--- pvfs2-mkspace.c 11 Nov 2005 21:30:57 -0000 1.19
+++ pvfs2-mkspace.c 21 Jul 2008 18:19:48 -0000 1.19.30.1
@@ -46,7 +46,7 @@ static void print_help(char *progname, o
static int parse_args(int argc, char **argv, options_t *opts)
{
int ret = 0, option_index = 0;
- char *cur_option = NULL;
+ const char *cur_option = NULL;
static struct option long_opts[] =
{
{"help",0,0,0},
@@ -76,7 +76,7 @@ static int parse_args(int argc, char **a
switch (ret)
{
case 0:
- cur_option = (char *)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if (strcmp("help", cur_option) == 0)
{
Index: pvfs2-perror.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-perror.c,v
diff -p -u -r1.2 -r1.2.24.1
--- pvfs2-perror.c 29 May 2006 16:16:36 -0000 1.2
+++ pvfs2-perror.c 21 Jul 2008 18:19:48 -0000 1.2.24.1
@@ -43,7 +43,7 @@ int main(int argc, char **argv)
return(-1);
}
- fprintf(stderr, "Error code %d: ", user_opts->error_code);
+ fprintf(stderr, "Error code %d", user_opts->error_code);
PVFS_perror("", -user_opts->error_code);
return(0);
@@ -102,9 +102,7 @@ static struct options* parse_args(int ar
static void usage(int argc, char** argv)
{
- fprintf(stderr, "\n");
- fprintf(stderr, "Usage : %s <error_code>\n",
- argv[0]);
+ fprintf(stderr, "Usage: %s <error_code>\n", argv[0]);
return;
}
Index: pvfs2-ping.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-ping.c,v
diff -p -u -r1.51 -r1.51.4.1
--- pvfs2-ping.c 11 Sep 2006 20:22:01 -0000 1.51
+++ pvfs2-ping.c 21 Jul 2008 18:19:48 -0000 1.51.4.1
@@ -39,7 +39,6 @@ static void print_mntent(
struct PVFS_sys_mntent *entries, int num_entries);
static int print_config(PVFS_fs_id fsid);
static int noop_all_servers(PVFS_fs_id fsid);
-static int check_config_all_servers(PVFS_fs_id fsid);
static void print_error_details(PVFS_error_details * error_details);
static void print_root_check_error_details(PVFS_error_details * error_details);
@@ -231,16 +230,6 @@ int main(int argc, char **argv)
printf(" Ok; root handle is owned by exactly one server.\n");
printf("\n");
}
- ret = check_config_all_servers(cur_fs);
- if (ret == 0)
- {
- printf("\n Ok; config files are all consistent!\n");
- }
- else
- {
- printf("\n Failure; config files have inconsistencies\n");
- err = 1;
- }
PVFS_sys_finalize();
@@ -362,177 +351,6 @@ static int noop_all_servers(PVFS_fs_id f
return(0);
}
-
-static void hash2str(unsigned char *hash, int hash_length, unsigned char *str)
-{
- int i, count = 0;
-
- if (!str || !hash || hash_length < 0)
- {
- return;
- }
- for (i = 0; i < hash_length; i++)
- {
- int cnt;
- cnt = sprintf((char *)str + count, "%02x", hash[i]);
- count += cnt;
- }
- return;
-}
-
-/* check_config_all_servers()
- *
- * sends a getconfig to all servers listed in the config file
- *
- * returns -PVFS_error on failure, 0 on success
- */
-static int check_config_all_servers(PVFS_fs_id fsid)
-{
- PVFS_credentials creds;
- int ret = -1;
- size_t digest_len;
- int count;
- PVFS_BMI_addr_t* addr_array;
- int i;
- int tmp;
- char **fs_configs = NULL, **svc_configs = NULL;
- int *fs_sizes = NULL, *svc_sizes = NULL;
- char **sha1_fs_digests = NULL;
- int fs_conf_failed = 0;
-
- PVFS_util_gen_credentials(&creds);
-
- printf("(8) Config Files Integrity Checks\n");
- ret = PVFS_mgmt_count_servers(
- fsid, &creds, PVFS_MGMT_IO_SERVER | PVFS_MGMT_META_SERVER, &count);
- if (ret < 0)
- {
- PVFS_perror("PVFS_mgmt_count_servers()", ret);
- return ret;
- }
- if (count == 1)
- {
- return 0;
- }
- addr_array = (PVFS_BMI_addr_t *) malloc(
- count * sizeof(PVFS_BMI_addr_t));
- if (addr_array == NULL)
- {
- perror("malloc");
- return -PVFS_ENOMEM;
- }
-
- ret = PVFS_mgmt_get_server_array(
- fsid, &creds, PVFS_MGMT_IO_SERVER | PVFS_MGMT_META_SERVER, addr_array, &count);
- if (ret < 0)
- {
- PVFS_perror("PVFS_mgmt_get_server_array()", ret);
- free(addr_array);
- return ret;
- }
- fs_configs = (char **) calloc(count, sizeof(char *));
- if (fs_configs == NULL)
- {
- fprintf(stderr, "Could not allocate fs_configs\n");
- free(addr_array);
- return -PVFS_ENOMEM;
- }
- svc_configs = (char **) calloc(count, sizeof(char *));
- if (svc_configs == NULL)
- {
- fprintf(stderr, "Could not allocate svc_configs\n");
- free(addr_array);
- free(fs_configs);
- return -PVFS_ENOMEM;
- }
- fs_sizes = (int *) calloc(count, sizeof(int));
- if (fs_sizes == NULL)
- {
- fprintf(stderr, "Could not allocate fs_sizes\n");
- free(addr_array);
- free(fs_configs);
- free(svc_configs);
- return -PVFS_ENOMEM;
- }
- svc_sizes = (int *) calloc(count, sizeof(int));
- if (svc_sizes == NULL)
- {
- fprintf(stderr, "Could not allocate svc_sizes\n");
- free(addr_array);
- free(fs_configs);
- free(svc_configs);
- free(fs_sizes);
- return -PVFS_ENOMEM;
- }
- sha1_fs_digests = (char **) calloc(count, sizeof(char *));
- if (sha1_fs_digests == NULL)
- {
- fprintf(stderr, "Could not allocate sha1digests\n");
- free(addr_array);
- free(fs_configs);
- free(svc_configs);
- free(fs_sizes);
- free(svc_sizes);
- return -PVFS_ENOMEM;
- }
- /* fetch the fs_config and server configuration files for all servers associated with this fsid */
- ret = PINT_fetch_config_list(count, addr_array, fs_configs, svc_configs, fs_sizes, svc_sizes);
- if (ret < 0)
- {
- PVFS_perror("PINT_fetch_config_list", ret);
- free(addr_array);
- free(fs_configs);
- free(svc_configs);
- free(fs_sizes);
- free(svc_sizes);
- free(sha1_fs_digests);
- return ret;
- }
- for (i = 0; i < count; i++)
- {
- ret = PINT_util_digest_sha1(fs_configs[i], fs_sizes[i], &sha1_fs_digests[i], &digest_len);
- if (ret < 0)
- goto out;
- }
- ret = 0;
- for (i = 1; i < count; i++)
- {
- if (memcmp(sha1_fs_digests[0], sha1_fs_digests[i], digest_len))
- {
- fs_conf_failed = 1;
- }
- }
- if (fs_conf_failed)
- {
- for (i = 0; i < count; i++)
- {
- unsigned char str[256];
- hash2str((unsigned char *) sha1_fs_digests[i], digest_len, str);
- printf(" FS config file on %s -> (SHA1) %s\n",
- PVFS_mgmt_map_addr(fsid, &creds, addr_array[i], &tmp), str);
- }
- ret = -PVFS_EINVAL;
- goto out;
- }
-out:
- for (i = 0; i < count; i++)
- {
- if (fs_configs && fs_configs[i])
- free(fs_configs[i]);
- if (svc_configs && svc_configs[i])
- free(svc_configs[i]);
- if (sha1_fs_digests && sha1_fs_digests[i])
- free(sha1_fs_digests[i]);
- }
- free(sha1_fs_digests);
- free(addr_array);
- free(fs_configs);
- free(svc_configs);
- free(fs_sizes);
- free(svc_sizes);
- return (ret == -PVFS_EOPNOTSUPP) ? 0 : ret;
-}
-
/* print_config()
*
Index: pvfs2-remove-object.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-remove-object.c,v
diff -p -u -r1.7 -r1.7.30.1
--- pvfs2-remove-object.c 11 Nov 2005 21:30:58 -0000 1.7
+++ pvfs2-remove-object.c 21 Jul 2008 18:19:48 -0000 1.7.30.1
@@ -56,7 +56,7 @@ static void usage(int argc, char **argv)
static options_t *parse_args(int argc, char **argv)
{
int ret = 0, option_index = 0;
- char *cur_option = NULL;
+ const char *cur_option = NULL;
options_t *tmp_opts = NULL;
static struct option long_opts[] =
{
@@ -87,7 +87,7 @@ static options_t *parse_args(int argc, c
switch(ret)
{
case 0:
- cur_option = (char *)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if (strcmp("help", cur_option) == 0)
{
Index: pvfs2-rm.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-rm.c,v
diff -p -u -r1.9 -r1.9.46.1
--- pvfs2-rm.c 22 Jul 2005 20:39:12 -0000 1.9
+++ pvfs2-rm.c 21 Jul 2008 18:19:48 -0000 1.9.46.1
@@ -39,6 +39,7 @@ int main(int argc, char **argv)
{
int ret = -1, i = 0;
struct options *user_opts = NULL;
+ PVFS_sysresp_getattr resp_getattr;
/* look at command line arguments */
user_opts = parse_args(argc, argv);
@@ -70,6 +71,9 @@ int main(int argc, char **argv)
PVFS_sysresp_lookup resp_lookup;
PVFS_credentials credentials;
PVFS_object_ref parent_ref;
+ int tmp_len = 0;
+
+ PVFS_util_gen_credentials(&credentials);
/* Translate path into pvfs2 relative path */
rc = PVFS_util_resolve(working_file, &cur_fs, pvfs_path,
@@ -81,6 +85,46 @@ int main(int argc, char **argv)
break;
}
+ tmp_len = strlen(pvfs_path);
+ if(pvfs_path[tmp_len - 1] == '/')
+ {
+ /* User requested removal of something with a trailing slash.
+ * Strip slashes, but then confirm that the target is in fact a
+ * directory, or else the request is invalid
+ */
+ while(tmp_len > 1 && pvfs_path[tmp_len - 1] == '/')
+ {
+ pvfs_path[tmp_len - 1] = '\0';
+ tmp_len--;
+ }
+
+ memset(&resp_lookup, 0, sizeof(PVFS_sysresp_lookup));
+ rc = PVFS_sys_lookup(cur_fs, pvfs_path, &credentials,
+ &resp_lookup, PVFS2_LOOKUP_LINK_NO_FOLLOW);
+ if (rc)
+ {
+ PVFS_perror("PVFS_sys_lookup", rc);
+ ret = -1;
+ break;
+ }
+
+ memset(&resp_getattr, 0, sizeof(PVFS_sysresp_getattr));
+ rc = PVFS_sys_getattr(resp_lookup.ref, PVFS_ATTR_SYS_TYPE,
+ &credentials, &resp_getattr);
+ if (rc)
+ {
+ PVFS_perror("PVFS_sys_getattr", rc);
+ ret = -1;
+ break;
+ }
+ if (resp_getattr.attr.objtype != PVFS_TYPE_DIRECTORY)
+ {
+ fprintf(stderr, "Error: object is not a directory.\n");
+ ret = -1;
+ break;
+ }
+ }
+
/* break into file and directory */
rc = PINT_get_base_dir(pvfs_path, directory, PVFS_NAME_MAX);
if(rc < 0)
@@ -99,9 +143,6 @@ int main(int argc, char **argv)
ret = -1;
break;
}
-
- credentials.uid = getuid();
- credentials.gid = getuid();
memset(&resp_lookup, 0, sizeof(PVFS_sysresp_lookup));
rc = PVFS_sys_lookup(cur_fs, directory, &credentials,
Index: pvfs2-set-debugmask.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-set-debugmask.c,v
diff -p -u -r1.23 -r1.23.18.1
--- pvfs2-set-debugmask.c 29 May 2006 16:21:10 -0000 1.23
+++ pvfs2-set-debugmask.c 21 Jul 2008 18:19:48 -0000 1.23.18.1
@@ -108,7 +108,7 @@ int main(int argc, char **argv)
static struct options *parse_args(int argc, char **argv)
{
int ret = -1, len = 0, option_index = 0;
- char *cur_option = NULL;
+ const char *cur_option = NULL;
struct options *tmp_opts = NULL;
static struct option long_opts[] =
{
@@ -136,7 +136,7 @@ static struct options *parse_args(int ar
switch(ret)
{
case 0:
- cur_option = (char *)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if (strcmp("help", cur_option) == 0)
{
Index: pvfs2-set-sync.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-set-sync.c,v
diff -p -u -r1.3 -r1.3.34.1
--- pvfs2-set-sync.c 29 May 2006 16:16:36 -0000 1.3
+++ pvfs2-set-sync.c 21 Jul 2008 18:19:48 -0000 1.3.34.1
@@ -203,8 +203,7 @@ static struct options* parse_args(int ar
static void usage(int argc, char** argv)
{
fprintf(stderr, "\n");
- fprintf(stderr, "Usage : %s -m <fs_mount_point> "
- "-D [0|1] -M [0|1] -T [NUM]\n",
+ fprintf(stderr, "Usage : %s -m <fs_mount_point> -D [0|1] -M [0|1]\n",
argv[0]);
fprintf(stderr, " -D always implicitly sync file data (0=off, 1=on)\n");
fprintf(stderr, " -M always implicitly sync metadata (0=off, 1=on)\n");
Index: pvfs2-showcoll.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-showcoll.c,v
diff -p -u -r1.22 -r1.22.18.1
--- pvfs2-showcoll.c 14 Jun 2006 18:41:24 -0000 1.22
+++ pvfs2-showcoll.c 21 Jul 2008 18:19:48 -0000 1.22.18.1
@@ -60,8 +60,6 @@ int main(int argc, char **argv)
TROVE_ds_state state;
TROVE_keyval_s key, val;
TROVE_context_id trove_context = -1;
- char *method_name;
- char root_handle_string[] = ROOT_HANDLE_KEYSTR;
ret = parse_args(argc, argv);
if (ret < 0) {
@@ -72,8 +70,10 @@ int main(int argc, char **argv)
}
/* initialize trove, verifying storage space exists */
- ret = trove_initialize(storage_space, 0, &method_name, 0);
- if (ret < 0) {
+ ret = trove_initialize(
+ TROVE_METHOD_DBPF, NULL, storage_space, 0);
+ if (ret < 0)
+ {
fprintf(stderr,
"%s: error: trove initialize failed; aborting!\n",
argv[0]);
@@ -92,10 +92,10 @@ int main(int argc, char **argv)
fprintf(stderr,
"%s: error: collection iterate failed; aborting!\n",
argv[0]);
- trove_finalize();
+ trove_finalize(TROVE_METHOD_DBPF);
return -1;
}
- trove_finalize();
+ trove_finalize(TROVE_METHOD_DBPF);
return 0;
}
@@ -105,7 +105,8 @@ int main(int argc, char **argv)
* - print out information on the dataspaces in the collection
*/
- ret = trove_collection_lookup(collection,
+ ret = trove_collection_lookup(TROVE_METHOD_DBPF,
+ collection,
&coll_id,
NULL,
&op_id);
@@ -114,7 +115,7 @@ int main(int argc, char **argv)
"%s: error: collection lookup failed for collection '%s'; aborting!.\n",
argv[0],
collection);
- trove_finalize();
+ trove_finalize(TROVE_METHOD_DBPF);
return -1;
}
@@ -132,8 +133,8 @@ int main(int argc, char **argv)
}
/* find root handle */
- key.buffer = root_handle_string;
- key.buffer_sz = strlen(root_handle_string) + 1;
+ key.buffer = ROOT_HANDLE_KEYSTR;
+ key.buffer_sz = ROOT_HANDLE_KEYLEN;
val.buffer = &root_handle;
val.buffer_sz = sizeof(root_handle);
ret = trove_collection_geteattr(coll_id,
@@ -190,7 +191,7 @@ int main(int argc, char **argv)
}
trove_close_context(coll_id, trove_context);
- trove_finalize();
+ trove_finalize(TROVE_METHOD_DBPF);
return 0;
}
@@ -500,7 +501,8 @@ static int print_collections(void)
fprintf(stdout, "Storage space %s collections:\n", storage_space);
while (count > 0) {
- ret = trove_collection_iterate(&pos,
+ ret = trove_collection_iterate(TROVE_METHOD_DBPF,
+ &pos,
&name,
&coll_id,
&count,
Index: pvfs2-stat.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-stat.c,v
diff -p -u -r1.7 -r1.7.12.1
--- pvfs2-stat.c 16 Aug 2006 01:23:18 -0000 1.7
+++ pvfs2-stat.c 21 Jul 2008 18:19:48 -0000 1.7.12.1
@@ -255,7 +255,7 @@ static int parse_args(int argc, char** a
int i = 0,
ret = 0,
option_index = 0;
- char * cur_option = NULL;
+ const char * cur_option = NULL;
static struct option long_opts[] =
{
@@ -271,7 +271,7 @@ static int parse_args(int argc, char** a
switch (ret)
{
case 0:
- cur_option = (char*)long_opts[option_index].name;
+ cur_option = long_opts[option_index].name;
if(strcmp("help", cur_option) == 0)
{
@@ -478,7 +478,22 @@ void print_stats(const PVFS_object_ref *
{
fprintf(stdout, " dir entries : %llu\n", llu(attr->dirent_count));
}
-
+
+ if ((attr->mask & PVFS_ATTR_SYS_TYPE) &&
+ (attr->objtype & PVFS_TYPE_METAFILE))
+ {
+ if (attr->flags == 0)
+ fprintf(stdout, " flags : none");
+ else
+ fprintf(stdout, " flags : ");
+ if (attr->flags & PVFS_IMMUTABLE_FL)
+ fprintf(stdout, "immutable, ");
+ if (attr->flags & PVFS_APPEND_FL)
+ fprintf(stdout, "append-only, ");
+ if (attr->flags & PVFS_NOATIME_FL)
+ fprintf(stdout, "noatime ");
+ fprintf(stdout, "\n");
+ }
}
static void usage(int argc, char** argv)
Index: pvfs2-touch.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-touch.c,v
diff -p -u -r1.3 -r1.3.22.1
--- pvfs2-touch.c 1 Aug 2006 00:27:11 -0000 1.3
+++ pvfs2-touch.c 21 Jul 2008 18:19:48 -0000 1.3.22.1
@@ -15,9 +15,11 @@
#include <time.h>
#include <stdlib.h>
#include <getopt.h>
+#include <assert.h>
#include "pvfs2.h"
#include "str-utils.h"
+#include "bmi.h"
#ifndef PVFS2_VERSION
#define PVFS2_VERSION "Unknown"
@@ -26,6 +28,8 @@
/* optional parameters, filled in by parse_args() */
struct options
{
+ int random;
+ char* server_list;
uint32_t num_files;
char **filenames;
};
@@ -37,6 +41,13 @@ int main(int argc, char **argv)
{
int ret = -1, i = 0;
struct options *user_opts = NULL;
+ char* tmp_server;
+ int tmp_server_index;
+ PVFS_sys_layout layout;
+
+ layout.algorithm = PVFS_SYS_LAYOUT_DEFAULT;
+ layout.server_list.count = 0;
+ layout.server_list.servers = NULL;
/* look at command line arguments */
user_opts = parse_args(argc, argv);
@@ -63,6 +74,14 @@ int main(int argc, char **argv)
char directory[PVFS_NAME_MAX];
char filename[PVFS_SEGMENT_MAX];
+ layout.algorithm = PVFS_SYS_LAYOUT_DEFAULT;
+ layout.server_list.count = 0;
+ if(layout.server_list.servers)
+ {
+ free(layout.server_list.servers);
+ }
+ layout.server_list.servers = NULL;
+
char pvfs_path[PVFS_NAME_MAX] = {0};
PVFS_fs_id cur_fs;
PVFS_sysresp_lookup resp_lookup;
@@ -109,7 +128,7 @@ int main(int argc, char **argv)
memset(&attr, 0, sizeof(PVFS_sys_attr));
attr.owner = credentials.uid;
attr.group = credentials.gid;
- attr.perms = 0;
+ attr.perms = 0777;
attr.atime = time(NULL);
attr.mtime = attr.atime;
attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
@@ -117,11 +136,67 @@ int main(int argc, char **argv)
parent_ref = resp_lookup.ref;
+ if(user_opts->random)
+ {
+ layout.algorithm = PVFS_SYS_LAYOUT_RANDOM;
+ }
+ else if(user_opts->server_list)
+ {
+ layout.algorithm = PVFS_SYS_LAYOUT_LIST;
+ layout.server_list.count = 1;
+ tmp_server = user_opts->server_list;
+
+ /* iterate once to count servers */
+ while((tmp_server = index(tmp_server, ',')))
+ {
+ layout.server_list.count++;
+ tmp_server++;
+ }
+
+ layout.server_list.servers =
+ malloc(layout.server_list.count*sizeof(PVFS_BMI_addr_t));
+ if(!(layout.server_list.servers))
+ {
+ perror("malloc");
+ ret = -1;
+ break;
+ }
+
+ /* split servers out and resolve each addr */
+ tmp_server_index = 0;
+ for(tmp_server = strtok(user_opts->server_list, ",");
+ tmp_server != NULL;
+ tmp_server = strtok(NULL, ","))
+ {
+ assert(tmp_server_index < layout.server_list.count);
+
+ /* TODO: is there a way to do this without internal BMI
+ * functions?
+ */
+ rc = BMI_addr_lookup(
+ &layout.server_list.servers[tmp_server_index],
+ tmp_server);
+ if(rc < 0)
+ {
+ PVFS_perror("BMI_addr_lookup", rc);
+ break;
+ }
+ tmp_server_index++;
+ }
+ if(tmp_server_index != layout.server_list.count)
+ {
+ fprintf(stderr, "Error: unable to resolve server list.\n");
+ ret = -1;
+ break;
+ }
+ }
+
rc = PVFS_sys_create(filename,
parent_ref,
attr,
&credentials,
NULL,
+ &layout,
&resp_create);
if (rc)
{
@@ -134,6 +209,12 @@ int main(int argc, char **argv)
}
PVFS_sys_finalize();
+
+ if(user_opts->server_list)
+ {
+ free(layout.server_list.servers);
+ free(user_opts->server_list);
+ }
free(user_opts);
return ret;
@@ -148,7 +229,7 @@ int main(int argc, char **argv)
static struct options* parse_args(int argc, char **argv)
{
int one_opt = 0;
- char flags[] = "?";
+ char flags[] = "l:r?";
struct options *tmp_opts = NULL;
tmp_opts = (struct options *)malloc(sizeof(struct options));
@@ -159,6 +240,8 @@ static struct options* parse_args(int ar
memset(tmp_opts, 0, sizeof(struct options));
tmp_opts->filenames = 0;
+ tmp_opts->server_list = NULL;
+ tmp_opts->random = 0;
while((one_opt = getopt(argc, argv, flags)) != EOF)
{
@@ -167,9 +250,26 @@ static struct options* parse_args(int ar
case('?'):
usage(argc, argv);
exit(EXIT_FAILURE);
+ case('l'):
+ tmp_opts->server_list = strdup(optarg);
+ if(!tmp_opts->server_list)
+ {
+ perror("strdup");
+ exit(EXIT_FAILURE);
+ }
+ break;
+ case('r'):
+ tmp_opts->random = 1;
+ break;
}
}
+ if(tmp_opts->random && tmp_opts->server_list)
+ {
+ fprintf(stderr, "Error: only one of -r or -l may be specified.\n");
+ exit(EXIT_FAILURE);
+ }
+
if (optind < argc)
{
int i = 0;
@@ -193,7 +293,10 @@ static struct options* parse_args(int ar
static void usage(int argc, char **argv)
{
- fprintf(stderr, "Usage: %s [-rf] pvfs2_filename[s]\n", argv[0]);
+ fprintf(stderr, "Usage: %s pvfs2_filename[s]\n", argv[0]);
+ fprintf(stderr, " optional arguments:\n");
+ fprintf(stderr, " -l use list layout (requires comma separated list of servers)\n");
+ fprintf(stderr, " -r use random layout\n");
}
/*
Index: pvfs2-viewdist.c
===================================================================
RCS file: /projects/cvsroot/pvfs2-1/src/apps/admin/pvfs2-viewdist.c,v
diff -p -u -r1.15 -r1.15.32.1
--- pvfs2-viewdist.c 16 Jun 2006 21:01:11 -0000 1.15
+++ pvfs2-viewdist.c 21 Jul 2008 18:19:48 -0000 1.15.32.1
@@ -256,12 +256,7 @@ int main(int argc, char ** argv)
/* okay now print out by deserializing the buffer */
PINT_dist_decode(&dist, dist_buf);
printf("dist_name = %s\n", dist->dist_name);
- if (strcmp(dist->dist_name, PVFS_DIST_SIMPLE_STRIPE_NAME) == 0)
- {
- PVFS_simple_stripe_params params;
- PINT_dist_getparams(¶ms, dist);
- printf("strip_size = %ld\n", (unsigned long)(params.strip_size));
- }
+ printf("dist_params:\n%s\n", dist->methods->params_string(dist->params));
PINT_dist_free(dist);
printf("Number of datafiles/servers = %d\n", nservers);
for (i = 0; i < nservers; i++)
More information about the Pvfs2-cvs
mailing list