summaryrefslogtreecommitdiff
path: root/src/librbd/WatchCtx.cc
blob: 0f0c4142afc89de3172852342d5123282f05fa96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

#include "common/ceph_context.h"
#include "common/debug.h"
#include "common/perf_counters.h"

#include "librbd/ImageCtx.h"
#include "librbd/internal.h"

#include "librbd/WatchCtx.h"

#define dout_subsys ceph_subsys_rbd
#undef dout_prefix
#define dout_prefix *_dout << "librbd::WatchCtx: "

namespace librbd {

  void WatchCtx::invalidate()
  {
    Mutex::Locker l(lock);
    valid = false;
  }

  void WatchCtx::notify(uint8_t opcode, uint64_t ver, bufferlist& bl)
  {
    Mutex::Locker l(lock);
    ldout(ictx->cct, 1) <<  " got notification opcode=" << (int)opcode
			<< " ver=" << ver << " cookie=" << cookie << dendl;
    if (valid) {
      Mutex::Locker lictx(ictx->refresh_lock);
      ++ictx->refresh_seq;
      ictx->perfcounter->inc(l_librbd_notify);
    }
  }
}