From de6408bf975ca7e8e4a76d7eafd4f2192115b2fd Mon Sep 17 00:00:00 2001 From: Andriy Tkachuk Date: Wed, 1 Jun 2022 15:14:08 +0100 Subject: [PATCH] rgw_sal_motr: handle error from m0_layout_find_by_objsz() Such error can happen, for example, when there are too many failures in the cluster which are not tolerable by motr, so the pool version is not available and m0_layout_find_by_objsz() cannot return any meaningful result. Solution: handle errors from m0_layout_find_by_objsz(). Signed-off-by: Andriy Tkachuk --- src/rgw/rgw_sal_motr.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/rgw/rgw_sal_motr.cc b/src/rgw/rgw_sal_motr.cc index 02191e8149194..aa679af4034d7 100644 --- a/src/rgw/rgw_sal_motr.cc +++ b/src/rgw/rgw_sal_motr.cc @@ -2253,7 +2253,10 @@ int MotrObject::create_mobj(const DoutPrefixProvider *dpp, uint64_t sz) ldpp_dout(dpp, 20) <<__func__<< ": sz=" << sz << " oid=" << fid_str << dendl; int64_t lid = m0_layout_find_by_objsz(store->instance, nullptr, sz); - M0_ASSERT(lid > 0); + if (lid <= 0) { + ldpp_dout(dpp, 0) <<__func__<< ": failed to get lid: " << lid << dendl; + return lid == 0 ? -EINVAL : (int)lid; + } M0_ASSERT(mobj == nullptr); mobj = new m0_obj();