From: Samuel Just Date: Thu, 10 Oct 2013 23:08:53 +0000 (-0700) Subject: PGBackend: add PGTransaction X-Git-Tag: v0.78~286^2~39 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c60185c01a2fcbd49b60f7d861dcb6d3d5ed985d;p=ceph.git PGBackend: add PGTransaction Signed-off-by: Samuel Just --- diff --git a/src/osd/PGBackend.h b/src/osd/PGBackend.h index 07496898b5d4..5ccb5b7dca93 100644 --- a/src/osd/PGBackend.h +++ b/src/osd/PGBackend.h @@ -213,6 +213,120 @@ virtual ~PGBackend() {} + /** + * Client IO Interface + */ + class PGTransaction { + public: + /// Write + virtual void touch( + const hobject_t &hoid ///< [in] obj to touch + ) = 0; + virtual void stash( + const hobject_t &hoid, ///< [in] obj to remove + version_t former_version ///< [in] former object version + ) = 0; + virtual void remove( + const hobject_t &hoid ///< [in] obj to remove + ) = 0; + virtual void setattrs( + const hobject_t &hoid, ///< [in] object to write + map &attrs ///< [in] attrs, may be cleared + ) = 0; + virtual void setattr( + const hobject_t &hoid, ///< [in] object to write + const string &attrname, ///< [in] attr to write + bufferlist &bl ///< [in] val to write, may be claimed + ) = 0; + virtual void rmattr( + const hobject_t &hoid, ///< [in] object to write + const string &attrname ///< [in] attr to remove + ) = 0; + virtual void clone( + const hobject_t &from, + const hobject_t &to + ) = 0; + virtual void rename( + const hobject_t &from, + const hobject_t &to + ) = 0; + + /// Optional, not supported on ec-pool + virtual void write( + const hobject_t &hoid, ///< [in] object to write + uint64_t off, ///< [in] off at which to write + uint64_t len, ///< [in] len to write from bl + bufferlist &bl ///< [in] bl to write will be claimed to len + ) { assert(0); } + virtual void omap_setkeys( + const hobject_t &hoid, ///< [in] object to write + map &keys ///< [in] omap keys, may be cleared + ) { assert(0); } + virtual void omap_rmkeys( + const hobject_t &hoid, ///< [in] object to write + set &keys ///< [in] omap keys, may be cleared + ) { assert(0); } + virtual void omap_clear( + const hobject_t &hoid ///< [in] object to clear omap + ) { assert(0); } + virtual void omap_setheader( + const hobject_t &hoid, ///< [in] object to write + bufferlist &header ///< [in] header + ) { assert(0); } + virtual void clone_range( + const hobject_t &from, ///< [in] from + const hobject_t &to, ///< [in] to + uint64_t fromoff, ///< [in] offset + uint64_t len, ///< [in] len + uint64_t tooff ///< [in] offset + ) { assert(0); } + virtual void truncate( + const hobject_t &hoid, + uint64_t off + ) { assert(0); } + virtual void zero( + const hobject_t &hoid, + uint64_t off, + uint64_t len + ) { assert(0); } + + /// Supported on all backends + + /// off must be the current object size + virtual void append( + const hobject_t &hoid, ///< [in] object to write + uint64_t off, ///< [in] off at which to write + uint64_t len, ///< [in] len to write from bl + bufferlist &bl ///< [in] bl to write will be claimed to len + ) { write(hoid, off, len, bl); } + + /// to_append *must* have come from the same PGBackend (same concrete type) + virtual void append( + PGTransaction *to_append ///< [in] trans to append, to_append is cleared + ) = 0; + virtual void nop() = 0; + virtual bool empty() const = 0; + virtual uint64_t get_bytes_written() const = 0; + virtual ~PGTransaction() {} + }; + /// Get implementation specific empty transaction + virtual PGTransaction *get_transaction() = 0; + + /// execute implementation specific transaction + virtual void submit_transaction( + const hobject_t &hoid, ///< [in] object + const eversion_t &at_version, ///< [in] version + PGTransaction *t, ///< [in] trans to execute + const eversion_t &trim_to, ///< [in] trim log to here + vector &log_entries, ///< [in] log entries for t + Context *on_local_applied_sync, ///< [in] called when applied locally + Context *on_all_applied, ///< [in] called when all acked + Context *on_all_commit, ///< [in] called when all commit + tid_t tid, ///< [in] tid + osd_reqid_t reqid, ///< [in] reqid + OpRequestRef op ///< [in] op + ) = 0; + /// List objects in collection virtual int objects_list_partial( const hobject_t &begin,