Skip to content

Commit f1351ea

Browse files
committed
ec: rename object_size -> stripe_width in get_chunk_size()
`object_size` was misleading in my perception; it suggested to me that the chunking happens on objects, not their stripes. `stripe_width` corresponds with the naming in the ctor of `ECBackend`. Signed-off-by: Radosław Zarzyński <[email protected]>
1 parent 45e4495 commit f1351ea

File tree

11 files changed

+24
-24
lines changed

11 files changed

+24
-24
lines changed

src/erasure-code/ErasureCodeInterface.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,21 +261,21 @@ namespace ceph {
261261
/**
262262
* Return the size (in bytes) of a single chunk created by a call
263263
* to the **decode** method. The returned size multiplied by
264-
* **get_chunk_count()** is greater or equal to **object_size**.
264+
* **get_chunk_count()** is greater or equal to **stripe_width**.
265265
*
266266
* If the object size is properly aligned, the chunk size is
267-
* **object_size / get_chunk_count()**. However, if
268-
* **object_size** is not a multiple of **get_chunk_count** or if
267+
* **stripe_width / get_chunk_count()**. However, if
268+
* **stripe_width** is not a multiple of **get_chunk_count** or if
269269
* the implementation imposes additional alignment constraints,
270270
* the chunk size may be larger.
271271
*
272272
* The byte found at offset **B** of the original object is mapped
273273
* to chunk **B / get_chunk_size()** at offset **B % get_chunk_size()**.
274274
*
275-
* @param [in] object_size the number of bytes of the object to **encode()**
275+
* @param [in] stripe_width the number of bytes of the object to **encode()**
276276
* @return the size (in bytes) of a single chunk created by **encode()**
277277
*/
278-
virtual unsigned int get_chunk_size(unsigned int object_size) const = 0;
278+
virtual unsigned int get_chunk_size(unsigned int stripe_width) const = 0;
279279

280280
/**
281281
* Compute the smallest subset of **available** chunks that needs

src/erasure-code/clay/ErasureCodeClay.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ int ErasureCodeClay::init(ErasureCodeProfile &profile,
8787

8888
}
8989

90-
unsigned int ErasureCodeClay::get_chunk_size(unsigned int object_size) const
90+
unsigned int ErasureCodeClay::get_chunk_size(unsigned int stripe_width) const
9191
{
9292
unsigned int alignment_scalar_code = pft.erasure_code->get_chunk_size(1);
9393
unsigned int alignment = sub_chunk_no * k * alignment_scalar_code;
9494

95-
return round_up_to(object_size, alignment) / k;
95+
return round_up_to(stripe_width, alignment) / k;
9696
}
9797

9898
int ErasureCodeClay::minimum_to_decode(const set<int> &want_to_read,

src/erasure-code/clay/ErasureCodeClay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ErasureCodeClay final : public ceph::ErasureCode {
5858
return sub_chunk_no;
5959
}
6060

61-
unsigned int get_chunk_size(unsigned int object_size) const override;
61+
unsigned int get_chunk_size(unsigned int stripe_width) const override;
6262

6363
int minimum_to_decode(const std::set<int> &want_to_read,
6464
const std::set<int> &available,

src/erasure-code/isa/ErasureCodeIsa.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ ErasureCodeIsa::init(ErasureCodeProfile &profile, ostream *ss)
6363
// -----------------------------------------------------------------------------
6464

6565
unsigned int
66-
ErasureCodeIsa::get_chunk_size(unsigned int object_size) const
66+
ErasureCodeIsa::get_chunk_size(unsigned int stripe_width) const
6767
{
6868
unsigned alignment = get_alignment();
69-
unsigned chunk_size = ( object_size + k - 1 ) / k;
69+
unsigned chunk_size = (stripe_width + k - 1) / k;
7070
dout(20) << "get_chunk_size: chunk_size " << chunk_size
7171
<< " must be modulo " << alignment << dendl;
7272
unsigned modulo = chunk_size % alignment;

src/erasure-code/isa/ErasureCodeIsa.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class ErasureCodeIsa : public ceph::ErasureCode {
7171
return k;
7272
}
7373

74-
unsigned int get_chunk_size(unsigned int object_size) const override;
74+
unsigned int get_chunk_size(unsigned int stripe_width) const override;
7575

7676
int encode_chunks(const std::set<int> &want_to_encode,
7777
std::map<int, ceph::buffer::list> *encoded) override;

src/erasure-code/jerasure/ErasureCodeJerasure.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ int ErasureCodeJerasure::parse(ErasureCodeProfile &profile,
7777
return err;
7878
}
7979

80-
unsigned int ErasureCodeJerasure::get_chunk_size(unsigned int object_size) const
80+
unsigned int ErasureCodeJerasure::get_chunk_size(unsigned int stripe_width) const
8181
{
8282
unsigned alignment = get_alignment();
8383
if (per_chunk_alignment) {
84-
unsigned chunk_size = object_size / k;
85-
if (object_size % k)
84+
unsigned chunk_size = stripe_width / k;
85+
if (stripe_width % k)
8686
chunk_size++;
8787
dout(20) << "get_chunk_size: chunk_size " << chunk_size
8888
<< " must be modulo " << alignment << dendl;
@@ -95,8 +95,8 @@ unsigned int ErasureCodeJerasure::get_chunk_size(unsigned int object_size) const
9595
}
9696
return chunk_size;
9797
} else {
98-
unsigned tail = object_size % alignment;
99-
unsigned padded_length = object_size + ( tail ? ( alignment - tail ) : 0 );
98+
unsigned tail = stripe_width % alignment;
99+
unsigned padded_length = stripe_width + (tail ? (alignment - tail) : 0);
100100
ceph_assert(padded_length % k == 0);
101101
return padded_length / k;
102102
}

src/erasure-code/jerasure/ErasureCodeJerasure.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ErasureCodeJerasure : public ceph::ErasureCode {
5454
return k;
5555
}
5656

57-
unsigned int get_chunk_size(unsigned int object_size) const override;
57+
unsigned int get_chunk_size(unsigned int stripe_width) const override;
5858

5959
int encode_chunks(const std::set<int> &want_to_encode,
6060
std::map<int, ceph::buffer::list> *encoded) override;

src/erasure-code/lrc/ErasureCodeLrc.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,9 @@ set<int> ErasureCodeLrc::get_erasures(const set<int> &want,
555555
return result;
556556
}
557557

558-
unsigned int ErasureCodeLrc::get_chunk_size(unsigned int object_size) const
558+
unsigned int ErasureCodeLrc::get_chunk_size(unsigned int stripe_width) const
559559
{
560-
return layers.front().erasure_code->get_chunk_size(object_size);
560+
return layers.front().erasure_code->get_chunk_size(stripe_width);
561561
}
562562

563563
void p(const set<int> &s) { cerr << s; } // for gdb

src/erasure-code/lrc/ErasureCodeLrc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ErasureCodeLrc final : public ceph::ErasureCode {
103103
return data_chunk_count;
104104
}
105105

106-
unsigned int get_chunk_size(unsigned int object_size) const override;
106+
unsigned int get_chunk_size(unsigned int stripe_width) const override;
107107

108108
int encode_chunks(const std::set<int> &want_to_encode,
109109
std::map<int, ceph::buffer::list> *encoded) override;

src/erasure-code/shec/ErasureCodeShec.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ int ErasureCodeShec::init(ErasureCodeProfile &profile,
5858
return ErasureCode::init(profile, ss);
5959
}
6060

61-
unsigned int ErasureCodeShec::get_chunk_size(unsigned int object_size) const
61+
unsigned int ErasureCodeShec::get_chunk_size(unsigned int stripe_width) const
6262
{
6363
unsigned alignment = get_alignment();
64-
unsigned tail = object_size % alignment;
65-
unsigned padded_length = object_size + ( tail ? ( alignment - tail ) : 0 );
64+
unsigned tail = stripe_width % alignment;
65+
unsigned padded_length = stripe_width + (tail ? (alignment - tail) : 0);
6666

6767
ceph_assert(padded_length % k == 0);
6868
return padded_length / k;

0 commit comments

Comments
 (0)