From 29e4e7e316fe3f3028e6930bb5987cfe3a5e59ab Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 29 May 2013 09:49:11 -0700 Subject: osd: do not assume head obc object exists when getting snapdir For a list-snaps operation on the snapdir, do not assume that the obc for the head means the object exists. This fixes a race between a head deletion and a list-snaps that wrongly returns ENOENT, triggered by the DiffItersateStress test when thrashing OSDs. Fixes: #5183 Backport: cuttlefish Signed-off-by: Sage Weil Reviewed-by: Samuel Just --- src/osd/ReplicatedPG.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 761a77cd69c..e050eb3d8ee 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -4383,6 +4383,11 @@ int ReplicatedPG::find_object_context(const hobject_t& oid, if (oid.snap == CEPH_SNAPDIR) { // return head or snapdir, whichever exists. ObjectContext *obc = get_object_context(head, oloc, can_create); + if (obc && !obc->obs.exists) { + // ignore it if the obc exists but the object doesn't + put_object_context(obc); + obc = NULL; + } if (!obc) { obc = get_object_context(snapdir, oloc, can_create); } -- cgit v1.2.1 From 482733e9603e47a3a427b17bfb9b9189dacd5109 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 28 May 2013 10:51:11 -0700 Subject: mds: stay in SCAN state in file_eval If we are in the SCAN state, stay there until the recovery finishes. Do not jump to another state from file_eval(). Signed-off-by: Sage Weil (cherry picked from commit 0071b8e75bd3f5a09cc46e2225a018f6d1ef0680) --- src/mds/Locker.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index 4a23e0bc47f..3d8c5469a3c 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -4108,6 +4108,10 @@ void Locker::file_eval(ScatterLock *lock, bool *need_issue) if (lock->get_parent()->is_freezing_or_frozen()) return; + // wait for scan + if (lock->get_state() == LOCK_SCAN) + return; + // excl -> *? if (lock->get_state() == LOCK_EXCL) { dout(20) << " is excl" << dendl; -- cgit v1.2.1 From 50ac8917f175d1b107c18ecb025af1a7b103d634 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 29 May 2013 16:50:04 -0700 Subject: osd: initialize new_state field when we use it If we use operator[] on a new int field its value is undefined; avoid reading it or using |= et al until we initialize it. Fixes: #4967 Backport: cuttlefish, bobtail Signed-off-by: Sage Weil Reviewed-by: David Zafman --- src/mon/OSDMonitor.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 39e3fe9bbe0..338b5195af2 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -926,7 +926,8 @@ bool OSDMonitor::check_failure(utime_t now, int target_osd, failure_info_t& fi) << dendl; // already pending failure? - if (pending_inc.new_state[target_osd] & CEPH_OSD_UP) { + if (pending_inc.new_state.count(target_osd) && + pending_inc.new_state[target_osd] & CEPH_OSD_UP) { dout(10) << " already pending failure" << dendl; return true; } @@ -3174,6 +3175,8 @@ bool OSDMonitor::prepare_command(MMonCommand *m) done: dout(10) << " creating osd." << i << dendl; + if (pending_inc.new_state.count(i) == 0) + pending_inc.new_state[i] = 0; pending_inc.new_state[i] |= CEPH_OSD_EXISTS | CEPH_OSD_NEW; if (!uuid.is_zero()) pending_inc.new_uuid[i] = uuid; -- cgit v1.2.1