Skip to content
This repository was archived by the owner on May 3, 2024. It is now read-only.

Commit fc0f386

Browse files
committed
Add dix min_success to motr client interface
Signed-off-by: Tim Shaffer <[email protected]>
1 parent 2c7402b commit fc0f386

File tree

12 files changed

+51
-40
lines changed

12 files changed

+51
-40
lines changed

bindings/go/mio/mkv.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func (mkv *Mkv) doIdxOp(opcode uint32, key []byte, value []byte,
156156

157157
var rcI C.int32_t
158158
var op *C.struct_m0_op
159-
rc := C.m0_idx_op(mkv.idx, opcode, &k, vPtr, &rcI, flags, &op)
159+
rc := C.m0_idx_op(mkv.idx, opcode, &k, vPtr, &rcI, 1, flags, &op)
160160
if rc != 0 {
161161
return nil, fmt.Errorf("failed to init index op: %d", rc)
162162
}

hsm/m0hsm_api.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ static int get_next_extents(struct m0_idx *idx,
620620
ENTRY;
621621

622622
m0_idx_op(idx, M0_IC_NEXT,
623-
keys, vals, rc_list, flags, &ops[0]);
623+
keys, vals, rc_list, 1, flags, &ops[0]);
624624
m0_op_launch(ops, 1);
625625
rc = m0_op_wait(ops[0],
626626
M0_BITS(M0_OS_FAILED,
@@ -953,7 +953,7 @@ static int layer_extent_add(struct m0_uint128 subobjid,
953953

954954
ops[0] = NULL;
955955
m0_composite_layer_idx(subobjid, write, &idx);
956-
m0_idx_op(&idx, M0_IC_PUT, &keys, &vals, rcs,
956+
m0_idx_op(&idx, M0_IC_PUT, &keys, &vals, rcs, 1,
957957
overwrite ? M0_OIF_OVERWRITE : 0, &ops[0]);
958958
m0_op_launch(ops, 1);
959959
rc = m0_op_wait(ops[0],
@@ -1013,7 +1013,7 @@ static int layer_extent_del(struct m0_uint128 subobjid, off_t off, bool write)
10131013

10141014
ops[0] = NULL;
10151015
m0_composite_layer_idx(subobjid, write, &idx);
1016-
m0_idx_op(&idx, M0_IC_DEL, &keys, NULL, rcs, 0, &ops[0]);
1016+
m0_idx_op(&idx, M0_IC_DEL, &keys, NULL, rcs, 1, 0, &ops[0]);
10171017
m0_op_launch(ops, 1);
10181018
rc = m0_op_wait(ops[0],
10191019
M0_BITS(M0_OS_FAILED, M0_OS_STABLE),

motr/client.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1570,6 +1570,12 @@ void m0_idx_fini(struct m0_idx *idx);
15701570
*
15711571
* 'rcs' argument is mandatory for all operations except M0_IC_LOOKUP.
15721572
*
1573+
* Index operations are distributed across one or more CAS services to achieve
1574+
* the configured durability. The min_success argument specifies the
1575+
* minimum number of services that must successfully complete an operation
1576+
* for the operation as a whole to be considered successful. This should
1577+
* normally be set to (N+K)/2 + 1 to ensure consistency.
1578+
*
15731579
* For M0_CLOVIC_IC_PUT flags argument may be set.
15741580
* - 'flags' is a bit-mask of m0_op_idx_flags enum. M0_OIF_OVERWRITE and
15751581
* M0_OIF_SYNC_WAIT are supported for now.
@@ -1611,6 +1617,7 @@ int m0_idx_op(struct m0_idx *idx,
16111617
struct m0_bufvec *keys,
16121618
struct m0_bufvec *vals,
16131619
int32_t *rcs,
1620+
uint32_t min_success,
16141621
uint32_t flags,
16151622
struct m0_op **op);
16161623

motr/composite_layout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1348,7 +1348,7 @@ static int composite_layer_idx_next_query(struct m0_idx *idx,
13481348
int rc;
13491349
struct m0_op *ops[1] = {NULL};
13501350

1351-
m0_idx_op(idx, M0_IC_NEXT, keys, vals, rcs, flags,
1351+
m0_idx_op(idx, M0_IC_NEXT, keys, vals, rcs, 1, flags,
13521352
&ops[0]);
13531353
m0_op_launch(ops, 1);
13541354
rc = m0_op_wait(ops[0],

motr/examples/example2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ int index_put(struct m0_container *container, struct m0_uint128 *fid)
136136
}
137137

138138
m0_idx_init(&idx, &container->co_realm, fid);
139-
rc = m0_idx_op(&idx, M0_IC_PUT, &keys, &vals, rcs, 0, &ops[0]);
139+
rc = m0_idx_op(&idx, M0_IC_PUT, &keys, &vals, rcs, 1, 0, &ops[0]);
140140
if (rc == 0)
141141
rc = op_launch_wait_fini(&idx.in_entity, ops, NULL);
142142
for (i = 0; rc == 0 && i < KV_COUNT; i++) {
@@ -171,7 +171,7 @@ int index_get(struct m0_container *container, struct m0_uint128 *fid)
171171
}
172172

173173
m0_idx_init(&idx, &container->co_realm, fid);
174-
rc = m0_idx_op(&idx, M0_IC_GET, &keys, &vals, rcs, 0, &ops[0]);
174+
rc = m0_idx_op(&idx, M0_IC_GET, &keys, &vals, rcs, 1, 0, &ops[0]);
175175
if (rc == 0)
176176
rc = op_launch_wait_fini(&idx.in_entity, ops, NULL);
177177
for (i = 0; rc == 0 && i < KV_COUNT; i++) {

motr/idx.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static int idx_pool_version_get(struct m0_op_idx *oi)
164164
*/
165165
static int idx_op_init(struct m0_idx *idx, int opcode,
166166
struct m0_bufvec *keys, struct m0_bufvec *vals,
167-
int32_t *rcs, uint32_t flags,
167+
int32_t *rcs, uint32_t min_success, uint32_t flags,
168168
struct m0_op *op)
169169
{
170170
int rc;
@@ -180,6 +180,7 @@ static int idx_op_init(struct m0_idx *idx, int opcode,
180180

181181
M0_PRE(idx != NULL);
182182
M0_PRE(op != NULL);
183+
M0_PRE(min_success > 0);
183184

184185
/* Initialise the operation's generic part. */
185186
entity = &idx->in_entity;
@@ -205,6 +206,7 @@ static int idx_op_init(struct m0_idx *idx, int opcode,
205206
oi->oi_keys = keys;
206207
oi->oi_vals = vals;
207208
oi->oi_rcs = rcs;
209+
oi->oi_min_success = min_success;
208210
oi->oi_flags = flags;
209211

210212
locality = m0__locality_pick(oi_instance(oi));
@@ -557,6 +559,7 @@ int m0_idx_op(struct m0_idx *idx,
557559
struct m0_bufvec *keys,
558560
struct m0_bufvec *vals,
559561
int32_t *rcs,
562+
uint32_t min_success,
560563
uint32_t flags,
561564
struct m0_op **op)
562565
{
@@ -579,14 +582,15 @@ int m0_idx_op(struct m0_idx *idx,
579582
keys->ov_vec.v_count[i] ==
580583
sizeof(struct m0_uint128))));
581584
M0_PRE(op != NULL);
585+
M0_PRE(min_success > 0);
582586
M0_PRE(ergo(flags == M0_OIF_SYNC_WAIT,
583587
M0_IN(opcode, (M0_IC_PUT, M0_IC_DEL))));
584588

585589
rc = m0_op_get(op, sizeof(struct m0_op_idx));
586590
if (rc == 0) {
587591
M0_ASSERT(*op != NULL);
588-
rc = idx_op_init(idx, opcode, keys, vals, rcs, flags,
589-
*op);
592+
rc = idx_op_init(idx, opcode, keys, vals, rcs, min_success,
593+
flags, *op);
590594
}
591595

592596
return M0_RC(rc);
@@ -617,7 +621,7 @@ M0_INTERNAL int m0_idx_op_namei(struct m0_entity *entity,
617621
if (rc == 0) {
618622
M0_ASSERT(*op != NULL);
619623
idx = M0_AMB(idx, entity, in_entity);
620-
rc = idx_op_init(idx, opcode, NULL, NULL, NULL, 0,
624+
rc = idx_op_init(idx, opcode, NULL, NULL, NULL, 1, 0,
621625
*op);
622626
}
623627

motr/m0crate/crate_index.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ static int cr_execute_query(struct m0_fid *id,
10251025
FID_P(&idx.in_attr.idx_pver));
10261026
}
10271027

1028-
rc = m0_idx_op(&idx, op->m0_op, p->k, p->v, rcs, flags, &ops[0]);
1028+
rc = m0_idx_op(&idx, op->m0_op, p->k, p->v, rcs, 1, flags, &ops[0]);
10291029
if (rc != 0) {
10301030
crlog(CLL_ERROR, "Unable to init Client idx op: %s",
10311031
strerror(-rc));

motr/m0kv/index_op.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ int index_list(struct m0_realm *parent,
207207
return M0_RC(rc);
208208

209209
rc = m0_idx_op(&idx, M0_IC_LIST, keys, NULL,
210-
rcs, 0, &op);
210+
rcs, 1, 0, &op);
211211

212212
set_idx_flags(op);
213213

@@ -243,7 +243,7 @@ int index_lookup(struct m0_realm *parent,
243243
return M0_RC(rc);
244244

245245
rc = m0_idx_op(&idx, M0_IC_LOOKUP, NULL, NULL,
246-
NULL, 0, &op);
246+
NULL, 1, 0, &op);
247247

248248
set_idx_flags(op);
249249

@@ -277,7 +277,7 @@ static int index_op(struct m0_realm *parent,
277277
if (rc != 0)
278278
return M0_RC(rc);
279279

280-
rc = m0_idx_op(&idx, opcode, keys, vals, rcs,
280+
rc = m0_idx_op(&idx, opcode, keys, vals, rcs, 1,
281281
opcode == M0_IC_PUT ? M0_OIF_OVERWRITE : 0,
282282
&op);
283283

motr/st/api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ int st_idx_op(struct m0_idx *idx,
120120
{
121121
int rc;
122122

123-
rc = m0_idx_op(idx, opcode, keys, vals, rcs, flag, op);
123+
rc = m0_idx_op(idx, opcode, keys, vals, rcs, 1, flag, op);
124124
if (*op != NULL) st_mark_op(*op);
125125

126126
return rc;

motr/st/mt/mt_fom.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,19 +247,19 @@ static int st_common_tick(struct m0_fom *fom, void *data, int *phase,
247247
case REQ_PUT:
248248
rc = m0_idx_op(&idxs[ci % CMT_IDXS_NR],
249249
M0_IC_PUT,
250-
keys, vals, rcs, 0,
250+
keys, vals, rcs, 1, 0,
251251
&fctx->sfc_op);
252252
break;
253253
case REQ_DEL:
254254
rc = m0_idx_op(&idxs[ci % CMT_IDXS_NR],
255255
M0_IC_DEL,
256-
keys, NULL, rcs, 0,
256+
keys, NULL, rcs, 1, 0,
257257
&fctx->sfc_op);
258258
break;
259259
case REQ_GET:
260260
rc = m0_idx_op(&idxs[ci % CMT_IDXS_NR],
261261
M0_IC_GET,
262-
keys, vals, rcs, 0,
262+
keys, vals, rcs, 1, 0,
263263
&fctx->sfc_op);
264264
break;
265265
default:
@@ -423,7 +423,7 @@ void st_lsfid_inst(struct m0_client *cli,
423423
M0_ASSERT(rc == 0);
424424

425425
m0_idx_init(&idx0, &realm.co_realm, (struct m0_uint128 *)&ifid0);
426-
rc = m0_idx_op(&idx0, M0_IC_LIST, &keys, NULL, rcs, 0,
426+
rc = m0_idx_op(&idx0, M0_IC_LIST, &keys, NULL, rcs, 1, 0,
427427
&op);
428428
M0_ASSERT(rc == 0);
429429
m0_op_launch(&op, 1);
@@ -473,7 +473,7 @@ void st_lsfid_inst_cancel(struct m0_client *cli,
473473
m0_idx_init(&idx[i], &realm.co_realm,
474474
(struct m0_uint128 *)&ifid[i]);
475475
rc = m0_idx_op(&idx[i], M0_IC_LIST, &keys[i],
476-
NULL, rcs, 0,
476+
NULL, rcs, 1, 0,
477477
&op[i]);
478478
M0_ASSERT(rc == 0);
479479
}

0 commit comments

Comments
 (0)