summaryrefslogtreecommitdiffstats
path: root/src/tools/cephfs/JournalFilter.h
blob: f7a2db614a1356c2cf3a4444af1c8b1ee47b7a1b (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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// -*- mode:c++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
// vim: ts=8 sw=2 smarttab
/*
 * ceph - scalable distributed file system
 *
 * copyright (c) 2014 john spray <john.spray@inktank.com>
 *
 * this is free software; you can redistribute it and/or
 * modify it under the terms of the gnu lesser general public
 * license version 2.1, as published by the free software
 * foundation.  see file copying.
 */


#ifndef JOURNAL_FILTER_H
#define JOURNAL_FILTER_H

#include "mds/mdstypes.h"
#include "mds/LogEvent.h"
#include "mds/PurgeQueue.h"

/**
 * A set of conditions for narrowing down a search through the journal
 */
class JournalFilter
{
  private:

  /* Filtering by journal offset range */
  uint64_t range_start;
  uint64_t range_end;
  static const std::string range_separator;

  /* Filtering by file (sub) path */
  std::string path_expr;

  /* Filtering by inode */
  inodeno_t inode;

  /* Filtering by type */
  LogEvent::EventType event_type;

  std::string type;

  /* Filtering by PurgeItem::Action */
  PurgeItem::Action purge_action;

  /* Filtering by dirfrag */
  dirfrag_t frag;
  std::string frag_dentry;  //< optional, filter dentry name within fragment

  /* Filtering by metablob client name */
  entity_name_t client_name;

  public:
  JournalFilter(std::string t) :
    range_start(0),
    range_end(-1),
    inode(0),
    event_type(0),
    type(t),
    purge_action(PurgeItem::NONE) {}

  bool get_range(uint64_t &start, uint64_t &end) const;
  bool apply(uint64_t pos, LogEvent &le) const;
  bool apply(uint64_t pos, PurgeItem &pi) const;
  int parse_args(
    std::vector<const char*> &argv, 
    std::vector<const char*>::iterator &arg);
};

#endif // JOURNAL_FILTER_H