From efb4a83f77ea2e10e2938db4ca19d8fa5e0e92a3 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 12 Jan 2016 09:57:06 -0500 Subject: [PATCH] fs_types: file_layout_t: convert pool -1 (undefined) to 0 in legacy encoding 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 --- src/common/fs_types.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/common/fs_types.cc b/src/common/fs_types.cc index 72a0ddffc07..741e4f12331 100644 --- a/src/common/fs_types.cc +++ b/src/common/fs_types.cc @@ -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 -- 2.47.3