23 #define M0_TRACE_SUBSYSTEM M0_TRACE_SUBSYS_STOB 28 #include <sys/mount.h> 30 #include <sys/types.h> 165 #define STOB_PERF_DOM_CONFIG_PATH "/config" 166 #define STOB_PERF_DOM_LDOM_PATH "/backstore" 220 if (str_cfg_create !=
NULL) {
229 if (cfg_create !=
NULL)
237 config_path =
m0_alloc(strlen(location_data) +
239 if (config_path !=
NULL) {
240 strcpy(config_path, location_data);
250 #define __LINUXSTOB "linuxstob:" 253 if (ldom_location !=
NULL) {
255 strcat(ldom_location, location_data);
259 return ldom_location;
268 (strstr(cfg_str,
"null=true") !=
NULL ||
269 strstr(cfg_str,
"null=1") !=
NULL);
281 const char *location_data)
286 bool cfg_allocated =
false;
293 if (config_path ==
NULL)
296 rc =
stat(config_path, &st);
299 len = st.st_size + 1;
304 cfg_allocated =
true;
305 f = fopen(config_path,
"r");
309 read = fread(cfg_str, 1, len - 1,
f);
310 rc = ferror(
f) != 0 ?
M0_ERR(-errno) : 0;
313 cfg_str[read] =
'\0';
329 const char *location_data)
338 if (config_path ==
NULL)
341 f = fopen(config_path,
"w");
343 if (
rc == 0 && cfg_str !=
NULL) {
344 written = fwrite(cfg_str, 1, strlen(cfg_str),
f);
345 if (written != strlen(cfg_str))
350 rc2 = rc2 == EOF ?
M0_ERR(-errno) : 0;
359 const char *location_data,
375 if (pdom ==
NULL || ldom_location ==
NULL) {
415 (void)umount(location_data);
416 rc = rmdir(location_data);
430 static char sfx[] = {
'M',
'G',
'T' };
435 if (
size >= 1024 * 1024 * 1024)
436 return M0_ERR(-EOVERFLOW);
438 for (
i = 0;
size >= 1024; ++
i)
440 rc = snprintf(opts, opts_len,
"size=%zu%c",
size, sfx[
i]);
448 const char *location_data,
454 const char *cfg_str = cfg_create;
457 bool dir_created =
false;
466 if (ldom_location ==
NULL)
469 rc = mkdir(location_data, 0700);
471 #ifdef STOB_PERF_DOMAIN_CREATE_FORCE 476 rc = mkdir(location_data, 0700);
483 rc = mount(
"none", location_data,
"tmpfs", MS_NODEV | MS_NOEXEC,
499 if (
rc != 0 && dir_created)
506 const char *location_data)
511 if (ldom_location ==
NULL)
530 const struct m0_fid *stob_fid)
559 const struct m0_fid *stob_fid,
562 *lstob_fid = *stob_fid;
568 const struct m0_fid *stob_fid,
575 const char *create_cfg;
623 pio = stob_perf_ios_tlist_pop(&pstob->
sp_ios);
625 if (!stob_perf_ios_tlist_is_empty(&pstob->
sp_ios)) {
626 pio2 = stob_perf_ios_tlist_head(&pstob->
sp_ios);
652 const struct m0_fid *stob_fid)
671 pstob->sp_pdom = pdom;
672 pstob->sp_backstore = lstob;
673 stob_perf_ios_tlist_init(&pstob->sp_ios);
691 stob_perf_ios_tlist_fini(&pstob->
sp_ios);
712 const struct m0_fid *stob_fid,
804 if (stob_perf_ios_tlist_is_empty(&pstob->
sp_ios))
806 stob_perf_ios_tlist_add_tail(&pstob->
sp_ios, pio);
846 stob_perf_ios_tlink_init(pio);
878 stob_perf_ios_tlink_fini(pio);
928 .ft_name =
"perfstob",
934 #undef M0_TRACE_SUBSYSTEM struct m0_clink spi_clink
static int stob_perf_domain_tmpfs_opts(char *opts, size_t opts_len, struct stob_perf_domain_cfg *cfg)
const struct m0_stob_type m0_stob_perf_type
static int stob_perf_cfg_parse(const char *str_cfg_create, void **cfg_create)
enum m0_stob_io_flags si_flags
M0_INTERNAL void m0_mutex_unlock(struct m0_mutex *mutex)
M0_INTERNAL uint64_t m0_stob_domain__dom_key(const struct m0_fid *dom_id)
void(* sto_register)(struct m0_stob_type *type)
M0_INTERNAL void m0_chan_broadcast_lock(struct m0_chan *chan)
M0_INTERNAL void m0_stob_io_fini(struct m0_stob_io *io)
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)
M0_INTERNAL struct m0_locality * m0_locality_get(uint64_t value)
M0_INTERNAL int struct dentry struct kstat * stat
M0_INTERNAL void m0_clink_init(struct m0_clink *link, m0_chan_cb_t cb)
M0_INTERNAL void m0_clink_del(struct m0_clink *link)
static void stob_perf_linux_fid_set(struct m0_fid *lstob_fid, const struct m0_fid *stob_fid, struct stob_perf_domain *pdom)
static const struct m0_stob_io_op stob_perf_io_ops
M0_INTERNAL int m0_stob_locate(struct m0_stob *stob)
struct stob_perf * spi_pstob
const struct m0_stob_ops * so_ops
M0_INTERNAL void m0_stob_io_credit(const struct m0_stob_io *io, const struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
void(* sa_cb)(struct m0_sm_group *grp, struct m0_sm_ast *)
static int stob_perf_domain_destroy(struct m0_stob_type *type, const char *location_data)
static int stob_perf_domain_read_config(struct stob_perf_domain *pdom, const char *location_data)
struct stob_perf_domain * sp_pdom
static struct m0_sm_group * grp
static int stob_perf_io_init(struct m0_stob *stob, struct m0_stob_io *io)
#define M0_LOG(level,...)
M0_INTERNAL int m0_stob_find_by_key(struct m0_stob_domain *dom, const struct m0_fid *stob_fid, struct m0_stob **out)
static void stob_perf_ast_cb(struct m0_sm_group *grp, struct m0_sm_ast *ast)
M0_INTERNAL const struct m0_fid * m0_stob_domain_id_get(const struct m0_stob_domain *dom)
M0_INTERNAL void m0_sm_ast_post(struct m0_sm_group *grp, struct m0_sm_ast *ast)
static bool stob_perf_io_lio_completed(struct m0_clink *clink)
static void stob_perf_timer_start(struct stob_perf *pstob, struct stob_perf_io *pio)
static void stob_perf_domain_cfg_create_free(void *cfg_create)
static void stob_perf_fini(struct m0_stob *stob)
const struct m0_stob_io_op * si_op
M0_INTERNAL uint8_t m0_stob_type_id_get(const struct m0_stob_type *type)
static void stob_perf_consume_io(struct stob_perf_io *pio)
M0_INTERNAL int m0_timer_init(struct m0_timer *timer, enum m0_timer_type type, struct m0_timer_locality *loc, m0_timer_callback_t callback, unsigned long data)
static void stob_perf_domain_cfg_init_free(void *cfg_init)
#define container_of(ptr, type, member)
void(* sdo_fini)(struct m0_stob_domain *dom)
M0_INTERNAL void m0_mutex_lock(struct m0_mutex *mutex)
static int stob_perf_domain_cfg_create_parse(const char *str_cfg_create, void **cfg_create)
static int stob_perf_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
int(* sio_launch)(struct m0_stob_io *io)
static int stob_perf_domain_dir_clean(const char *location_data)
static int stob_perf_punch(struct m0_stob *stob, struct m0_indexvec *range, struct m0_dtx *dtx)
static void stob_perf_free(struct m0_stob_domain *dom, struct m0_stob *stob)
M0_INTERNAL uint32_t m0_stob_block_shift(struct m0_stob *stob)
M0_INTERNAL void m0_timer_fini(struct m0_timer *timer)
static struct m0_sm_ast ast[NR]
static int stob_perf_init(struct m0_stob *stob, struct m0_stob_domain *dom, const struct m0_fid *stob_fid)
static struct m0_stob * stob_perf_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)
M0_INTERNAL int m0_stob_domain_create(const char *location, const char *str_cfg_init, uint64_t dom_key, const char *str_cfg_create, struct m0_stob_domain **out)
static void stob_perf_type_deregister(struct m0_stob_type *type)
return M0_ERR(-EOPNOTSUPP)
static int stob_perf_punch_credit(struct m0_stob *stob, struct m0_indexvec *want, struct m0_indexvec *got, struct m0_be_tx_credit *accum)
static char * stob_perf_domain_config(const char *location_data)
M0_INTERNAL int m0_stob_io_prepare_and_launch(struct m0_stob_io *io, struct m0_stob *obj, struct m0_dtx *tx, struct m0_io_scope *scope)
M0_INTERNAL void m0_timer_stop(struct m0_timer *timer)
struct m0_indexvec si_stob
#define STOB_PERF_DOM_CONFIG_PATH
static struct m0_stob * stob
static struct m0_stob_ops stob_perf_ops
M0_INTERNAL void m0_timer_start(struct m0_timer *timer, m0_time_t expire)
M0_INTERNAL void m0_stob_destroy_credit(struct m0_stob *stob, struct m0_be_tx_credit *accum)
static struct stob_perf_domain * stob_perf_domain_container(struct m0_stob_domain *dom)
static void stob_perf_write_credit(const struct m0_stob_domain *dom, const struct m0_stob_io *io, struct m0_be_tx_credit *accum)
static void stob_perf_domain_fini(struct m0_stob_domain *dom)
stob_perf_latency_cb_t spc_latency_cb
static struct m0_stob_domain * dom
static void stob_perf_io_completed(struct stob_perf_io *pio)
void * m0_alloc(size_t size)
M0_INTERNAL void m0_mutex_init(struct m0_mutex *mutex)
struct m0_sm_group * lo_grp
static int stob_perf_io_launch(struct m0_stob_io *io)
enum m0_stob_io_state si_state
static struct m0_clink clink[RDWR_REQUEST_MAX]
struct m0_stob_domain spd_dom
m0_time_t(* stob_perf_latency_cb_t)(struct stob_perf_io *)
static struct m0_stob_io io
struct m0_stob_io spi_lio
M0_TL_DESCR_DEFINE(stob_perf_ios, "List of perfstob I/O", static, struct stob_perf_io, spi_link, spi_magic, M0_STOB_PERF_IO_MAGIC, M0_STOB_PERF_IO_HEAD_MAGIC)
static void stob_perf_cfg_free(void *cfg_create)
M0_INTERNAL void m0_stob_domain_fini(struct m0_stob_domain *dom)
M0_INTERNAL int m0_stob_create(struct m0_stob *stob, struct m0_dtx *dtx, const char *str_cfg)
void m0_clink_add_lock(struct m0_chan *chan, struct m0_clink *link)
static uint32_t stob_perf_block_shift(struct m0_stob *stob)
M0_INTERNAL int m0_stob_punch_credit(struct m0_stob *stob, struct m0_indexvec *want, struct m0_indexvec *got, struct m0_be_tx_credit *accum)
M0_INTERNAL int m0_stob_domain_destroy_location(const char *location)
static struct stob_perf * stob_perf_container(struct m0_stob *stob)
static int stob_perf_domain_init(struct m0_stob_type *type, const char *location_data, void *cfg_init, struct m0_stob_domain **out)
static void stob_perf_domain_cfg_parse(struct stob_perf_domain_cfg *cfg, const char *cfg_str)
M0_INTERNAL int m0_stob_destroy(struct m0_stob *stob, struct m0_dtx *dtx)
static int stob_perf_domain_cfg_init_parse(const char *str_cfg_init, void **cfg_init)
static unsigned long stob_perf_timer_cb(unsigned long data)
M0_INTERNAL enum m0_stob_state m0_stob_state_get(struct m0_stob *stob)
void(* sop_fini)(struct m0_stob *stob)
static struct m0_stob_type_ops stob_perf_type_ops
M0_INTERNAL int m0_stob_domain_init(const char *location, const char *str_cfg_init, struct m0_stob_domain **out)
M0_INTERNAL void m0_fid_tchange(struct m0_fid *fid, uint8_t tid)
static int stob_perf_linux_init_create(struct stob_perf_domain *pdom, const struct m0_fid *stob_fid, struct m0_dtx *dtx, bool create, struct m0_stob **out)
static void stob_perf_io_fini(struct m0_stob_io *io)
M0_INTERNAL void m0_stob_domain__id_set(struct m0_stob_domain *dom, struct m0_fid *dom_id)
#define M0_ALLOC_PTR(ptr)
M0_INTERNAL int m0_stob_fd(struct m0_stob *stob)
m0_time_t m0_time_from_now(uint64_t secs, long ns)
static int stob_perf_domain_write_config(const char *cfg_str, uint64_t dom_key, const char *location_data)
M0_INTERNAL void m0_mutex_fini(struct m0_mutex *mutex)
M0_INTERNAL void m0_clink_fini(struct m0_clink *link)
static int stob_perf_create(struct m0_stob *stob, struct m0_stob_domain *dom, struct m0_dtx *dtx, const struct m0_fid *stob_fid, void *cfg)
static m0_time_t stob_perf_latency_const(struct stob_perf_io *pio)
M0_INTERNAL void m0_stob_io_init(struct m0_stob_io *io)
const struct m0_stob_domain_ops * sd_ops
static char * stob_perf_domain_ldom_location(const char *location_data)
struct stob_perf_domain_cfg spd_cfg
struct stob_perf_stats sp_stats
M0_INTERNAL int m0_stob_punch(struct m0_stob *stob, struct m0_indexvec *range, struct m0_dtx *dtx)
M0_INTERNAL void m0_stob_create_credit(struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
struct m0_stob_domain * spd_ldom
struct m0_stob_io * spi_io
const struct m0_stob_type_ops * st_ops
static void stob_perf_type_register(struct m0_stob_type *type)
M0_TL_DEFINE(stob_perf_ios, static, struct stob_perf_io)
static int stob_perf_fd(struct m0_stob *stob)
static int stob_perf_domain_create(struct m0_stob_type *type, const char *location_data, uint64_t dom_key, void *cfg_create)
static struct m0_stob_domain_ops stob_perf_domain_ops
struct m0_io_scope * si_scope
static void stob_perf_create_credit(struct m0_stob_domain *dom, struct m0_be_tx_credit *accum)
M0_INTERNAL uint8_t m0_stob_domain__type_id(const struct m0_fid *dom_id)
M0_INTERNAL void m0_stob_put(struct m0_stob *stob)
struct m0_stob * sp_backstore
static void stob_perf_destroy_credit(struct m0_stob *stob, struct m0_be_tx_credit *accum)
#define STOB_PERF_DOM_LDOM_PATH
enum m0_stob_io_opcode si_opcode