22 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_STOB 31 #include <sys/types.h> 163 rc = id_file_path ==
NULL ? -EOVERFLOW : 0;
165 id_file = fopen(id_file_path,
get ?
"r" :
"w");
172 rc = fscanf(id_file,
"%"SCNx64"\n", dom_key);
173 rc =
rc == 1 ? 0 :
rc != EOF ? -EINVAL :
174 ferror(id_file) == 0 ? -EINVAL : -errno;
176 rc = fprintf(id_file,
"%"SCNx64"\n", *dom_key);
177 rc =
rc > 0 ? 0 : -EINVAL;
179 rc1 = fclose(id_file);
180 rc =
rc == 0 && rc1 != 0 ? rc1 :
rc;
182 return M0_IN(
rc, (0, -ENOENT)) ?
M0_RC(
rc) :
193 rc = cfg ==
NULL ? -ENOMEM : 0;
197 .sldc_file_flags = 0,
198 .sldc_use_directio =
false,
200 if (str_cfg_init !=
NULL) {
202 "directio=true") !=
NULL;
228 const char *location_data,
245 rc = ldom ==
NULL || path ==
NULL ? -ENOMEM : 0;
288 rc = dir_domain ==
NULL || dir_stob ==
NULL ? -ENOMEM : 0;
293 rc = mkdir(dir_domain,
mode) == 0 ? 0 : -errno;
296 rc = mkdir(dir_stob,
mode) == 0 ? 0 : -errno;
321 const char *location_data,
330 const char *location_data)
337 const struct m0_fid *stob_fid)
369 rc = fstat(lstob->
sl_fd, &statbuf);
372 lstob->
sl_mode = statbuf.st_mode;
378 const struct m0_fid *stob_fid,
392 if (file_stob ==
NULL)
395 rc =
create && cfg !=
NULL ? symlink((
char *)cfg, file_stob) : 0;
410 const struct m0_fid *stob_fid)
419 if (lstob->
sl_fd != -1) {
441 const struct m0_fid *stob_fid,
469 rc = file_stob ==
NULL ? -ENOMEM : unlink(file_stob);
485 #ifdef FALLOC_FL_PUNCH_HOLE 498 length =
count << bshift;
504 return M0_ERR(-EOVERFLOW);
505 if (
offset + length > off_max)
506 length = off_max -
offset;
513 FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
521 rc = ftruncate(lstob->
sl_fd, 0);
595 const struct m0_fid *conf_sdev)
612 return M0_ERR(-EOVERFLOW);
613 rc = open(path, O_RDONLY);
625 return close(
fd) == 0 ? 0 :
M0_ERR(-errno);
676 .ft_name =
"linuxstob",
682 #undef M0_TRACE_SUBSYSTEM M0_INTERNAL void m0_stob_ioq_fini(struct m0_stob_ioq *ioq)
M0_INTERNAL void m0_ivec_cursor_init(struct m0_ivec_cursor *cur, const struct m0_indexvec *ivec)
void(* sto_register)(struct m0_stob_type *type)
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)
int const char const void size_t int flags
M0_INTERNAL int struct dentry struct kstat * stat
M0_INTERNAL m0_bcount_t m0_ivec_cursor_step(const struct m0_ivec_cursor *cur)
static struct buffer * cur(struct m0_addb2_mach *mach, m0_bcount_t space)
const struct m0_stob_ops * so_ops
M0_INTERNAL uint32_t m0_stob_ioq_bshift(struct m0_stob_ioq *ioq)
static void stob_linux_close(struct m0_stob_linux *lstob)
static void stob_linux_destroy_credit(struct m0_stob *stob, struct m0_be_tx_credit *accum)
#define M0_LOG(level,...)
static void stob_linux_type_deregister(struct m0_stob_type *type)
M0_INTERNAL bool m0_stob_ioq_directio(struct m0_stob_ioq *ioq)
static int stob_linux_domain_destroy(struct m0_stob_type *type, const char *location_data)
M0_INTERNAL bool m0_stob_domain_is_of_type(const struct m0_stob_domain *dom, const struct m0_stob_type *dt)
M0_INTERNAL uint8_t m0_stob_type_id_get(const struct m0_stob_type *type)
static struct m0_stob_type_ops stob_linux_type_ops
M0_INTERNAL int m0_stob_linux_reopen(struct m0_stob_id *stob_id, const char *f_path)
struct m0_stob_linux_domain_cfg sld_cfg
M0_INTERNAL const struct m0_fid * m0_stob_fid_get(struct m0_stob *stob)
#define container_of(ptr, type, member)
void(* sdo_fini)(struct m0_stob_domain *dom)
struct m0_fid sl_conf_sdev
struct m0_stob_domain * so_domain
static void stob_linux_type_register(struct m0_stob_type *type)
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)
M0_INTERNAL uint32_t m0_stob_block_shift(struct m0_stob *stob)
M0_INTERNAL struct m0_stob_linux * m0_stob_linux_container(struct m0_stob *stob)
static struct m0_stob * stob_linux_alloc(struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
M0_INTERNAL bool m0_stob_domain__dom_key_is_valid(uint64_t dom_key)
#define M0_ERR_INFO(rc, fmt,...)
return M0_ERR(-EOPNOTSUPP)
static int stob_linux_domain_key_get_set(const char *path, uint64_t *dom_key, bool get)
static int stob_linux_open(struct m0_stob *stob, struct m0_stob_domain *dom, const struct m0_fid *stob_fid, void *cfg, bool create)
M0_INTERNAL void m0_stob_ioq_directio_setup(struct m0_stob_ioq *ioq, bool use_directio)
static int stob_linux_domain_cfg_create_parse(const char *str_cfg_create, void **cfg_create)
static void stob_linux_free(struct m0_stob_domain *dom, struct m0_stob *stob)
static struct m0_stob * stob
static char * stob_linux_file_domain_id(const char *path)
static struct m0_stob_domain * dom
static int stob_linux_fd(struct m0_stob *stob)
static char * stob_linux_dir_stob(const char *path)
static char * stob_linux_file_stob(const char *path, const struct m0_fid *stob_fid)
static int stob_linux_domain_cfg_init_parse(const char *str_cfg_init, void **cfg_init)
static int struct dentry int mode
static int stob_linux_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
static m0_bindex_t offset
static uint32_t stob_linux_block_shift(struct m0_stob *stob)
M0_INTERNAL int m0_stob_linux_domain_fd_put(struct m0_stob_domain *dom, int fd)
M0_INTERNAL bool m0_ivec_cursor_move(struct m0_ivec_cursor *cur, m0_bcount_t count)
M0_INTERNAL int m0_stob_linux_domain_fd_get(struct m0_stob_domain *dom, int *fd)
M0_INTERNAL int m0_stob_ioq_init(struct m0_stob_ioq *ioq)
static struct m0_stob_io io
static void stob_linux_domain_cfg_init_free(void *cfg_init)
static void stob_linux_create_credit(struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
static int stob_linux_domain_create(struct m0_stob_type *type, const char *location_data, uint64_t dom_key, void *cfg_create)
M0_INTERNAL int m0_stob_create(struct m0_stob *stob, struct m0_dtx *dtx, const char *str_cfg)
M0_INTERNAL int m0_stob_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
M0_INTERNAL enum m0_stob_state m0_stob_state_get(struct m0_stob *stob)
void(* sop_fini)(struct m0_stob *stob)
static int stob_linux_domain_create_destroy(struct m0_stob_type *type, const char *path, uint64_t dom_key, void *cfg, bool create)
static struct m0_stob_ops stob_linux_ops
M0_INTERNAL void m0_stob_domain__id_set(struct m0_stob_domain *dom, struct m0_fid *dom_id)
#define M0_ALLOC_PTR(ptr)
static void stob_linux_fini(struct m0_stob *stob)
static char * stob_linux_dir_domain(const char *path)
M0_INTERNAL m0_bindex_t m0_ivec_cursor_index(const struct m0_ivec_cursor *cur)
static void stob_linux_domain_cfg_create_free(void *cfg_create)
static char * stob_linux_vsnprintf(const char *format,...)
M0_INTERNAL bool m0_stob_linux_domain_directio(struct m0_stob_domain *dom)
struct m0_stob_domain sld_dom
struct m0t1fs_filedata * fd
M0_INTERNAL int m0_stob_linux_io_init(struct m0_stob *stob, struct m0_stob_io *io)
M0_INTERNAL bool m0_indexvec_is_universal(const struct m0_indexvec *iv)
M0_INTERNAL int m0_stob_find(const struct m0_stob_id *id, struct m0_stob **out)
const struct m0_stob_domain_ops * sd_ops
static void stob_linux_cfg_free(void *cfg_create)
M0_INTERNAL struct m0_stob_linux_domain * m0_stob_linux_domain_container(struct m0_stob_domain *dom)
const struct m0_stob_type_ops * st_ops
static int stob_linux_cfg_parse(const char *str_cfg_create, void **cfg_create)
static int stob_linux_punch(struct m0_stob *stob, struct m0_indexvec *range, struct m0_dtx *dtx)
M0_INTERNAL void m0_stob_linux_conf_sdev_associate(struct m0_stob *stob, const struct m0_fid *conf_sdev)
static int stob_linux_stat(struct m0_stob_linux *lstob)
static int stob_linux_domain_init(struct m0_stob_type *type, const char *location_data, void *cfg_init, struct m0_stob_domain **out)
struct m0_stob_ioq sld_ioq
const struct m0_stob_type m0_stob_linux_type
static struct m0_stob_domain_ops stob_linux_domain_ops
static int stob_linux_init(struct m0_stob *stob, struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
static void stob_linux_write_credit(const struct m0_stob_domain *dom, const struct m0_stob_io *io, struct m0_be_tx_credit *accum)
static int stob_linux_punch_credit(struct m0_stob *stob, struct m0_indexvec *want, struct m0_indexvec *got, struct m0_be_tx_credit *accum)
M0_INTERNAL int m0_cleandir(const char *dir)
M0_INTERNAL void m0_stob_put(struct m0_stob *stob)
struct m0_stob_linux_domain * sl_dom
static void stob_linux_domain_fini(struct m0_stob_domain *dom)