]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/cephfs: fix layout handling in injection 6719/head
authorJohn Spray <john.spray@redhat.com>
Fri, 27 Nov 2015 01:21:12 +0000 (01:21 +0000)
committerJohn Spray <john.spray@redhat.com>
Tue, 1 Dec 2015 14:57:23 +0000 (14:57 +0000)
When the stashed-layout handling stuff was added,
the guessing part got lost from the path where
we only had a single object.  Broke test_data_scan.

Signed-off-by: John Spray <john.spray@redhat.com>
src/tools/cephfs/DataScan.cc
src/tools/cephfs/DataScan.h

index ce083cefff23bc5abbb418d20b358ee2faa3faed..05bb864731616d4834fdeffee3a18cc4b59c7cf6 100644 (file)
@@ -495,7 +495,7 @@ int DataScan::scan_inodes()
     ceph_file_layout loaded_layout = g_default_file_layout;
     int r = ClsCephFSClient::fetch_inode_accumulate_result(
         data_io, oid, &backtrace, &loaded_layout, &accum_res);
-    
+
     if (r < 0) {
       dout(4) << "Unexpected error loading accumulated metadata from '"
               << oid << "': " << cpp_strerror(r) << dendl;
@@ -508,7 +508,6 @@ int DataScan::scan_inodes()
 
     const time_t file_mtime = accum_res.max_mtime;
     uint64_t file_size = 0;
-    uint32_t chunk_size = g_default_file_layout.fl_object_size;
     bool have_backtrace = !(backtrace.ancestors.empty());
 
     // This is the layout we will use for injection, populated either
@@ -516,8 +515,9 @@ int DataScan::scan_inodes()
     ceph_file_layout guessed_layout;
     guessed_layout.fl_pg_pool = data_pool_id;
 
-    // Calculate file_size, guess chunk_size
+    // Calculate file_size, guess the layout
     if (accum_res.ceiling_obj_index > 0) {
+      uint32_t chunk_size = g_default_file_layout.fl_object_size;
       // When there are multiple objects, the largest object probably
       // indicates the chunk size.  But not necessarily, because files
       // can be sparse.  Only make this assumption if size seen
@@ -531,9 +531,10 @@ int DataScan::scan_inodes()
         guessed_layout.fl_object_size = chunk_size;
         guessed_layout.fl_stripe_unit = chunk_size;
         guessed_layout.fl_stripe_count = 1;
-      } else if (loaded_layout.fl_object_size < accum_res.max_obj_size) {
+      } else if (!ceph_file_layout_is_valid(&loaded_layout) ||
+          loaded_layout.fl_object_size < accum_res.max_obj_size) {
         // If the max size seen exceeds what the stashed layout claims, then
-        // disbelieve it.  Guess instead.
+        // disbelieve it.  Guess instead.  Same for invalid layouts on disk.
         dout(4) << "bogus xattr layout on 0x" << std::hex << obj_name_ino
                 << std::dec << ", ignoring in favour of best guess" << dendl;
         guessed_layout.fl_object_size = chunk_size;
@@ -616,6 +617,14 @@ int DataScan::scan_inodes()
       }
     } else {
       file_size = accum_res.ceiling_obj_size;
+      if (loaded_layout.fl_pg_pool == uint32_t(-1)
+          || loaded_layout.fl_object_size < accum_res.max_obj_size) {
+        // No layout loaded, or inconsistent layout, use default
+        guessed_layout = g_default_file_layout;
+        guessed_layout.fl_pg_pool = data_pool_id;
+      } else {
+        guessed_layout = loaded_layout;
+      }
     }
 
     // Santity checking backtrace ino against object name
index 252e6e3284e0cb4f7f2e38da18eb367639ce66cc..b2787b9b06588429c70be19ae98761fadb36c1a8 100644 (file)
@@ -260,7 +260,8 @@ class DataScan : public MDSUtility
 
     DataScan()
       : driver(NULL), data_pool_id(-1), n(0), m(1),
-        force_pool(false)
+        force_pool(false), force_corrupt(false),
+        force_init(false)
     {
     }