Browse Source

Rename osd_read_stripe_t to osd_rmw_stripe_t

blocking-uring-test
Vitaliy Filippov 2 years ago
parent
commit
88e56a564f
  1. 2
      osd.h
  2. 10
      osd_primary.cpp
  3. 18
      osd_rmw.cpp
  4. 14
      osd_rmw.h
  5. 2
      osd_rmw_test.cpp

2
osd.h

@ -157,7 +157,7 @@ struct osd_client_t
};
struct osd_primary_read_t;
struct osd_read_stripe_t;
struct osd_rmw_stripe_t;
class osd_t
{

10
osd_primary.cpp

@ -17,7 +17,7 @@ struct osd_primary_op_data_t
uint64_t target_ver;
int n_subops = 0, done = 0, errors = 0;
int degraded = 0, pg_size, pg_minsize;
osd_read_stripe_t *stripes;
osd_rmw_stripe_t *stripes;
osd_op_t *subops = NULL;
void *rmw_buf = NULL;
@ -63,11 +63,11 @@ bool osd_t::prepare_primary_rw(osd_op_t *cur_op)
return false;
}
osd_primary_op_data_t *op_data = (osd_primary_op_data_t*)calloc(
sizeof(osd_primary_op_data_t) + sizeof(osd_read_stripe_t) * pgs[pg_num].pg_size, 1
sizeof(osd_primary_op_data_t) + sizeof(osd_rmw_stripe_t) * pgs[pg_num].pg_size, 1
);
op_data->pg_num = pg_num;
op_data->oid = oid;
op_data->stripes = ((osd_read_stripe_t*)(op_data+1));
op_data->stripes = ((osd_rmw_stripe_t*)(op_data+1));
cur_op->op_data = op_data;
split_stripes(pgs[pg_num].pg_minsize, bs_block_size, (uint32_t)(cur_op->req.rw.offset - oid.stripe), cur_op->req.rw.len, op_data->stripes);
return true;
@ -140,7 +140,7 @@ void osd_t::handle_primary_read_subop(osd_op_t *cur_op, int ok)
{
// Reconstruct missing stripes
// FIXME: Always EC(k+1) by now. Add different coding schemes
osd_read_stripe_t *stripes = op_data->stripes;
osd_rmw_stripe_t *stripes = op_data->stripes;
for (int role = 0; role < op_data->pg_minsize; role++)
{
if (stripes[role].read_end != 0 && stripes[role].missing)
@ -165,7 +165,7 @@ void osd_t::handle_primary_read_subop(osd_op_t *cur_op, int ok)
void osd_t::submit_read_subops(int read_pg_size, const uint64_t* osd_set, osd_op_t *cur_op)
{
osd_primary_op_data_t *op_data = (osd_primary_op_data_t*)cur_op->op_data;
osd_read_stripe_t *stripes = op_data->stripes;
osd_rmw_stripe_t *stripes = op_data->stripes;
// Allocate subops
int n_subops = 0, force_read = -1;
for (int role = 0; role < read_pg_size; role++)

18
osd_rmw.cpp

@ -3,7 +3,7 @@
#include "xor.h"
#include "osd_rmw.h"
static inline void extend_read(uint32_t start, uint32_t end, osd_read_stripe_t & stripe)
static inline void extend_read(uint32_t start, uint32_t end, osd_rmw_stripe_t & stripe)
{
if (stripe.read_end == 0)
{
@ -19,7 +19,7 @@ static inline void extend_read(uint32_t start, uint32_t end, osd_read_stripe_t &
}
}
static inline void cover_read(uint32_t start, uint32_t end, osd_read_stripe_t & stripe)
static inline void cover_read(uint32_t start, uint32_t end, osd_rmw_stripe_t & stripe)
{
// Subtract <to> write request from <from> request
if (start >= stripe.req_start &&
@ -53,7 +53,7 @@ static inline void cover_read(uint32_t start, uint32_t end, osd_read_stripe_t &
}
}
void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start, uint32_t end, osd_read_stripe_t *stripes)
void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start, uint32_t end, osd_rmw_stripe_t *stripes)
{
end = start+end;
for (int role = 0; role < pg_minsize; role++)
@ -66,7 +66,7 @@ void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start,
}
}
void reconstruct_stripe(osd_read_stripe_t *stripes, int pg_size, int role)
void reconstruct_stripe(osd_rmw_stripe_t *stripes, int pg_size, int role)
{
int prev = -2;
for (int other = 0; other < pg_size; other++)
@ -98,7 +98,7 @@ void reconstruct_stripe(osd_read_stripe_t *stripes, int pg_size, int role)
}
}
int extend_missing_stripes(osd_read_stripe_t *stripes, osd_num_t *osd_set, int minsize, int size)
int extend_missing_stripes(osd_rmw_stripe_t *stripes, osd_num_t *osd_set, int minsize, int size)
{
for (int role = 0; role < minsize; role++)
{
@ -131,7 +131,7 @@ int extend_missing_stripes(osd_read_stripe_t *stripes, osd_num_t *osd_set, int m
return 0;
}
void* alloc_read_buffer(osd_read_stripe_t *stripes, int read_pg_size, uint64_t add_size)
void* alloc_read_buffer(osd_rmw_stripe_t *stripes, int read_pg_size, uint64_t add_size)
{
// Calculate buffer size
uint64_t buf_size = add_size;
@ -156,7 +156,7 @@ void* alloc_read_buffer(osd_read_stripe_t *stripes, int read_pg_size, uint64_t a
return buf;
}
void* calc_rmw_reads(void *write_buf, osd_read_stripe_t *stripes, uint64_t *osd_set, uint64_t pg_size, uint64_t pg_minsize, uint64_t pg_cursize)
void* calc_rmw_reads(void *write_buf, osd_rmw_stripe_t *stripes, uint64_t *osd_set, uint64_t pg_size, uint64_t pg_minsize, uint64_t pg_cursize)
{
// Generic parity modification (read-modify-write) algorithm
// Reconstruct -> Read -> Calc parity -> Write
@ -238,7 +238,7 @@ void* calc_rmw_reads(void *write_buf, osd_read_stripe_t *stripes, uint64_t *osd_
return rmw_buf;
}
static void get_old_new_buffers(osd_read_stripe_t & stripe, uint32_t wr_start, uint32_t wr_end, buf_len_t *bufs, int & nbufs)
static void get_old_new_buffers(osd_rmw_stripe_t & stripe, uint32_t wr_start, uint32_t wr_end, buf_len_t *bufs, int & nbufs)
{
uint32_t ns = 0, ne = 0, os = 0, oe = 0;
if (stripe.req_end > wr_start &&
@ -319,7 +319,7 @@ static void xor_multiple_buffers(buf_len_t *xor1, int n1, buf_len_t *xor2, int n
}
}
void calc_rmw_parity(osd_read_stripe_t *stripes, int pg_size)
void calc_rmw_parity(osd_rmw_stripe_t *stripes, int pg_size)
{
if (stripes[pg_size-1].missing)
{

14
osd_rmw.h

@ -14,7 +14,7 @@ struct buf_len_t
uint64_t len;
};
struct osd_read_stripe_t
struct osd_rmw_stripe_t
{
void *read_buf, *write_buf;
uint32_t req_start, req_end;
@ -23,14 +23,14 @@ struct osd_read_stripe_t
bool missing;
};
void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start, uint32_t len, osd_read_stripe_t *stripes);
void split_stripes(uint64_t pg_minsize, uint32_t bs_block_size, uint32_t start, uint32_t len, osd_rmw_stripe_t *stripes);
void reconstruct_stripe(osd_read_stripe_t *stripes, int pg_size, int role);
void reconstruct_stripe(osd_rmw_stripe_t *stripes, int pg_size, int role);
int extend_missing_stripes(osd_read_stripe_t *stripes, osd_num_t *osd_set, int minsize, int size);
int extend_missing_stripes(osd_rmw_stripe_t *stripes, osd_num_t *osd_set, int minsize, int size);
void* alloc_read_buffer(osd_read_stripe_t *stripes, int read_pg_size, uint64_t add_size);
void* alloc_read_buffer(osd_rmw_stripe_t *stripes, int read_pg_size, uint64_t add_size);
void* calc_rmw_reads(void *write_buf, osd_read_stripe_t *stripes, uint64_t *osd_set, uint64_t pg_size, uint64_t pg_minsize, uint64_t pg_cursize);
void* calc_rmw_reads(void *write_buf, osd_rmw_stripe_t *stripes, uint64_t *osd_set, uint64_t pg_size, uint64_t pg_minsize, uint64_t pg_cursize);
void calc_rmw_parity(osd_read_stripe_t *stripes, int pg_size);
void calc_rmw_parity(osd_rmw_stripe_t *stripes, int pg_size);

2
osd_rmw_test.cpp

@ -12,7 +12,7 @@
int main(int narg, char *args[])
{
osd_num_t osd_set[3] = { 1, 0, 3 };
osd_read_stripe_t stripes[3] = { 0 };
osd_rmw_stripe_t stripes[3] = { 0 };
// Test 1
split_stripes(2, 128*1024, 128*1024-4096, 8192, stripes);
assert(stripes[0].req_start == 128*1024-4096 && stripes[0].req_end == 128*1024);

Loading…
Cancel
Save