Index: trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm
===================================================================
--- trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 16282)
+++ trunk/Nebulous-Server/lib/Nebulous/Server/SQL.pm	(revision 17072)
@@ -1,5 +1,5 @@
 # Copyright (c) 2004  Joshua Hoblitt
 #
-# $Id: SQL.pm,v 1.48 2008-02-02 02:10:52 jhoblitt Exp $
+# $Id: SQL.pm,v 1.49 2008-03-20 21:10:57 jhoblitt Exp $
 
 package Nebulous::Server::SQL;
@@ -246,18 +246,19 @@
     find_objects_with_unavailable_instances => qq{
         SELECT
-            so_id,
+            storage_object.so_id,
             ext_id,
             count(ins_id) as instances,
             count(mountedvol.vol_id) as available_instances,
             count(mountedvol.vol_id) < count(ins_id) as need_recovery,
-            count(mountedvol.vol_id) > 0 as recoverable
+            count(mountedvol.vol_id) > 0 as recoverable,
+            storage_object_xattr.value as copies
         FROM storage_object
         JOIN storage_object_attr
             USING(so_id)
-        JOIN storage_object_xattr
+        JOIN instance
+            USING(so_id)
+        LEFT JOIN storage_object_xattr
             ON storage_object.so_id = storage_object_xattr.so_id
             AND storage_object_xattr.name = 'copies'
-        JOIN instance
-            USING(so_id)
         LEFT JOIN mountedvol
             USING(vol_id)
