[Pvfs2-cvs] commit by nlmills in pvfs2/src/apps/admin: pvfs2-getmattr pvfs2-setmattr pvfs2-change-fsid.c pvfs2-check-config.c pvfs2-cp.c pvfs2-fs-dump.c pvfs2-fsck.c pvfs2-genconfig pvfs2-ls.c pvfs2-migrate-collection.c pvfs2-mkspace.c pvfs2-showcoll.c pvfs2-stat.c pvfs2-xattr.c .cvsignore

CVS commit program cvs at parl.clemson.edu
Fri Jun 18 20:01:18 EDT 2010


Update of /projects/cvsroot/pvfs2/src/apps/admin
In directory parlweb1:/tmp/cvs-serv17259/src/apps/admin

Modified Files:
      Tag: cu-security-branch
	pvfs2-change-fsid.c pvfs2-check-config.c pvfs2-cp.c 
	pvfs2-fs-dump.c pvfs2-fsck.c pvfs2-genconfig pvfs2-ls.c 
	pvfs2-migrate-collection.c pvfs2-mkspace.c pvfs2-showcoll.c 
	pvfs2-stat.c pvfs2-xattr.c 
Added Files:
      Tag: cu-security-branch
	pvfs2-getmattr pvfs2-setmattr 
Removed Files:
      Tag: cu-security-branch
	.cvsignore 
Log Message:
initial merge with Orange-Branch. much will be broken




Index: pvfs2-change-fsid.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-change-fsid.c,v
diff -p -u -r1.1.8.1 -r1.1.8.2
--- pvfs2-change-fsid.c	25 Aug 2009 17:55:47 -0000	1.1.8.1
+++ pvfs2-change-fsid.c	19 Jun 2010 00:01:16 -0000	1.1.8.2
@@ -38,7 +38,8 @@ typedef struct
     char db_path[PATH_MAX];
     char fs_conf[PATH_MAX];
     char fs_name[PATH_MAX];
-    char storage_path[PATH_MAX];
+    char data_storage_path[PATH_MAX];
+    char meta_storage_path[PATH_MAX];
     int32_t old_fsid;
     int32_t new_fsid;
     char old_fsid_hex[9];
@@ -313,23 +314,37 @@ int get_old_fsid_from_conf(void)
 int move_hex_dir(void)
 {
     FILE * fptr = NULL;
-    char command[PATH_MAX];
-    char output[PATH_MAX];
+    char datacommand[PATH_MAX];
+    char metacommand[PATH_MAX];
+    char dataoutput[PATH_MAX];
+    char metaoutput[PATH_MAX];
     struct stat buf;
-    char path[PATH_MAX];
-    char new_path[PATH_MAX];
+    char datapath[PATH_MAX];
+    char new_datapath[PATH_MAX];
+    char metapath[PATH_MAX];
+    char new_metapath[PATH_MAX];
     int ret = 0;
     
-    memset(path,0,sizeof(path));
-    sprintf(path,"%s/%s", opts.storage_path, opts.old_fsid_hex);
+    memset(datapath, 0, sizeof(datapath));
+    memset(metapath, 0, sizeof(metapath));
+    sprintf(datapath, "%s%s", opts.data_storage_path, opts.old_fsid_hex);
+    sprintf(metapath, "%s/%s", opts.meta_storage_path, opts.old_fsid_hex);
 
-    /* See if directory exists */
-    ret = stat(path, &buf);
+    /* See if each directory exists */
+    ret = stat(datapath, &buf);
+    if(ret)
+    {
+        fprintf(stderr,
+                "Error checking for data directory's existance. [%s]\n",
+                datapath);
+        return -1;
+    }
+    ret = stat(metapath, &buf);
     if(ret)
     {
         fprintf(stderr,
-                "Error checking for directory's existance. [%s]\n",
-                path);
+                "Error checking for meta directory's existance. [%s]\n",
+                metapath);
         return -1;
     }
 
@@ -340,31 +355,53 @@ int move_hex_dir(void)
         return 0;
     }
     
-    memset(command,0,sizeof(command));
-    memset(output,0,sizeof(output));
-    memset(new_path,0,sizeof(new_path));
+	memset(datacommand, 0, sizeof(datacommand));
+	memset(metacommand, 0, sizeof(metacommand));
+	memset(dataoutput, 0, sizeof(dataoutput));
+	memset(metaoutput, 0, sizeof(metaoutput));
+	memset(new_datapath, 0, sizeof(new_datapath));
+    memset(new_metapath, 0, sizeof(new_metapath));
+
+    /* Move the directories */
+	sprintf(new_datapath, "%s/%s", opts.data_storage_path, opts.new_fsid_hex);
+	sprintf(new_metapath, "%s%s", opts.meta_storage_path, opts.new_fsid_hex);
+	sprintf(datacommand, "mv %s %s", datapath, new_datapath);
+	sprintf(metacommand, "mv %s %s", metapath, new_metapath);
 
-    /* Move the directory */
-    sprintf(new_path, "%s/%s", opts.storage_path, opts.new_fsid_hex);
-    sprintf(command, "mv %s %s", path, new_path);
+	/* move the data dir */
+    fptr = popen(datacommand, "r");
+    if(fptr == NULL)
+    {
+        fprintf(stderr,"Error opening pipe. errno=%d",errno);
+        exit(-1);
+    }
+    ret = fscanf(fptr, "%s", dataoutput);
+    if(ret && strncmp(dataoutput,"",PATH_MAX))
+    {
+        printf("mv from [%s] to [%s] failed.\n", datapath, new_datapath);
+        return -1;
+    }
+    pclose(fptr);
 
-    fptr = popen(command, "r");
+	/* move the meta dir */
+	fptr = popen(metacommand, "r");
     if(fptr == NULL)
     {
         fprintf(stderr,"Error opening pipe. errno=%d",errno);
         exit(-1);
     }
-    ret = fscanf(fptr, "%s", output);
-    if(ret && strncmp(output,"",PATH_MAX))
+    ret = fscanf(fptr, "%s", metaoutput);
+    if(ret && strncmp(metaoutput,"",PATH_MAX))
     {
-        printf("mv from [%s] to [%s] failed.\n", path, new_path);
+        printf("mv from [%s] to [%s] failed.\n", metapath, new_metapath);
         return -1;
     }
     pclose(fptr);
 
     if(opts.verbose)
     {
-        printf("Successful dir move from [%s] to [%s]\n", path, new_path);
+        printf("Successful data dir move from [%s] to [%s]\n", datapath, new_datapath);
+		printf("Successful meta dir move from [%s] to [%s]\n", metapath, new_metapath);
     }
 
     return 0;
@@ -516,7 +553,8 @@ int process_args(int argc, char ** argv)
         {"fsname",1,0,0},
         {"dbpath",1,0,0},
         {"fsconf",1,0,0},
-        {"storage",1,0,0},
+        {"datastorage",1,0,0},
+        {"metastorage",1,0,0},
         {"view",0,0,0},
         {0,0,0,0}
     };
@@ -561,11 +599,15 @@ int process_args(int argc, char ** argv)
                 strncpy(opts.fs_conf, optarg, PATH_MAX);
                 break;
 
-            case 7: /* storage */
-                strncpy(opts.storage_path, optarg, PATH_MAX);
+            case 7: /* data storage */
+                strncpy(opts.data_storage_path, optarg, PATH_MAX);
                 break;
 
-            case 8: /* view */
+	    	case 8: /* meta storage */
+				strncpy(opts.meta_storage_path, optarg, PATH_MAX);
+				break;
+
+            case 9: /* view */
                 opts.view_only = 1;
                 break;
 
@@ -592,10 +634,18 @@ int process_args(int argc, char ** argv)
         return(-1);
     }
 
-    /* storage_path must be set */
-    if(!strncmp(opts.storage_path,"",PATH_MAX))
+    /* data storage_path must be set */
+    if(!strncmp(opts.data_storage_path,"",PATH_MAX))
+    {
+        fprintf(stderr,"Error: --datastorage option must be given.\n");
+        print_help(argv[0]);
+        return(-1);
+    }
+
+    /* meta storage_path must be set */
+    if(!strncmp(opts.meta_storage_path,"",PATH_MAX))
     {
-        fprintf(stderr,"Error: --storage option must be given.\n");
+        fprintf(stderr,"Error: --metastorage option must be given.\n");
         print_help(argv[0]);
         return(-1);
     }
@@ -612,8 +662,10 @@ void print_help(char * progname)
             "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,"  --datastorage=</path/to/pvfs2-data-storage-space>     "
+            "Local data storage space for the the file system being modified.\n");
+    fprintf(stderr,"  --metastorage=</path/to/pvfs2-meta-storage-space>     "
+            "Local meta storage space for the the file system being modified.\n");
     fprintf(stderr, "\n");
     fprintf(stderr,"The following arguments are optional:\n");
     fprintf(stderr,"--------------\n");

Index: pvfs2-check-config.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-check-config.c,v
diff -p -u -r1.5.52.3 -r1.5.52.4
--- pvfs2-check-config.c	27 May 2010 04:38:02 -0000	1.5.52.3
+++ pvfs2-check-config.c	19 Jun 2010 00:01:16 -0000	1.5.52.4
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
         fprintf(stderr, "Unable to initialize PVFS\n");
         return -1;
     }
-    
+
     /* Construct the list of mount points */
     mnt = PVFS_util_parse_pvfstab(0);
     if (0 != mnt)

Index: pvfs2-cp.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-cp.c,v
diff -p -u -r1.26.2.13 -r1.26.2.14
--- pvfs2-cp.c	4 Jun 2010 19:26:25 -0000	1.26.2.13
+++ pvfs2-cp.c	19 Jun 2010 00:01:16 -0000	1.26.2.14
@@ -303,7 +303,7 @@ static void usage(int argc, char** argv)
     fprintf(stderr, "Where ARGS is one or more of"
 	"\n-s <strip_size>\t\t\tsize of access to PVFS2 volume"
 	"\n-n <num_datafiles>\t\tnumber of PVFS2 datafiles to use"
-	"\n-b <buffer_size>\t\thow much data to read/write at once"
+	"\n-b <buffer_size in bytes>\thow much data to read/write at once"
 	"\n-t\t\t\t\tprint some timing information"
 	"\n-v\t\t\t\tprint version number and exit\n");
     return;

Index: pvfs2-fs-dump.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-fs-dump.c,v
diff -p -u -r1.43.34.8 -r1.43.34.9
--- pvfs2-fs-dump.c	4 Jun 2010 19:26:25 -0000	1.43.34.8
+++ pvfs2-fs-dump.c	19 Jun 2010 00:01:16 -0000	1.43.34.9
@@ -360,7 +360,7 @@ int build_handlelist(PVFS_fs_id cur_fs,
     do
     {
 	PVFS_util_refresh_credential(creds);
-        ret = PVFS_mgmt_iterate_handles_list(cur_fs,
+	ret = PVFS_mgmt_iterate_handles_list(cur_fs,
 					     creds,
 					     handle_matrix,
 					     hcount_array,

Index: pvfs2-fsck.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-fsck.c,v
diff -p -u -r1.24.4.8 -r1.24.4.9
--- pvfs2-fsck.c	4 Jun 2010 19:26:25 -0000	1.24.4.8
+++ pvfs2-fsck.c	19 Jun 2010 00:01:16 -0000	1.24.4.9
@@ -899,7 +899,7 @@ struct handlelist *find_sub_trees(PVFS_f
 	PVFS_object_ref handle_ref;
 	PVFS_sysresp_getattr getattr_resp;
 
-        PVFS_util_refresh_credential(creds);
+	PVFS_util_refresh_credential(creds);
 
 	handle_ref.handle = handle;
 	handle_ref.fs_id  = cur_fs;
@@ -982,7 +982,7 @@ struct handlelist *fill_lost_and_found(P
 	PVFS_object_ref handle_ref;
 	PVFS_sysresp_getattr getattr_resp;
 
-        PVFS_util_refresh_credential(creds);
+	PVFS_util_refresh_credential(creds);
 
 	handle_ref.handle = handle;
 	handle_ref.fs_id  = cur_fs;
@@ -1095,7 +1095,7 @@ void cull_leftovers(PVFS_fs_id cur_fs,
 	PVFS_object_ref handle_ref;
 	PVFS_sysresp_getattr getattr_resp;
 
-        PVFS_util_refresh_credential(creds);
+	PVFS_util_refresh_credential(creds);
 
 	handle_ref.handle = handle;
 	handle_ref.fs_id  = cur_fs;

Index: pvfs2-genconfig
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-genconfig,v
diff -p -u -r1.78.2.9 -r1.78.2.10
--- pvfs2-genconfig	21 May 2010 17:33:56 -0000	1.78.2.9
+++ pvfs2-genconfig	19 Jun 2010 00:01:16 -0000	1.78.2.10
@@ -9,8 +9,6 @@
 use Term::ReadLine;
 use Getopt::Long;
 use Math::BigInt;
-use File::Basename;
-use Cwd 'abs_path';;
 
 # turn on strictness
 use strict 'vars';
@@ -30,8 +28,6 @@ my $opt_ioservers = '';
 my $opt_metaservers = '';
 my $opt_logfile = '';
 my $opt_storage = '';
-my $opt_pubkey = '';
-my $opt_privkey = '';
 my $opt_trovesync = '1';
 my $opt_trovemethod = '';
 my $opt_quiet = '';
@@ -60,10 +56,8 @@ my $opt_metaspec = undef;
 my %all_endpoints = ();
 
 my $default_storage = undef;
+my $default_meta_storage = undef;
 my $default_logfile = undef;
-my $default_pubkey = undef;
-my $default_privkey = undef;
-my $security_flag = '';
 
 my $bmi_module = undef;
 
@@ -74,7 +68,6 @@ my $IO_ENDPOINT   = 0x2;
 
 my $OUT = undef;
 my $term = undef;
-my $dirname = undef;
 
 #$num_unexp_reqs = prompt_num("How many unexpected requests should we be prepared to receive?  ");
 my $num_unexp_reqs = 50;
@@ -157,8 +150,15 @@ sub parse_hostlist
     # hostc{1,2,3}
     #
     @components = $inputline =~ /(?:,?[ ]*([^{,]+(?:{[^}]+})?[^,]*))/g;
-    foreach my $comp (@components)
+    foreach my $comp_ws (@components)
     {
+        my $comp;
+
+        # Trim leading and trailing whitespace
+        $comp = $comp_ws;
+        $comp =~ s/^\s+//;
+        $comp =~ s/\s+$//;
+
         # if we've got a component that has {..}, then expand.
         # match the prefix (hostname) and curly brackets
         if($comp =~ /([^{]+){([^}]+)}(.*)$/)
@@ -216,7 +216,12 @@ sub emit_defaults
 
     if(defined($default_storage))
     {
-        print $target "\n\tStorageSpace " . $default_storage . "\n";
+        print $target "\n\tDataStorageSpace " . $default_storage . "\n";
+    }
+
+    if(defined($default_meta_storage))
+    {
+        print $target "\tMetadataStorageSpace " . $default_meta_storage . "\n\n";
     }
 
     if(defined($default_logfile))
@@ -228,16 +233,6 @@ sub emit_defaults
     {
         print $target "\tTCPBindSpecific yes\n";
     }
-    
-    if(!($default_pubkey eq ""))
-    {
-        print $target "\tKeyStore " . $default_pubkey . "\n";
-    }
-    
-    if(!($default_privkey eq ""))
-    {
-        print $target "\tServerKey " . $default_privkey . "\n";
-    }
 
     print $target "</Defaults>\n";
 }
@@ -390,7 +385,8 @@ sub emit_serveropts
         my $endpoint = $all_endpoints{$alias};
         print $target "\n<ServerOptions>\n";
         print $target "\tServer $alias\n";
-        print $target "\tStorageSpace $endpoint->{STORAGE}\n";
+        print $target "\tDataStorageSpace $endpoint->{STORAGE}\n";
+        print $target "\tMetadataStorageSpace $endpoint->{METASTORAGE}\n";
         print $target "\tLogFile $endpoint->{LOGFILE}\n";
         print $target "</ServerOptions>\n";
     }
@@ -399,9 +395,10 @@ sub emit_serveropts
 
 sub emit_server_conf
 {
-    my($target, $node, $storage, $logfile) = @_;
+    my($target, $node, $storage, $metastorage, $logfile) = @_;
 
-    print $target "StorageSpace $storage\n";
+    print $target "DataStorageSpace $storage\n";
+    print $target "MetadataStorageSpace $metastorage\n";
     print $target "HostID \"" . get_bmi_endpoint($node) . "\"\n";
     print $target "LogFile $logfile\n";
 }
@@ -852,44 +849,18 @@ sub get_storage
     return $storage;
 }
 
-sub get_pubkey
-{
-    my $pubkey = $dirname . "/keystore";
-    if ($opt_pubkey) {
-        $pubkey = $opt_pubkey;
-    } elsif (!$opt_quiet) {
-        if($security_flag eq "")
-        {
-            print $OUT "Choose whether or not you compiled with encryption enabled.\n";
-            $security_flag = prompt_word("Did you compile with encryption [Default is n]? ","n");
-        }
-        if(($security_flag eq "n" or $security_flag eq "no"))
-        {
-            return "";
-        }
-        print $OUT "Choose the path to the public key file.\n";
-        $pubkey = prompt_word("Enter public key file path: [Default is " . $dirname . "/keystore]: ",$dirname . "/keystore");
-    }
-    return $pubkey;
-}
-
-sub get_privkey
+sub get_meta_storage
 {
-    if(($security_flag eq "n" or $security_flag eq "no"))
-    {
-        return "";
-    }
-    my $privkey = $dirname . "/privkey.pem";
-    if ($opt_privkey) {
-        $privkey = $opt_privkey;
+    my $metastorage = "/pvfs2-storage-space";
+    if ($opt_storage) {
+        $metastorage = $opt_storage;
     } elsif (!$opt_quiet) {
-        print $OUT "Choose the path to the private key file.\n";
-        $privkey = prompt_word("Enter private key file path: [Default is " . $dirname . "/privkey.pem]: ",$dirname . "/privkey.pem");
+            print $OUT "Choose a directory for each server to store metadata in.\n";
+            $metastorage = prompt_word("Enter directory name: [Default is /pvfs2-storage-space]: ","/pvfs2-storage-space");
     }
-    return $privkey;
+    return $metastorage;
 }
 
-
 # get host port
 sub tcp_get_port
 {
@@ -994,9 +965,8 @@ sub get_ionames
 {
     my $portmap = shift;
     my $storage = shift;
+    my $metastorage = shift;
     my $logfile = shift;
-    my $pubkey = shift;
-    my $privkey = shift;
     my $ioline = '';
     if ($opt_ioservers) {
         $ioline = $opt_ioservers;
@@ -1025,10 +995,9 @@ sub get_ionames
                 TYPE => $IO_ENDPOINT,
                 HOSTNAME => $io_host, 
                 PORTMAP => $portmap, 
-                STORAGE => $storage, 
-                LOGFILE => $logfile,
-                PUBKEY => $pubkey,
-                PRIVKEY => $privkey};
+                STORAGE => $storage,
+                METASTORAGE => $metastorage, 
+                LOGFILE => $logfile};
         }
     }
 }
@@ -1037,9 +1006,8 @@ sub get_metanames
 {
     my $portmap = shift;
     my $storage = shift;
+    my $metastorage = shift;
     my $logfile = shift;
-    my $pubkey = shift;
-    my $privkey = shift;
     my $metaline = '';
     my @meta_hosts;
     if ($opt_metaservers) {
@@ -1084,10 +1052,9 @@ sub get_metanames
                 TYPE => $META_ENDPOINT,
                 HOSTNAME => $meta_host, 
                 PORTMAP => $portmap, 
-                STORAGE => $storage, 
-                LOGFILE => $logfile,
-                PUBKEY => $pubkey,
-                PRIVKEY => $privkey};
+                STORAGE => $storage,
+                METASTORAGE => $metastorage, 
+                LOGFILE => $logfile};
         }
     }
 }
@@ -1115,6 +1082,7 @@ sub get_specs
     foreach my $ep (@endpoints)
     {
         my $stor = undef;
+        my $mstor = undef;
         my $logf = undef;
         my $proto = undef;
         my $hostname = undef;
@@ -1125,12 +1093,14 @@ sub get_specs
             # the string must have multiple protocols specified for the same
             # endpoint.  We want to match on [...]:storage:logfile
             # and place the stuff between the [] in $1, and optionally
-            # place the matched storage path and logfile in $2 and $3 
+            # place the matched storage path and meta path in $2 and $3,
+            # logfile is in $4
             #
             $ep =~ /\[([^\]]+)\](?::([^:]+))?(?::([^:]+))?/;
 
             $stor = $2;
-            $logf = $3;
+            $mstor = $3;
+            $logf = $4;
 
             if(!defined($1))
             {
@@ -1181,7 +1151,8 @@ sub get_specs
                 TYPE => $type,
                 HOSTNAME => $hostname, 
                 PORTMAP => \%port, 
-                STORAGE => $stor, 
+                STORAGE => $stor,
+                METASTORAGE => $mstor, 
                 LOGFILE => $logf};
         }
         else
@@ -1228,12 +1199,14 @@ sub get_specs
             my $branges = $3;
             my $pranges = $4;
             $stor = $5;
-            $logf = $6;
+            $mstor = $6;
+            $logf = $7;
 
             if($proto !~ /mx/)
             {
                 $logf = $stor;
-                $stor = $pranges;
+                $stor = $mstor;
+                $mstor = $pranges;
                 $pranges = $branges;
                 $branges = undef;
             }
@@ -1275,6 +1248,7 @@ sub get_specs
                                 HOSTNAME => $hostname,
                                 PORTMAP => $portmap, 
                                 STORAGE => $stor, 
+                                METASTORAGE => $mstor,
                                 LOGFILE => $logf};
                         }
                     }
@@ -1296,6 +1270,7 @@ sub get_specs
                                     HOSTNAME => $hostname,
                                     PORTMAP => $portmap,
                                     STORAGE => $stor,
+                                    METASTORAGE => $mstor,
                                     LOGFILE => $logf};
                             }
                         }
@@ -1334,6 +1309,7 @@ sub get_specs
                                         HOSTNAME => $hostname,
                                         PORTMAP => $portmap,
                                         STORAGE => $stor,
+                                        METASTORAGE => $mstor,
                                         LOGFILE => $logf};
                                 }
                             }
@@ -1455,8 +1431,6 @@ GetOptions('protocol=s'    => \$opt_prot
     'server-job-timeout=i' => \$opt_server_job_timeout,
     'client-job-timeout=i' => \$opt_client_job_timeout,
     'storage=s'     => \$opt_storage,
-    'pubkey=s'      => \$opt_pubkey,
-    'privkey=s'		=> \$opt_privkey,
     'help'          => \$show_help,
     'quiet!'        => \$opt_quiet,
     'trovesync!'    => \$opt_trovesync,
@@ -1525,7 +1499,6 @@ else
         die "Can't open specified file $ARGV[0]: $!\n";
     }
     $output_target = \*FILEOUT;
-    $dirname = abs_path(dirname($ARGV[0]));
 }
 
 die "-port not allowed with -iospec or -metaspec."
@@ -1553,12 +1526,11 @@ else
     $bmi_module = join(',', map("bmi_" . $_, keys (%{$portmap})));
 
     $default_storage = get_storage();
+    $default_meta_storage = get_meta_storage();
     $default_logfile = get_logfile();
-    $default_pubkey = get_pubkey();
-    $default_privkey = get_privkey();
 
-    get_ionames($portmap, $default_storage, $default_logfile, $default_pubkey, $default_privkey);
-    get_metanames($portmap, $default_storage, $default_logfile, $default_pubkey, $default_privkey);
+    get_ionames($portmap, $default_storage, $default_logfile);
+    get_metanames($portmap, $default_meta_storage, $default_logfile);
 }
 
 # find out if any of the storage or logfile entries in the endpoints
@@ -1574,37 +1546,25 @@ if(needs_default_value(STORAGE))
     set_default_value(STORAGE, $default_storage);
 }
 
-if(needs_default_value(LOGFILE))
+if(needs_default_value(METASTORAGE))
 {
-    if(!defined($default_logfile))
+    if(!defined($default_meta_storage))
     {
-        $default_logfile = get_logfile();
+        $default_meta_storage = get_meta_storage();
     }
-
-    set_default_value(LOGFILE, $default_logfile);
-    set_default_value(LOGFILE, $default_logfile);
+    set_default_value(METASTORAGE, $default_meta_storage);
+    set_default_value(METASTORAGE, $default_meta_storage);
 }
 
-if(needs_default_value(PUBKEY))
-{
-    if(!defined($default_pubkey))
-    {
-        $default_pubkey = get_pubkey();
-    }
-
-    set_default_value(PUBKEY, $default_pubkey);
-    set_default_value(PUBKEY, $default_pubkey);
-}
-
-if(needs_default_value(PRIVKEY))
+if(needs_default_value(LOGFILE))
 {
-    if(!defined($default_pubkey))
+    if(!defined($default_logfile))
     {
-        $default_privkey = get_privkey();
+        $default_logfile = get_logfile();
     }
 
-    set_default_value(PRIVKEY, $default_privkey);
-    set_default_value(PRIVKEY, $default_privkey);
+    set_default_value(LOGFILE, $default_logfile);
+    set_default_value(LOGFILE, $default_logfile);
 }
 
 my $count = scalar(keys %all_endpoints);

Index: pvfs2-ls.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-ls.c,v
diff -p -u -r1.73.2.7 -r1.73.2.8
--- pvfs2-ls.c	1 Jun 2010 16:36:04 -0000	1.73.2.7
+++ pvfs2-ls.c	19 Jun 2010 00:01:16 -0000	1.73.2.8
@@ -29,7 +29,14 @@
 /* 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    113
+/* MAX_NUM_DIRENTS cannot be any larger than PVFS_REQ_LIMIT_LISTATTR */
+#define MAX_NUM_DIRENTS  60
+
+/*
+  Define the maximum length of a single line of output. This is about the 
+  size of 256 maximum path segments, a file name, and attributes.
+ */
+#define ENTRY_MAX          66560
 
 /*
   arbitrarily restrict the number of paths
@@ -37,6 +44,16 @@
 */
 #define MAX_NUM_PATHS       8
 
+/*
+  Max length of the fully formatted date/time fields
+*/
+#define MAX_TIME_LENGTH    128
+
+/*
+  Length of the formatted date/time for --all-times option
+*/
+#define ALL_TIMES_LENGTH    25
+
 /* optional parameters, filled in by parse_args() */
 struct options
 {
@@ -51,6 +68,7 @@ struct options
     int list_all;
     int list_no_owner;
     int list_inode;
+    int list_all_times;
     int list_use_si_units;
     char *start[MAX_NUM_PATHS];
     int num_starts;
@@ -76,19 +94,22 @@ static void print_entry(
     PVFS_fs_id fs_id,
     PVFS_sys_attr *attr,
     int attr_error,
-    struct options *opts);
+    struct options *opts,
+    char* entry_buffer);
 
 static int do_list(
     char *full_path,
     char *start,
     int fs_id,
-    struct options *opts);
+    struct options *opts,
+    char *entry_buffer);
 
 static void print_entry_attr(
     PVFS_handle handle,
     char *entry_name,
     PVFS_sys_attr *attr,
-    struct options *opts);
+    struct options *opts,
+    char *entry_buffer);
 
 #define print_dot_and_dot_dot_info_if_required(refn)        \
 do {                                                        \
@@ -106,9 +127,11 @@ do {                                    
         }                                                   \
         else if (opts->list_long) {                         \
             print_entry(".", refn.handle,                   \
-                        refn.fs_id, NULL, 0, opts);         \
+                        refn.fs_id, NULL, 0, opts,          \
+                        entry_buffer);                      \
             print_entry(".. (faked)", refn.handle,          \
-                        refn.fs_id, NULL, 0, opts);         \
+                        refn.fs_id, NULL, 0, opts,          \
+                        entry_buffer);                      \
         }                                                   \
         else {                                              \
             printf(".\n");                                  \
@@ -188,22 +211,24 @@ void print_entry_attr(
     PVFS_handle handle,
     char *entry_name,
     PVFS_sys_attr *attr,
-    struct options *opts)
+    struct options *opts,
+    char *entry_buffer)
 {
-    char buf[128] = {0}, *formatted_size = NULL;
-    char *formatted_owner = NULL, *formatted_group = NULL;
+    char *formatted_size = NULL;
+    char *formatted_owner = NULL, *formatted_group = NULL, *formatted_time = 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;    
+    time_t mtime, atime, ctime;
+    struct tm *time;
     PVFS_size size = 0;
-    char scratch_owner[16] = {0}, scratch_group[16] = {0};
+    char scratch_owner[16] = {0}, scratch_group[16] = {0}, scratch_time[MAX_TIME_LENGTH] = {0}, scratch_big_time[MAX_TIME_LENGTH] = {0};
     char scratch_size[16] = {0}, scratch_inode[16] = {0};
     char f_type = '-';
     char group_x_char = '-';
+    int num_bytes = 0;
 
     if (!opts->list_all && (entry_name[0] == '.'))
     {
@@ -213,8 +238,32 @@ void print_entry_attr(
     {
         return;
     }
+
     mtime = (time_t)attr->mtime;
     time = localtime(&mtime);
+    if(opts->list_all_times)
+    {
+        atime = (time_t)attr->atime;
+        ctime = (time_t)attr->ctime;
+
+        num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+1,"%F %H:%M:%S %z",time );
+        strncpy(scratch_big_time,scratch_time,num_bytes);
+
+        time = localtime(&atime);
+        num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3,"  %F %H:%M:%S %z",time );
+        strncat(scratch_big_time,scratch_time,num_bytes);
+
+        time = localtime(&ctime);
+        num_bytes = strftime( scratch_time,ALL_TIMES_LENGTH+3,"  %F %H:%M:%S %z",time );
+        strncat(scratch_big_time,scratch_time,num_bytes);
+
+        format_size_string(scratch_big_time,strlen(scratch_big_time),&formatted_time,0,1);
+    }
+    else
+    {
+        strftime( scratch_time,17,"%F %H:%M",time );
+        format_size_string(scratch_time,16,&formatted_time,0,1);
+    }
 
     snprintf(scratch_owner,16,"%d",(int)attr->owner);
     snprintf(scratch_group,16,"%d",(int)attr->group);
@@ -301,8 +350,8 @@ void print_entry_attr(
         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",
+    snprintf(entry_buffer,ENTRY_MAX,"%s%c%c%c%c%c%c%c%c%c%c    1 %s %s %s "
+             "%s %s",
              inode,
              f_type,
              ((attr->perms & PVFS_U_READ) ? 'r' : '-'),
@@ -317,11 +366,7 @@ void print_entry_attr(
              formatted_owner,
              formatted_group,
              formatted_size,
-             (time->tm_year + 1900),
-             (time->tm_mon + 1),
-             time->tm_mday,
-             (time->tm_hour),
-             (time->tm_min),
+             formatted_time,
              entry_name);
 
     if (formatted_size)
@@ -336,6 +381,10 @@ void print_entry_attr(
     {
         free(formatted_group);
     }
+    if (formatted_time)
+    {
+        free(formatted_time);
+    }
 
     if (attr->objtype == PVFS_TYPE_SYMLINK)
     {
@@ -343,16 +392,16 @@ void print_entry_attr(
 
         if (opts->list_long)
         {
-            printf("%s -> %s\n", buf, attr->link_target);
+            printf("%s -> %s\n", entry_buffer, attr->link_target);
         }
         else
         {
-            printf("%s\n",buf);
+            printf("%s\n",entry_buffer);
         }
     }
     else
     {
-        printf("%s\n",buf);
+        printf("%s\n",entry_buffer);
     }
 }
 
@@ -362,7 +411,8 @@ void print_entry(
     PVFS_fs_id fs_id,
     PVFS_sys_attr *attr,
     int attr_error,
-    struct options *opts)
+    struct options *opts,
+    char *entry_buffer)
 {
     int ret = -1;
     PVFS_object_ref ref;
@@ -409,11 +459,11 @@ void print_entry(
                 PVFS_perror("Getattr failure", ret);
                 return;
             }
-            print_entry_attr(handle, entry_name,  &getattr_response.attr, opts);
+            print_entry_attr(handle, entry_name,  &getattr_response.attr, opts, entry_buffer);
         }
         else
         {
-            print_entry_attr(handle, entry_name, attr, opts);
+            print_entry_attr(handle, entry_name, attr, opts, entry_buffer);
         }
     }
 }
@@ -429,7 +479,8 @@ int do_list(
     char *full_path,
     char *start,
     int fs_id,
-    struct options *opts)
+    struct options *opts,
+    char *entry_buffer)
 {
     int i = 0, printed_dot_info = 0;
     int ret = -1;
@@ -503,14 +554,14 @@ int do_list(
             if (opts->list_long)
             {
                 print_entry_attr(ref.handle, segment,
-                                 &getattr_response.attr, opts);
+                                 &getattr_response.attr, opts, entry_buffer);
             }
             else
             {
                 print_entry(segment, ref.handle, ref.fs_id, 
                         NULL,
                         0,
-                        opts);
+                        opts, entry_buffer);
             }
             return 0;
         }
@@ -567,7 +618,7 @@ int do_list(
             print_entry(cur_file, cur_handle, fs_id,
                     &rdplus_response.attr_array[i],
                     rdplus_response.stat_err_array[i],
-                    opts);
+                    opts, entry_buffer);
 
             PVFS_sys_attr *attr = &rdplus_response.attr_array[i];
             if(attr->objtype == PVFS_TYPE_DIRECTORY && opts->list_recursive)
@@ -648,7 +699,7 @@ int do_list(
         while(current)
         {
             printf("\n");
-            do_list(full_path,current->path,fs_id,opts);
+            do_list(full_path,current->path,fs_id,opts,entry_buffer);
             current = current->next;
             free(head->path);
             free(head);
@@ -684,6 +735,7 @@ static struct options* parse_args(int ar
         {"all",0,0,0},
         {"inode",0,0,0},
         {"size",0,0,0},
+        {"all-times",0,0,0},
         {0,0,0,0}
     };
 
@@ -753,6 +805,10 @@ static struct options* parse_args(int ar
                 {
                     goto list_inode;
                 }
+                else if (strcmp("all-times", cur_option) == 0)
+                {
+                    goto list_all_times;
+                }
                 else
                 {
                     usage(argc, argv);
@@ -804,6 +860,9 @@ static struct options* parse_args(int ar
           list_inode:
                 tmp_opts->list_inode = 1;
                 break;
+          list_all_times:
+                tmp_opts->list_all_times = 1;
+                break;
             case 't':
                 do_timing = 1;
                 break;
@@ -853,6 +912,8 @@ static void usage(int argc, char** argv)
             "format\n");
     fprintf(stderr,"  -n, --numeric-uid-gid      like -l, but list "
             "numeric UIDs and GIDs\n");
+    fprintf(stderr,"      --all-times            display atime, mtime,"
+            " and ctime information\n");
     fprintf(stderr,"  -o                         like -l, but do not "
             "list group information\n");
     fprintf(stderr,"      --help                 display this help "
@@ -875,9 +936,9 @@ int main(int argc, char **argv)
     struct options* user_opts = NULL;
     char current_dir[PVFS_NAME_MAX] = {0};
     int found_one = 0;
+    char *entry_buffer = malloc(ENTRY_MAX);
 
     process_name = argv[0];
-
     user_opts = parse_args(argc, argv);
     if (!user_opts)
     {
@@ -968,17 +1029,19 @@ int main(int argc, char **argv)
         }
         else /* Root directory case has nothing to match */
         {
-            substr = &user_opts->start[i][strlen(user_opts->start[i])-1];
+            substr = &user_opts->start[i][strlen(user_opts->start[i])];
         }
 
-        while (index != substr)
+
+        while ((index != substr) && (substr != NULL))
         {
             index++;
             j++;
         }
-        user_opts->start[i][j] = '\0';
 
-        do_list(user_opts->start[i], pvfs_path[i], fs_id_array[i], user_opts);
+        user_opts->start[i][++j] = '\0';
+
+        do_list(user_opts->start[i], pvfs_path[i], fs_id_array[i], user_opts, entry_buffer);
 
         if (user_opts->num_starts > 1)
         {
@@ -988,6 +1051,7 @@ int main(int argc, char **argv)
 
     PVFS_sys_finalize();
     free(user_opts);
+    free(entry_buffer);
 
     return(ret);
 }

Index: pvfs2-migrate-collection.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-migrate-collection.c,v
diff -p -u -r1.20.8.3 -r1.20.8.4
--- pvfs2-migrate-collection.c	8 Jun 2010 15:55:07 -0000	1.20.8.3
+++ pvfs2-migrate-collection.c	19 Jun 2010 00:01:17 -0000	1.20.8.4
@@ -62,9 +62,9 @@ int verbose = 0;
 static void print_help(char *progname);
 static int parse_args(int argc, char **argv, options_t *opts);
 static int src_get_version(
-    char* storage_space, TROVE_coll_id coll_id, char* coll_name,
+    char* meta_storage_space, TROVE_coll_id coll_id, char* coll_name,
     char* ver_string, int ver_string_max);
-static int remove_collection_entry(char* storage_space, char* collname);
+static int remove_collection_entry(char* meta_storage_space, char* collname);
 
 int migrate_collection(void * config, void * sconfig);
 void fs_config_dummy_free(void *);
@@ -72,10 +72,10 @@ int recursive_rmdir(char* dir);
 
 /* functions specific to reading 0.0.1 collections */
 static int src_get_version_0_0_1(
-    char* storage_space, TROVE_coll_id coll_id, 
+    char* meta_storage_space, TROVE_coll_id coll_id, 
     char* ver_string, int ver_string_max);
 static int translate_0_0_1(
-    char* storage_space, char* old_coll_path, 
+    char* data_storage_space, char* meta_storage_space, char* old_coll_path, 
     char* coll_name, TROVE_coll_id coll_id);
 static int translate_coll_eattr_0_0_1(
     char* old_coll_path, TROVE_coll_id coll_id, char* coll_name,
@@ -87,7 +87,7 @@ static int translate_keyvals_0_0_1(
     char* old_coll_path, TROVE_coll_id coll_id, char* coll_name,
     TROVE_context_id trove_context);
 static int translate_bstreams_0_0_1(
-    char* storage_space, char* old_coll_path, 
+    char* data_storage_space, char* old_coll_path, 
     TROVE_coll_id coll_id, char* coll_name,
     TROVE_context_id trove_context);
 static int translate_keyval_db_0_0_1(
@@ -233,10 +233,15 @@ int migrate_collection(void * config, vo
     struct server_configuration_s * server_config =
         (struct server_configuration_s *) sconfig;
 
+    if(server_config->meta_path == NULL)
+    {
+	server_config->meta_path = server_config->data_path;
+    }
+
     memset(version, 0, 256);
     /* find version of source storage space */
     ret = src_get_version(
-        server_config->storage_path, 
+        server_config->meta_path, 
         fs_config->coll_id, 
         fs_config->file_system_name,
         version, 254);
@@ -253,7 +258,7 @@ int migrate_collection(void * config, vo
     if(strncmp(version, "0.0.1", 5) == 0)
     {
         sprintf(old_coll_path, "%s/%08x-old-%s",
-                server_config->storage_path, 
+                server_config->meta_path, 
                 fs_config->coll_id, version);
 
         ret = access(old_coll_path, F_OK);
@@ -292,7 +297,9 @@ int migrate_collection(void * config, vo
         }
 
         ret = translate_0_0_1(
-            server_config->storage_path, old_coll_path, 
+            server_config->data_path, 
+            server_config->meta_path,
+            old_coll_path, 
             fs_config->file_system_name, 
             fs_config->coll_id);
         if(ret < 0)
@@ -327,7 +334,8 @@ int migrate_collection(void * config, vo
              * of creating it, but we don't know what the version
              * is anymore
              */
-            DIR * storage_dir;
+            DIR * data_storage_dir;
+            DIR * meta_storage_dir;
             struct dirent * next_dirent;
             char collname[PATH_MAX];
             int collname_length;
@@ -335,15 +343,15 @@ int migrate_collection(void * config, vo
 
             collname_length = sprintf(collname, "%08x-old", fs_config->coll_id);
 
-            storage_dir = opendir(server_config->storage_path);
-            if(!storage_dir)
+            data_storage_dir = opendir(server_config->data_path);
+            if(!data_storage_dir)
             {
-                fprintf(stderr, "Error: failed to open directory: %s\n",
-                        server_config->storage_path);
+                fprintf(stderr, "Error: failed to open data directory: %s\n",
+                        server_config->data_path);
                 return -1;
             }
 
-            while((next_dirent = readdir(storage_dir)) != NULL)
+            while((next_dirent = readdir(data_storage_dir)) != NULL)
             {
                 int d_namelen = strlen(next_dirent->d_name);
                 if(collname_length < d_namelen &&
@@ -352,7 +360,7 @@ int migrate_collection(void * config, vo
                     char old_coll_path[PATH_MAX];
 
                     sprintf(old_coll_path, "%s/%s",
-                            server_config->storage_path, next_dirent->d_name);
+                            server_config->data_path, next_dirent->d_name);
 
                     /* found an old version, delete it */
                     if(verbose) 
@@ -365,13 +373,55 @@ int migrate_collection(void * config, vo
                             stderr, 
                             "Error: failed to remove old collection at: %s\n",
                             old_coll_path);
-                        closedir(storage_dir);
+                        closedir(data_storage_dir);
                         return -1;
                     }
                     removed_olddirs = 1;
                 }
             }
 
+	    /* if the meta and data paths are the same, don't try to remove twice */
+        if (strcmp(server_config->data_path, server_config->meta_path))
+        {
+            meta_storage_dir = opendir(server_config->meta_path);
+            if(!meta_storage_dir)
+            {
+                    fprintf(stderr, "Error: failed to open meta directory: %s\n",
+                        server_config->meta_path);
+                    return -1;
+                }
+
+	        while((next_dirent = readdir(meta_storage_dir)) != NULL)
+                {
+                    int d_namelen = strlen(next_dirent->d_name);
+                    if(collname_length < d_namelen &&
+                       strncmp(next_dirent->d_name, collname, collname_length) == 0)
+                    { 
+                        char old_coll_path[PATH_MAX];
+
+                        sprintf(old_coll_path, "%s/%s",
+                                server_config->meta_path, next_dirent->d_name);
+
+                         /* found an old version, delete it */
+                        if(verbose) 
+                            printf("VERBOSE Removing old collection at: %s\n",
+                                   old_coll_path);
+                        ret = recursive_rmdir(old_coll_path);
+                        if(ret < 0)
+                        {
+                            fprintf(
+                                stderr, 
+                                "Error: failed to remove old collection at: %s\n",
+                                old_coll_path);
+                            closedir(meta_storage_dir);
+                            return -1;
+                        }
+                        removed_olddirs = 1;
+                    }
+                }
+		closedir(meta_storage_dir);
+	    }
+
             if(removed_olddirs == 0)
             {
                 printf("\nWARNING: No old collections with name \"%s\" "
@@ -379,7 +429,7 @@ int migrate_collection(void * config, vo
                        fs_config->file_system_name);
             }
 
-            closedir(storage_dir);
+            closedir(data_storage_dir);
         }
         else
         {
@@ -526,7 +576,7 @@ static void print_help(
  * \return 0 on succes, -1 on failure
  */
 static int src_get_version(
-    char* storage_space,       /**< path to storage space */
+    char* meta_storage_space,       /**< path to storage space */
     TROVE_coll_id coll_id,     /**< collection id */
     char* coll_name,           /**< collection name */
     char* ver_string,          /**< version in string format */
@@ -536,14 +586,14 @@ static int src_get_version(
 
 
     ret = src_get_version_0_0_1(
-        storage_space, coll_id, ver_string, ver_string_max);
+        meta_storage_space, coll_id, ver_string, ver_string_max);
 
     if(ret != 0)
     {
         fprintf(stderr, 
                 "Error: all known collection version checks "
                 "failed for \ncollection %s (%08x) in storage space %s\n", 
-                coll_name, coll_id, storage_space);
+                coll_name, coll_id, meta_storage_space);
     }
 
     return(ret);
@@ -555,7 +605,7 @@ static int src_get_version(
  * \return 0 on succes, -1 on failure
  */
 static int src_get_version_0_0_1(
-    char* storage_space,   /**< path to storage space */
+    char* meta_storage_space,   /**< path to storage space */
     TROVE_coll_id coll_id, /**< collection id */
     char* ver_string,      /**< version in string format */
     int ver_string_max)    /**< maximum size of version string */
@@ -566,7 +616,7 @@ static int src_get_version_0_0_1(
     DBT key, data;
 
     sprintf(coll_db, "%s/%08x/collection_attributes.db", 
-            storage_space, coll_id);
+            meta_storage_space, coll_id);
 
     /* try to find a collections db */
     ret = access(coll_db, F_OK);
@@ -629,7 +679,8 @@ static int src_get_version_0_0_1(
  * \return 0 on succes, -1 on failure
  */
 static int translate_0_0_1(
-    char* storage_space,   /**< path to storage space */
+    char* data_storage_space,   /**< path to data storage space */
+    char* meta_storage_space, /**< path to metadata storage space */
     char* old_coll_path,   /**< path to old collection */
     char* coll_name,       /**< collection name */
     TROVE_coll_id coll_id) /**< collection id in string format */
@@ -644,7 +695,7 @@ static int translate_0_0_1(
     char current_path[PATH_MAX];
 
     /* rename old collection */
-    snprintf(current_path, PATH_MAX, "%s/%08x", storage_space, coll_id);
+    snprintf(current_path, PATH_MAX, "%s/%08x", meta_storage_space, coll_id);
 
     if(access(current_path, F_OK) != 0)
     {
@@ -663,7 +714,7 @@ static int translate_0_0_1(
         return(-1);
     }
 
-    ret = remove_collection_entry(storage_space, coll_name);
+    ret = remove_collection_entry(meta_storage_space, coll_name);
     if(ret < 0)
     {
         fprintf(stderr, "Error: failed to remove collection entry: %s\n",
@@ -678,7 +729,8 @@ static int translate_0_0_1(
     if(verbose) 
         printf("VERBOSE Creating temporary collection to migrate to.\n");
     ret = pvfs2_mkspace(
-        storage_space, 
+        data_storage_space,
+        meta_storage_space,
         coll_name,
         coll_id, 
         TROVE_HANDLE_NULL,
@@ -699,18 +751,18 @@ static int translate_0_0_1(
     {
         PVFS_perror("PINT_dist_initialize", ret);
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
 
     /* initialize trove and lookup collection */
     ret = trove_initialize(
-        TROVE_METHOD_DBPF, NULL, storage_space, 0);
+        TROVE_METHOD_DBPF, NULL, data_storage_space, meta_storage_space,0);
     if (ret < 0)
     {
         PVFS_perror("trove_initialize", ret);
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
     ret = trove_collection_lookup(
@@ -719,7 +771,7 @@ static int translate_0_0_1(
     {   
         fprintf(stderr, "Error: failed to lookup new collection.\n");
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return -1; 
     }   
 
@@ -737,7 +789,7 @@ static int translate_0_0_1(
     {
         fprintf(stderr, "Error: failed to migrate collection extended attributes.\n");
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
 
@@ -748,7 +800,7 @@ static int translate_0_0_1(
     {
         fprintf(stderr, "Error: failed to migrate dspace attributes.\n");
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
 
@@ -759,7 +811,7 @@ static int translate_0_0_1(
     {
         fprintf(stderr, "Error: failed to migrate keyvals.\n");
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
 
@@ -770,12 +822,12 @@ static int translate_0_0_1(
 
     /* convert bstreams */
     ret = translate_bstreams_0_0_1(
-        storage_space, old_coll_path, coll_id, coll_name, trove_context);
+        data_storage_space, old_coll_path, coll_id, coll_name, trove_context);
     if(ret < 0)
     {
         fprintf(stderr, "Error: failed to migrate bstreams.\n");
         if(verbose) printf("VERBOSE Destroying temporary collection.\n");
-        pvfs2_rmspace(storage_space, coll_name, coll_id, 1, 0);
+        pvfs2_rmspace(data_storage_space, meta_storage_space, coll_name, coll_id, 1, 0);
         return(-1);
     }
 
@@ -794,7 +846,7 @@ static int translate_0_0_1(
     return(0);
 }
 
-static int remove_collection_entry(char* storage_space, char* collname)
+static int remove_collection_entry(char* meta_storage_space, char* collname)
 {
     char collections_db[PATH_MAX];
     DB * dbp;
@@ -802,7 +854,7 @@ static int remove_collection_entry(char*
     int ret = 0;
     TROVE_coll_id coll_id;
 
-    sprintf(collections_db, "%s/collections.db", storage_space);
+    sprintf(collections_db, "%s/collections.db", meta_storage_space);
 
     ret = access(collections_db, F_OK);
     if(ret == -1 && errno == ENOENT)
@@ -1493,7 +1545,7 @@ static int translate_keyval_db_0_0_1(
  * \return 0 on succes, -1 on failure
  */
 static int translate_bstreams_0_0_1(
-    char* storage_space,            /**< path to trove storage space */
+    char* data_storage_space,            /**< path to trove storage space */
     char* old_coll_path,            /**< path to old collection */
     TROVE_coll_id coll_id,          /**< collection id */
     char* new_name,                 /**< name of collection */
@@ -1530,7 +1582,7 @@ static int translate_bstreams_0_0_1(
                 snprintf(bstream_file, PATH_MAX, "%s/bstreams/%.8d/%s",
                     old_coll_path, i, tmp_ent->d_name);
                 snprintf(new_bstream_file, PATH_MAX, "%s/%08x/bstreams/%.8d/%s",
-                    storage_space, coll_id, i, tmp_ent->d_name);
+                    data_storage_space, coll_id, i, tmp_ent->d_name);
                 /* hard link to new location */
                 ret = link(bstream_file, new_bstream_file);
                 if(ret != 0)

Index: pvfs2-mkspace.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-mkspace.c,v
diff -p -u -r1.20 -r1.20.20.1
--- pvfs2-mkspace.c	16 Sep 2006 21:48:39 -0000	1.20
+++ pvfs2-mkspace.c	19 Jun 2010 00:01:17 -0000	1.20.20.1
@@ -31,7 +31,8 @@ typedef struct
     char meta_ranges[PATH_MAX];
     char data_ranges[PATH_MAX];
     char collection[PATH_MAX];
-    char storage_space[PATH_MAX];
+    char data_space[PATH_MAX];
+    char meta_space[PATH_MAX];
 } options_t;
 
 static int default_verbose = 0;
@@ -53,7 +54,8 @@ static int parse_args(int argc, char **a
         {"version",0,0,0},
         {"verbose",0,0,0},
         {"defaults",0,0,0},
-        {"storage-space",1,0,0},
+        {"data-space",1,0,0},
+        {"meta-space",1,0,0},
         {"coll-id",1,0,0},
         {"coll-name",1,0,0},
         {"root-handle",1,0,0},
@@ -70,7 +72,7 @@ static int parse_args(int argc, char **a
         exit(1);
     }
 
-    while ((ret = getopt_long(argc, argv, "s:c:i:r:vVhadDM:N:",
+    while ((ret = getopt_long(argc, argv, "c:i:r:vVhadDM:N:",
                               long_opts, &option_index)) != -1)
     {
 	switch (ret)
@@ -90,10 +92,14 @@ static int parse_args(int argc, char **a
                 {
                     goto do_verbose;
                 }
-                else if (strcmp("storage-space", cur_option) == 0)
+                else if (strcmp("data-space", cur_option) == 0)
                 {
-                    goto do_storage_space;
+                    strncpy(opts->data_space, optarg, PATH_MAX);
                 }
+				else if (strcmp("meta-space", cur_option) == 0)
+				{
+		    		strncpy(opts->meta_space, optarg, PATH_MAX);
+				}
                 else if (strcmp("coll-id", cur_option) == 0)
                 {
                     goto do_collection_id;
@@ -173,10 +179,6 @@ static int parse_args(int argc, char **a
           do_data_handle_range:
 		strncpy(opts->data_ranges, optarg, PATH_MAX);
 		break;
-	    case 's':
-          do_storage_space:
-		strncpy(opts->storage_space, optarg, PATH_MAX);
-		break;
 	    case 'v':
           do_verbose:
 		opts->verbose = PVFS2_MKSPACE_STDERR_VERBOSE;
@@ -223,9 +225,12 @@ static void print_options(options_t *opt
         printf("\tdata handle ranges  : %s\n",
                (strlen(opts->data_ranges) ?
                 opts->data_ranges : "None specified"));
-        printf("\tstorage space       : %s\n",
-               (strlen(opts->storage_space) ?
-                opts->storage_space : "None specified"));
+        printf("\tdata storage space       : %s\n",
+               (strlen(opts->data_space) ?
+                opts->data_space : "None specified"));
+		printf("metadata storage space : %s\n",
+	       		(strlen(opts->meta_space) ?
+		opts->meta_space : "None specified"));
     }
 }
 
@@ -258,8 +263,10 @@ static void print_help(char *progname, o
     fprintf(stderr,"  -N, --data-handle-range=RANGE        "
             "create collection with the specified\n        "
             "                                data handle range\n");
-    fprintf(stderr,"  -s, --storage-space=PATH             "
-            "create storage space at this location\n");
+    fprintf(stderr,"       --data-space=PATH             "
+            "create data storage space at this location\n");
+    fprintf(stderr,"       --meta-space=PATH             "
+            "create metadata storage space at this location\n");
     fprintf(stderr,"  -v, --verbose                        "
             "operate in verbose mode\n");
     fprintf(stderr,"  -V, --version                        "
@@ -296,9 +303,15 @@ int main(int argc, char **argv)
 
     print_options(&opts);
 
-    if (strlen(opts.storage_space) == 0)
+    if (strlen(opts.data_space) == 0)
+    {
+        fprintf(stderr, "Error: You MUST specify a data storage space\n");
+        return -1;
+    }
+
+    if (strlen(opts.meta_space) == 0)
     {
-        fprintf(stderr, "Error: You MUST specify a storage space\n");
+        fprintf(stderr, "Error: You MUST specify a metadata storage space\n");
         return -1;
     }
 
@@ -318,16 +331,17 @@ int main(int argc, char **argv)
 
     if (opts.delete_storage)
     {
-        ret = pvfs2_rmspace(opts.storage_space, opts.collection,
-                            opts.coll_id, opts.collection_only,
-                            opts.verbose);
+        ret = pvfs2_rmspace(opts.data_space, opts.meta_space,
+			    opts.collection, opts.coll_id, 
+			    opts.collection_only, opts.verbose);
     }
     else
     {
-        ret = pvfs2_mkspace(opts.storage_space, opts.collection,
-                            opts.coll_id, opts.root_handle,
-                            opts.meta_ranges, opts.data_ranges,
-                            opts.collection_only, opts.verbose);
+        ret = pvfs2_mkspace(opts.data_space, opts.meta_space,
+			    opts.collection, opts.coll_id, 
+			    opts.root_handle, opts.meta_ranges, 
+			    opts.data_ranges, opts.collection_only, 
+			    opts.verbose);
     }
     return ret;
 }

Index: pvfs2-showcoll.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-showcoll.c,v
diff -p -u -r1.24.18.1 -r1.24.18.2
--- pvfs2-showcoll.c	25 Aug 2009 17:55:49 -0000	1.24.18.1
+++ pvfs2-showcoll.c	19 Jun 2010 00:01:17 -0000	1.24.18.2
@@ -23,7 +23,8 @@
 /* declare the strnlen prototype */
 size_t strnlen(const char *s, size_t limit);
 
-static char storage_space[PATH_MAX] = "/tmp/pvfs2-test-space";
+static char data_path[PATH_MAX] = "/tmp/pvfs2-test-space";
+static char meta_path[PATH_MAX] = "/tmp/pvfs2-test-space";
 static char collection[PATH_MAX];
 static int verbose = 0, got_collection = 0, print_keyvals = 0, got_dspace_handle = 0;
 TROVE_handle dspace_handle;
@@ -71,7 +72,7 @@ int main(int argc, char **argv)
 
     /* initialize trove, verifying storage space exists */
     ret = trove_initialize(
-        TROVE_METHOD_DBPF, NULL, storage_space, 0);
+      TROVE_METHOD_DBPF, NULL, data_path, meta_path, 0);
     if (ret < 0) 
     {
 	fprintf(stderr,
@@ -81,9 +82,9 @@ int main(int argc, char **argv)
     }
 
     if (verbose) fprintf(stderr,
-			 "%s: info: initialized with storage space '%s'.\n",
+			 "%s: info: initialized with storage spaces '%s' and '%s'.\n",
 			 argv[0],
-			 storage_space);
+			 data_path, meta_path);
 
     /* if no collection was specified, simply print out the collections and exit */
     if (!got_collection) {
@@ -164,17 +165,19 @@ int main(int argc, char **argv)
     /* print basic stats on collection */
     if (no_root_handle) {
 	fprintf(stdout,
-		"Storage space %s, collection %s (coll_id = %d, "
+		"Storage space %s and %s, collection %s (coll_id = %d, "
                 "*** no root_handle found ***):\n",
-		storage_space,
+		data_path,
+		meta_path,
 		collection,
 		coll_id);
     }
     else {
 	fprintf(stdout,
-		"Storage space %s, collection %s (coll_id = %d, "
+		"Storage space %s and %s, collection %s (coll_id = %d, "
                 "root_handle = 0x%08llx):\n",
-		storage_space,
+		data_path,
+		meta_path,
 		collection,
 		coll_id,
 		llu(root_handle));
@@ -200,11 +203,13 @@ static int parse_args(int argc, char **a
 {
     int c;
 
-    while ((c = getopt(argc, argv, "s:c:d:kvh")) != EOF) {
+    while ((c = getopt(argc, argv, "s:m:c:d:kvh")) != EOF) {
 	switch (c) {
-	    case 's':
-		strncpy(storage_space, optarg, PATH_MAX);
+		case 's':
+		strncpy(data_path, optarg, PATH_MAX);
 		break;
+		case 'm':
+		strncpy(meta_path, optarg, PATH_MAX);
 	    case 'c': /* collection */
 		got_collection = 1;
 		strncpy(collection, optarg, PATH_MAX);
@@ -224,7 +229,7 @@ static int parse_args(int argc, char **a
 		fprintf(stderr, "%s: error: unrecognized option '%c'.\n", argv[0], c);
 	    case 'h':
 		fprintf(stderr,
-			"usage: pvfs2-showcoll [-s storage_space] [-c collection_name] [-d dspace_handle] [-v] [-k] [-h]\n");
+			"usage: pvfs2-showcoll [-s data_storage_space] [-m metadata storage space] [-c collection_name] [-d dspace_handle] [-v] [-k] [-h]\n");
 		fprintf(stderr, "\tdefault storage space is '/tmp/pvfs2-test-space'.\n");
 		fprintf(stderr, "\t'-v' turns on verbose output.\n");
 		fprintf(stderr, "\t'-k' prints data in keyval spaces.\n");
@@ -498,7 +503,8 @@ static int print_collections(void)
     count = 1;
     pos = TROVE_ITERATE_START;
 
-    fprintf(stdout, "Storage space %s collections:\n", storage_space);
+    fprintf(stdout, "Storage space %s and %s collections:\n",
+	    data_path, meta_path);
 
     while (count > 0) {
 	ret = trove_collection_iterate(TROVE_METHOD_DBPF,

Index: pvfs2-stat.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-stat.c,v
diff -p -u -r1.9.18.6 -r1.9.18.7
--- pvfs2-stat.c	1 Jun 2010 16:36:04 -0000	1.9.18.6
+++ pvfs2-stat.c	19 Jun 2010 00:01:17 -0000	1.9.18.7
@@ -54,6 +54,7 @@ void print_stats(const PVFS_object_ref *
 int main(int argc, char **argv)
 {
    int               ret          = -1,
+                     ret_agg      =  0,
                      i            =  0;
    char           ** ppszPvfsPath = NULL;
    PVFS_fs_id     *  pfs_id       = NULL;
@@ -150,6 +151,7 @@ int main(int argc, char **argv)
       {
          fprintf(stderr, "Error stating [%s]\n", user_opts.pszFiles[i]);
       }
+      ret_agg |= ret;
    }
 
    PVFS_sys_finalize();
@@ -178,7 +180,7 @@ int main(int argc, char **argv)
       free(pfs_id);
    }
 
-   return(0);
+   return(ret_agg);
 }
 
 static int do_stat(const char             * pszFile,
@@ -477,6 +479,13 @@ void print_stats(const PVFS_object_ref *
    {
       fprintf(stdout, "  datafiles     : %d\n", attr->dfile_count);
    }
+
+   if( (attr->mask & PVFS_ATTR_SYS_BLKSIZE) &&
+       (attr->objtype == PVFS_TYPE_METAFILE))
+   {
+      fprintf(stdout, "  blksize       : %lld\n", lld(attr->blksize));
+   }
+
    /* dirent_count is only valid on directories */
    if( (attr->mask & PVFS_ATTR_SYS_DIRENT_COUNT) &&
        (attr->objtype == PVFS_TYPE_DIRECTORY))

Index: pvfs2-xattr.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/apps/admin/pvfs2-xattr.c,v
diff -p -u -r1.6.8.8 -r1.6.8.9
--- pvfs2-xattr.c	1 Jun 2010 16:36:04 -0000	1.6.8.8
+++ pvfs2-xattr.c	19 Jun 2010 00:01:17 -0000	1.6.8.9
@@ -2,6 +2,9 @@
  * (C) 2004 Clemson University and The University of Chicago
  * 
  * See COPYING in top-level directory.
+ *
+ * 03/19/07 - Added set and get for user.pvfs2.mirror.mode and ..mirror.copies.
+ *            Added get for user.pvfs2.mirror.handles and ..mirror.status
  */
 
 #include <unistd.h>
@@ -25,6 +28,8 @@
 
 #include "xattr-utils.h"
 
+#include "pvfs2-mirror.h"
+
 #define VALBUFSZ 1024
 
 /* extended attribute name spaces supported in PVFS2 */
@@ -40,10 +45,10 @@ const char *PINT_eattr_namespaces[] =
 /* optional parameters, filled in by parse_args() */
 struct options
 {
-    PVFS_ds_keyval key;
-    PVFS_ds_keyval val;
+    PVFS_ds_keyval *key;
+    PVFS_ds_keyval *val;
     char* srcfile;
-    int get, text;
+    int get, text, key_count;
 };
 
 enum object_type { 
@@ -77,8 +82,14 @@ typedef struct file_object_s {
 
 static struct options* parse_args(int argc, char* argv[]);
 static int generic_open(file_object *obj, PVFS_credential *credentials);
-static int pvfs2_eattr(int get, file_object *, PVFS_ds_keyval *key_p,
-        PVFS_ds_keyval *val_p, PVFS_credential *creds);
+
+static int pvfs2_eattr(int get
+                      ,file_object      *obj
+                      ,PVFS_ds_keyval   *key_p
+                      ,PVFS_ds_keyval   *val_p
+                      ,PVFS_credential  *creds
+                      ,int key_count); 
+
 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);
@@ -91,6 +102,7 @@ int main(int argc, char **argv)
   struct options* user_opts = NULL;
   file_object src;
   PVFS_credential credentials;
+  int i;
 
   memset(&src, 0, sizeof(src));
   /* look at command line arguments */
@@ -123,49 +135,118 @@ int main(int argc, char **argv)
       fprintf(stderr, "Could not open %s\n", user_opts->srcfile);
       return -1;
   }
-  if (!eattr_is_prefixed(user_opts->key.buffer))
+
+  if (!eattr_is_prefixed(user_opts->key[0].buffer))
   {
-      fprintf(stderr, "extended attribute key is not prefixed %s\n", (char *) user_opts->key.buffer);
+      fprintf(stderr, "extended attribute key is not prefixed %s\n"
+                    , (char *) user_opts->key[0].buffer);
       return -1;
   }
   if (!user_opts->get)
   {
-      if (!permit_set(&user_opts->key))
+      if (!permit_set(&user_opts->key[0]))
       {
-          fprintf(stderr, "Not permitted to set key %s\n", (char *) user_opts->key.buffer);
+          fprintf(stderr, "Not permitted to set key %s\n"
+                        , (char *) user_opts->key[0].buffer);
           return -1;
       }
-      if (modify_val(&user_opts->key, &user_opts->val) < 0)
+      if (modify_val(&user_opts->key[0], &user_opts->val[0]) < 0)
       {
-          fprintf(stderr, "Invalid value for user-settable hint %s, %s\n", (char *) user_opts->key.buffer, (char *) user_opts->val.buffer);
+          fprintf(stderr, "Invalid value for user-settable attribute %s, %s\n"
+                        , (char *) user_opts->key[0].buffer
+                        , (char *) user_opts->val[0].buffer);
           return -1;
       }
   }
 
-    ret = pvfs2_eattr(user_opts->get, &src, &user_opts->key, &user_opts->val, &credentials);
+    ret = pvfs2_eattr(user_opts->get
+                     ,&src
+                     ,user_opts->key
+                     ,user_opts->val
+                     ,&credentials
+                     ,user_opts->key_count);
     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 (strncmp(user_opts->key[0].buffer
+                   ,"user.pvfs2.meta_hint"
+                   ,SPECIAL_METAFILE_HINT_KEYLEN) == 0) {
+            PVFS_metafile_hint *hint = 
+                            (PVFS_metafile_hint *) user_opts->val[0].buffer;
+            printf("Metafile hints (0x%08x)",(unsigned int)hint->flags);
             if (hint->flags & PVFS_IMMUTABLE_FL) {
-                printf("immutable file ");
+                printf(" :immutable file ");
             }
             if (hint->flags & PVFS_APPEND_FL) {
-                printf("Append-only file ");
+                printf(" :Append-only file ");
             }
             if (hint->flags & PVFS_NOATIME_FL) {
-                printf("Atime updates disabled.");
+                printf(" :Atime updates disabled");
+            }
+            if (hint->flags & PVFS_MIRROR_FL) {
+		printf("  :Mirroring is enabled");
             }
             printf("\n");
+        } else if ( strncmp(user_opts->key[0].buffer
+                           ,"user.pvfs2.mirror.handles"
+                           ,sizeof("user.pvfs2.mirror.handles")) == 0)
+        {
+             PVFS_handle *myHandles = (PVFS_handle *)user_opts->val[0].buffer;
+             int copies = *(int *)user_opts->val[1].buffer;
+             int dfile_count = src.u.pvfs2.attr.dfile_count;
+             for (i=0; i<(copies * dfile_count); i++)
+             {
+                 printf("Handle(%d):%llu\n",i,llu(myHandles[i]));
+             }
+        } else if ( strncmp(user_opts->key[0].buffer
+                           ,"user.pvfs2.mirror.copies"
+                           ,sizeof("user.pvfs2.mirror.copies")) == 0)
+        {
+             int *myCopies = (int *)user_opts->val[0].buffer;
+             printf("Number of Mirrored Copies : %d\n",*myCopies);
+        } else if ( strncmp(user_opts->key[0].buffer
+                           ,"user.pvfs2.mirror.status"
+                           ,sizeof("user.pvfs2.mirror.status")) == 0)
+        {
+             int copies = *(int *)user_opts->val[1].buffer;
+             int dfile_count = src.u.pvfs2.attr.dfile_count;
+             PVFS_handle *status = (PVFS_handle *)user_opts->val[0].buffer;
+             for (i=0; i<(dfile_count * copies); i++)
+                 printf("src handle(%d) : status(%s) : value(%llu)\n"
+                       ,i
+                       ,status[i]==0?"usable":"UNusable"
+                       ,llu(status[i]));
+        } else if ( strncmp(user_opts->key[0].buffer
+                           ,"user.pvfs2.mirror.mode"
+                           , sizeof("user.pvfs2.mirror.mode")) == 0)
+        {
+             printf("Mirroring Mode : ");
+             switch(*(MIRROR_MODE *)user_opts->val[0].buffer)
+             {
+                case NO_MIRRORING :
+                {
+                    printf("Turned OFF\n");
+                    break;
+                }
+                case MIRROR_ON_IMMUTABLE :
+                {
+                    printf("Create Mirror when IMMUTABLE is set\n");
+                    break;
+                }
+                default:
+                {
+                    printf("Unknown mode(%d)\n"
+                          ,*(int *)user_opts->val[0].buffer);
+                    break;
+                }
+             }/*end switch*/
         } else {
-            printf("key:%s Value:\n%s\n",
-                    (char *)user_opts->key.buffer,
-                    (char *)user_opts->val.buffer);
+            printf("key : \"%s\" \tValue : \"%s\"\n",
+                    (char *)user_opts->key[0].buffer,
+                    (char *)user_opts->val[0].buffer);
         }
     }
   PVFS_sys_finalize();
@@ -174,7 +255,8 @@ int main(int argc, char **argv)
 
 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)
+    if (strncmp(key_p->buffer,"user.pvfs2.meta_hint"
+                             , SPECIAL_METAFILE_HINT_KEYLEN) == 0)
     {
         PVFS_metafile_hint hint;
         memset(&hint, 0, sizeof(hint));
@@ -194,7 +276,18 @@ static int modify_val(PVFS_ds_keyval *ke
             return -1;
         memcpy(val_p->buffer, &hint, sizeof(hint));
         val_p->buffer_sz = sizeof(hint);
+    } else if (strncmp(key_p->buffer,"user.pvfs2.mirror.mode"
+                                    ,sizeof("user.pvfs2.mirror.mode")) == 0)
+    {
+       printf("Setting mirror mode to %d\n",*(int *)val_p->buffer);
+    } else if (strncmp(key_p->buffer,"user.pvfs2.mirror.copies"
+                                    ,sizeof("user.pvfs2.mirror.mode")) == 0)
+    {
+       printf("Setting number of mirrored copies to %d\n"
+             ,*(int *)val_p->buffer);
     }
+
+
     return 0;
 }
 
@@ -213,8 +306,12 @@ static int permit_set(PVFS_ds_keyval *ke
  *
  * 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_credential *creds) 
+static int pvfs2_eattr(int get
+                      ,file_object      *obj
+                      ,PVFS_ds_keyval   *key_p
+                      ,PVFS_ds_keyval   *val_p
+                      ,PVFS_credential  *creds
+                      ,int key_count) 
 {
   int ret = -1;
 
@@ -223,9 +320,17 @@ static int pvfs2_eattr(int get, file_obj
       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)
+        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)
+        if ((ret = fgetxattr(obj->u.ufs.fd
+                            ,key_p->buffer
+                            ,val_p->buffer
+                            ,val_p->buffer_sz 
+                            ,0
+                            ,0)) < 0)
 #endif
         {
             perror("fgetxattr:");
@@ -252,11 +357,34 @@ static int pvfs2_eattr(int get, file_obj
   }
   else
   {
-      if (get == 1)
+      if (get == 1 && key_count == 1)
       {
           ret = PVFS_sys_geteattr(obj->u.pvfs2.ref, creds, key_p, val_p, NULL);
-      }
-      else {
+      } else if (get == 1 && key_count == 2)
+      {
+          PVFS_sysresp_geteattr *resp = malloc(sizeof(*resp));
+          if (!resp)
+          {
+             fprintf(stderr,"Unable to allocate resp structure.\n");
+             exit(EXIT_FAILURE);
+          }
+          memset(resp,0,sizeof(*resp));
+          resp->val_array = val_p;
+          resp->err_array = malloc(2 * sizeof(PVFS_error));
+          if (!resp->err_array)
+          {
+             fprintf(stderr,"Unable to allocate err_array.\n");
+             exit(EXIT_FAILURE);
+          }
+          memset(resp->err_array,0,sizeof(2 * sizeof(PVFS_error)));
+          
+          ret = PVFS_sys_geteattr_list(obj->u.pvfs2.ref
+                                      ,creds
+                                      ,key_count
+                                      ,key_p
+                                      ,resp
+                                      ,NULL );
+      } else {
           ret = PVFS_sys_seteattr(obj->u.pvfs2.ref, creds, key_p, val_p, 0, NULL);
       }
 
@@ -290,9 +418,28 @@ static struct options* parse_args(int ar
     }
     memset(tmp_opts, 0, sizeof(struct options));
 
+    /*create one key structure*/
+    tmp_opts->key = malloc(sizeof(PVFS_ds_keyval));
+    if (!tmp_opts->key)
+    {
+        fprintf(stderr,"Unable to allocate tmp_opts->key.\n");
+        exit(EXIT_FAILURE);
+    }
+    memset(tmp_opts->key,0,sizeof(PVFS_ds_keyval));
+
+    /*create one val structure*/
+    tmp_opts->val = malloc(sizeof(PVFS_ds_keyval));
+    if (!tmp_opts->val)
+    {
+        fprintf(stderr,"Unable to allocate tmp_opts->val.\n");
+        exit(EXIT_FAILURE);
+    }
+    memset(tmp_opts->val,0,sizeof(PVFS_ds_keyval));
+
+    /*set default key_count*/
+    tmp_opts->key_count = 1;
+
     /* 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;
 
@@ -307,38 +454,124 @@ static struct options* parse_args(int ar
                 tmp_opts->get = 0;
                 break;
             case 'k':
-                tmp_opts->key.buffer = strdup(optarg);
-                tmp_opts->key.buffer_sz = strlen(tmp_opts->key.buffer) + 1;
+                tmp_opts->key[0].buffer = strdup(optarg);
+                tmp_opts->key[0].buffer_sz = strlen(tmp_opts->key[0].buffer) + 1;
                 break;
             case 'v':
-                tmp_opts->val.buffer = strdup(optarg);
-                tmp_opts->val.buffer_sz = strlen(tmp_opts->val.buffer) + 1;
-                break;
+                if (strncmp(tmp_opts->key[0].buffer
+                           ,"user.pvfs2.mirror.mode"
+                           ,sizeof("user.pvfs2.mirror.mode")) == 0 ||
+                    strncmp(tmp_opts->key[0].buffer
+                           ,"user.pvfs2.mirror.copies"
+                           ,sizeof("user.pvfs2.mirror.copies")) == 0)
+                { /*convert string argument into numeric argument*/
+                  tmp_opts->val[0].buffer = malloc(sizeof(int));
+                  if (!tmp_opts->val[0].buffer)
+                  {
+                     printf("Unable to allocate memory for key value.\n");
+                     exit(EXIT_FAILURE);
+                  }
+                  memset(tmp_opts->val[0].buffer,0,sizeof(int));
+                  *(int *)tmp_opts->val[0].buffer = atoi(optarg);
+                  tmp_opts->val[0].buffer_sz = sizeof(int);
+                  break;
+                } else {
+                  tmp_opts->val[0].buffer = strdup(optarg);
+                  tmp_opts->val[0].buffer_sz = strlen(tmp_opts->val[0].buffer);
+                  break;
+                }
 	    case('?'):
                 printf("?\n");
 		usage(argc, argv);
 		exit(EXIT_FAILURE);
 	}
     }
+    /*ensure that the given mode is supported by PVFS*/
+    if (!tmp_opts->get &&
+         strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.mode") == 0)
+    {
+       if (*(int *)tmp_opts->val[0].buffer < BEGIN_MIRROR_MODE ||
+           *(int *)tmp_opts->val[0].buffer > END_MIRROR_MODE )
+       {
+          fprintf(stderr,"Invalid Mirror Mode ==> %d\n"
+                         "\tValid Modes\n"
+                         "\t1. %d == No Mirroring\n"
+                         "\t2. %d == Mirroring on Immutable\n"
+                        ,*(int *)tmp_opts->val[0].buffer
+                        ,NO_MIRRORING,MIRROR_ON_IMMUTABLE);
+
+          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)
+        /*if user wants mirror.handles or mirror.status, then we must also */
+        /*retrieve the number of copies, so we know how to display the     */
+        /*information properly.                                            */
+        if (strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.handles") == 0 ||
+            strcmp(tmp_opts->key[0].buffer,"user.pvfs2.mirror.status") == 0 )
         {
-            fprintf(stderr, "Could not allocate val\n");
-            exit(EXIT_FAILURE);
+           tmp_opts->key_count = 2;
+           PVFS_ds_keyval *myKeys = malloc(tmp_opts->key_count * 
+                                           sizeof(PVFS_ds_keyval));
+           if (!myKeys)
+           {
+               fprintf(stderr,"Unable to allocate myKeys.\n");
+               exit(EXIT_FAILURE);
+           }
+           memset(myKeys,0,sizeof(tmp_opts->key_count *
+                                  sizeof(PVFS_ds_keyval)));
+           myKeys[0] = *tmp_opts->key;
+           myKeys[1].buffer = strdup("user.pvfs2.mirror.copies");
+           myKeys[1].buffer_sz = sizeof("user.pvfs2.mirror.copies");
+           free(tmp_opts->key);
+           tmp_opts->key = myKeys;
+        }/*end if handles or status*/
+
+        
+
+        tmp_opts->val[0].buffer = calloc(1, VALBUFSZ);
+        if (!tmp_opts->val[0].buffer)
+        {
+           fprintf(stderr,"Unable to allocate tmp_opts->val[0].buffer.\n");
+           exit(EXIT_FAILURE);
         }
-    }
-    else {
-        if (tmp_opts->val.buffer == NULL)
+        tmp_opts->val[0].buffer_sz = VALBUFSZ;
+        
+        if (tmp_opts->key_count == 2)
+        {
+           PVFS_ds_keyval *myVals = malloc(tmp_opts->key_count * 
+                                           sizeof(PVFS_ds_keyval));
+           if (!myVals)
+           {
+               fprintf(stderr,"Unable to allocate myVals.\n");
+               exit(EXIT_FAILURE);
+           }
+           memset(myVals,0,sizeof(tmp_opts->key_count *
+                                  sizeof(PVFS_ds_keyval)));
+           myVals[0] = *tmp_opts->val;
+           free(tmp_opts->val);
+
+           myVals[1].buffer = malloc(sizeof(int));
+           if (!myVals[1].buffer)
+           {
+              fprintf(stderr,"Unable to allocate myVals[1].buffer.\n");
+              exit(EXIT_FAILURE);
+           }
+           myVals[1].buffer_sz = sizeof(int);
+           tmp_opts->val = myVals;
+         }/*end if*/  
+    } else {
+        if (tmp_opts->val[0].buffer == NULL)
         {
-            fprintf(stderr, "Please specify value if setting extended attributes\n");
+            fprintf(stderr, "Please specify value if setting extended "
+                            "attributes\n");
             usage(argc, argv);
             exit(EXIT_FAILURE);
         }
     }
-    if (tmp_opts->key.buffer == NULL)
+    if (tmp_opts->key[0].buffer == NULL)
     {
         fprintf(stderr, "Please specify key if getting extended attributes\n");
         usage(argc, argv);
@@ -350,7 +583,8 @@ static struct options* parse_args(int ar
 
 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]);
+    fprintf(stderr,"Usage: %s -s {set xattrs} -k <key> -v <val> "
+                   "-t {print attributes} filename\n",argv[0]);
     return;
 }
 
@@ -449,7 +683,11 @@ static int generic_open(file_object *obj
         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;
+        /* we should not modify the returned mask, so we know which data fields
+         * in the attribute structure are valid.  I don't see any reason why
+         * it is being reset here.
+        */
+        //obj->u.pvfs2.attr.mask = PVFS_ATTR_SYS_ALL_SETABLE;
         obj->u.pvfs2.ref = ref;
     }
     return 0;




More information about the Pvfs2-cvs mailing list