From: Sage Weil Date: Tue, 12 Jan 2016 14:57:06 +0000 (-0500) Subject: fs_types: file_layout_t: convert pool -1 (undefined) to 0 in legacy encoding X-Git-Tag: v10.1.0~241^2~12 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=efb4a83f77ea2e10e2938db4ca19d8fa5e0e92a3;p=ceph.git 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 --- diff --git a/src/common/fs_types.cc b/src/common/fs_types.cc index 72a0ddffc07c..741e4f123310 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