From 1d0c8ab140fb0a050d5a29ca7bdabd264e75c978 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 3 Apr 2009 13:05:49 -0700 Subject: [PATCH] mds: fix open on snapped files rdlock the filelock to make sure we get the snapped metadata. Also make sure the filelock is SYNC so that the data ends up on disk. (On the auth mds, we may rdlock by going to LOCK state.) --- src/mds/Locker.h | 2 ++ src/mds/Server.cc | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mds/Locker.h b/src/mds/Locker.h index 3efed871d31df..d48ea39d007fa 100644 --- a/src/mds/Locker.h +++ b/src/mds/Locker.h @@ -108,7 +108,9 @@ protected: void simple_eval(SimpleLock *lock); void handle_simple_lock(SimpleLock *lock, MLock *m); +public: bool simple_sync(SimpleLock *lock); +protected: void simple_lock(SimpleLock *lock); void simple_xlock(SimpleLock *lock); diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 0998f0742a4ff..d05647e040875 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -4854,15 +4854,28 @@ void Server::handle_client_open(MDRequest *mdr) } } - // rdlock filelock if snapped. - // this makes us wait for writers to flushsnaps, ensuring we get accurate metadata. + // sync filelock if snapped. + // this makes us wait for writers to flushsnaps, ensuring we get accurate metadata, + // and that data itself is flushed so that we can read the snapped data off disk. if (mdr->ref_snapid != CEPH_NOSNAP && !cur->is_dir()) { + // first rdlock. set rdlocks = mdr->rdlocks; set wrlocks = mdr->wrlocks; set xlocks = mdr->xlocks; rdlocks.insert(&cur->filelock); if (!mds->locker->acquire_locks(mdr, rdlocks, wrlocks, xlocks)) return; + + // sure sure we ended up in the SYNC state + if (cur->filelock.is_stable() && cur->filelock.get_state() != LOCK_SYNC) { + assert(cur->is_auth()); + mds->locker->simple_sync(&cur->filelock); + } + if (!cur->filelock.is_stable()) { + dout(10) << " waiting for filelock to stabilize on " << *cur << dendl; + cur->filelock.add_waiter(SimpleLock::WAIT_STABLE, new C_MDS_RetryRequest(mdcache, mdr)); + return; + } } -- 2.39.5