Motr  M0
idx_mock.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 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 #include "motr/client.h"
24 #include "motr/client_internal.h"
25 #include "motr/addb.h"
26 #include "motr/idx.h"
27 
28 #include "lib/errno.h" /* ENOMEM */
29 
30 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_CLIENT
31 #include "lib/trace.h"
32 
33 #ifndef __KERNEL__
34 
35 #include <stdio.h>
36 #include <unistd.h>
37 #include <string.h>
38 #include <sys/types.h>
39 #include <sys/stat.h>
40 #include <fcntl.h>
41 
42 static char *idx_store_path = NULL;
43 
47 struct key {
48  int k_len;
49  void *k_data;
50 };
51 
52 struct val {
53  int v_len;
54  void *v_data;
55 };
56 
57 struct kv_pair {
58  uint64_t p_magic;
59  struct m0_hlink p_link;
60 
61  struct key p_key;
62  struct val p_val;
63 };
64 
65 static uint64_t kv_hash(const struct m0_htable *htable, const struct key *key)
66 {
67  int i;
68  uint64_t h = 0;
69 
70  for(i = 0; i < key->k_len; i++)
71  h += ((char *)key->k_data)[i];
72  h = h % htable->h_bucket_nr;
73 
74  return h;
75 }
76 
77 static int kv_hash_key_eq(const struct key *k1, const struct key *k2)
78 {
79  if (k1->k_len != k2->k_len)
80  return M0_RC(0);
81 
82  if (k1->k_data == NULL || k2->k_data == NULL)
83  return M0_RC(0);
84 
85  if (memcmp(k1->k_data, k2->k_data, k1->k_len) == 0)
86  return M0_RC(1);
87  else
88  return M0_RC(0);
89 }
90 
91 M0_HT_DESCR_DEFINE(kv_pairs, "Hash of key value pairs",
92  static, struct kv_pair,
93  p_link, p_magic, 0x41, 0x67, p_key,
95 M0_HT_DEFINE(kv_pairs, static, struct kv_pair, struct key);
96 
101 struct index {
102  uint64_t i_magic;
103  struct m0_hlink i_link;
104 
107 };
108 
112 static uint64_t idx_hash(const struct m0_htable *htable,
113  const struct m0_uint128 *key)
114 {
115  const uint64_t k = key->u_lo;
116  return k % htable->h_bucket_nr;
117 }
118 
122 static int idx_hash_key_eq(const struct m0_uint128 *key1,
123  const struct m0_uint128 *key2)
124 {
125  const uint64_t k1 = key1->u_lo;
126  const uint64_t k2 = key2->u_lo;
127  return k1 == k2;
128 }
129 
130 M0_HT_DESCR_DEFINE(indices, "Hash of key value pairs",
131  static, struct index,
132  i_link, i_magic, 0x43, 0x67, i_fid,
134 M0_HT_DEFINE(indices, static, struct index, struct m0_uint128);
135 static struct m0_htable idx_htable;
136 
137 
141 #define MAX_IDX_FNAME_LEN (256)
142 #define IDX_CSV_DELIMITER (',')
143 
144 static int make_idx_fname(char *fname, struct m0_uint128 idx_fid)
145 {
146  return sprintf(fname,
147  "%s/%" PRIx64 "_%"PRIx64,
148  idx_store_path, idx_fid.u_hi, idx_fid.u_lo);
149 }
150 
151 static int idx_access(struct m0_uint128 idx_fid)
152 {
153  int rc;
154  char *idx_fname;
155 
156  idx_fname = m0_alloc(MAX_IDX_FNAME_LEN);
157  if (idx_fname == NULL)
158  return -ENOMEM;
159 
160  make_idx_fname(idx_fname, idx_fid);
161  rc = access(idx_fname, F_OK);
162  m0_free(idx_fname);
163 
164  return M0_RC(rc);
165 }
166 
167 static int idx_rm(struct m0_uint128 idx_fid)
168 {
169  int rc;
170  char *idx_fname;
171 
172  idx_fname = m0_alloc(MAX_IDX_FNAME_LEN);
173  if (idx_fname == NULL)
174  return M0_ERR(-ENOMEM);
175 
176  make_idx_fname(idx_fname, idx_fid);
177  rc = remove(idx_fname);
178  m0_free(idx_fname);
179 
180  return M0_RC(rc);
181 }
182 
183 static struct index* idx_load(struct m0_uint128 idx_fid)
184 {
185  char *delimiter;
186  char *idx_fname = NULL;
187  char *line = NULL;
188  struct kv_pair *kvp;
189  struct index *midx = NULL;
190  FILE *fp;
191 
192  /* Open and scan the index file. */
193  idx_fname = m0_alloc(MAX_IDX_FNAME_LEN);
194  if (idx_fname == NULL)
195  goto error;
196 
197  make_idx_fname(idx_fname, idx_fid);
198  fp = fopen(idx_fname, "r+");
199  if (fp == NULL)
200  goto error;
201 
202  midx = m0_alloc(sizeof *midx);
203  if (midx == NULL)
204  goto error;
205  kv_pairs_htable_init(&midx->i_kv_pairs, 11);
206 
207  midx->i_fid = idx_fid;
208  m0_tlink_init(&indices_tl, midx);
209  indices_htable_add(&idx_htable, midx);
210 
211  /* Allocate memory for line buffer and midx.*/
212  line = m0_alloc(1024);
213  if (line == NULL)
214  goto error;
215 
216  while(fgets(line, 1024, fp)) {
217  kvp = m0_alloc(sizeof *kvp);
218  if (kvp == NULL)
219  break;
220 
221  delimiter = strchr(line, IDX_CSV_DELIMITER);
222  kvp->p_key.k_len = delimiter - line;
223  kvp->p_key.k_data = strndup(line, kvp->p_key.k_len);
224 
225  kvp->p_val.v_len = strlen(line) - kvp->p_key.k_len - 1;
226  kvp->p_val.v_data = strndup(delimiter + 1, kvp->p_val.v_len);
227 
228  /* Insert into hash table. */
229  m0_tlink_init(&kv_pairs_tl, kvp);
230  kv_pairs_htable_add(&midx->i_kv_pairs, kvp);
231  }
232 
233  return midx;
234 
235 error:
236  m0_free(line);
237  m0_free(midx);
238  m0_free(idx_fname);
239 
240  return NULL;
241 }
242 
243 static int idx_dump(struct index *midx)
244 {
245  int rc;
246  int cursor;
247  int buf_len;
248  char *buf;
249  char *idx_fname;
250  struct key *key;
251  struct val *val;
252  struct kv_pair *kvp;
253  FILE *fp;
254 
255  /* Assemble index file. */
256  idx_fname = m0_alloc(MAX_IDX_FNAME_LEN);
257  if (idx_fname == NULL)
258  return M0_ERR(-ENOMEM);
259 
260  make_idx_fname(idx_fname, midx->i_fid);
261  fp = fopen(idx_fname, "w+");
262  if (fp == NULL) {
263  m0_free(idx_fname);
264  return M0_ERR(-ENOMEM);
265  }
266 
267  /* Allocate memory for buffer.*/
268  buf_len = 1024 * 1024; /* 1MB */
269  buf = m0_alloc(buf_len);
270  if (buf == NULL) {
271  fclose(fp);
272  m0_free(idx_fname);
273  return M0_ERR(-ENOMEM);
274  }
275 
276  /*
277  * Pack K-V pairs into buffer and flush to disk when it is full.
278  */
279  cursor = 0;
280  m0_htable_for(kv_pairs, kvp, &midx->i_kv_pairs) {
281  key = &kvp->p_key;
282  val = &kvp->p_val;
283  if (key->k_len + val->v_len > buf_len)
284  break;
285 
286  if (cursor + key->k_len + val->v_len > buf_len) {
287  rc = fwrite(buf, cursor, 1, fp);
288  if (rc != cursor)
289  break;
290  cursor = 0;
291  }
292 
293  /* Copy the key part. */
294  memcpy(buf + cursor, key->k_data, key->k_len);
295  cursor += key->k_len;
296  buf[cursor] = ',';
297  cursor++;
298 
299  /* Copy the val part. */
300  memcpy(buf + cursor, val->v_data, val->v_len);
301  cursor += val->v_len;
302  buf[cursor] = '\n';
303  cursor++;
304 
305  /* Remvoe this K-V pair from hash table. */
306  m0_htable_del(&midx->i_kv_pairs, kvp);
307  m0_free(kvp);
308  }
310 
311  indices_htable_fini(&midx->i_kv_pairs);
312 
313  /* Flush the last bif. */
314  fwrite(buf, cursor, 1, fp);
315 
316  /* Free memory */
317  m0_free(idx_fname);
318  m0_free(buf);
319  fclose(fp);
320 
321  return M0_RC(0);
322 }
323 
332 static int idx_find(struct m0_uint128 idx_fid,
333  struct index **midx, bool to_load)
334 {
335  int rc;
336  struct index *found_midx;
337 
338  found_midx = m0_htable_lookup(&idx_htable, &idx_fid);
339  if (found_midx != NULL) {
340  if (midx != NULL)
341  *midx = found_midx;
342  return 1;
343  }
344 
345  if (to_load) {
346  if (midx == NULL)
347  return M0_ERR(-EINVAL);
348 
349  *midx = idx_load(idx_fid);
350  rc = (*midx != NULL) ? 1 : 0;
351  } else {
352  rc = idx_access(idx_fid);
353  rc = (rc == 0) ? 1 : 0;
354  }
355 
356  return rc;
357 }
358 
363 static int idx_mock_namei_new(struct m0_op_idx *oi)
364 {
365  int found;
366  struct m0_uint128 idx_fid;
367  struct index *midx;
368 
369  idx_fid = oi->oi_idx->in_entity.en_id;
370  found = idx_find(idx_fid, NULL, false);
371  if (found == 1)
372  return M0_ERR(-EEXIST);
373 
374  /* Create a new index and insert into hash table. */
375  midx = m0_alloc(sizeof *midx);
376  if (midx == NULL)
377  return M0_ERR(-ENOMEM);
378  kv_pairs_htable_init(&midx->i_kv_pairs, 11);
379 
380  midx->i_fid = idx_fid;
381  m0_tlink_init(&indices_tl, midx);
382  indices_htable_add(&idx_htable, midx);
383 
384  return M0_RC(0);
385 }
386 
387 static int idx_mock_namei_del(struct m0_op_idx *oi)
388 {
389  int rc;
390  struct m0_uint128 idx_fid;
391  struct index *midx = NULL;
392  struct kv_pair *kvp;
393 
394  idx_fid = oi->oi_idx->in_entity.en_id;
395  rc = idx_find(idx_fid, &midx, false);
396  if (rc == 0)
397  return M0_ERR(-ENOENT);
398  else if (rc < 0)
399  return M0_RC(rc);
400 
401  if (midx == NULL)
402  goto rm_index_file;
403 
404  /* Remove and free each K-V pair. */
405  m0_htable_for(kv_pairs, kvp, &midx->i_kv_pairs) {
406  m0_htable_del(&midx->i_kv_pairs, kvp);
407  m0_free(kvp);
408  }
410 
411  indices_htable_fini(&midx->i_kv_pairs);
412 
413  /* Remove from index hash table.*/
414  m0_htable_del(&idx_htable, midx);
415  m0_free(midx);
416 
417 rm_index_file:
418  /* Remove index file on disk. */
419  idx_rm(idx_fid);
420 
421  return M0_RC(0);
422 }
423 
424 static int idx_mock_namei_lookup(struct m0_op_idx *oi)
425 {
426  return M0_ERR(-ENOSYS);
427 }
428 
429 static int idx_mock_namei_list(struct m0_op_idx *oi)
430 {
431  return M0_ERR(-ENOSYS);
432 }
433 
434 static int idx_mock_get(struct m0_op_idx *oi)
435 {
436  int i;
437  int rc;
438  int nr_found = 0;
439  struct key mkey;
440  struct val mval;
441  struct kv_pair *kvp;
442  struct index *midx;
443  struct m0_bufvec *keys;
444  struct m0_bufvec *vals;
445  struct m0_uint128 idx_fid;
446 
447  M0_ENTRY();
448 
449  keys = oi->oi_keys;
450  vals = oi->oi_vals;
451  if (keys->ov_vec.v_nr != vals->ov_vec.v_nr)
452  return M0_ERR(-EINVAL);
453 
454  idx_fid = oi->oi_idx->in_entity.en_id;
455  rc = idx_find(idx_fid, &midx, true);
456  if (rc == 0)
457  return M0_RC(-ENOENT);
458  else if (rc < 0)
459  return M0_RC(rc);
460 
461  /* Exaamine each input keys and find their values. */
462  for (i = 0; i < keys->ov_vec.v_nr; i++) {
463  mkey.k_len = keys->ov_vec.v_count[i];
464  mkey.k_data = keys->ov_buf[i];
465  kvp = m0_htable_lookup(&midx->i_kv_pairs, &mkey);
466 
467  if (kvp == NULL) {
468  oi->oi_rcs[i] = -ENOENT;
469  vals->ov_buf[i] = NULL;
470  continue;
471  }
472  mval = kvp->p_val;
473 
474  /* Copy value. */
475  vals->ov_buf[i] = m0_alloc(mval.v_len);
476  if (vals->ov_buf[i] == NULL)
477  break;
478  memcpy(vals->ov_buf[i], mval.v_data, mval.v_len);
479  vals->ov_vec.v_count[i] = mval.v_len;
480  oi->oi_rcs[i] = 0;
481 
482  nr_found++;
483  }
484 
485  /* Whether or not key found, operation is successful */
486  return M0_RC(0);
487 }
488 
489 static int idx_mock_put(struct m0_op_idx *oi)
490 {
491  int i;
492  int rc;
493  int nr_inserted = 0;
494  int nr_kvp;
495  struct key mkey;
496  struct kv_pair *kvp = NULL;
497  struct index *midx;
498  struct m0_bufvec *keys;
499  struct m0_bufvec *vals;
500  struct m0_uint128 idx_fid;
501 
502  M0_ENTRY();
503 
504  keys = oi->oi_keys;
505  vals = oi->oi_vals;
506  if (keys->ov_vec.v_nr != vals->ov_vec.v_nr)
507  return M0_ERR(-EINVAL);
508 
509  idx_fid = oi->oi_idx->in_entity.en_id;
510  rc = idx_find(idx_fid, &midx, true);
511  if (rc == 0)
512  return M0_RC(-ENOENT);
513  else if (rc < 0)
514  return M0_RC(rc);
515 
516  /* Exaamine each input keys and find their values. */
517  nr_kvp = keys->ov_vec.v_nr;
518  for (i = 0; i < nr_kvp; i++) {
519  mkey.k_len = keys->ov_vec.v_count[i];
520  mkey.k_data = keys->ov_buf[i];
521  kvp = m0_htable_lookup(&midx->i_kv_pairs, &mkey);
522 
523  if (kvp == NULL) {
524  kvp = m0_alloc(sizeof *kvp);
525  if (kvp == NULL)
526  break;
527 
528  kvp->p_key.k_len = mkey.k_len;
529  kvp->p_key.k_data = m0_alloc(mkey.k_len);
530  if (kvp->p_key.k_data == NULL)
531  break;
532  memcpy(kvp->p_key.k_data, mkey.k_data, mkey.k_len);
533  kvp->p_val.v_len = 0;
534  kvp->p_val.v_data = NULL;
535 
536  m0_tlink_init(&kv_pairs_tl, kvp);
537  kv_pairs_htable_add(&midx->i_kv_pairs, kvp);
538  }
539 
540  if (kvp->p_val.v_len != vals->ov_vec.v_count[i]) {
541  if (kvp->p_val.v_len != 0)
542  m0_free(kvp->p_val.v_data);
543 
544  kvp->p_val.v_len = vals->ov_vec.v_count[i];
545  kvp->p_val.v_data = m0_alloc(kvp->p_val.v_len);
546  if (kvp->p_val.v_data == NULL)
547  break;
548  memcpy(kvp->p_val.v_data, vals->ov_buf[i],
549  kvp->p_val.v_len);
550  }
551 
552  nr_inserted++;
553  }
554 
555  if (i != nr_kvp) {
556  if (kvp && kvp->p_key.k_data)
557  m0_free(kvp->p_key.k_data);
558  if (kvp && kvp->p_val.v_data)
559  m0_free(kvp->p_val.v_data);
560  if (kvp)
561  m0_free(kvp);
562  }
563 
564  /* The query is considered successful if nr_inserted > 0. */
565  rc = (nr_inserted > 0) ? 0 : -ENOMEM;
566 
567  return M0_RC(rc);
568 }
569 
570 static int idx_mock_del(struct m0_op_idx *oi)
571 {
572  int i;
573  int rc;
574  int nr_deleted = 0;
575  int nr_kvp;
576  struct key mkey;
577  struct kv_pair *kvp;
578  struct index *midx;
579  struct m0_uint128 idx_fid;
580 
581  M0_ENTRY();
582 
583  idx_fid = oi->oi_idx->in_entity.en_id;
584  rc = idx_find(idx_fid, &midx, true);
585  if (rc == 0)
586  return M0_RC(-ENOENT);
587  else if (rc < 0)
588  return M0_RC(rc);
589 
590  /* Exaamine each input keys and find their values. */
591  nr_kvp = oi->oi_keys->ov_vec.v_nr;
592  for (i = 0; i < nr_kvp; i++) {
593  if (oi->oi_keys->ov_buf[i] == NULL)
594  continue;
595 
596  mkey.k_len = oi->oi_keys->ov_vec.v_count[i];
597  mkey.k_data = oi->oi_keys->ov_buf[i];
598  kvp = m0_htable_lookup(&midx->i_kv_pairs, &mkey);
599  if (kvp == NULL)
600  continue;
601 
602  m0_htable_del(&midx->i_kv_pairs, kvp);
603  m0_free(kvp->p_key.k_data);
604  m0_free(kvp->p_val.v_data);
605  m0_free(kvp);
606 
607  nr_deleted++;
608  }
609 
610  /* The query is considered successful if nr_deleted > 0. */
611  rc = (nr_deleted > 0) ? 0 : -ENOENT;
612 
613  return M0_RC(rc);
614 }
615 
616 static int idx_mock_next(struct m0_op_idx *oi)
617 {
618  int rc;
619  struct index *midx;
620  struct m0_uint128 idx_fid;
621 
622  M0_ENTRY();
623 
624  idx_fid = oi->oi_idx->in_entity.en_id;
625  rc = idx_find(idx_fid, &midx, true);
626  if (rc == 0)
627  return M0_RC(-ENOENT);
628  else if (rc < 0)
629  return M0_RC(rc);
630 
631  return M0_RC(0);
632 }
633 
636  .iqo_namei_delete = idx_mock_namei_del,
637  .iqo_namei_lookup = idx_mock_namei_lookup,
638  .iqo_namei_list = idx_mock_namei_list,
639 
640  .iqo_get = idx_mock_get,
641  .iqo_put = idx_mock_put,
642  .iqo_del = idx_mock_del,
643  .iqo_next = idx_mock_next,
644 };
645 
646 static int idx_mock_init(void *svc)
647 {
648  int rc;
649  struct m0_idx_service_ctx *ctx;
650 
651  M0_ENTRY();
652 
653  if (svc == NULL)
654  return M0_ERR(-EINVAL);
655  ctx = (struct m0_idx_service_ctx *)svc;
656 
657  /* Check permissions on index store path. */
658  idx_store_path = (char *)ctx->isc_svc_conf;
659  if (idx_store_path == NULL)
660  return M0_ERR(-EINVAL);
661 
662  rc = access(idx_store_path, R_OK | W_OK | X_OK);
663  if (rc == 0)
664  goto idx_htable;
665 
666  if (errno != ENOENT) {
667  rc = -errno;
668  goto exit;
669  }
670 
671  /* Create the directory for all index files. */
672  rc = mkdir(idx_store_path, 0777);
673  if (rc != 0) {
674  rc = -errno;
675  goto exit;
676  }
677 
678 idx_htable:
679  indices_htable_init(&idx_htable, 11);
680 
681 exit:
682  return M0_RC(rc);
683 }
684 
685 static int idx_mock_fini(void *svc)
686 {
687  struct index *idx;
688 
690  /* Dump all key/value pairs into disk. */
691  idx_dump(idx);
692 
693  m0_htable_del(&idx_htable, idx);
694  m0_free(idx);
695  }
697 
698  indices_htable_fini(&idx_htable);
699 
700  return M0_RC(0);
701 }
702 
705  .iso_fini = idx_mock_fini
706 };
707 
708 #else
709 
710 static int idx_mock_init(void *svc)
711 {
712  return 0;
713 }
714 
715 static int idx_mock_fini(void *svc)
716 {
717  return 0;
718 }
719 
720 static int idx_mock_namei_new(struct m0_op_idx *oi)
721 {
722  return 0;
723 }
724 
725 static int idx_mock_namei_del(struct m0_op_idx *oi)
726 {
727  return 0;
728 }
729 
730 static int idx_mock_get(struct m0_op_idx *oi)
731 {
732  return 0;
733 }
734 
735 static int idx_mock_put(struct m0_op_idx *oi)
736 {
737  return 0;
738 }
739 
740 static int idx_mock_del(struct m0_op_idx *oi)
741 {
742  return 0;
743 }
744 
745 static int idx_mock_next(struct m0_op_idx *oi)
746 {
747  return 0;
748 }
749 
750 static struct m0_idx_query_ops idx_mock_query_ops = {
752  .iqo_namei_delete = idx_mock_namei_del,
753  .iqo_namei_lookup = NULL,
754  .iqo_namei_list = NULL,
755  .iqo_get = idx_mock_get,
756  .iqo_put = idx_mock_put,
757  .iqo_del = idx_mock_del,
758  .iqo_next = idx_mock_next,
759 };
760 
761 static struct m0_idx_service_ops idx_mock_svc_ops = {
763  .iso_fini = idx_mock_fini
764 };
765 
766 #endif
767 
768 M0_INTERNAL void m0_idx_mock_register(void)
769 {
772 }
773 
774 #undef M0_TRACE_SUBSYSTEM
775 
776 /*
777  * Local variables:
778  * c-indentation-style: "K&R"
779 
780  * c-basic-offset: 8
781  * tab-width: 8
782  * fill-column: 80
783  * scroll-step: 1
784  * End:
785  */
786 /*
787  * vim: tabstop=8 shiftwidth=8 noexpandtab textwidth=80 nowrap
788  */
static struct m0_idx_query_ops idx_mock_query_ops
Definition: idx_mock.c:634
static uint64_t kv_hash(const struct m0_htable *htable, const struct key *key)
Definition: idx_mock.c:65
static m0_bindex_t indices[ZEROVEC_UT_SEGS_NR]
Definition: zerovec.c:38
struct val p_val
Definition: idx_mock.c:62
#define IDX_CSV_DELIMITER
Definition: idx_mock.c:142
#define m0_htable_for(name, var, htable)
Definition: hash.h:483
M0_INTERNAL void * m0_htable_lookup(const struct m0_htable *htable, const void *key)
Definition: hash.c:162
static const uint64_t k1
Definition: hash_fnc.c:34
#define NULL
Definition: misc.h:38
uint64_t i_magic
Definition: idx_mock.c:102
Definition: idx_mock.c:52
M0_INTERNAL void m0_idx_service_register(int svc_id, struct m0_idx_service_ops *sops, struct m0_idx_query_ops *qops)
Definition: idx.c:670
struct m0_vec ov_vec
Definition: vec.h:147
static int idx_mock_put(struct m0_op_idx *oi)
Definition: idx_mock.c:489
int v_len
Definition: idx_mock.c:53
M0_INTERNAL void m0_idx_mock_register(void)
Definition: idx_mock.c:768
int k_len
Definition: idx_mock.c:48
static int error
Definition: mdstore.c:64
static int void * buf
Definition: dir.c:1019
struct m0_bufvec * oi_keys
static int make_idx_fname(char *fname, struct m0_uint128 idx_fid)
Definition: idx_mock.c:144
void ** ov_buf
Definition: vec.h:149
#define PRIx64
Definition: types.h:61
static int idx_mock_namei_list(struct m0_op_idx *oi)
Definition: idx_mock.c:429
Definition: sock.c:887
return M0_RC(rc)
#define M0_ENTRY(...)
Definition: trace.h:170
int(* iqo_namei_create)(struct m0_op_idx *oi)
Definition: idx.h:123
struct m0_entity in_entity
Definition: client.h:836
int i
Definition: dir.c:1033
static int idx_find(struct m0_uint128 idx_fid, struct index **midx, bool to_load)
Definition: idx_mock.c:332
struct m0_hlink p_link
Definition: idx_mock.c:59
M0_HT_DESCR_DEFINE(kv_pairs, "Hash of key value pairs", static, struct kv_pair, p_link, p_magic, 0x41, 0x67, p_key, kv_hash, kv_hash_key_eq)
return M0_ERR(-EOPNOTSUPP)
static struct m0_htable idx_htable
Definition: idx_mock.c:135
void * k_data
Definition: idx_mock.c:49
struct m0_htable i_kv_pairs
Definition: idx_mock.c:106
struct m0_idx * oi_idx
static int key
Definition: locality.c:283
if(value==NULL)
Definition: dir.c:350
static int idx_mock_init(void *svc)
Definition: idx_mock.c:646
static int idx_access(struct m0_uint128 idx_fid)
Definition: idx_mock.c:151
struct m0_hlink i_link
Definition: idx_mock.c:103
#define MAX_IDX_FNAME_LEN
Definition: idx_mock.c:141
static int idx_mock_del(struct m0_op_idx *oi)
Definition: idx_mock.c:570
static int idx_dump(struct index *midx)
Definition: idx_mock.c:243
uint64_t u_hi
Definition: types.h:36
void * m0_alloc(size_t size)
Definition: memory.c:126
int(* iso_init)(void *svc)
Definition: idx.h:137
uint32_t v_nr
Definition: vec.h:51
M0_HT_DEFINE(kv_pairs, static, struct kv_pair, struct key)
static int kv_hash_key_eq(const struct key *k1, const struct key *k2)
Definition: idx_mock.c:77
int32_t * oi_rcs
m0_bcount_t * v_count
Definition: vec.h:53
struct m0_uint128 en_id
Definition: client.h:708
M0_INTERNAL void m0_tlink_init(const struct m0_tl_descr *d, void *obj)
Definition: tlist.c:63
static struct fdmi_ctx ctx
Definition: main.c:80
struct m0_uint128 i_fid
Definition: idx_mock.c:105
static const uint64_t k2
Definition: hash_fnc.c:35
static int idx_hash_key_eq(const struct m0_uint128 *key1, const struct m0_uint128 *key2)
Definition: idx_mock.c:122
static char * idx_store_path
Definition: idx_mock.c:42
struct m0_bufvec * oi_vals
struct key p_key
Definition: idx_mock.c:61
static int idx_mock_fini(void *svc)
Definition: idx_mock.c:685
static struct m0_net_test_service svc
Definition: service.c:34
static int idx_mock_namei_del(struct m0_op_idx *oi)
Definition: idx_mock.c:387
static int idx_mock_get(struct m0_op_idx *oi)
Definition: idx_mock.c:434
M0_INTERNAL void m0_htable_del(struct m0_htable *htable, void *amb)
Definition: hash.c:150
static int idx_mock_namei_lookup(struct m0_op_idx *oi)
Definition: idx_mock.c:424
static int idx_mock_next(struct m0_op_idx *oi)
Definition: idx_mock.c:616
static uint64_t found
Definition: base.c:376
static uint64_t idx_hash(const struct m0_htable *htable, const struct m0_uint128 *key)
Definition: idx_mock.c:112
Definition: nucleus.c:42
static struct m0_idx_service_ops idx_mock_svc_ops
Definition: idx_mock.c:703
Definition: rcv_session.c:58
static int idx_rm(struct m0_uint128 idx_fid)
Definition: idx_mock.c:167
void * v_data
Definition: idx_mock.c:54
static struct index * idx_load(struct m0_uint128 idx_fid)
Definition: idx_mock.c:183
uint64_t u_lo
Definition: types.h:37
uint64_t p_magic
Definition: idx_mock.c:58
void m0_free(void *data)
Definition: memory.c:146
#define m0_htable_endfor
Definition: hash.h:491
int32_t rc
Definition: trigger_fop.h:47
uint64_t h_bucket_nr
Definition: hash.h:178
static int idx_mock_namei_new(struct m0_op_idx *oi)
Definition: idx_mock.c:363
Definition: vec.h:145
Definition: idx_mock.c:47