]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
erasure-code: Add minimum granularity interface to EC plugins
authorJamie Pryde <jamiepry@uk.ibm.com>
Tue, 26 Nov 2024 10:00:25 +0000 (10:00 +0000)
committerJon Bailey <jonathan.bailey1@ibm.com>
Wed, 5 Mar 2025 16:15:01 +0000 (16:15 +0000)
Add get_minimum_granularity() function to the EC plugin interface,
which returns the minimum size in bytes that can be used for partial writes.
This is based on the minimum size of coding chunk update
that the particular technique supports.

Signed-off-by: Jamie Pryde <jamiepry@uk.ibm.com>
Signed-off-by: Jon Bailey <jonathan.bailey1@ibm.com>
src/erasure-code/ErasureCodeInterface.h
src/erasure-code/clay/ErasureCodeClay.cc
src/erasure-code/clay/ErasureCodeClay.h
src/erasure-code/isa/ErasureCodeIsa.h
src/erasure-code/jerasure/ErasureCodeJerasure.h
src/erasure-code/lrc/ErasureCodeLrc.cc
src/erasure-code/lrc/ErasureCodeLrc.h
src/erasure-code/shec/ErasureCodeShec.h
src/test/erasure-code/ErasureCodeExample.h
src/test/erasure-code/TestErasureCode.cc

index 673136a701ba5d571581c8d67e784381a9623a6f..bd7c2c44302f5c1d0cca375da2de5c130405817f 100644 (file)
@@ -327,6 +327,15 @@ namespace ceph {
                                             const std::map<int, int> &available,
                                             std::set<int> *minimum) = 0;
 
+    /**
+     * Return the minimum number of bytes that the plugin and technique
+     * support for partial writes. This is the minimum size of update
+     * to coding chunks that the particular technique supports.
+     *
+     * @return minimum number of bytes.
+     */
+    virtual size_t get_minimum_granularity() = 0;
+
     /**
      * Encode the content of **in** and store the result in
      * **encoded**. All buffers pointed to by **encoded** have the
index ab74542a3ea73d1237561c9a73315efc001b351f..265756352c18ba7984e2144e9a0502980afdf724 100644 (file)
@@ -95,6 +95,11 @@ unsigned int ErasureCodeClay::get_chunk_size(unsigned int stripe_width) const
   return round_up_to(stripe_width, alignment) / k;
 }
 
+size_t ErasureCodeClay::get_minimum_granularity()
+{
+  return mds.erasure_code->get_minimum_granularity();
+}
+
 int ErasureCodeClay::minimum_to_decode(const set<int> &want_to_read,
                                       const set<int> &available,
                                       map<int, vector<pair<int, int>>> *minimum)
index 3697df721ef355a04bdaaa37b776c0bd143faa9b..f847d090e4f0da3ad425023468ee26acbc51c2a9 100644 (file)
@@ -60,6 +60,8 @@ public:
 
   unsigned int get_chunk_size(unsigned int stripe_width) const override;
 
+  size_t get_minimum_granularity() override;
+
   int minimum_to_decode(const std::set<int> &want_to_read,
                        const std::set<int> &available,
                        std::map<int, std::vector<std::pair<int, int>>> *minimum) override;
index 4d338c8b418fbe85750ed7a47373fd6a43f95d33..d38b996a84a5c716e53f21fc93041bf844f4118e 100644 (file)
@@ -152,6 +152,11 @@ public:
 
   unsigned get_alignment() const override;
 
+  size_t get_minimum_granularity() override
+  {
+    return 1;
+  }
+
   void prepare() override;
 
  private:
index 75d5c3c1a56ccd17cc2a3e3c6162f14988c62241..48e98747ad65ff03638550440e8b3bc1bc81de08 100644 (file)
@@ -103,6 +103,10 @@ public:
                                char **coding,
                                int blocksize) override;
   unsigned get_alignment() const override;
+  size_t get_minimum_granularity() override
+  {
+    return 1;
+  }
   void prepare() override;
 private:
   int parse(ceph::ErasureCodeProfile& profile, std::ostream *ss) override;
@@ -133,6 +137,10 @@ public:
                                char **coding,
                                int blocksize) override;
   unsigned get_alignment() const override;
+  size_t get_minimum_granularity() override
+  {
+    return 1;
+  }
   void prepare() override;
 private:
   int parse(ceph::ErasureCodeProfile& profile, std::ostream *ss) override;
@@ -166,6 +174,10 @@ public:
                                char **coding,
                                int blocksize) override;
   unsigned get_alignment() const override;
+  size_t get_minimum_granularity() override
+  {
+    return w * packetsize;
+  }
   void prepare_schedule(int *matrix);
 private:
   int parse(ceph::ErasureCodeProfile& profile, std::ostream *ss) override;
@@ -215,6 +227,10 @@ public:
                                char **coding,
                                int blocksize) override;
   unsigned get_alignment() const override;
+  size_t get_minimum_granularity() override
+  {
+    return w * packetsize;
+  }
   virtual bool check_k(std::ostream *ss) const;
   virtual bool check_w(std::ostream *ss) const;
   virtual bool check_packetsize_set(std::ostream *ss) const;
index b05df07c6145f6daa7f31a3f41a4aa63ae3cadb0..dc62c450da44d15abf454f1ed879aa1e2e0a4076 100644 (file)
@@ -559,6 +559,11 @@ unsigned int ErasureCodeLrc::get_chunk_size(unsigned int stripe_width) const
   return layers.front().erasure_code->get_chunk_size(stripe_width);
 }
 
+size_t ErasureCodeLrc::get_minimum_granularity()
+{
+  return layers.front().erasure_code->get_minimum_granularity();
+}
+
 void p(const set<int> &s) { cerr << s; } // for gdb
 
 int ErasureCodeLrc::_minimum_to_decode(const set<int> &want_to_read,
index d5e3a07e847a1392fc1b5a579a5d91a0c3b6d3d4..7a41014a27ccd18e8b80aa095619116dcfe9a355 100644 (file)
@@ -105,6 +105,8 @@ public:
 
   unsigned int get_chunk_size(unsigned int stripe_width) const override;
 
+  size_t get_minimum_granularity() override;
+
   int encode_chunks(const std::set<int> &want_to_encode,
                    std::map<int, ceph::buffer::list> *encoded) override;
 
index 51e20359a4184a628cfd2ed9053dce0974cbd46f..1440b4d29377181d0bd4760fca09bfc1ea394752 100644 (file)
@@ -139,6 +139,10 @@ public:
                          char **coding,
                          int blocksize) override;
   unsigned get_alignment() const override;
+  size_t get_minimum_granularity() override
+  {
+    return 1;
+  }
   void prepare() override;
 private:
   int parse(const ceph::ErasureCodeProfile &profile) override;
index 4226361c47eb7633a46c39907e33d189464b5824..c036199c5d9b0883952609dc98e2d1db68460a46 100644 (file)
@@ -88,6 +88,10 @@ public:
     return ( object_size / DATA_CHUNKS ) + 1;
   }
 
+  size_t get_minimum_granularity() override {
+    return 1;
+  }
+
   int encode(const std::set<int> &want_to_encode,
                      const bufferlist &in,
                      std::map<int, bufferlist> *encoded) override {
index 05b95ded4029881fae675bbae8b86c8f976e8af4..367a1574a89db12c3344f42703df4a0e8f78fd20 100644 (file)
@@ -44,6 +44,7 @@ public:
   unsigned int get_chunk_size(unsigned int object_size) const override {
     return chunk_size;
   }
+  size_t get_minimum_granularity() override { return 1; }
   int encode_chunks(const set<int> &want_to_encode,
                            map<int, bufferlist> *encoded) override {
     encode_chunks_encoded = *encoded;