@@ -476,6 +476,78 @@ namespace ceph {
476476 virtual int decode_concat (const std::map<int , bufferlist> &chunks,
477477 bufferlist *decoded) = 0;
478478
479+ using plugin_flags = uint64_t ;
480+
481+ /* *
482+ * Return a set of flags indicating which EC optimizations are supported
483+ * by the plugin.
484+ *
485+ * @return logical OR of the supported performance optimizations
486+ */
487+ virtual plugin_flags get_supported_optimizations () const = 0;
488+ enum {
489+ /* Partial read optimization assumes that the erasure code is systematic
490+ * and that concatenating the data chunks in the order returned by
491+ * get_chunk_mapping will create the data encoded for a stripe. The
492+ * optimization permits small reads to read data directly from the data
493+ * chunks without calling decode.
494+ */
495+ FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION = 1 <<0 ,
496+ /* Partial write optimization assumes that a write to less than one
497+ * chunk only needs to read this fragment from each data chunk in the
498+ * stripe and can then use encode to create the corresponding coding
499+ * fragments.
500+ */
501+ FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION = 1 <<1 ,
502+ /* Zero input zero output optimization means the erasure code has the
503+ * property that if all the data chunks are zero then the coding parity
504+ * chunks will also be zero.
505+ */
506+ FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION = 1 <<2 ,
507+ /* Zero padding optimization permits the encode and decode methods to
508+ * be called with buffers that are zero length. The plugin treats
509+ * this as a chunk of all zeros.
510+ */
511+ FLAG_EC_PLUGIN_ZERO_PADDING_OPTIMIZATION = 1 <<3 ,
512+ /* Parity delta write optimization means the encode_delta and
513+ * apply_delta methods are supported which allows small updates
514+ * to a stripe to be applied using a read-modify-write of a
515+ * data chunk and the coding parity chunks.
516+ */
517+ FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION = 1 <<4 ,
518+ };
519+ static const char *get_optimization_flag_name (const plugin_flags flag) {
520+ switch (flag) {
521+ case FLAG_EC_PLUGIN_PARTIAL_READ_OPTIMIZATION: return " partialread" ;
522+ case FLAG_EC_PLUGIN_PARTIAL_WRITE_OPTIMIZATION: return " partialwrite" ;
523+ case FLAG_EC_PLUGIN_ZERO_INPUT_ZERO_OUTPUT_OPTIMIZATION: return " zeroinout" ;
524+ case FLAG_EC_PLUGIN_ZERO_PADDING_OPTIMIZATION: return " zeropadding" ;
525+ case FLAG_EC_PLUGIN_PARITY_DELTA_OPTIMIZATION: return " paritydelta" ;
526+ default : return " ???" ;
527+ }
528+ }
529+ static std::string get_optimization_flags_string (plugin_flags flags) {
530+ std::string s;
531+ for (unsigned n=0 ; flags && n<64 ; ++n) {
532+ if (flags & (1ull << n)) {
533+ if (s.length ())
534+ s += " ," ;
535+ s += get_optimization_flag_name (1ull << n);
536+ flags -= flags & (1ull << n);
537+ }
538+ }
539+ return s;
540+ }
541+
542+ /* *
543+ * Return a string describing which EC optimizations are supported
544+ * by the plugin.
545+ *
546+ * @return string of optimizations supported by the plugin
547+ */
548+ virtual std::string get_optimizations_flags_string () const {
549+ return get_optimization_flags_string (get_supported_optimizations ());
550+ }
479551 };
480552
481553 typedef std::shared_ptr<ErasureCodeInterface> ErasureCodeInterfaceRef;
0 commit comments