Motr  M0
linux.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2020 Seagate Technology LLC and/or its Affiliates
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  * For any questions about this software or licensing,
17  * please email opensource@seagate.com or cortx-questions@seagate.com.
18  *
19  */
20 
21 
22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_STOB
23 #include "lib/trace.h"
24 
25 #include "stob/linux.h"
26 
27 #include <stdio.h> /* fopen */
28 #include <stdarg.h> /* va_list */
29 #include <string.h> /* strncpy */
30 
31 #include <sys/types.h> /* lstat */
32 #include <sys/stat.h> /* lstat */
33 #include <unistd.h> /* lstat */
34 #include <fcntl.h> /* open */
35 #include <limits.h> /* PATH_MAX */
36 
37 #include "lib/errno.h" /* ENOENT */
38 #include "lib/memory.h" /* M0_ALLOC_PTR */
39 #include "lib/string.h" /* m0_strdup */
40 #include "lib/fs.h" /* m0_cleandir */
41 #include "conf/obj.h" /* m0_conf_fid_is_valid */
42 #include "stob/type.h" /* m0_stob_type_id_get */
43 #include "stob/ioq.h" /* m0_stob_ioq_init */
44 
82 enum {
84 };
85 
87 
91 
93 {
94 }
95 
97 {
98 }
99 
100 M0_INTERNAL struct m0_stob_linux *m0_stob_linux_container(struct m0_stob *stob)
101 {
102  return container_of(stob, struct m0_stob_linux, sl_stob);
103 }
104 
105 M0_INTERNAL struct m0_stob_linux_domain *
107 {
109  return container_of(dom, struct m0_stob_linux_domain, sld_dom);
110 }
111 
119 static char *stob_linux_vsnprintf(const char *format, ...)
120 {
121  va_list ap;
122  char str[MAXPATHLEN];
123  size_t len;
124 
125  va_start(ap, format);
126  len = vsnprintf(str, ARRAY_SIZE(str), format, ap);
127  va_end(ap);
128 
129  return len < 0 || len >= ARRAY_SIZE(str) ? NULL : m0_strdup(str);
130 }
131 
132 static char *stob_linux_dir_domain(const char *path)
133 {
134  return stob_linux_vsnprintf("%s", path);
135 }
136 
137 static char *stob_linux_dir_stob(const char *path)
138 {
139  return stob_linux_vsnprintf("%s/o", path);
140 }
141 
142 static char *stob_linux_file_domain_id(const char *path)
143 {
144  return stob_linux_vsnprintf("%s/id", path);
145 }
146 
147 static char *stob_linux_file_stob(const char *path, const struct m0_fid *stob_fid)
148 {
149  return stob_linux_vsnprintf("%s/o/%" PRIx64 ":%" PRIx64 "", path,
150  stob_fid->f_container, stob_fid->f_key);
151 }
152 
153 static int stob_linux_domain_key_get_set(const char *path,
154  uint64_t *dom_key,
155  bool get)
156 {
157  char *id_file_path;
158  FILE *id_file;
159  int rc;
160  int rc1;
161 
162  id_file_path = stob_linux_file_domain_id(path);
163  rc = id_file_path == NULL ? -EOVERFLOW : 0;
164  if (rc == 0) {
165  id_file = fopen(id_file_path, get ? "r" : "w");
166  m0_free(id_file_path);
167  if (id_file == NULL)
168  rc = -errno;
169  }
170  if (rc == 0) {
171  if (get) {
172  rc = fscanf(id_file, "%"SCNx64"\n", dom_key);
173  rc = rc == 1 ? 0 : rc != EOF ? -EINVAL :
174  ferror(id_file) == 0 ? -EINVAL : -errno;
175  } else {
176  rc = fprintf(id_file, "%"SCNx64"\n", *dom_key);
177  rc = rc > 0 ? 0 : -EINVAL;
178  }
179  rc1 = fclose(id_file);
180  rc = rc == 0 && rc1 != 0 ? rc1 : rc;
181  }
182  return M0_IN(rc, (0, -ENOENT)) ? M0_RC(rc) :
183  M0_ERR_INFO(rc, "path=%s", path);
184 }
185 
186 static int stob_linux_domain_cfg_init_parse(const char *str_cfg_init,
187  void **cfg_init)
188 {
189  struct m0_stob_linux_domain_cfg *cfg;
190  int rc;
191 
192  M0_ALLOC_PTR(cfg);
193  rc = cfg == NULL ? -ENOMEM : 0;
194  if (rc == 0) {
195  *cfg = (struct m0_stob_linux_domain_cfg) {
196  .sldc_file_mode = 0700,
197  .sldc_file_flags = 0,
198  .sldc_use_directio = false,
199  };
200  if (str_cfg_init != NULL) {
201  cfg->sldc_use_directio = strstr(str_cfg_init,
202  "directio=true") != NULL;
203  }
204  }
205  if (rc == 0)
206  *cfg_init = cfg;
207  else
208  m0_free(cfg);
209  return M0_RC(rc);
210 }
211 
212 static void stob_linux_domain_cfg_init_free(void *cfg_init)
213 {
214  m0_free(cfg_init);
215 }
216 
217 static int stob_linux_domain_cfg_create_parse(const char *str_cfg_create,
218  void **cfg_create)
219 {
220  return 0;
221 }
222 
223 static void stob_linux_domain_cfg_create_free(void *cfg_create)
224 {
225 }
226 
228  const char *location_data,
229  void *cfg_init,
230  struct m0_stob_domain **out)
231 {
232  struct m0_stob_linux_domain *ldom;
233  uint64_t dom_key;
234  struct m0_fid dom_id;
235  uint8_t type_id;
236  int rc;
237  char *path;
238 
239  M0_PRE(location_data != NULL);
240 
241  M0_ALLOC_PTR(ldom);
242  if (ldom != NULL)
243  ldom->sld_cfg = *(struct m0_stob_linux_domain_cfg *)cfg_init;
244  path = m0_strdup(location_data);
245  rc = ldom == NULL || path == NULL ? -ENOMEM : 0;
246 
247  rc = rc ?: stob_linux_domain_key_get_set(path, &dom_key, true);
248  rc = rc ?: m0_stob_domain__dom_key_is_valid(dom_key) ? 0 : -EINVAL;
249  rc = rc ?: m0_stob_ioq_init(&ldom->sld_ioq);
250  if (rc == 0) {
252  ldom->sld_cfg.sldc_use_directio);
254  ldom->sld_path = path;
255  type_id = m0_stob_type_id_get(type);
256  m0_stob_domain__dom_id_make(&dom_id, type_id, 0, dom_key);
257  m0_stob_domain__id_set(&ldom->sld_dom, &dom_id);
258  }
259  if (rc != 0) {
260  m0_free(path);
261  m0_free(ldom);
262  }
263  *out = rc == 0 ? &ldom->sld_dom : NULL;
264  return M0_RC(rc);
265 }
266 
268 {
270 
271  m0_stob_ioq_fini(&ldom->sld_ioq);
272  m0_free(ldom->sld_path);
273  m0_free(ldom);
274 }
275 
277  const char *path,
278  uint64_t dom_key,
279  void *cfg,
280  bool create)
281 {
282  mode_t mode = 0700;
283  char *dir_domain = stob_linux_dir_domain(path);
284  char *dir_stob = stob_linux_dir_stob(path);
285  int rc;
286  int rc1;
287 
288  rc = dir_domain == NULL || dir_stob == NULL ? -ENOMEM : 0;
289  if (rc != 0)
290  goto out;
291  if (!create)
292  goto destroy;
293  rc = mkdir(dir_domain, mode) == 0 ? 0 : -errno;
294  if (rc != 0)
295  goto out;
296  rc = mkdir(dir_stob, mode) == 0 ? 0 : -errno;
297  if (rc != 0)
298  goto destroy;
299  rc = stob_linux_domain_key_get_set(path, &dom_key, false);
300  if (rc == 0)
301  goto out;
302 destroy:
303  rc1 = m0_cleandir(dir_stob);
304  if (rc1 != 0)
305  M0_LOG(M0_ERROR, "m0_cleandir(%s) failed: rc=%d",
306  dir_stob, rc1);
307  rc1 = m0_cleandir(dir_domain);
308  if (rc1 != 0)
309  M0_LOG(M0_ERROR, "m0_cleandir(%s) failed: rc=%d",
310  dir_domain, rc1);
311  if (rc == 0)
312  rc = rc1;
313 out:
314  m0_free(dir_stob);
315  m0_free(dir_domain);
316 
317  return M0_RC(rc);
318 }
319 
321  const char *location_data,
322  uint64_t dom_key,
323  void *cfg_create)
324 {
325  return stob_linux_domain_create_destroy(type, location_data, dom_key,
326  cfg_create, true);
327 }
328 
330  const char *location_data)
331 {
332  return stob_linux_domain_create_destroy(type, location_data, 0,
333  NULL, false);
334 }
335 
337  const struct m0_fid *stob_fid)
338 {
339  struct m0_stob_linux *lstob;
340 
341  M0_ALLOC_PTR(lstob);
342  return lstob == NULL ? NULL : &lstob->sl_stob;
343 }
344 
345 static void stob_linux_free(struct m0_stob_domain *dom,
346  struct m0_stob *stob)
347 {
348  if (stob != NULL)
350 }
351 
352 static int stob_linux_cfg_parse(const char *str_cfg_create,
353  void **cfg_create)
354 {
355  *cfg_create = str_cfg_create == NULL ? NULL : m0_strdup(str_cfg_create);
356  return 0;
357 }
358 
359 static void stob_linux_cfg_free(void *cfg_create)
360 {
361  m0_free(cfg_create);
362 }
363 
364 static int stob_linux_stat(struct m0_stob_linux *lstob)
365 {
366  struct stat statbuf;
367  int rc;
368 
369  rc = fstat(lstob->sl_fd, &statbuf);
370  if (rc == -1)
371  return M0_ERR(-errno);
372  lstob->sl_mode = statbuf.st_mode;
373  return M0_RC(0);
374 }
375 
376 static int stob_linux_open(struct m0_stob *stob,
377  struct m0_stob_domain *dom,
378  const struct m0_fid *stob_fid,
379  void *cfg,
380  bool create)
381 {
383  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
384  char *file_stob;
385  int flags = ldom->sld_cfg.sldc_file_flags;
386  int rc;
387 
389  lstob->sl_dom = ldom;
390 
391  file_stob = stob_linux_file_stob(ldom->sld_path, stob_fid);
392  if (file_stob == NULL)
393  return M0_ERR(-ENOMEM);
394 
395  rc = create && cfg != NULL ? symlink((char *)cfg, file_stob) : 0;
396  flags |= O_RDWR;
397  flags |= create && cfg == NULL ? O_CREAT : 0;
398  flags |= m0_stob_ioq_directio(&ldom->sld_ioq) ? O_DIRECT : 0;
399  lstob->sl_fd = rc ?: open(file_stob, flags,
400  ldom->sld_cfg.sldc_file_mode);
401  rc = lstob->sl_fd == -1 ? -errno : stob_linux_stat(lstob);
402 
403  m0_free(file_stob);
404 
405  return M0_RC(rc);
406 }
407 
408 static int stob_linux_init(struct m0_stob *stob,
409  struct m0_stob_domain *dom,
410  const struct m0_fid *stob_fid)
411 {
412  return stob_linux_open(stob, dom, stob_fid, NULL, false);
413 }
414 
415 static void stob_linux_close(struct m0_stob_linux *lstob)
416 {
417  int rc;
418 
419  if (lstob->sl_fd != -1) {
420  rc = close(lstob->sl_fd);
421  M0_ASSERT(rc == 0);
422  lstob->sl_fd = -1;
423  }
424 }
425 
426 static void stob_linux_fini(struct m0_stob *stob)
427 {
428  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
429 
430  stob_linux_close(lstob);
431 }
432 
434  struct m0_be_tx_credit *accum)
435 {
436 }
437 
438 static int stob_linux_create(struct m0_stob *stob,
439  struct m0_stob_domain *dom,
440  struct m0_dtx *dtx,
441  const struct m0_fid *stob_fid,
442  void *cfg)
443 {
444  return stob_linux_open(stob, dom, stob_fid, cfg, true);
445 }
446 
448  struct m0_be_tx_credit *accum)
449 {
450 }
451 
453  struct m0_indexvec *want,
454  struct m0_indexvec *got,
455  struct m0_be_tx_credit *accum)
456 {
457  return 0;
458 }
459 
460 static int stob_linux_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
461 {
462  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
463  char *file_stob;
464  int rc;
465 
466  stob_linux_close(lstob);
467  file_stob = stob_linux_file_stob(lstob->sl_dom->sld_path,
469  rc = file_stob == NULL ? -ENOMEM : unlink(file_stob);
470  m0_free(file_stob);
471  return M0_RC(rc);
472 }
473 
479 static int stob_linux_punch(struct m0_stob *stob,
480  struct m0_indexvec *range,
481  struct m0_dtx *dtx)
482 {
483  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
484  int rc;
485 #ifdef FALLOC_FL_PUNCH_HOLE
486  m0_bindex_t off_max = LLONG_MAX;
489  m0_bcount_t length;
490  struct m0_ivec_cursor cur;
491  uint32_t bshift = m0_stob_block_shift(stob);
492 
493  m0_ivec_cursor_init(&cur, range);
494  count = 0;
495  while (!m0_ivec_cursor_move(&cur, count)) {
497  offset = m0_ivec_cursor_index(&cur) << bshift;
498  length = count << bshift;
499  M0_LOG(M0_DEBUG, "lstob=%p, punching [%" PRIi64 ", +%" PRIi64 ")",
500  lstob, offset, length);
501  if (offset > off_max)
502  continue; /* Too large, nothing there anyway. */
503  if (offset + length < offset)
504  return M0_ERR(-EOVERFLOW);
505  if (offset + length > off_max)
506  length = off_max - offset;
507  rc = fallocate(lstob->sl_fd,
508  /*
509  * The FALLOC_FL_PUNCH_HOLE flag must be ORed
510  * with FALLOC_FL_KEEP_SIZE ...
511  * -- man fallocate(2)
512  */
513  FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
514  offset, length);
515  if (rc != 0)
516  return M0_ERR(-errno);
517  }
518  return M0_RC(0);
519 #else
521  rc = ftruncate(lstob->sl_fd, 0);
522  if (rc != 0)
523  rc = M0_ERR(-errno);
524  return M0_RC(rc);
525 #endif
526 }
527 
528 static void stob_linux_write_credit(const struct m0_stob_domain *dom,
529  const struct m0_stob_io *io,
530  struct m0_be_tx_credit *accum)
531 {
532 }
533 
534 static uint32_t stob_linux_block_shift(struct m0_stob *stob)
535 {
536  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
537 
538  return m0_stob_ioq_bshift(&lstob->sl_dom->sld_ioq);
539 }
540 
541 static int stob_linux_fd(struct m0_stob *stob)
542 {
543  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
544 
545  return lstob->sl_fd;
546 }
547 
554 M0_INTERNAL int m0_stob_linux_reopen(struct m0_stob_id *stob_id,
555  const char *f_path)
556 {
557  struct m0_stob *bstore;
558  enum m0_stob_state st;
559  int rc;
560 
561  rc = m0_stob_find(stob_id, &bstore);
562  if (rc != 0)
563  return M0_RC(rc);
566  st = m0_stob_state_get(bstore);
567  M0_ASSERT(st == CSS_EXISTS);
568  /*
569  * We need to release the reference for AD stob domain
570  * created on this stob.
571  */
572  m0_stob_put(bstore);
573  rc = m0_stob_destroy(bstore, NULL);
574  if (rc != 0) {
575  return M0_ERR_INFO(rc, "Failed to destroy stob "STOB_ID_F,
576  STOB_ID_P(stob_id));
577  }
579  rc = m0_stob_find(stob_id, &bstore);
580  if (rc != 0)
581  return M0_RC(rc);
582  st = m0_stob_state_get(bstore);
583  M0_ASSERT(st == CSS_NOENT);
584  rc = m0_stob_create(bstore, NULL, f_path);
585  rc = rc ?: m0_stob_state_get(bstore) == CSS_EXISTS ? 0 : -ENOENT;
586  if (rc != 0) {
587  m0_stob_put(bstore);
588  return M0_ERR_INFO(rc, "Failed to create stob: %s", f_path);
589  }
590  return M0_RC(0);
591 }
592 
593 M0_INTERNAL void
595  const struct m0_fid *conf_sdev)
596 {
597  struct m0_stob_linux *lstob = m0_stob_linux_container(stob);
598 
600 
601  lstob->sl_conf_sdev = *conf_sdev;
602 }
603 
604 M0_INTERNAL int m0_stob_linux_domain_fd_get(struct m0_stob_domain *dom, int *fd)
605 {
606  char *path;
607  int rc;
608 
611  if (path == NULL)
612  return M0_ERR(-EOVERFLOW);
613  rc = open(path, O_RDONLY);
614  m0_free(path);
615  if (rc < 0)
616  return M0_ERR(-errno);
617  *fd = rc;
618  return M0_RC(0);
619 }
620 
621 M0_INTERNAL int m0_stob_linux_domain_fd_put(struct m0_stob_domain *dom, int fd)
622 {
624 
625  return close(fd) == 0 ? 0 : M0_ERR(-errno);
626 }
627 
629 {
631 
633 
634  return ldom->sld_cfg.sldc_use_directio;
635 }
636 
637 static struct m0_stob_type_ops stob_linux_type_ops = {
639  .sto_deregister = &stob_linux_type_deregister,
640  .sto_domain_cfg_init_parse = &stob_linux_domain_cfg_init_parse,
641  .sto_domain_cfg_init_free = &stob_linux_domain_cfg_init_free,
642  .sto_domain_cfg_create_parse = &stob_linux_domain_cfg_create_parse,
643  .sto_domain_cfg_create_free = &stob_linux_domain_cfg_create_free,
644  .sto_domain_init = &stob_linux_domain_init,
645  .sto_domain_create = &stob_linux_domain_create,
646  .sto_domain_destroy = &stob_linux_domain_destroy,
647 };
648 
651  .sdo_stob_alloc = &stob_linux_alloc,
652  .sdo_stob_free = &stob_linux_free,
653  .sdo_stob_cfg_parse = &stob_linux_cfg_parse,
654  .sdo_stob_cfg_free = &stob_linux_cfg_free,
655  .sdo_stob_init = &stob_linux_init,
656  .sdo_stob_create_credit = &stob_linux_create_credit,
657  .sdo_stob_create = &stob_linux_create,
658  .sdo_stob_write_credit = &stob_linux_write_credit,
659 };
660 
661 static struct m0_stob_ops stob_linux_ops = {
663  .sop_destroy_credit = &stob_linux_destroy_credit,
664  .sop_destroy = &stob_linux_destroy,
665  .sop_punch_credit = &stob_linux_punch_credit,
666  .sop_punch = &stob_linux_punch,
667  .sop_io_init = &m0_stob_linux_io_init,
668  .sop_block_shift = &stob_linux_block_shift,
669  .sop_fd = &stob_linux_fd,
670 };
671 
672 const struct m0_stob_type m0_stob_linux_type = {
674  .st_fidt = {
675  .ft_id = STOB_TYPE_LINUX,
676  .ft_name = "linuxstob",
677  },
678 };
679 
682 #undef M0_TRACE_SUBSYSTEM
683 
684 /*
685  * Local variables:
686  * c-indentation-style: "K&R"
687  * c-basic-offset: 8
688  * tab-width: 8
689  * fill-column: 80
690  * scroll-step: 1
691  * End:
692  */
M0_INTERNAL void m0_stob_ioq_fini(struct m0_stob_ioq *ioq)
Definition: ioq.c:716
M0_INTERNAL void m0_ivec_cursor_init(struct m0_ivec_cursor *cur, const struct m0_indexvec *ivec)
Definition: vec.c:707
#define M0_PRE(cond)
Definition: dtm.h:554
#define m0_strdup(s)
Definition: string.h:43
void(* sto_register)(struct m0_stob_type *type)
Definition: type.h:73
M0_INTERNAL void m0_stob_domain__dom_id_make(struct m0_fid *dom_id, uint8_t type_id, uint64_t dom_container, uint64_t dom_key)
Definition: domain.c:327
#define MAXPATHLEN
Definition: stob.h:41
int const char const void size_t int flags
Definition: dir.c:328
M0_INTERNAL int struct dentry struct kstat * stat
Definition: dir.c:1433
#define NULL
Definition: misc.h:38
M0_INTERNAL m0_bcount_t m0_ivec_cursor_step(const struct m0_ivec_cursor *cur)
Definition: vec.c:726
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
Definition: addb2.c:791
const struct m0_stob_ops * so_ops
Definition: stob.h:164
M0_INTERNAL uint32_t m0_stob_ioq_bshift(struct m0_stob_ioq *ioq)
Definition: ioq.c:732
static void stob_linux_close(struct m0_stob_linux *lstob)
Definition: linux.c:415
static void stob_linux_destroy_credit(struct m0_stob *stob, struct m0_be_tx_credit *accum)
Definition: linux.c:447
#define M0_LOG(level,...)
Definition: trace.h:167
#define SCNx64
Definition: types.h:62
static void stob_linux_type_deregister(struct m0_stob_type *type)
Definition: linux.c:96
static void create(void)
Definition: service_ut.c:546
M0_INTERNAL bool m0_stob_ioq_directio(struct m0_stob_ioq *ioq)
Definition: ioq.c:747
static int stob_linux_domain_destroy(struct m0_stob_type *type, const char *location_data)
Definition: linux.c:329
M0_INTERNAL bool m0_stob_domain_is_of_type(const struct m0_stob_domain *dom, const struct m0_stob_type *dt)
Definition: domain.c:349
M0_INTERNAL uint8_t m0_stob_type_id_get(const struct m0_stob_type *type)
Definition: type.c:164
static struct m0_stob_type_ops stob_linux_type_ops
Definition: linux.c:88
uint64_t m0_bindex_t
Definition: types.h:80
M0_INTERNAL int m0_stob_linux_reopen(struct m0_stob_id *stob_id, const char *f_path)
Definition: linux.c:554
struct m0_stob_linux_domain_cfg sld_cfg
Definition: linux.h:53
uint64_t m0_bcount_t
Definition: types.h:77
M0_INTERNAL const struct m0_fid * m0_stob_fid_get(struct m0_stob *stob)
Definition: stob.c:255
#define container_of(ptr, type, member)
Definition: misc.h:33
void(* sdo_fini)(struct m0_stob_domain *dom)
Definition: domain.h:111
#define PRIx64
Definition: types.h:61
struct m0_stob sl_stob
Definition: linux.h:57
static m0_bcount_t count
Definition: xcode.c:167
struct m0_fid sl_conf_sdev
Definition: linux.h:64
struct m0_stob_domain * so_domain
Definition: stob.h:165
static void stob_linux_type_register(struct m0_stob_type *type)
Definition: linux.c:92
static int stob_linux_create(struct m0_stob *stob, struct m0_stob_domain *dom, struct m0_dtx *dtx, const struct m0_fid *stob_fid, void *cfg)
Definition: linux.c:438
return M0_RC(rc)
M0_INTERNAL uint32_t m0_stob_block_shift(struct m0_stob *stob)
Definition: stob.c:270
M0_INTERNAL struct m0_stob_linux * m0_stob_linux_container(struct m0_stob *stob)
Definition: linux.c:100
int sl_fd
Definition: linux.h:60
static struct m0_stob * stob_linux_alloc(struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
Definition: linux.c:336
M0_INTERNAL bool m0_stob_domain__dom_key_is_valid(uint64_t dom_key)
Definition: domain.c:344
#define M0_ERR_INFO(rc, fmt,...)
Definition: trace.h:215
return M0_ERR(-EOPNOTSUPP)
static int stob_linux_domain_key_get_set(const char *path, uint64_t *dom_key, bool get)
Definition: linux.c:153
static int stob_linux_open(struct m0_stob *stob, struct m0_stob_domain *dom, const struct m0_fid *stob_fid, void *cfg, bool create)
Definition: linux.c:376
M0_INTERNAL void m0_stob_ioq_directio_setup(struct m0_stob_ioq *ioq, bool use_directio)
Definition: ioq.c:752
static int stob_linux_domain_cfg_create_parse(const char *str_cfg_create, void **cfg_create)
Definition: linux.c:217
Definition: stob.h:163
static void stob_linux_free(struct m0_stob_domain *dom, struct m0_stob *stob)
Definition: linux.c:345
static struct m0_stob * stob
Definition: storage.c:39
#define M0_ASSERT(cond)
static char * stob_linux_file_domain_id(const char *path)
Definition: linux.c:142
#define STOB_ID_P(si)
Definition: stob.h:109
mode_t sl_mode
Definition: linux.h:62
static struct m0_stob_domain * dom
Definition: storage.c:38
static int stob_linux_fd(struct m0_stob *stob)
Definition: linux.c:541
static char * stob_linux_dir_stob(const char *path)
Definition: linux.c:137
static char * stob_linux_file_stob(const char *path, const struct m0_fid *stob_fid)
Definition: linux.c:147
uint64_t f_container
Definition: fid.h:39
static int stob_linux_domain_cfg_init_parse(const char *str_cfg_init, void **cfg_init)
Definition: linux.c:186
static int struct dentry int mode
Definition: dir.c:589
static int stob_linux_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
Definition: linux.c:460
static m0_bindex_t offset
Definition: dump.c:173
Definition: io.h:285
static uint32_t stob_linux_block_shift(struct m0_stob *stob)
Definition: linux.c:534
M0_INTERNAL int m0_stob_linux_domain_fd_put(struct m0_stob_domain *dom, int fd)
Definition: linux.c:621
M0_INTERNAL bool m0_ivec_cursor_move(struct m0_ivec_cursor *cur, m0_bcount_t count)
Definition: vec.c:718
M0_INTERNAL int m0_stob_linux_domain_fd_get(struct m0_stob_domain *dom, int *fd)
Definition: linux.c:604
M0_INTERNAL int m0_stob_ioq_init(struct m0_stob_ioq *ioq)
Definition: ioq.c:686
static struct m0_stob_io io
Definition: ad.c:59
static void stob_linux_domain_cfg_init_free(void *cfg_init)
Definition: linux.c:212
static void stob_linux_create_credit(struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
Definition: linux.c:433
char * sd_location_data
Definition: domain.h:98
static int stob_linux_domain_create(struct m0_stob_type *type, const char *location_data, uint64_t dom_key, void *cfg_create)
Definition: linux.c:320
M0_INTERNAL int m0_stob_create(struct m0_stob *stob, struct m0_dtx *dtx, const char *str_cfg)
Definition: stob.c:154
format
Definition: hist.py:128
M0_INTERNAL int m0_stob_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
Definition: stob.c:200
M0_INTERNAL enum m0_stob_state m0_stob_state_get(struct m0_stob *stob)
Definition: stob.c:265
void(* sop_fini)(struct m0_stob *stob)
Definition: stob.h:187
static int stob_linux_domain_create_destroy(struct m0_stob_type *type, const char *path, uint64_t dom_key, void *cfg, bool create)
Definition: linux.c:276
Definition: stob.h:91
static struct m0_stob_ops stob_linux_ops
Definition: linux.c:90
Definition: fid.h:38
uint64_t f_key
Definition: fid.h:40
M0_INTERNAL void m0_stob_domain__id_set(struct m0_stob_domain *dom, struct m0_fid *dom_id)
Definition: domain.c:311
#define M0_ALLOC_PTR(ptr)
Definition: memory.h:86
static void stob_linux_fini(struct m0_stob *stob)
Definition: linux.c:426
#define PRIi64
Definition: types.h:59
m0_stob_state
Definition: stob.h:81
static char * stob_linux_dir_domain(const char *path)
Definition: linux.c:132
M0_INTERNAL m0_bindex_t m0_ivec_cursor_index(const struct m0_ivec_cursor *cur)
Definition: vec.c:733
static void stob_linux_domain_cfg_create_free(void *cfg_create)
Definition: linux.c:223
static char * stob_linux_vsnprintf(const char *format,...)
Definition: linux.c:119
M0_INTERNAL bool m0_stob_linux_domain_directio(struct m0_stob_domain *dom)
Definition: linux.c:628
struct m0_stob_domain sld_dom
Definition: linux.h:48
struct m0t1fs_filedata * fd
Definition: dir.c:1030
M0_INTERNAL int m0_stob_linux_io_init(struct m0_stob *stob, struct m0_stob_io *io)
Definition: ioq.c:161
M0_INTERNAL bool m0_indexvec_is_universal(const struct m0_indexvec *iv)
Definition: vec.c:1129
M0_INTERNAL int m0_stob_find(const struct m0_stob_id *id, struct m0_stob **out)
Definition: stob.c:92
struct m0_fid_arr f_path
Definition: onwire.h:284
const struct m0_stob_domain_ops * sd_ops
Definition: domain.h:94
static void stob_linux_cfg_free(void *cfg_create)
Definition: linux.c:359
#define STOB_ID_F
Definition: stob.h:108
M0_INTERNAL struct m0_stob_linux_domain * m0_stob_linux_domain_container(struct m0_stob_domain *dom)
Definition: linux.c:106
#define out(...)
Definition: gen.c:41
int type
Definition: dir.c:1031
const struct m0_stob_type_ops * st_ops
Definition: type.h:60
static int stob_linux_cfg_parse(const char *str_cfg_create, void **cfg_create)
Definition: linux.c:352
static int stob_linux_punch(struct m0_stob *stob, struct m0_indexvec *range, struct m0_dtx *dtx)
Definition: linux.c:479
M0_INTERNAL void m0_stob_linux_conf_sdev_associate(struct m0_stob *stob, const struct m0_fid *conf_sdev)
Definition: linux.c:594
static int stob_linux_stat(struct m0_stob_linux *lstob)
Definition: linux.c:364
static int stob_linux_domain_init(struct m0_stob_type *type, const char *location_data, void *cfg_init, struct m0_stob_domain **out)
Definition: linux.c:227
void m0_free(void *data)
Definition: memory.c:146
struct m0_stob_ioq sld_ioq
Definition: linux.h:49
const struct m0_stob_type m0_stob_linux_type
Definition: linux.c:86
int32_t rc
Definition: trigger_fop.h:47
#define ARRAY_SIZE(a)
Definition: misc.h:45
static struct m0_stob_domain_ops stob_linux_domain_ops
Definition: linux.c:89
static int stob_linux_init(struct m0_stob *stob, struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
Definition: linux.c:408
static void stob_linux_write_credit(const struct m0_stob_domain *dom, const struct m0_stob_io *io, struct m0_be_tx_credit *accum)
Definition: linux.c:528
static int stob_linux_punch_credit(struct m0_stob *stob, struct m0_indexvec *want, struct m0_indexvec *got, struct m0_be_tx_credit *accum)
Definition: linux.c:452
M0_INTERNAL int m0_cleandir(const char *dir)
Definition: fs.c:25
M0_INTERNAL void m0_stob_put(struct m0_stob *stob)
Definition: stob.c:291
struct m0_stob_linux_domain * sl_dom
Definition: linux.h:58
static void stob_linux_domain_fini(struct m0_stob_domain *dom)
Definition: linux.c:267
char * sld_path
Definition: linux.h:51