From cd41ca2968d07d32b5432aa137e2077ef0ffff17 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 5 Apr 2016 16:37:25 -0400 Subject: [PATCH] mds: fix legacy layout decode with pool 0 If you data pool was pool 0, this was transforming that to -1 unconditionally, which broke upgrades. We only want do that for a fully zeroed ceph_file_layout, so that it still maps to a file_layout_t. If any fields are set, though, we trust the fl_pgpool to be a valid pool. Signed-off-by: Sage Weil --- src/common/fs_types.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/fs_types.cc b/src/common/fs_types.cc index 741e4f123310c..3c7e5e1c905f7 100644 --- a/src/common/fs_types.cc +++ b/src/common/fs_types.cc @@ -46,8 +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) + // in the legacy encoding, a zeroed structure was the default and + // would have pool 0 instead of -1. + if (pool_id == 0 && stripe_unit == 0 && stripe_count == 0 && object_size == 0) pool_id = -1; pool_ns.clear(); } -- 2.39.5