Motr  M0
meta.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2016-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
23 
30 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_DIX
31 #include "lib/trace.h"
32 #include "lib/memory.h"
33 #include "lib/vec.h"
34 #include "pool/pool.h"
35 #include "fid/fid.h"
36 #include "dix/imask.h"
37 #include "dix/layout.h"
38 #include "dix/client.h"
39 #include "dix/client_internal.h"
40 #include "dix/meta.h"
41 
42 #define DFID(x, y) M0_FID_TINIT('x', (x), (y))
43 
44 M0_INTERNAL const struct m0_fid m0_dix_root_fid = DFID(0,1);
45 M0_INTERNAL const struct m0_fid m0_dix_layout_fid = DFID(0,2);
46 M0_INTERNAL const struct m0_fid m0_dix_ldescr_fid = DFID(0,3);
47 
48 enum {
53 };
54 
55 static struct m0_dix_cli *meta_req_cli(const struct m0_dix_meta_req *req)
56 {
57  return req->dmr_req.dr_cli;
58 }
59 
60 static int dix_mreq_rc(const struct m0_dix_req *req)
61 {
62  return M0_RC(m0_dix_req_rc(req));
63 }
64 
71 static int dix_root_add(struct m0_bufvec *keys,
72  struct m0_bufvec *vals,
73  uint32_t idx,
74  const char *iname,
75  const struct m0_fid *ifid,
76  const struct m0_dix_ldesc *idesc)
77 {
78  m0_bcount_t klen;
79  struct m0_bufvec val;
80  int rc;
81 
82  M0_PRE(keys != NULL);
83  M0_PRE(iname != NULL);
84  M0_PRE((vals != NULL) == (ifid != NULL));
85  M0_PRE((vals != NULL) == (idesc != NULL));
86  klen = strlen(iname);
87  if (vals != NULL) {
88  rc = m0_dix__meta_val_enc(ifid, idesc, 1, &val);
89  if (rc != 0)
90  return M0_ERR(rc);
91  }
92  keys->ov_buf[idx] = m0_alloc(klen);
93  if (keys->ov_buf[idx] == NULL) {
94  if (vals != NULL)
96  return M0_ERR(-ENOMEM);
97  }
98  if (vals != NULL) {
99  vals->ov_vec.v_count[idx] = val.ov_vec.v_count[0];
100  vals->ov_buf[idx] = val.ov_buf[0];
101  m0_free(val.ov_buf);
102  m0_free(val.ov_vec.v_count);
103  }
104  keys->ov_vec.v_count[idx] = klen;
105  memcpy(keys->ov_buf[idx], iname, klen);
106  return 0;
107 }
108 
109 static int dix_root_put(struct m0_dix_cli *cli,
110  struct m0_sm_group *grp,
111  const struct m0_dix_ldesc *dld_layout,
112  const struct m0_dix_ldesc *dld_ldescr)
113 {
114  struct m0_dix_req dreq;
115  struct m0_dix root = {};
116  struct m0_bufvec keys = {};
117  struct m0_bufvec vals;
118  int rc;
119 
120  rc = m0_dix__root_set(cli, &root) ?:
121  m0_bufvec_empty_alloc(&keys, 2) ?:
122  m0_bufvec_empty_alloc(&vals, 2);
123  if (rc != 0) {
124  m0_dix_fini(&root);
125  m0_bufvec_free(&keys);
126  return M0_ERR(rc);
127  }
128  rc = dix_root_add(&keys, &vals, 0, "layout", &m0_dix_layout_fid,
129  dld_layout) ?:
130  dix_root_add(&keys, &vals, 1, "layout-descr", &m0_dix_ldescr_fid,
131  dld_ldescr);
132  if (rc != 0)
133  goto bvecs_free;
134  m0_dix_mreq_init(&dreq, cli, grp);
135  m0_dix_req_lock(&dreq);
136  rc = m0_dix_put(&dreq, &root, &keys, &vals, NULL, 0) ?:
138  M0_TIME_NEVER) ?:
139  dix_mreq_rc(&dreq);
140  m0_dix_req_unlock(&dreq);
141  m0_dix_req_fini_lock(&dreq);
142 bvecs_free:
143  m0_dix_fini(&root);
144  m0_bufvec_free(&keys);
145  m0_bufvec_free(&vals);
146  return M0_RC(rc);
147 }
148 
149 static void dix_meta_indices_fini(struct m0_dix *meta)
150 {
151  int i;
152 
153  for (i = 0; i < DIX_META_INDICES_NR; i++)
154  m0_dix_fini(&meta[i]);
155 }
156 
158  struct m0_dix_cli *cli,
159  struct m0_dix_ldesc *dld_layout,
160  struct m0_dix_ldesc *dld_ldescr)
161 {
162  int rc;
163 
165  if (rc != 0)
166  return M0_ERR(rc);
167 
168  if (dld_layout != NULL) {
169  indices[1].dd_fid = m0_dix_layout_fid;
171  dld_layout);
172  }
173  else {
175  }
176  if (rc != 0)
177  goto err;
178 
179  if (dld_ldescr != NULL) {
180  indices[2].dd_fid = m0_dix_ldescr_fid;
182  dld_ldescr);
183  }
184  else {
186  }
187  if (rc != 0)
188  goto err;
189  M0_ASSERT(rc == 0);
190  return 0;
191 err:
193  return M0_ERR(rc);
194 }
195 
196 static int dix_meta_create(struct m0_dix_cli *cli,
197  struct m0_sm_group *grp,
198  struct m0_dix_ldesc *dld_layout,
199  struct m0_dix_ldesc *dld_ldescr)
200 {
201  struct m0_dix_req dreq;
202  struct m0_dix dix[DIX_META_INDICES_NR] = {};
203  int rc;
204 
205  M0_ENTRY();
206  rc = dix_meta_indices_init(dix, cli, dld_layout, dld_ldescr);
207  if (rc != 0)
208  return M0_ERR(rc);
209  m0_dix_mreq_init(&dreq, cli, grp);
210  m0_dix_req_lock(&dreq);
211  rc = m0_dix_create(&dreq, dix, ARRAY_SIZE(dix), NULL, 0) ?:
213  M0_TIME_NEVER) ?:
214  dix_mreq_rc(&dreq);
215  m0_dix_req_unlock(&dreq);
216  m0_dix_req_fini_lock(&dreq);
218  return M0_RC(rc);
219 }
220 
221 static int dix_meta_delete(struct m0_dix_cli *cli,
222  struct m0_sm_group *grp,
223  struct m0_dix_ldesc *dld_layout,
224  struct m0_dix_ldesc *dld_ldescr)
225 {
226  struct m0_dix_req dreq;
227  struct m0_dix dix[DIX_META_INDICES_NR] = {};
228  int rc;
229 
230  M0_ENTRY();
231  rc = dix_meta_indices_init(dix, cli, dld_layout, dld_ldescr);
232  if (rc != 0)
233  return M0_ERR(rc);
234  m0_dix_mreq_init(&dreq, cli, grp);
235  m0_dix_req_lock(&dreq);
236  rc = m0_dix_delete(&dreq, dix, ARRAY_SIZE(dix), NULL, 0) ?:
238  M0_TIME_NEVER) ?:
239  dix_mreq_rc(&dreq);
240  m0_dix_req_unlock(&dreq);
241  m0_dix_req_fini_lock(&dreq);
243  return M0_RC(rc);
244 }
245 
246 static bool dix_meta_op_done_cb(struct m0_clink *clink)
247 {
249  struct m0_sm *sm = M0_AMB(sm, clink->cl_chan, sm_chan);
250 
251  M0_PRE(req != NULL);
252  if (M0_IN(sm->sm_state, (DIXREQ_FINAL, DIXREQ_FAILURE))) {
254  m0_chan_broadcast_lock(&req->dmr_chan);
255  }
256  return true;
257 }
258 
259 M0_INTERNAL void m0_dix_meta_req_init(struct m0_dix_meta_req *req,
260  struct m0_dix_cli *cli,
261  struct m0_sm_group *grp)
262 {
263  M0_ENTRY();
264  M0_SET0(req);
265  m0_dix_mreq_init(&req->dmr_req, cli, grp);
266  m0_mutex_init(&req->dmr_wait_mutex);
267  m0_chan_init(&req->dmr_chan, &req->dmr_wait_mutex);
268  m0_clink_init(&req->dmr_clink, dix_meta_op_done_cb);
269  M0_LEAVE();
270 }
271 
273 {
274  M0_ENTRY();
275  M0_PRE(req != NULL);
276  m0_chan_fini_lock(&req->dmr_chan);
277  m0_mutex_fini(&req->dmr_wait_mutex);
278  m0_dix_req_fini(&req->dmr_req);
279  m0_bufvec_free(&req->dmr_keys);
280  m0_bufvec_free(&req->dmr_vals);
281  m0_clink_fini(&req->dmr_clink);
282  M0_LEAVE();
283 }
284 
285 M0_INTERNAL void m0_dix_meta_req_fini(struct m0_dix_meta_req *req)
286 {
287  M0_PRE(m0_dix_req_is_locked(&req->dmr_req));
289 }
290 
292 {
293  M0_PRE(!m0_dix_req_is_locked(&req->dmr_req));
294  m0_dix_req_lock(&req->dmr_req);
296  m0_dix_req_unlock(&req->dmr_req);
297 }
298 
299 M0_INTERNAL void m0_dix_meta_lock(struct m0_dix_meta_req *req)
300 {
301  m0_dix_req_lock(&req->dmr_req);
302 }
303 
304 M0_INTERNAL void m0_dix_meta_unlock(struct m0_dix_meta_req *req)
305 {
306  m0_dix_req_unlock(&req->dmr_req);
307 }
308 
309 M0_INTERNAL int m0_dix_meta_generic_rc(const struct m0_dix_meta_req *req)
310 {
311  return M0_RC(m0_dix_generic_rc(&req->dmr_req));
312 }
313 
314 M0_INTERNAL int m0_dix_meta_item_rc(const struct m0_dix_meta_req *req,
315  uint64_t idx)
316 {
318  return m0_dix_item_rc(&req->dmr_req, idx);
319 }
320 
321 M0_INTERNAL int m0_dix_meta_req_nr(const struct m0_dix_meta_req *req)
322 {
323  return m0_dix_req_nr(&req->dmr_req);
324 }
325 
326 M0_INTERNAL int m0_dix_meta_create(struct m0_dix_cli *cli,
327  struct m0_sm_group *grp,
328  struct m0_dix_ldesc *dld_layout,
329  struct m0_dix_ldesc *dld_ldescr)
330 {
331  int rc;
332 
334  rc = dix_meta_create(cli, grp, dld_layout, dld_ldescr);
335  if (rc == 0) {
336  rc = dix_root_put(cli, grp, dld_layout, dld_ldescr);
337  if (rc != 0)
338  dix_meta_delete(cli, grp, dld_layout, dld_ldescr);
339  }
340  return M0_RC(rc);
341 }
342 
343 M0_INTERNAL int m0_dix_meta_check(struct m0_dix_cli *cli,
344  struct m0_sm_group *grp,
345  bool *result)
346 {
347  struct m0_dix_req dreq;
348  struct m0_dix indices[DIX_META_INDICES_NR] = {};
349  int rc;
350 
351  M0_ENTRY();
352  M0_PRE(result != NULL);
354  /*
355  * If DIX client is ready, then existence of 'layout' and 'layout-descr'
356  * indices was checked during client startup.
357  */
359  if (rc != 0)
360  return M0_ERR(rc);
361  m0_dix_mreq_init(&dreq, cli, grp);
362  m0_dix_req_lock(&dreq);
365  M0_TIME_NEVER) ?:
366  dix_mreq_rc(&dreq);
367  if (rc == -ENOENT) {
368  rc = 0;
369  *result = false;
370  } else if (rc == 0) {
371  *result = true;
372  }
373  m0_dix_req_unlock(&dreq);
374  m0_dix_req_fini_lock(&dreq);
376  return M0_RC(rc);
377 }
378 
379 M0_INTERNAL int m0_dix_root_read(struct m0_dix_meta_req *req)
380 {
381  int rc;
382  struct m0_bufvec *keys = &req->dmr_keys;
383  struct m0_dix_cli *cli = req->dmr_req.dr_cli;
384  struct m0_dix root = {};
385 
386  M0_ENTRY();
387  M0_PRE(req != NULL);
388  M0_PRE(M0_IN(cli->dx_sm.sm_state, (DIXCLI_READY,
390  DIXCLI_STARTING)));
391  rc = m0_dix__root_set(cli, &root) ?:
392  m0_bufvec_empty_alloc(keys, 2);
393  if (rc != 0) {
394  m0_dix_fini(&root);
395  return M0_ERR(rc);
396  }
397  rc = dix_root_add(keys, NULL, 0, "layout", NULL, NULL) ?:
398  dix_root_add(keys, NULL, 1, "layout-descr", NULL, NULL);
399  if (rc != 0)
400  goto err;
401 
402  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
403  rc = m0_dix_get(&req->dmr_req, &root, &req->dmr_keys);
404  if (rc != 0) {
405  m0_clink_del(&req->dmr_clink);
406  goto err;
407  }
408  m0_dix_fini(&root);
409  return M0_RC(0);
410 err:
411  m0_dix_fini(&root);
412  m0_bufvec_free(keys);
413  return M0_ERR(rc);
414 }
415 
417  uint64_t idx,
418  const struct m0_fid *expected,
419  struct m0_dix_ldesc *out)
420 {
421  struct m0_bufvec vals;
422  struct m0_dix_get_reply rep;
423  struct m0_fid fid;
424  struct m0_dix_ldesc ldesc = {};
425  int rc;
426 
427  M0_PRE(m0_dix_generic_rc(&req->dmr_req) == 0);
428  m0_dix_get_rep(&req->dmr_req, idx, &rep);
429  if (rep.dgr_rc != 0)
430  return M0_ERR(rep.dgr_rc);
431  vals = M0_BUFVEC_INIT_BUF(&rep.dgr_val.b_addr, &rep.dgr_val.b_nob);
432  rc = m0_dix__meta_val_dec(&vals, &fid, &ldesc, 1);
433  if (rc == 0) {
434  if (!m0_fid_eq(&fid, expected))
435  rc = M0_ERR(-EPROTO);
436  else
437  rc = m0_dix_ldesc_copy(out, &ldesc);
438  m0_dix_ldesc_fini(&ldesc);
439  }
440  return M0_RC(rc);
441 }
442 
443 M0_INTERNAL int m0_dix_root_read_rep(struct m0_dix_meta_req *req,
444  struct m0_dix_ldesc *layout,
445  struct m0_dix_ldesc *ldescr)
446 {
447  int rc;
448 
449  M0_ENTRY();
450  /*
451  * Exactly two records are expected in reply: the one for 'layout' index
452  * and an another for 'layout-descr' index. The reply should contain
453  * records in exactly this order ('layout' index first).
454  */
455  if (m0_dix_req_nr(&req->dmr_req) != 2)
456  return M0_ERR(-EPROTO);
458  if (rc == 0) {
460  ldescr);
461  if (rc != 0)
462  m0_dix_ldesc_fini(layout);
463  }
464  return M0_RC(rc);
465 }
466 
467 M0_INTERNAL int m0_dix_meta_destroy(struct m0_dix_cli *cli,
468  struct m0_sm_group *grp)
469 {
470  int rc;
471 
472  M0_ENTRY();
474  rc = dix_meta_delete(cli, grp, NULL, NULL);
475  return M0_RC(rc);
476 }
477 
478 M0_INTERNAL int m0_dix_ldescr_put(struct m0_dix_meta_req *req,
479  const uint64_t *lid,
480  const struct m0_dix_ldesc *ldesc,
481  uint32_t nr)
482 {
483  int rc;
484  struct m0_dix index = {};
485 
486  M0_ENTRY();
487  M0_PRE(req != NULL);
488  M0_PRE(ldesc != NULL);
489  M0_PRE(lid != NULL);
491  m0_dix__ldesc_vals_enc(lid, ldesc, nr,
492  &req->dmr_keys, &req->dmr_vals);
493  if (rc != 0) {
494  m0_dix_fini(&index);
495  return M0_ERR(rc);
496  }
497  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
498  rc = m0_dix_put(&req->dmr_req, &index, &req->dmr_keys, &req->dmr_vals,
499  NULL, 0);
500  if (rc != 0)
501  m0_clink_del(&req->dmr_clink);
502  m0_dix_fini(&index);
503  return M0_RC(rc);
504 }
505 
506 M0_INTERNAL int m0_dix_ldescr_get(struct m0_dix_meta_req *req,
507  const uint64_t *lid,
508  uint32_t nr)
509 {
510  int rc;
511  struct m0_dix index = {};
512 
513  M0_ENTRY();
514  M0_PRE(req != NULL);
515  M0_PRE(lid != NULL);
517  m0_dix__ldesc_vals_enc(lid, NULL, nr, &req->dmr_keys, NULL);
518  if (rc != 0) {
519  m0_dix_fini(&index);
520  return M0_ERR(rc);
521  }
522  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
523  rc = m0_dix_get(&req->dmr_req, &index, &req->dmr_keys);
524  if (rc != 0)
525  m0_clink_del(&req->dmr_clink);
526  m0_dix_fini(&index);
527  return M0_RC(rc);
528 }
529 
530 M0_INTERNAL int m0_dix_ldescr_rep_get(struct m0_dix_meta_req *req,
531  uint64_t idx,
532  struct m0_dix_ldesc *ldesc)
533 {
534  int rc;
535  struct m0_dix_get_reply rep;
536  struct m0_bufvec vals;
537 
538  M0_ENTRY();
540  m0_dix_get_rep(&req->dmr_req, idx, &rep);
541  rc = rep.dgr_rc;
542  if (rc == 0) {
543  vals = M0_BUFVEC_INIT_BUF(&rep.dgr_val.b_addr,
544  &rep.dgr_val.b_nob);
545  rc = m0_dix__ldesc_vals_dec(NULL, &vals, NULL, ldesc, 1);
546  }
547  return M0_RC(rc);
548 }
549 
550 M0_INTERNAL int m0_dix_ldescr_del(struct m0_dix_meta_req *req,
551  const uint64_t *lid,
552  uint32_t nr)
553 {
554  int rc;
555  struct m0_dix index = {};
556 
557  M0_ENTRY();
558  M0_PRE(req != NULL);
559  M0_PRE(lid != NULL);
561  m0_dix__ldesc_vals_enc(lid, NULL, nr, &req->dmr_keys, NULL);
562  if (rc != 0) {
563  m0_dix_fini(&index);
564  return M0_ERR(rc);
565  }
566  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
567  rc = m0_dix_del(&req->dmr_req, &index, &req->dmr_keys, NULL, 0);
568  if (rc != 0)
569  m0_clink_del(&req->dmr_clink);
570  m0_dix_fini(&index);
571  return M0_RC(rc);
572 }
573 
574 M0_INTERNAL int m0_dix_layout_put(struct m0_dix_meta_req *req,
575  const struct m0_fid *fid,
576  const struct m0_dix_layout *dlay,
577  uint32_t nr,
578  uint32_t flags)
579 {
580  int rc;
581  struct m0_dix index = {};
582 
583  M0_ENTRY();
584  M0_PRE(req != NULL);
585  M0_PRE(fid != NULL);
586  M0_PRE(dlay != NULL);
589  &req->dmr_keys, &req->dmr_vals);
590  if (rc != 0) {
591  m0_dix_fini(&index);
592  return M0_ERR(rc);
593  }
594  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
595  rc = m0_dix_put(&req->dmr_req, &index, &req->dmr_keys, &req->dmr_vals,
596  NULL, flags);
597  if (rc != 0)
598  m0_clink_del(&req->dmr_clink);
599  m0_dix_fini(&index);
600  return M0_RC(rc);
601 }
602 
603 M0_INTERNAL int m0_dix_layout_del(struct m0_dix_meta_req *req,
604  const struct m0_fid *fid,
605  uint32_t nr)
606 {
607  int rc;
608  struct m0_dix index = {};
609 
610  M0_ENTRY();
611  M0_PRE(req != NULL);
613  m0_dix__layout_vals_enc(fid, NULL, nr, &req->dmr_keys, NULL);
614  if (rc != 0) {
615  m0_dix_fini(&index);
616  return M0_ERR(rc);
617  }
618  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
619  rc = m0_dix_del(&req->dmr_req, &index, &req->dmr_keys, NULL, 0);
620  if (rc != 0)
621  m0_clink_del(&req->dmr_clink);
622  m0_dix_fini(&index);
623  return M0_RC(rc);
624 }
625 
626 M0_INTERNAL int m0_dix_layout_get(struct m0_dix_meta_req *req,
627  const struct m0_fid *fid,
628  uint32_t nr)
629 {
630  int rc;
631  struct m0_dix index = {};
632 
633  M0_ENTRY();
634  M0_PRE(req != NULL);
635  M0_PRE(fid != NULL);
637  m0_dix__layout_vals_enc(fid, NULL, nr, &req->dmr_keys, NULL);
638  if (rc != 0) {
639  m0_dix_fini(&index);
640  return M0_ERR(rc);
641  }
642  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
643  rc = m0_dix_get(&req->dmr_req, &index, &req->dmr_keys);
644  if (rc != 0)
645  m0_clink_del(&req->dmr_clink);
646  m0_dix_fini(&index);
647  return M0_RC(rc);
648 }
649 
650 M0_INTERNAL int m0_dix_layout_rep_get(struct m0_dix_meta_req *req,
651  uint64_t idx,
652  struct m0_dix_layout *dlay)
653 {
654  int rc;
655  struct m0_dix_get_reply rep;
656  struct m0_bufvec vals;
657 
658  M0_ENTRY();
659  m0_dix_get_rep(&req->dmr_req, idx, &rep);
660  rc = rep.dgr_rc;
661  if (rc == 0 && dlay != NULL) {
662  vals = M0_BUFVEC_INIT_BUF(&rep.dgr_val.b_addr,
663  &rep.dgr_val.b_nob);
664  rc = m0_dix__layout_vals_dec(NULL, &vals, NULL, dlay, 1);
665  }
666  return M0_RC(rc);
667 }
668 
669 M0_INTERNAL int m0_dix_index_list(struct m0_dix_meta_req *req,
670  const struct m0_fid *start_fid,
671  uint32_t indices_nr)
672 {
673  int rc;
674  struct m0_bufvec *keys = &req->dmr_keys;
675  uint32_t keys_nr = indices_nr;
676  struct m0_dix index = {};
677 
678  M0_ENTRY();
679  M0_PRE(req != NULL);
680  M0_PRE(start_fid != NULL);
681  M0_PRE(indices_nr != 0);
683  m0_dix__layout_vals_enc(start_fid, NULL, 1, keys, NULL);
684  if (rc != 0) {
685  m0_dix_fini(&index);
686  return M0_ERR(rc);
687  }
688 
689  m0_clink_add(&req->dmr_req.dr_sm.sm_chan, &req->dmr_clink);
690  rc = m0_dix_next(&req->dmr_req, &index, &req->dmr_keys, &keys_nr, 0);
691  if (rc != 0) {
692  m0_clink_del(&req->dmr_clink);
693  m0_bufvec_free(keys);
694  }
695  m0_dix_fini(&index);
696  return M0_RC(rc);
697 }
698 
700 {
701  return m0_dix_next_rep_nr(&req->dmr_req, 0);
702 }
703 
704 M0_INTERNAL int m0_dix_index_list_rep(struct m0_dix_meta_req *req,
705  uint32_t idx,
706  struct m0_fid *fid)
707 {
708  int rc;
709  struct m0_bufvec index;
710  struct m0_dix_next_reply rep;
711 
712  M0_ENTRY();
713  m0_dix_next_rep(&req->dmr_req, 0, idx, &rep);
714  index = M0_BUFVEC_INIT_BUF(&rep.dnr_key.b_addr,
715  &rep.dnr_key.b_nob);
717  return M0_RC(rc);
718 }
719 #undef DFID
720 #undef M0_TRACE_SUBSYSTEM
721 
724 /*
725  * Local variables:
726  * c-indentation-style: "K&R"
727  * c-basic-offset: 8
728  * tab-width: 8
729  * fill-column: 80
730  * scroll-step: 1
731  * End:
732  */
733 /*
734  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
735  */
#define M0_BUFVEC_INIT_BUF(addr_ptr, count_ptr)
Definition: vec.h:165
M0_INTERNAL int m0_dix_layout_put(struct m0_dix_meta_req *req, const struct m0_fid *fid, const struct m0_dix_layout *dlay, uint32_t nr, uint32_t flags)
Definition: meta.c:574
static m0_bindex_t indices[ZEROVEC_UT_SEGS_NR]
Definition: zerovec.c:38
static size_t nr
Definition: dump.c:1505
M0_INTERNAL int m0_dix_layout_get(struct m0_dix_meta_req *req, const struct m0_fid *fid, uint32_t nr)
Definition: meta.c:626
#define M0_PRE(cond)
M0_INTERNAL int m0_dix__layout_set(const struct m0_dix_cli *cli, struct m0_dix *out)
Definition: client.c:295
M0_INTERNAL void m0_dix_get_rep(const struct m0_dix_req *req, uint64_t idx, struct m0_dix_get_reply *rep)
Definition: req.c:2378
M0_INTERNAL void m0_chan_broadcast_lock(struct m0_chan *chan)
Definition: chan.c:178
static int dix_meta_delete(struct m0_dix_cli *cli, struct m0_sm_group *grp, struct m0_dix_ldesc *dld_layout, struct m0_dix_ldesc *dld_ldescr)
Definition: meta.c:221
int const char const void size_t int flags
Definition: dir.c:328
M0_INTERNAL int m0_dix_meta_create(struct m0_dix_cli *cli, struct m0_sm_group *grp, struct m0_dix_ldesc *dld_layout, struct m0_dix_ldesc *dld_ldescr)
Definition: meta.c:326
#define NULL
Definition: misc.h:38
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
Definition: chan.c:201
M0_INTERNAL void m0_clink_del(struct m0_clink *link)
Definition: chan.c:267
M0_INTERNAL int m0_dix__root_set(const struct m0_dix_cli *cli, struct m0_dix *out)
Definition: client.c:288
Definition: idx_mock.c:52
M0_INTERNAL int m0_dix_desc_set(struct m0_dix *dix, const struct m0_dix_ldesc *desc)
Definition: req.c:2596
const m0_time_t M0_TIME_NEVER
Definition: time.c:108
static struct io_request req
Definition: file.c:100
M0_INTERNAL int m0_dix_root_read(struct m0_dix_meta_req *req)
Definition: meta.c:379
static struct m0_sm_group * grp
Definition: bytecount.c:38
M0_LEAVE()
M0_INTERNAL const struct m0_fid m0_dix_layout_fid
Definition: meta.c:45
M0_INTERNAL int m0_dix_ldescr_rep_get(struct m0_dix_meta_req *req, uint64_t idx, struct m0_dix_ldesc *ldesc)
Definition: meta.c:530
static int dix_layout_from_read_rep(struct m0_dix_meta_req *req, uint64_t idx, const struct m0_fid *expected, struct m0_dix_ldesc *out)
Definition: meta.c:416
struct m0_vec ov_vec
Definition: vec.h:147
M0_INTERNAL void m0_dix_mreq_init(struct m0_dix_req *req, struct m0_dix_cli *cli, struct m0_sm_group *grp)
Definition: req.c:221
M0_INTERNAL int m0_dix_delete(struct m0_dix_req *req, const struct m0_dix *indices, uint64_t indices_nr, struct m0_dtx *dtx, uint32_t flags)
Definition: req.c:1190
M0_INTERNAL void m0_dix_meta_req_init(struct m0_dix_meta_req *req, struct m0_dix_cli *cli, struct m0_sm_group *grp)
Definition: meta.c:259
M0_INTERNAL int m0_dix_req_rc(const struct m0_dix_req *req)
Definition: req.c:2489
M0_INTERNAL int m0_dix_index_list_rep_nr(struct m0_dix_meta_req *req)
Definition: meta.c:699
M0_INTERNAL int m0_dix_item_rc(const struct m0_dix_req *req, uint64_t idx)
Definition: req.c:2475
static int dix_mreq_rc(const struct m0_dix_req *req)
Definition: meta.c:60
M0_INTERNAL int m0_dix_root_read_rep(struct m0_dix_meta_req *req, struct m0_dix_ldesc *layout, struct m0_dix_ldesc *ldescr)
Definition: meta.c:443
#define M0_BITS(...)
Definition: misc.h:236
uint64_t m0_bcount_t
Definition: types.h:77
#define M0_SET0(obj)
Definition: misc.h:64
#define DFID(x, y)
Definition: meta.c:42
struct m0_fop_getxattr_rep * rep
Definition: dir.c:455
static int dix_root_put(struct m0_dix_cli *cli, struct m0_sm_group *grp, const struct m0_dix_ldesc *dld_layout, const struct m0_dix_ldesc *dld_ldescr)
Definition: meta.c:109
void ** ov_buf
Definition: vec.h:149
M0_INTERNAL void m0_dix_req_fini(struct m0_dix_req *req)
Definition: req.c:2553
M0_INTERNAL int m0_dix_ldesc_copy(struct m0_dix_ldesc *dst, const struct m0_dix_ldesc *src)
Definition: layout.c:189
M0_INTERNAL int m0_dix__layout_vals_dec(const struct m0_bufvec *keys, const struct m0_bufvec *vals, struct m0_fid *out_fid, struct m0_dix_layout *out_dlay, uint32_t nr)
Definition: encdec.c:157
struct m0_fid fid
Definition: di.c:46
return M0_RC(rc)
M0_INTERNAL uint64_t m0_dix_req_nr(const struct m0_dix_req *req)
Definition: req.c:2504
#define M0_ENTRY(...)
Definition: trace.h:170
M0_INTERNAL void m0_bufvec_free(struct m0_bufvec *bufvec)
Definition: vec.c:395
static int expected
Definition: locality.c:102
int i
Definition: dir.c:1033
M0_INTERNAL int m0_dix__ldesc_vals_enc(const uint64_t *lid, const struct m0_dix_ldesc *ldesc, uint32_t nr, struct m0_bufvec *keys, struct m0_bufvec *vals)
Definition: encdec.c:195
M0_INTERNAL int m0_dix_layout_rep_get(struct m0_dix_meta_req *req, uint64_t idx, struct m0_dix_layout *dlay)
Definition: meta.c:650
M0_INTERNAL int m0_dix__layout_vals_enc(const struct m0_fid *fid, const struct m0_dix_layout *dlay, uint32_t nr, struct m0_bufvec *keys, struct m0_bufvec *vals)
Definition: encdec.c:111
M0_INTERNAL int m0_dix_next(struct m0_dix_req *req, const struct m0_dix *index, const struct m0_bufvec *start_keys, const uint32_t *recs_nr, uint32_t flags)
Definition: req.c:2415
struct m0_conf_root * root
Definition: note.c:50
return M0_ERR(-EOPNOTSUPP)
static void dix_meta_req_fini(struct m0_dix_meta_req *req)
Definition: meta.c:272
#define M0_AMB(obj, ptr, field)
Definition: misc.h:320
M0_INTERNAL void m0_chan_init(struct m0_chan *chan, struct m0_mutex *ch_guard)
Definition: chan.c:96
#define M0_ASSERT(cond)
M0_INTERNAL int m0_dix_get(struct m0_dix_req *req, const struct m0_dix *index, const struct m0_bufvec *keys)
Definition: req.c:2357
static int dix_root_add(struct m0_bufvec *keys, struct m0_bufvec *vals, uint32_t idx, const char *iname, const struct m0_fid *ifid, const struct m0_dix_ldesc *idesc)
Definition: meta.c:71
M0_INTERNAL int m0_dix_ldescr_get(struct m0_dix_meta_req *req, const uint64_t *lid, uint32_t nr)
Definition: meta.c:506
M0_INTERNAL int m0_dix_meta_item_rc(const struct m0_dix_meta_req *req, uint64_t idx)
Definition: meta.c:314
M0_INTERNAL void m0_dix_req_lock(struct m0_dix_req *req)
Definition: req.c:184
M0_INTERNAL int m0_dix_req_wait(struct m0_dix_req *req, uint64_t states, m0_time_t to)
Definition: req.c:201
M0_INTERNAL int m0_dix_meta_check(struct m0_dix_cli *cli, struct m0_sm_group *grp, bool *result)
Definition: meta.c:343
M0_INTERNAL void m0_dix_meta_unlock(struct m0_dix_meta_req *req)
Definition: meta.c:304
void * m0_alloc(size_t size)
Definition: memory.c:126
M0_INTERNAL void m0_dix_meta_req_fini(struct m0_dix_meta_req *req)
Definition: meta.c:285
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
Definition: mutex.c:35
M0_INTERNAL int m0_dix__ldescr_set(const struct m0_dix_cli *cli, struct m0_dix *out)
Definition: client.c:302
struct m0_sm dx_sm
Definition: client.h:183
M0_INTERNAL void m0_dix_req_fini_lock(struct m0_dix_req *req)
Definition: req.c:2577
static void dix_meta_indices_fini(struct m0_dix *meta)
Definition: meta.c:149
M0_INTERNAL int m0_dix__ldesc_vals_dec(const struct m0_bufvec *keys, const struct m0_bufvec *vals, uint64_t *out_lid, struct m0_dix_ldesc *out_ldesc, uint32_t nr)
Definition: encdec.c:234
m0_bcount_t * v_count
Definition: vec.h:53
static struct m0_clink clink[RDWR_REQUEST_MAX]
static bool dix_meta_op_done_cb(struct m0_clink *clink)
Definition: meta.c:246
M0_INTERNAL int m0_dix_create(struct m0_dix_req *req, const struct m0_dix *indices, uint32_t indices_nr, struct m0_dtx *dtx, uint32_t flags)
Definition: req.c:990
M0_INTERNAL int m0_dix_index_list(struct m0_dix_meta_req *req, const struct m0_fid *start_fid, uint32_t indices_nr)
Definition: meta.c:669
M0_INTERNAL int m0_dix_index_list_rep(struct m0_dix_meta_req *req, uint32_t idx, struct m0_fid *fid)
Definition: meta.c:704
M0_INTERNAL void m0_dix_ldesc_fini(struct m0_dix_ldesc *ld)
Definition: layout.c:197
M0_INTERNAL bool m0_fid_eq(const struct m0_fid *fid0, const struct m0_fid *fid1)
Definition: fid.c:164
M0_INTERNAL void m0_dix_meta_req_fini_lock(struct m0_dix_meta_req *req)
Definition: meta.c:291
M0_INTERNAL int m0_dix__meta_val_dec(const struct m0_bufvec *vals, struct m0_fid *out_fid, struct m0_dix_ldesc *out_dld, uint32_t nr)
Definition: encdec.c:74
M0_INTERNAL int m0_dix_meta_destroy(struct m0_dix_cli *cli, struct m0_sm_group *grp)
Definition: meta.c:467
Definition: fid.h:38
M0_INTERNAL const struct m0_fid m0_dix_ldescr_fid
Definition: meta.c:46
M0_INTERNAL int m0_dix_ldescr_put(struct m0_dix_meta_req *req, const uint64_t *lid, const struct m0_dix_ldesc *ldesc, uint32_t nr)
Definition: meta.c:478
struct m0_chan sm_chan
Definition: sm.h:331
M0_INTERNAL void m0_clink_add(struct m0_chan *chan, struct m0_clink *link)
Definition: chan.c:228
M0_INTERNAL int m0_dix_del(struct m0_dix_req *req, const struct m0_dix *index, const struct m0_bufvec *keys, struct m0_dtx *dtx, uint32_t flags)
Definition: req.c:2388
M0_INTERNAL int m0_dix_ldescr_del(struct m0_dix_meta_req *req, const uint64_t *lid, uint32_t nr)
Definition: meta.c:550
M0_INTERNAL int m0_dix_meta_generic_rc(const struct m0_dix_meta_req *req)
Definition: meta.c:309
Definition: sm.h:301
static struct m0_dix_cli * meta_req_cli(const struct m0_dix_meta_req *req)
Definition: meta.c:55
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
Definition: mutex.c:42
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
Definition: chan.c:208
M0_INTERNAL void m0_dix_req_unlock(struct m0_dix_req *req)
Definition: req.c:190
M0_INTERNAL int m0_dix_meta_req_nr(const struct m0_dix_meta_req *req)
Definition: meta.c:321
M0_INTERNAL int m0_dix_layout_del(struct m0_dix_meta_req *req, const struct m0_fid *fid, uint32_t nr)
Definition: meta.c:603
#define out(...)
Definition: gen.c:41
static int dix_meta_create(struct m0_dix_cli *cli, struct m0_sm_group *grp, struct m0_dix_ldesc *dld_layout, struct m0_dix_ldesc *dld_ldescr)
Definition: meta.c:196
M0_INTERNAL void m0_dix_next_rep(const struct m0_dix_req *req, uint64_t key_idx, uint64_t val_idx, struct m0_dix_next_reply *rep)
Definition: req.c:2449
M0_INTERNAL bool m0_dix_req_is_locked(const struct m0_dix_req *req)
Definition: req.c:196
M0_INTERNAL void m0_chan_fini_lock(struct m0_chan *chan)
Definition: chan.c:112
void m0_free(void *data)
Definition: memory.c:146
M0_INTERNAL uint32_t m0_dix_next_rep_nr(const struct m0_dix_req *req, uint64_t key_idx)
Definition: req.c:2468
uint32_t sm_state
Definition: sm.h:307
static int dix_meta_indices_init(struct m0_dix *indices, struct m0_dix_cli *cli, struct m0_dix_ldesc *dld_layout, struct m0_dix_ldesc *dld_ldescr)
Definition: meta.c:157
M0_INTERNAL const struct m0_fid m0_dix_root_fid
Definition: meta.c:44
static struct m0_fid ifid
Definition: service_ut.c:66
int32_t rc
Definition: trigger_fop.h:47
M0_INTERNAL void m0_dix_meta_lock(struct m0_dix_meta_req *req)
Definition: meta.c:299
#define ARRAY_SIZE(a)
Definition: misc.h:45
M0_INTERNAL int m0_dix_cctgs_lookup(struct m0_dix_req *req, const struct m0_dix *indices, uint32_t indices_nr)
Definition: req.c:1214
M0_INTERNAL int m0_dix_put(struct m0_dix_req *req, const struct m0_dix *index, const struct m0_bufvec *keys, const struct m0_bufvec *vals, struct m0_dtx *dtx, uint32_t flags)
Definition: req.c:2326
M0_INTERNAL void m0_dix_fini(struct m0_dix *dix)
Definition: req.c:2603
M0_INTERNAL int m0_dix__meta_val_enc(const struct m0_fid *fid, const struct m0_dix_ldesc *dld, uint32_t nr, struct m0_bufvec *vals)
Definition: encdec.c:48
struct m0_clink dmr_clink
Definition: meta.h:99
Definition: vec.h:145
Definition: req.h:110
M0_INTERNAL int m0_bufvec_empty_alloc(struct m0_bufvec *bufvec, uint32_t num_segs)
Definition: vec.c:213
M0_INTERNAL int m0_dix_generic_rc(const struct m0_dix_req *req)
Definition: req.c:2483