Skip to content

Commit

Permalink
objclass, osd: dissect PGLSFilter into the osd_types.h header.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski committed Aug 24, 2019
1 parent 10fca23 commit 2c0f089
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 46 deletions.
1 change: 1 addition & 0 deletions src/cls/cephfs/cls_cephfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <errno.h>

#include "objclass/objclass.h"
#include "osd/osd_types.h"

#include "cls_cephfs.h"

Expand Down
1 change: 1 addition & 0 deletions src/cls/hello/cls_hello.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <cerrno>

#include "objclass/objclass.h"
#include "osd/osd_types.h"

using ceph::bufferlist;
using std::string;
Expand Down
8 changes: 0 additions & 8 deletions src/crimson/osd/osd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,6 @@ namespace {
using ceph::common::local_conf;
using ceph::os::FuturizedStore;

PGLSFilter::PGLSFilter() : cct(nullptr)
{
}

PGLSFilter::~PGLSFilter()
{
}

namespace ceph::osd {

OSD::OSD(int id, uint32_t nonce,
Expand Down
31 changes: 1 addition & 30 deletions src/objclass/objclass.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "include/rados/objclass.h"

struct obj_list_watch_response_t;
class PGLSFilter;

extern "C" {
#endif
Expand Down Expand Up @@ -74,36 +75,6 @@ extern void class_fini(void);

#ifdef __cplusplus
}
class PGLSFilter {
CephContext* cct;
protected:
std::string xattr;
public:
PGLSFilter();
virtual ~PGLSFilter();
virtual bool filter(const hobject_t &obj,
const ceph::buffer::list& xattr_data) const = 0;

/**
* Arguments passed from the RADOS client. Implementations must
* handle any encoding errors, and return an appropriate error code,
* or 0 on valid input.
*/
virtual int init(ceph::buffer::list::const_iterator &params) = 0;

/**
* xattr key, or empty string. If non-empty, this xattr will be fetched
* and the value passed into ::filter
*/
virtual const std::string& get_xattr() const { return xattr; }

/**
* If true, objects without the named xattr (if xattr name is not empty)
* will be rejected without calling ::filter
*/
virtual bool reject_empty_xattr() const { return true; }
};

// Classes expose a filter constructor that returns a subclass of PGLSFilter
typedef PGLSFilter* (*cls_cxx_filter_factory_t)();

Expand Down
8 changes: 0 additions & 8 deletions src/osd/PrimaryLogPG.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ static ostream& _prefix(std::ostream *_dout, T *pg) {

MEMPOOL_DEFINE_OBJECT_FACTORY(PrimaryLogPG, replicatedpg, osd);

PGLSFilter::PGLSFilter() : cct(nullptr)
{
}

PGLSFilter::~PGLSFilter()
{
}

/**
* The CopyCallback class defines an interface for completions to the
* copy_start code. Users of the copy infrastructure must implement
Expand Down
8 changes: 8 additions & 0 deletions src/osd/osd_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6692,3 +6692,11 @@ void init_pg_ondisk(
encode(struct_v, values[string(infover_key)]);
t.omap_setkeys(coll, pgmeta_oid, values);
}

PGLSFilter::PGLSFilter() : cct(nullptr)
{
}

PGLSFilter::~PGLSFilter()
{
}
31 changes: 31 additions & 0 deletions src/osd/osd_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6095,4 +6095,35 @@ struct omap_stat_t {
int64_t omap_keys;
};

// filter for pg listings
class PGLSFilter {
CephContext* cct;
protected:
std::string xattr;
public:
PGLSFilter();
virtual ~PGLSFilter();
virtual bool filter(const hobject_t &obj,
const ceph::buffer::list& xattr_data) const = 0;

/**
* Arguments passed from the RADOS client. Implementations must
* handle any encoding errors, and return an appropriate error code,
* or 0 on valid input.
*/
virtual int init(ceph::buffer::list::const_iterator &params) = 0;

/**
* xattr key, or empty string. If non-empty, this xattr will be fetched
* and the value passed into ::filter
*/
virtual const std::string& get_xattr() const { return xattr; }

/**
* If true, objects without the named xattr (if xattr name is not empty)
* will be rejected without calling ::filter
*/
virtual bool reject_empty_xattr() const { return true; }
};

#endif

0 comments on commit 2c0f089

Please sign in to comment.