From patchwork Mon Aug 5 06:10:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Yan, Zheng" X-Patchwork-Id: 2838533 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D4288BF535 for ; Mon, 5 Aug 2013 06:10:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DDD0720124 for ; Mon, 5 Aug 2013 06:10:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8DB9320182 for ; Mon, 5 Aug 2013 06:10:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754663Ab3HEGKl (ORCPT ); Mon, 5 Aug 2013 02:10:41 -0400 Received: from mga03.intel.com ([143.182.124.21]:46271 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754560Ab3HEGKk (ORCPT ); Mon, 5 Aug 2013 02:10:40 -0400 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 04 Aug 2013 23:10:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.89,816,1367996400"; d="scan'208";a="341696535" Received: from zyan5-mobl.sh.intel.com ([10.239.13.8]) by azsmga001.ch.intel.com with ESMTP; 04 Aug 2013 23:10:37 -0700 From: "Yan, Zheng" To: ceph-devel@vger.kernel.org Cc: sage@inktank.com, "Yan, Zheng" Subject: [PATCH 5/6] mds: change LOCK_SCAN to unstable state Date: Mon, 5 Aug 2013 14:10:26 +0800 Message-Id: <1375683030-28305-6-git-send-email-zheng.z.yan@intel.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1375683030-28305-1-git-send-email-zheng.z.yan@intel.com> References: <1375683030-28305-1-git-send-email-zheng.z.yan@intel.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Yan, Zheng" commit 0071b8e75b (mds: stay in SCAN state in file_eval) makes Locker::file_eval() ignore lock in LOCK_SCAN state. If there is no request changes the lock state, the lock can be stuck in LOCK_SCAN state forever. This can cause client read/write hang because lock in LOCK_SCAN state does not allow Frw caps. The fix is change LOCK_SCAN to a unstable state. Thank to the CInode::STATE_RECOVERING check in Locker::eval_gather(), the lock stays in the SCAN state while file is being recovering. The lock will transit to a stable state once the recovery finishes. Signed-off-by: Yan, Zheng --- src/mds/Locker.cc | 18 +++++------------- src/mds/MDCache.cc | 1 + src/mds/locks.c | 3 +-- src/mds/locks.h | 1 - 4 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/mds/Locker.cc b/src/mds/Locker.cc index efb5a74..084d64a 100644 --- a/src/mds/Locker.cc +++ b/src/mds/Locker.cc @@ -3441,7 +3441,6 @@ bool Locker::simple_sync(SimpleLock *lock, bool *need_issue) switch (lock->get_state()) { case LOCK_MIX: lock->set_state(LOCK_MIX_SYNC); break; - case LOCK_SCAN: case LOCK_LOCK: lock->set_state(LOCK_LOCK_SYNC); break; case LOCK_XSYN: lock->set_state(LOCK_XSYN_SYNC); break; case LOCK_EXCL: lock->set_state(LOCK_EXCL_SYNC); break; @@ -3518,7 +3517,6 @@ void Locker::simple_excl(SimpleLock *lock, bool *need_issue) in = static_cast(lock->get_parent()); switch (lock->get_state()) { - case LOCK_SCAN: case LOCK_LOCK: lock->set_state(LOCK_LOCK_EXCL); break; case LOCK_SYNC: lock->set_state(LOCK_SYNC_EXCL); break; case LOCK_XSYN: lock->set_state(LOCK_XSYN_EXCL); break; @@ -3577,7 +3575,6 @@ void Locker::simple_lock(SimpleLock *lock, bool *need_issue) int old_state = lock->get_state(); switch (lock->get_state()) { - case LOCK_SCAN: lock->set_state(LOCK_SCAN_LOCK); break; case LOCK_SYNC: lock->set_state(LOCK_SYNC_LOCK); break; case LOCK_XSYN: file_excl(static_cast(lock), need_issue); @@ -4163,10 +4160,6 @@ 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; @@ -4353,7 +4346,6 @@ void Locker::file_excl(ScatterLock *lock, bool *need_issue) switch (lock->get_state()) { case LOCK_SYNC: lock->set_state(LOCK_SYNC_EXCL); break; case LOCK_MIX: lock->set_state(LOCK_MIX_EXCL); break; - case LOCK_SCAN: case LOCK_LOCK: lock->set_state(LOCK_LOCK_EXCL); break; case LOCK_XSYN: lock->set_state(LOCK_XSYN_EXCL); break; default: assert(0); @@ -4464,12 +4456,12 @@ void Locker::file_recover(ScatterLock *lock) issue_caps(in); gather++; } - if (gather) { - lock->get_parent()->auth_pin(lock); - } else { - lock->set_state(LOCK_SCAN); + + lock->set_state(LOCK_SCAN); + if (gather) + in->state_set(CInode::STATE_NEEDSRECOVER); + else mds->mdcache->queue_file_recover(in); - } } diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 77d3d8b..898dcd3 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -5718,6 +5718,7 @@ void MDCache::identify_files_to_recover(vector& recover_q, vectorauth_pin(&in->filelock); in->filelock.set_state(LOCK_PRE_SCAN); recover_q.push_back(in); diff --git a/src/mds/locks.c b/src/mds/locks.c index 9031087..37e3f5e 100644 --- a/src/mds/locks.c +++ b/src/mds/locks.c @@ -122,8 +122,7 @@ const struct sm_state_t filelock[LOCK_MAX] = { [LOCK_EXCL_XSYN] = { LOCK_XSYN, false, LOCK_LOCK, 0, 0, XCL, 0, 0, 0, 0, 0,CEPH_CAP_GCACHE|CEPH_CAP_GBUFFER,0,0 }, [LOCK_PRE_SCAN] = { LOCK_SCAN, false, LOCK_LOCK, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0 }, - [LOCK_SCAN] = { 0, false, LOCK_LOCK, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0 }, - [LOCK_SCAN_LOCK] = { LOCK_LOCK, false, LOCK_LOCK, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0 }, + [LOCK_SCAN] = { LOCK_LOCK, false, LOCK_LOCK, 0, 0, 0, 0, 0, 0, 0, 0,0,0,0 }, }; const struct sm_t sm_filelock = { diff --git a/src/mds/locks.h b/src/mds/locks.h index 2adcbf2..d1585ce 100644 --- a/src/mds/locks.h +++ b/src/mds/locks.h @@ -86,7 +86,6 @@ enum { LOCK_PRE_SCAN, LOCK_SCAN, - LOCK_SCAN_LOCK, LOCK_SNAP_SYNC,