]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: add missing locks for PurgeQueue methods
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 18 Dec 2018 23:08:11 +0000 (15:08 -0800)
committerNathan Cutler <ncutler@suse.com>
Thu, 31 Jan 2019 10:12:16 +0000 (11:12 +0100)
These could race with the asynchronous workings of the PQ.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
(cherry picked from commit c7350ac23c73867b52cd9b7bb23b6c618eebe44d)

Conflicts:
src/mds/PurgeQueue.cc
- use Mutex::Locker instead of std::lock_guard
- no "ceph_assert" in mimic

src/mds/PurgeQueue.cc
src/mds/PurgeQueue.h

index 40ea03002f00c60383dc84a01e5e848563ef4a33..cb8de5e6ddb0f8ae38be75f16d5df153ed9b17bd 100644 (file)
@@ -311,7 +311,7 @@ void PurgeQueue::push(const PurgeItem &pi, Context *completion)
   if (!could_consume) {
     // Usually, it is not necessary to explicitly flush here, because the reader
     // will get flushes generated inside Journaler::is_readable.  However,
-    // if we remain in a can_consume()==false state for a long period then
+    // if we remain in a _can_consume()==false state for a long period then
     // we should flush in order to allow MDCache to drop its strays rather
     // than having them wait for purgequeue to progress.
     if (!delayed_flush) {
@@ -357,7 +357,7 @@ uint32_t PurgeQueue::_calculate_ops(const PurgeItem &item) const
   return ops_required;
 }
 
-bool PurgeQueue::can_consume()
+bool PurgeQueue::_can_consume()
 {
   dout(20) << ops_in_flight << "/" << max_purge_ops << " ops, "
            << in_flight.size() << "/" << g_conf->mds_max_purge_files
@@ -391,7 +391,7 @@ bool PurgeQueue::_consume()
   assert(lock.is_locked_by_me());
 
   bool could_consume = false;
-  while(can_consume()) {
+  while(_can_consume()) {
 
     if (delayed_flush) {
       // We are now going to read from the journal, so any proactive
@@ -662,6 +662,8 @@ bool PurgeQueue::drain(
     size_t *in_flight_count
     )
 {
+  Mutex::Locker l(lock);
+
   assert(progress != nullptr);
   assert(progress_total != nullptr);
   assert(in_flight_count != nullptr);
index 27c99e6e7420a82cfa07c1ed49a7e011a444850c..92c677260a063ce88c8aec728e8e4cdabb1da0da 100644 (file)
@@ -134,7 +134,7 @@ protected:
 
   uint32_t _calculate_ops(const PurgeItem &item) const;
 
-  bool can_consume();
+  bool _can_consume();
 
   // How many bytes were remaining when drain() was first called,
   // used for indicating progress.