Skip to content

Commit d9f4ee4

Browse files
committed
osd: Create EC Direct Read flag and pass through to EC.
This is in preperation for supporting sparse and sync reads in EC. Such ops will only be supported for "balance reads". Signed-off-by: Alex Ainscow <[email protected]>
1 parent 454ea7c commit d9f4ee4

File tree

9 files changed

+26
-8
lines changed

9 files changed

+26
-8
lines changed

src/crimson/osd/pg.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,8 +1615,7 @@ bool PG::can_discard_op(const MOSDOp& m) const {
16151615
return true;
16161616
}
16171617

1618-
if ((m.get_flags() & (CEPH_OSD_FLAG_BALANCE_READS |
1619-
CEPH_OSD_FLAG_LOCALIZE_READS))
1618+
if ((m.get_flags() & CEPH_OSD_FLAGS_DIRECT_READ)
16201619
&& !is_primary()
16211620
&& (m.get_map_epoch() <
16221621
peering_state.get_info().history.same_interval_since))

src/include/rados.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,12 @@ enum {
481481
CEPH_OSD_FLAG_IGNORE_REDIRECT = 0x2000000, /* ignore redirection */
482482
CEPH_OSD_FLAG_RETURNVEC = 0x4000000, /* allow overall result >= 0, and return >= 0 and buffer for each op in opvec */
483483
CEPH_OSD_FLAG_SUPPORTSPOOLEIO = 0x8000000, /* client understands pool EIO flag */
484+
CEPH_OSD_FLAG_EC_DIRECT_READ = 0x10000000, /* Erasure code doing a partial read direct to OSD. */
484485
};
485486

487+
// Indicates an IO which is direct-to-OSD and may not be on the primary.
488+
#define CEPH_OSD_FLAGS_DIRECT_READ (CEPH_OSD_FLAG_BALANCE_READS | CEPH_OSD_FLAG_LOCALIZE_READS | CEPH_OSD_FLAG_EC_DIRECT_READ)
489+
486490
enum {
487491
CEPH_OSD_OP_FLAG_EXCL = 0x1, /* EXCL object create */
488492
CEPH_OSD_OP_FLAG_FAILOK = 0x2, /* continue despite failure */

src/osd/OpRequest.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ struct OpRequest : public TrackedOp {
4848
bool need_skip_handle_cache() const { return op_info.need_skip_handle_cache(); }
4949
bool need_skip_promote() const { return op_info.need_skip_promote(); }
5050
bool allows_returnvec() const { return op_info.allows_returnvec(); }
51+
bool ec_direct_read() const { return op_info.ec_direct_read(); }
52+
void set_ec_direct_read() { return op_info.set_ec_direct_read(); }
5153

5254
std::vector<OpInfo::ClassInfo> classes() const {
5355
return op_info.get_classes();

src/osd/PG.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1940,8 +1940,7 @@ bool PG::can_discard_op(OpRequestRef& op)
19401940
return true;
19411941
}
19421942

1943-
if ((m->get_flags() & (CEPH_OSD_FLAG_BALANCE_READS |
1944-
CEPH_OSD_FLAG_LOCALIZE_READS)) &&
1943+
if ((m->get_flags() & CEPH_OSD_FLAGS_DIRECT_READ) &&
19451944
!is_primary() &&
19461945
m->get_map_epoch() < info.history.same_interval_since) {
19471946
// Note: the Objecter will resend on interval change without the primary

src/osd/PrimaryLogPG.cc

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2047,16 +2047,22 @@ void PrimaryLogPG::do_op(OpRequestRef& op)
20472047
}
20482048

20492049
// check for op with rwordered and rebalance or localize reads
2050-
if ((m->has_flag(CEPH_OSD_FLAG_BALANCE_READS) || m->has_flag(CEPH_OSD_FLAG_LOCALIZE_READS)) &&
2051-
op->rwordered()) {
2050+
if (m->has_flag(CEPH_OSD_FLAGS_DIRECT_READ) && op->rwordered()) {
20522051
dout(4) << __func__ << ": rebelance or localized reads with rwordered not allowed "
20532052
<< *m << dendl;
20542053
osd->reply_op_error(op, -EINVAL);
20552054
return;
20562055
}
20572056

2058-
if ((m->get_flags() & (CEPH_OSD_FLAG_BALANCE_READS |
2059-
CEPH_OSD_FLAG_LOCALIZE_READS)) &&
2057+
if (m->get_flags() & CEPH_OSD_FLAG_EC_DIRECT_READ) {
2058+
if (is_primary() || is_nonprimary()) {
2059+
op->set_ec_direct_read();
2060+
} else {
2061+
osd->handle_misdirected_op(this, op);
2062+
return;
2063+
}
2064+
} else if ((m->get_flags() & (CEPH_OSD_FLAG_BALANCE_READS |
2065+
CEPH_OSD_FLAG_LOCALIZE_READS)) &&
20602066
op->may_read() &&
20612067
!(op->may_write() || op->may_cache())) {
20622068
// balanced reads; any replica will do

src/osd/osd_op_util.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ bool OpInfo::need_skip_promote() const {
5252
bool OpInfo::allows_returnvec() const {
5353
return check_rmw(CEPH_OSD_RMW_FLAG_RETURNVEC);
5454
}
55+
bool OpInfo::ec_direct_read() const {
56+
return check_rmw(CEPH_OSD_RMW_FLAG_EC_DIRECT_READ);
57+
}
5558
/**
5659
* may_read_data()
5760
*
@@ -79,6 +82,7 @@ void OpInfo::set_skip_promote() { set_rmw_flags(CEPH_OSD_RMW_FLAG_SKIP_PROMOTE);
7982
void OpInfo::set_force_rwordered() { set_rmw_flags(CEPH_OSD_RMW_FLAG_RWORDERED); }
8083
void OpInfo::set_returnvec() { set_rmw_flags(CEPH_OSD_RMW_FLAG_RETURNVEC); }
8184
void OpInfo::set_read_data() { set_rmw_flags(CEPH_OSD_RMW_FLAG_READ_DATA); }
85+
void OpInfo::set_ec_direct_read() { set_rmw_flags(CEPH_OSD_RMW_FLAG_EC_DIRECT_READ); }
8286

8387

8488
int OpInfo::set_from_op(

src/osd/osd_op_util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class OpInfo {
5959
bool need_skip_handle_cache() const;
6060
bool need_skip_promote() const;
6161
bool allows_returnvec() const;
62+
bool ec_direct_read() const;
6263

6364
void set_read();
6465
void set_write();
@@ -72,6 +73,7 @@ class OpInfo {
7273
void set_force_rwordered();
7374
void set_returnvec();
7475
void set_read_data();
76+
void set_ec_direct_read();
7577

7678
int set_from_op(
7779
const MOSDOp *m,

src/osd/osd_types.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const char *ceph_osd_flag_name(unsigned flag)
103103
case CEPH_OSD_FLAG_IGNORE_REDIRECT: return "ignore_redirect";
104104
case CEPH_OSD_FLAG_RETURNVEC: return "returnvec";
105105
case CEPH_OSD_FLAG_SUPPORTSPOOLEIO: return "supports_pool_eio";
106+
case CEPH_OSD_FLAG_EC_DIRECT_READ: return "ec_direct_read";
106107
default: return "???";
107108
}
108109
}

src/osd/osd_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ enum {
383383
CEPH_OSD_RMW_FLAG_RWORDERED = (1 << 10),
384384
CEPH_OSD_RMW_FLAG_RETURNVEC = (1 << 11),
385385
CEPH_OSD_RMW_FLAG_READ_DATA = (1 << 12),
386+
CEPH_OSD_RMW_FLAG_EC_DIRECT_READ = (1 << 13),
386387
};
387388

388389

0 commit comments

Comments
 (0)