]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
fs_types: file_layout_t: convert pool -1 (undefined) to 0 in legacy encoding
authorSage Weil <sage@redhat.com>
Tue, 12 Jan 2016 14:57:06 +0000 (09:57 -0500)
committerSage Weil <sage@redhat.com>
Tue, 1 Mar 2016 16:18:17 +0000 (11:18 -0500)
Old code assumes that fl_pg_pool == 0 means the pool is not defined, while
file_layout_t uses -1.  Translate between the two.

Note that this means a valid file_layout_t with pool_id == 0 cannot be
accurately translated to a legacy file_layout_t.  That is somewhat
unavoidable, and should not be a problem since real clusters create 'rbd'
as pool 0 and it does not use any file layouts.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/fs_types.cc

index 72a0ddffc07c6ac322f72954bdb6238ccfcc6186..741e4f123310ca295778a1beaeccd54716132cc2 100644 (file)
@@ -46,6 +46,9 @@ void file_layout_t::from_legacy(const ceph_file_layout& fl)
   stripe_count = fl.fl_stripe_count;
   object_size = fl.fl_object_size;
   pool_id = (int32_t)fl.fl_pg_pool;
+  // in the legacy encoding, pool 0 was undefined.
+  if (pool_id == 0)
+    pool_id = -1;
   pool_ns.clear();
 }
 
@@ -57,7 +60,11 @@ void file_layout_t::to_legacy(ceph_file_layout *fl) const
   fl->fl_cas_hash = 0;
   fl->fl_object_stripe_unit = 0;
   fl->fl_unused = 0;
-  fl->fl_pg_pool = pool_id;
+  // in the legacy encoding, pool 0 was undefined.
+  if (pool_id >= 0)
+    fl->fl_pg_pool = pool_id;
+  else
+    fl->fl_pg_pool = 0;
 }
 
 void file_layout_t::encode(bufferlist& bl, uint64_t features) const