Motr  M0
m0hsm.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 Seagate Technology LLC and/or its Affiliates
3  * COPYRIGHT 2017-2018 CEA[1] and SAGE partners
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  * [1]Commissariat a l'energie atomique et aux energies alternatives
21  *
22  * Original author: Thomas Leibovici <thomas.leibovici@cea.fr>
23  */
24 
25 #include <errno.h>
26 #include <stdlib.h>
27 #include <unistd.h>
28 #include <getopt.h>
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <fcntl.h>
32 #include <stdio.h>
33 #include <editline/readline.h>
34 
35 #include "lib/string.h"
36 #include "m0hsm_api.h"
37 #include "motr/idx.h"
38 
39 static const char RCFILE[] = ".hsm/config";
40 
41 /* Client parameters */
42 static char *local_addr;
43 static char *ha_addr;
44 static char *profile;
45 static char *proc_fid;
46 
47 static struct m0_client *instance = NULL;
48 static struct m0_container container;
49 static struct m0_realm uber_realm;
50 static struct m0_config client_conf;
52 
55  .op_timeout = 10,
56 };
57 
58 static void client_fini(void)
59 {
60  m0_client_fini(instance, true);
61 }
62 
63 static int client_init(void)
64 {
65  int rc;
66 
67  client_conf.mc_is_oostore = true;
68  client_conf.mc_is_read_verify = false;
69  client_conf.mc_local_addr = local_addr;
70  client_conf.mc_ha_addr = ha_addr;
71  client_conf.mc_profile = profile;
72  client_conf.mc_process_fid = proc_fid;
73 
74  /*
75  * Note: max_rpc_msg_size should match server side configuration for
76  * optimal performance.
77  */
78  /* TODO Implement runtime configuration to override the defaults:
79  * (M0_NET_TM_RECV_QUEUE_DEF_LEN and M0_RPC_DEF_MAX_RPC_MSG_SIZE).
80  * The following values are tuned for the SAGE prototype cluster: */
81  client_conf.mc_tm_recv_queue_min_len = 64;
82  client_conf.mc_max_rpc_msg_size = 65536;
83 
84  client_conf.mc_layout_id = 0;
85  /* using DIX index */
86  client_conf.mc_idx_service_id = M0_IDX_DIX;
87  dix_conf.kc_create_meta = false;
88  client_conf.mc_idx_service_conf = &dix_conf;
89 
91  if (rc != 0) {
92  fprintf(stderr, "m0_client_init() failed: %d\n", rc);
93  return rc;
94  }
95 
96  /* Initialize root realm */
99  if (rc != 0) {
100  fprintf(stderr, "m0_container_init() failed: %d\n", rc);
101  goto out;
102  }
103 
105 out:
106  if (rc)
107  client_fini();
108  return rc;
109 }
110 
112 static int open_entity(struct m0_entity *entity)
113 {
114  struct m0_op *ops[1] = {NULL};
115  int rc;
116 
117  m0_entity_open(entity, &ops[0]);
118  m0_op_launch(ops, 1);
120  M0_OS_STABLE),
122  m0_op_fini(ops[0]);
123  m0_op_free(ops[0]);
124  ops[0] = NULL;
125 
126  return rc;
127 }
128 
130 static int m0hsm_write_file(struct m0_uint128 id, const char *path)
131 {
132 #define IO_SIZE (1024 * 1024)
133  struct m0_obj obj;
134  void *io_buff;
135  ssize_t read_nr;
136  off_t off = 0;
137  int fd;
138  int rc;
139 
140  /* Open source file */
141  fd = open(path, O_RDONLY);
142  if (fd < 0) {
143  fprintf(stderr, "open '%s' failed: %s\n", path,
144  strerror(errno));
145  return -1;
146  }
147 
148  /* allocate I/O buffer */
149  io_buff = malloc(IO_SIZE);
150  if (!io_buff) {
151  fprintf(stderr, "failed to allocate IO buffer\n");
152  return -ENOMEM;
153  }
154 
155  memset(&obj, 0, sizeof(struct m0_obj));
157 
158  /* open the entity */
159  rc = open_entity(&obj.ob_entity);
160  if (rc) {
161  fprintf(stderr,
162  "open object %#" PRIx64 ":%#" PRIx64 " failed: %d\n",
163  id.u_hi, id.u_lo, rc);
164  goto err;
165  }
166 
167  while ((read_nr = read(fd, io_buff, IO_SIZE)) > 0) {
168  rc = m0hsm_pwrite(&obj, io_buff, read_nr, off);
169  if (rc) {
170  fprintf(stderr, "error on writting at %zu to "
171  "%#" PRIx64 ":%#" PRIx64 ": %d\n", (size_t)off,
172  id.u_hi, id.u_lo, rc);
173  break;
174  }
175 
176  /* increase offset */
177  off += read_nr;
178  }
179 
180  if (read_nr < 0) {
181  fprintf(stderr, "error after reading %zu bytes from '%s': %s\n",
182  (size_t)off, path, strerror(errno));
183  rc = -1;
184  }
185 
186  m0_entity_fini(&obj.ob_entity);
187 err:
188  free(io_buff);
189  return rc;
190 }
191 
192 
193 static int load_env(char **tgt, const char *env)
194 {
195  *tgt = getenv(env);
196  if (*tgt == NULL) {
197  fprintf(stderr, "%s environment variable is not set\n", env);
198  return -1;
199  }
200  return 0;
201 }
202 
203 static int load_client_env()
204 {
205  if (load_env(&local_addr, "CLIENT_LADDR"))
206  return -1;
207  if (load_env(&ha_addr, "CLIENT_HA_ADDR"))
208  return -1;
209  if (load_env(&profile, "CLIENT_PROFILE"))
210  return -1;
211  if (load_env(&proc_fid, "CLIENT_PROC_FID"))
212  return -1;
213  return 0;
214 }
215 
216 static void usage()
217 {
218  printf("Usage: m0hsm <action> <fid> [...]\n");
219  printf(" actions:\n");
220  printf(" create <fid> <tier>\n");
221  printf(" show <fid>\n");
222  printf(" dump <fid>\n");
223  printf(" write <fid> <offset> <len> <seed>\n");
224  printf(" write_file <fid> <path>\n");
225  printf(" read <fid> <offset> <len>\n");
226  printf(" copy <fid> <offset> <len> <src_tier> "
227  "<tgt_tier> [options: mv,keep_prev,w2dest]\n");
228  printf(" move <fid> <offset> <len> <src_tier> "
229  "<tgt_tier> [options: keep_prev,w2dest]\n");
230  printf(" stage <fid> <offset> <len> <tgt_tier> "
231  "[options: mv,w2dest]\n");
232  printf(" archive <fid> <offset> <len> <tgt_tier> "
233  "[options: mv,keep_prev,w2dest]\n");
234  printf(" release <fid> <offset> <len> <tier> "
235  "[options: keep_latest]\n");
236  printf(" multi_release <fid> <offset> <len> <max_tier> "
237  "[options: keep_latest]\n");
238  printf(" set_write_tier <fid> <tier>\n\n");
239  printf(" <fid> parameter format is [hi:]lo. "
240  "(hi == 0 if not specified.)\n");
241  printf(" The numbers are read in decimal, hexadecimal "
242  "(when prefixed with `0x')\n"
243  " or octal (when prefixed with `0') formats.\n");
244 }
245 
246 
247 /* read a 64 bits argument. Interprets 0x as base16, 0 as base 8,
248  * others as base 10 */
249 int64_t read_arg64(const char *s)
250 {
251  long long ll = -1LL;
252 
253  if (sscanf(s, "%lli", &ll) != 1)
254  return -1LL;
255 
256  return ll;
257 }
258 
263 int read_fid(const char *s, struct m0_uint128 *fid)
264 {
265  int res;
266  long long hi, lo;
267 
268  res = sscanf(s, "%lli:%lli", &hi, &lo);
269  if (res == 1) {
270  fid->u_hi = 0;
271  fid->u_lo = hi;
272  } else if (res == 2) {
273  fid->u_hi = hi;
274  fid->u_lo = lo;
275  }
276 
277  return res;
278 }
279 
280 static int parse_copy_subopt(char *opts, enum hsm_cp_flags *flags)
281 {
282  enum copy_opt {
283  OPT_MOVE = 0,
284  OPT_KEEP_PREV_VERS = 1,
285  OPT_WRITE_TO_DEST = 2,
286  };
287  char *const options[] = {
288  [OPT_MOVE] = "mv",
289  [OPT_KEEP_PREV_VERS] = "keep_prev",
290  [OPT_WRITE_TO_DEST] = "w2dest",
291  NULL,
292  };
293  char *subopts = opts;
294  char *value;
295 
296  while (*subopts != '\0') {
297  switch (getsubopt(&subopts, options, &value)) {
298  case OPT_MOVE:
299  *flags |= HSM_MOVE;
300  break;
301 
302  case OPT_KEEP_PREV_VERS:
304  break;
305 
306  case OPT_WRITE_TO_DEST:
308  break;
309  default:
310  fprintf(stderr, "Unexpected option: %s\n", value);
311  return -EINVAL;
312  }
313  }
314  return 0;
315 }
316 
317 static int parse_release_subopt(char *opts, enum hsm_rls_flags *flags)
318 {
319  enum release_opt {
320  OPT_KEEP_LATEST = 0,
321  };
322  char *const options[] = {
323  [OPT_KEEP_LATEST] = "keep_latest",
324  NULL,
325  };
326  char *subopts = opts;
327  char *value;
328 
329  while (*subopts != '\0') {
330  switch (getsubopt(&subopts, options, &value)) {
331  case OPT_KEEP_LATEST:
333  break;
334 
335  default:
336  fprintf(stderr, "Unexpected option: %s\n", value);
337  return -EINVAL;
338  }
339  }
340  return 0;
341 }
342 
343 static const struct option option_tab[] = {
344  {"quiet", no_argument, NULL, 'q'},
345  {"verbose", required_argument, NULL, 'v'},
346 };
347 #define SHORT_OPT "qv"
348 
349 static int parse_cmd_options(int argc, char **argv)
350 {
351  int c, option_index = 0;
352 
353  while ((c = getopt_long(argc, argv, SHORT_OPT, option_tab,
354  &option_index)) != -1) {
355  switch (c) {
356  case 'q':
359  break;
360  case 'v':
363  break;
364  case ':':
365  case '?':
366  default:
367  return -EINVAL;
368  }
369  }
370  return 0;
371 }
372 
373 /* test functions hidden in m0hsm_api */
374 int m0hsm_test_write(struct m0_uint128 id, off_t offset, size_t len, int seed);
375 int m0hsm_test_read(struct m0_uint128 id, off_t offset, size_t len);
376 
377 static int run_cmd(int argc, char **argv)
378 {
379  struct m0_uint128 id;
380  const char *action;
381  int rc = 0;
382 
383  if (m0_streq(argv[optind], "help")) {
384  usage();
385  return 0;
386  }
387 
388  /* expect at least cmd <action> <fid> */
389  if (optind > argc - 2) {
390  usage();
391  return -1;
392  }
393 
394  action = argv[optind];
395 
396  optind++;
397  id = M0_ID_APP;
398  rc = read_fid(argv[optind], &id);
399  if (rc <= 0) {
400  usage();
401  return -1;
402  }
403  optind++;
404 
405  if (m0_streq(action, "create")) {
406  int tier;
407  struct m0_obj obj;
408 
409  if (optind > argc - 1) {
410  usage();
411  return -1;
412  }
413  tier = atoi(argv[optind]);
414  optind++;
415 
416  M0_SET0(&obj);
417  /* Create the object */
418  rc = m0hsm_create(id, &obj, tier, false);
419 
420  } else if (m0_streq(action, "show")) {
421  /* get and display the composite layout */
422  rc = m0hsm_dump(stdout, id, false);
423  } else if (m0_streq(action, "dump")) {
424  /* get and display the composite layout */
425  rc = m0hsm_dump(stdout, id, true);
426  } else if (m0_streq(action, "write")) {
427  off_t offset;
428  size_t len;
429  int seed;
430 
431  if (optind > argc - 3) {
432  usage();
433  return -1;
434  }
435  offset = read_arg64(argv[optind++]);
436  len = read_arg64(argv[optind++]);
437  seed = atoi(argv[optind]);
438 
439  rc = m0hsm_test_write(id, offset, len, seed);
440 
441  } else if (m0_streq(action, "write_file")) {
442  const char *path;
443 
444  if (optind > argc - 1) {
445  usage();
446  return -1;
447  }
448  path = argv[optind];
449  optind++;
450 
451  rc = m0hsm_write_file(id, path);
452 
453  } else if (m0_streq(action, "read")) {
454  off_t offset;
455  size_t len;
456 
457  if (optind > argc - 2) {
458  usage();
459  return -1;
460  }
461  offset = read_arg64(argv[optind]);
462  optind++;
463  len = read_arg64(argv[optind]);
464  optind++;
465 
466  rc = m0hsm_test_read(id, offset, len);
467 
468  } else if (m0_streq(action, "copy") ||
469  m0_streq(action, "move")) {
470  off_t offset;
471  size_t len;
472  int src_tier;
473  int tgt_tier;
474  enum hsm_cp_flags flags = 0;
475 
476  /* at least 4 arguments */
477  if (optind > argc - 4) {
478  usage();
479  return -1;
480  }
481  offset = read_arg64(argv[optind]);
482  optind++;
483  len = read_arg64(argv[optind]);
484  optind++;
485  src_tier = atoi(argv[optind]);
486  optind++;
487  tgt_tier = atoi(argv[optind]);
488  optind++;
489  if (src_tier > HSM_TIER_MAX || tgt_tier > HSM_TIER_MAX) {
490  fprintf(stderr, "Max tier index: %u\n", HSM_TIER_MAX);
491  return -1;
492  }
493  if (optind < argc)
494  if (parse_copy_subopt(argv[optind], &flags))
495  return -1;
496 
497  /* force move flag for 'move' action */
498  if (m0_streq(action, "move"))
499  flags |= HSM_MOVE;
500 
501  rc = m0hsm_copy(id, src_tier, tgt_tier, offset, len, flags);
502 
503  } else if (m0_streq(action, "stage")) {
504  off_t offset;
505  size_t len;
506  int tgt_tier;
507  enum hsm_cp_flags flags = 0;
508 
509  /* at least 3 arguments */
510  if (optind > argc - 3) {
511  usage();
512  return -1;
513  }
514  offset = read_arg64(argv[optind]);
515  optind++;
516  len = read_arg64(argv[optind]);
517  optind++;
518  tgt_tier = atoi(argv[optind]);
519  optind++;
520  if (tgt_tier > HSM_TIER_MAX) {
521  fprintf(stderr, "Max tier index: %u\n", HSM_TIER_MAX);
522  return -1;
523  }
524  if (optind < argc)
525  if (parse_copy_subopt(argv[optind], &flags))
526  return -1;
527 
528  rc = m0hsm_stage(id, tgt_tier, offset, len, flags);
529 
530  } else if (m0_streq(action, "archive")) {
531  off_t offset;
532  size_t len;
533  int tgt_tier;
534  enum hsm_cp_flags flags = 0;
535 
536  /* at least 3 arguments */
537  if (optind > argc - 3) {
538  usage();
539  return -1;
540  }
541  offset = read_arg64(argv[optind]);
542  optind++;
543  len = read_arg64(argv[optind]);
544  optind++;
545  tgt_tier = atoi(argv[optind]);
546  optind++;
547  if (tgt_tier > HSM_TIER_MAX) {
548  fprintf(stderr, "Max tier index: %u\n", HSM_TIER_MAX);
549  return -1;
550  }
551  if (optind < argc)
552  if (parse_copy_subopt(argv[optind], &flags))
553  return -1;
554 
555  rc = m0hsm_archive(id, tgt_tier, offset, len, flags);
556 
557  } else if (m0_streq(action, "release") ||
558  m0_streq(action, "multi_release")) {
559  off_t offset;
560  size_t len;
561  int tier;
562  enum hsm_rls_flags flags = 0;
563 
564  if (optind > argc - 3) {
565  usage();
566  return -1;
567  }
568  offset = read_arg64(argv[optind]);
569  optind++;
570  len = read_arg64(argv[optind]);
571  optind++;
572  tier = atoi(argv[optind]);
573  optind++;
574  if (tier > HSM_TIER_MAX) {
575  fprintf(stderr, "Max tier index: %u\n", HSM_TIER_MAX);
576  return -1;
577  }
578  if (optind < argc)
579  if (parse_release_subopt(argv[optind], &flags))
580  return -1;
581 
582  if (m0_streq(action, "release"))
583  /* XXX only handle the case of an extent copied to a lower tier */
584  rc = m0hsm_release(id, tier, offset, len, flags);
585  else if (m0_streq(action, "multi_release"))
586  rc = m0hsm_multi_release(id, tier, offset, len, flags);
587 
588  } else if (m0_streq(action, "set_write_tier")) {
589  int tier;
590 
591  if (optind > argc - 1) {
592  usage();
593  return -1;
594  }
595  tier = atoi(argv[optind]);
596  optind++;
597 
598  rc = m0hsm_set_write_tier(id, tier);
599 
600  } else {
601  usage();
602  return -1;
603  }
604 
605  return rc;
606 }
607 
608 #define SH_TOK_BUFSIZE 64
609 #define SH_TOK_DELIM " \t\r\n\a"
610 char **sh_split_line(char *line, int *argc)
611 {
612  int bufsize = SH_TOK_BUFSIZE, position = 0;
613  char **tokens = malloc(bufsize * sizeof(char*)), **tt;
614  char *token;
615 
616  if (!tokens) {
617  fprintf(stderr, "m0hsm: allocation error\n");
618  return NULL;
619  }
620 
621  /* set first arg add command name to be getopt compliant */
622  tokens[0] = "m0hsm";
623  position++;
624 
625  token = strtok(line, SH_TOK_DELIM);
626  while (token != NULL) {
627  tokens[position] = token;
628  position++;
629 
630  if (position >= bufsize) {
631  bufsize += SH_TOK_BUFSIZE;
632  tt = realloc(tokens, bufsize * sizeof(char*));
633  if (!tt) {
634  fprintf(stderr, "m0hsm: allocation error\n");
635  goto err;
636  }
637  tokens = tt;
638  }
639 
640  token = strtok(NULL, SH_TOK_DELIM);
641  }
642  tokens[position] = NULL;
643  *argc = position;
644  return tokens;
645  err:
646  free(tokens);
647  return NULL;
648 }
649 
650 
651 
652 static int shell_loop()
653 {
654  char *line;
655  int argc;
656  char **argv;
657 
658  using_history();
659  while (1) {
660  optind = 1;
661  line = readline("m0hsm> ");
662  if (!line)
663  break;
664  if (strlen(line) > 0)
665  add_history(line);
666  argv = sh_split_line(line, &argc);
667 
668  if (argc > 1) {
669  if (m0_streq(argv[1], "quit"))
670  break;
671  run_cmd(argc, argv);
672  }
673 
674  free(argv);
675  free(line);
676  }
677  return 0;
678 }
679 
680 int main(int argc, char **argv)
681 {
682  int rc = -1;
683  FILE *rcfile;
684  char rcpath[256 + ARRAY_SIZE(RCFILE)];
685 
686  snprintf(rcpath, ARRAY_SIZE(rcpath), "%s/%s", getenv("HOME"), RCFILE);
687  rcfile = fopen(rcpath, "r");
688  if (rcfile == NULL) {
689  fprintf(stderr, "m0hsm: error on opening %s file: %s\n",
690  rcpath, strerror(errno));
691  exit(EXIT_FAILURE);
692  }
693 
694  if (load_client_env())
695  goto out;
696 
697  if (parse_cmd_options(argc, argv))
698  goto out;
699 
700  /* expect at least m0hsm <action|shell> */
701  if (optind > argc - 1) {
702  usage();
703  goto out;
704  }
705 
706  /* Initialize cloivis */
707  rc = client_init();
708  if (rc < 0) {
709  fprintf(stderr, "m0hsm: error: client_init() failed!\n");
710  goto out;
711  }
712 
713  /* Initialize HSM API */
714  hsm_options.log_stream = stderr;
715  hsm_options.rcfile = rcfile;
717  if (rc < 0) {
718  fprintf(stderr, "m0hsm: error: m0hsm_init() failed!\n");
719  goto fini;
720  }
721 
722  if (m0_streq(argv[optind], "shell")) {
723  /* run shell */
724  rc = shell_loop();
725  } else {
726  /* run command */
727  rc = run_cmd(argc, argv);
728  }
729  fini:
730  /* terminate */
731  client_fini();
732  out:
733  fclose(rcfile);
734  if (rc != 0)
735  exit(EXIT_FAILURE);
736  exit(EXIT_SUCCESS);
737 }
738 
739 /*
740  * Local variables:
741  * c-indentation-style: "K&R"
742  * c-basic-offset: 8
743  * tab-width: 8
744  * fill-column: 80
745  * scroll-step: 1
746  * End:
747  */
int m0hsm_archive(struct m0_uint128 id, uint8_t tgt_tier, off_t offset, size_t length, enum hsm_cp_flags flags)
Definition: m0hsm_api.c:2831
uint64_t id
Definition: cob.h:2380
int optind
void m0_entity_fini(struct m0_entity *entity)
Definition: client.c:438
Definition: client.h:788
int const char const void size_t int flags
Definition: dir.c:328
#define NULL
Definition: misc.h:38
#define HSM_TIER_MAX
Definition: m0hsm_api.h:65
int m0hsm_stage(struct m0_uint128 id, uint8_t tgt_tier, off_t offset, size_t length, enum hsm_cp_flags flags)
Definition: m0hsm_api.c:2773
void m0_op_fini(struct m0_op *op)
Definition: client.c:847
FILE * log_stream
Definition: m0hsm_api.h:56
static struct m0_client * instance
Definition: m0hsm.c:47
static char * local_addr
Definition: m0hsm.c:42
Definition: beck.c:189
struct m0hsm_options options
Definition: m0hsm_api.c:56
int m0hsm_multi_release(struct m0_uint128 id, uint8_t max_tier, off_t offset, size_t length, enum hsm_rls_flags flags)
Definition: m0hsm_api.c:2499
enum hsm_log_level trace_level
Definition: m0hsm_api.h:52
static struct m0_realm uber_realm
Definition: m0hsm.c:49
void m0_client_fini(struct m0_client *m0c, bool fini_m0)
Definition: client_init.c:1711
Definition: idx.h:70
int const char const void * value
Definition: dir.c:325
hsm_cp_flags
Definition: m0hsm_api.h:111
uint64_t m0_client_layout_id(const struct m0_client *instance)
Definition: obj.c:859
uint64_t u_lo
Definition: types.h:58
#define M0_BITS(...)
Definition: misc.h:236
static char * ha_addr
Definition: m0hsm.c:43
#define M0_SET0(obj)
Definition: misc.h:64
int m0_client_init(struct m0_client **m0c, struct m0_config *conf, bool init_m0)
Definition: client_init.c:1533
const struct m0_uint128 M0_UBER_REALM
Definition: client.c:85
static void client_fini(void)
Definition: m0hsm.c:58
static struct foo * obj
Definition: tlist.c:302
#define PRIx64
Definition: types.h:61
static const struct option option_tab[]
Definition: m0hsm.c:343
const struct m0_uint128 M0_ID_APP
Definition: client.c:92
struct m0_fid fid
Definition: di.c:46
int32_t m0_op_wait(struct m0_op *op, uint64_t bits, m0_time_t to)
Definition: client.c:739
int m0hsm_dump(FILE *stream, struct m0_uint128 id, bool details)
Definition: m0hsm_api.c:875
#define SH_TOK_BUFSIZE
Definition: m0hsm.c:608
#define SHORT_OPT
Definition: m0hsm.c:347
struct m0_realm co_realm
Definition: client.h:881
Definition: client.h:641
static int run_cmd(int argc, char **argv)
Definition: m0hsm.c:377
static int load_client_env()
Definition: m0hsm.c:203
struct m0_entity re_entity
Definition: client.h:871
int64_t read_arg64(const char *s)
Definition: m0hsm.c:249
char ** sh_split_line(char *line, int *argc)
Definition: m0hsm.c:610
time_t op_timeout
Definition: m0hsm_api.h:54
static struct m0_addb2_callback c
Definition: consumer.c:41
#define m0_streq(a, b)
Definition: string.h:34
static int client_init(void)
Definition: m0hsm.c:63
void m0_op_launch(struct m0_op **op, uint32_t nr)
Definition: client.c:725
uint64_t u_hi
Definition: types.h:57
int m0hsm_pwrite(struct m0_obj *obj, void *buffer, size_t length, off_t offset)
Definition: m0hsm_api.c:1968
int m0hsm_test_write(struct m0_uint128 id, off_t offset, size_t len, int seed)
Definition: m0hsm_api.c:1875
static int open_entity(struct m0_entity *entity)
Definition: m0hsm.c:112
static int parse_cmd_options(int argc, char **argv)
Definition: m0hsm.c:349
static char * proc_fid
Definition: m0hsm.c:45
static struct m0_idx_dix_config dix_conf
Definition: m0hsm.c:51
static int load_env(char **tgt, const char *env)
Definition: m0hsm.c:193
static const char RCFILE[]
Definition: m0hsm.c:39
struct m0hsm_options hsm_options
Definition: m0hsm.c:53
int m0hsm_copy(struct m0_uint128 id, uint8_t src_tier, uint8_t tgt_tier, off_t offset, size_t len, enum hsm_cp_flags flags)
Definition: m0hsm_api.c:2715
static void token(struct ff2c_context *ctx, struct ff2c_term *term, struct ff2c_token *tok)
Definition: parser.c:66
int32_t sm_rc
Definition: sm.h:336
int read_fid(const char *s, struct m0_uint128 *fid)
Definition: m0hsm.c:263
static m0_bindex_t offset
Definition: dump.c:173
struct m0_pdclust_tgt_addr tgt
Definition: fd.c:110
static struct m0_container container
Definition: m0hsm.c:48
static int shell_loop()
Definition: m0hsm.c:652
static int parse_copy_subopt(char *opts, enum hsm_cp_flags *flags)
Definition: m0hsm.c:280
int main(int argc, char **argv)
Definition: m0hsm.c:680
int m0hsm_init(struct m0_client *instance, struct m0_realm *uber_realm, const struct m0hsm_options *in_options)
Definition: m0hsm_api.c:166
m0_time_t m0_time_from_now(uint64_t secs, long ns)
Definition: time.c:96
int m0hsm_create(struct m0_uint128 id, struct m0_obj *obj, uint8_t tier_idx, bool keep_open)
Definition: m0hsm_api.c:1571
bool kc_create_meta
Definition: idx.h:183
static int parse_release_subopt(char *opts, enum hsm_rls_flags *flags)
Definition: m0hsm.c:317
#define SH_TOK_DELIM
Definition: m0hsm.c:609
int m0hsm_release(struct m0_uint128 id, uint8_t tier, off_t offset, size_t len, enum hsm_rls_flags flags)
Definition: m0hsm_api.c:2493
void m0_obj_init(struct m0_obj *obj, struct m0_realm *parent, const struct m0_uint128 *id, uint64_t layout_id)
Definition: client.c:403
struct m0t1fs_filedata * fd
Definition: dir.c:1030
int m0hsm_set_write_tier(struct m0_uint128 id, uint8_t tier_idx)
Definition: m0hsm_api.c:1224
int fini(struct workload *w)
int m0hsm_test_read(struct m0_uint128 id, off_t offset, size_t len)
Definition: m0hsm_api.c:2045
static int m0hsm_write_file(struct m0_uint128 id, const char *path)
Definition: m0hsm.c:130
void m0_container_init(struct m0_container *con, struct m0_realm *parent, const struct m0_uint128 *id, struct m0_client *instance)
Definition: realm.c:31
FILE * rcfile
Definition: m0hsm_api.h:58
static char * profile
Definition: m0hsm.c:44
#define out(...)
Definition: gen.c:41
void m0_op_free(struct m0_op *op)
Definition: client.c:885
struct m0_sm en_sm
Definition: client.h:732
static void usage()
Definition: m0hsm.c:216
int m0_entity_open(struct m0_entity *entity, struct m0_op **op)
Definition: obj.c:885
struct m0_fom_ops ops
Definition: io_foms.c:623
#define IO_SIZE
static struct m0_addb2_source * s
Definition: consumer.c:39
int32_t rc
Definition: trigger_fop.h:47
static void hi(void)
Definition: nucleus.c:93
#define ARRAY_SIZE(a)
Definition: misc.h:45
hsm_rls_flags
Definition: m0hsm_api.h:146