Index: trunk/Nebulous-Server/bin/neb-admin
===================================================================
--- trunk/Nebulous-Server/bin/neb-admin	(revision 23340)
+++ trunk/Nebulous-Server/bin/neb-admin	(revision 23345)
@@ -23,4 +23,6 @@
     $dbpass,
     $dbuser,
+    $so_id_start,
+    $so_id_range,
     $limit,
     $pending,
@@ -41,4 +43,6 @@
     'pendingreplicate|r'    => \$pending,
     'pendingremoval'        => \$removal,
+    'so_id_start=i'         => \$so_id_start,
+    'so_id_range=i'         => \$so_id_range,
     'limit|l=i'             => \$limit,
     'verbose|v'             => \$verbose,
@@ -58,4 +62,5 @@
 
 # check to make sure that only one instance of neb-admin is running
+# XXX this implies we should move pending replicate elsewhere
 my $pidfile = '/var/tmp/neb-admin';
 # abort if an instance is already running
@@ -91,4 +96,22 @@
     $dbh->do("INSERT INTO myvolume SELECT * FROM volume");
 
+    if (not defined $so_id_start) { $so_id_start = 0; }
+    if (not defined $so_id_range) { $so_id_range = 100000; }
+    my $so_id_end = $so_id_start + $so_id_range;
+
+    # XXX check if so_id_start is beyond MAX(so_id): if so, exit with exit status 10
+    { 
+	my $query = $dbh->prepare("SELECT MAX(so_id) from storage_object");
+	$query->execute;
+        my $answer = $query->fetchrow_arrayref;
+        my $max_so_id = $$answer[0];
+	$query->finish;
+
+	if ($so_id_start > $max_so_id) { 
+	    print STDERR "at end of so_id range, reset please\n";
+	    exit 10;
+	}
+    }
+	
     my $query = $dbh->prepare(
     "        SELECT
@@ -111,5 +134,7 @@
                 USING(vol_id)
             WHERE mymountedvol.available = 1
-    --        WHERE storage_object_xattr.name = 'user.copies'
+            AND storage_object_xattr.name = 'user.copies'
+            AND storage_object.so_id >= $so_id_start
+            AND storage_object.so_id <  $so_id_end
             GROUP BY so_id
             HAVING available_instances < instances OR instances < copies
