From 4866d89cfbcd76bd8da47a9a7ec21b5a514193dc Mon Sep 17 00:00:00 2001 From: John Spray Date: Mon, 27 Jul 2015 11:05:56 +0100 Subject: [PATCH] osd: make PGLSFilter xattr read optional The cephfs filter needs to be able to express interest in an xattr, but not reject objects which do not have it. Signed-off-by: John Spray --- src/osd/ReplicatedPG.cc | 7 +++++-- src/osd/ReplicatedPG.h | 13 ++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index aa399a3bd0f10..3d0eb012966e4 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -549,8 +549,11 @@ bool ReplicatedPG::pgls_filter(PGLSFilter *filter, hobject_t& sobj, bufferlist& filter->get_xattr(), &bl); dout(0) << "getattr (sobj=" << sobj << ", attr=" << filter->get_xattr() << ") returned " << ret << dendl; - if (ret < 0) - return false; + if (ret < 0) { + if (ret != -ENODATA || filter->reject_empty_xattr()) { + return false; + } + } } return filter->filter(sobj, bl, outdata); diff --git a/src/osd/ReplicatedPG.h b/src/osd/ReplicatedPG.h index b5e143455b570..70696b529fbdb 100644 --- a/src/osd/ReplicatedPG.h +++ b/src/osd/ReplicatedPG.h @@ -65,7 +65,18 @@ public: virtual ~PGLSFilter(); virtual bool filter(const hobject_t &obj, bufferlist& xattr_data, bufferlist& outdata) = 0; - virtual string& get_xattr() { return xattr; } + + /** + * xattr key, or empty string. If non-empty, this xattr will be fetched + * and the value passed into ::filter + */ + virtual string& get_xattr() { 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() { return true; } }; class PGLSPlainFilter : public PGLSFilter { -- 2.39.5