From: John Spray Date: Mon, 27 Jul 2015 10:05:56 +0000 (+0100) Subject: osd: make PGLSFilter xattr read optional X-Git-Tag: v9.1.0~400^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F5353%2Fhead;p=ceph.git 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 --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index aa399a3bd0f..3d0eb012966 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 b5e143455b5..70696b529fb 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 {