Beispiel #1
0
static int
glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
{
        cmd_args_t    *cmd_args = NULL;
        struct rlimit  lim = {0, };
        call_pool_t   *pool = NULL;

        xlator_mem_acct_init (THIS, cli_mt_end);

        ctx->process_uuid = generate_uuid ();
        if (!ctx->process_uuid)
                return -1;

        ctx->page_size  = 128 * GF_UNIT_KB;

        ctx->iobuf_pool = iobuf_pool_new (8 * GF_UNIT_MB, ctx->page_size);
        if (!ctx->iobuf_pool)
                return -1;

        ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
        if (!ctx->event_pool)
                return -1;

        pool = GF_CALLOC (1, sizeof (call_pool_t),
                          cli_mt_call_pool_t);
        if (!pool)
                return -1;

        /* frame_mem_pool size 112 * 16k */
        pool->frame_mem_pool = mem_pool_new (call_frame_t, 16384);

        if (!pool->frame_mem_pool)
                return -1;

        /* stack_mem_pool size 256 * 8k */
        pool->stack_mem_pool = mem_pool_new (call_stack_t, 8192); 

        if (!pool->stack_mem_pool)
                return -1;

        ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024);
        if (!ctx->stub_mem_pool)
                return -1;

        INIT_LIST_HEAD (&pool->all_frames);
        LOCK_INIT (&pool->lock);
        ctx->pool = pool;

        pthread_mutex_init (&(ctx->lock), NULL);

        cmd_args = &ctx->cmd_args;

        INIT_LIST_HEAD (&cmd_args->xlator_options);

        lim.rlim_cur = RLIM_INFINITY;
        lim.rlim_max = RLIM_INFINITY;
        setrlimit (RLIMIT_CORE, &lim);

        return 0;
}
Beispiel #2
0
static int
logging_init (void)
{
        glusterfs_ctx_t *ctx;
        char log_file[PATH_MAX];
        int ret = -1;

        ctx = glusterfs_ctx_new ();
        if (!ctx) {
                fprintf (stderr, "glusterfs_ctx_new failed\n");
                goto out;
        }

        ret = glusterfs_globals_init (ctx);
        if (ret) {
                fprintf (stderr, "glusterfs_globals_init failed\n");
                goto out;
        }

        THIS->ctx = ctx;
        xlator_mem_acct_init (THIS, gf_common_mt_end);

        snprintf (log_file, PATH_MAX,
                  "%s/umountd.log", DEFAULT_LOG_FILE_DIRECTORY);

        ret = gf_log_init (ctx, log_file, "umountd");
        if (ret) {
                fprintf (stderr, "gf_log_init failed\n");
                goto out;
        }

        if (signal (SIGHUP, *log_rotate) == SIG_ERR) {
                gf_log ("umountd", GF_LOG_ERROR, "signal () failed");
                goto out;
        }

        ret = 0;
out:
        return ret;
}
Beispiel #3
0
static int
glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
{
        cmd_args_t    *cmd_args = NULL;
        struct rlimit  lim = {0, };
        call_pool_t   *pool = NULL;
        int            ret         = -1;

        ret = xlator_mem_acct_init (THIS, cli_mt_end);
        if (ret != 0) {
                return ret;
        }

        ctx->process_uuid = generate_glusterfs_ctx_id ();
        if (!ctx->process_uuid)
                return -1;

        ctx->page_size  = 128 * GF_UNIT_KB;

        ctx->iobuf_pool = iobuf_pool_new ();
        if (!ctx->iobuf_pool)
                return -1;

        ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE,
                                          STARTING_EVENT_THREADS);
        if (!ctx->event_pool)
                return -1;

        pool = GF_CALLOC (1, sizeof (call_pool_t),
                          cli_mt_call_pool_t);
        if (!pool)
                return -1;

        /* frame_mem_pool size 112 * 64 */
        pool->frame_mem_pool = mem_pool_new (call_frame_t, 32);
        if (!pool->frame_mem_pool)
                return -1;

        /* stack_mem_pool size 256 * 128 */
        pool->stack_mem_pool = mem_pool_new (call_stack_t, 16);

        if (!pool->stack_mem_pool)
                return -1;

        ctx->stub_mem_pool = mem_pool_new (call_stub_t, 16);
        if (!ctx->stub_mem_pool)
                return -1;

        ctx->dict_pool = mem_pool_new (dict_t, 32);
        if (!ctx->dict_pool)
                return -1;

        ctx->dict_pair_pool = mem_pool_new (data_pair_t, 512);
        if (!ctx->dict_pair_pool)
                return -1;

        ctx->dict_data_pool = mem_pool_new (data_t, 512);
        if (!ctx->dict_data_pool)
                return -1;

        ctx->logbuf_pool = mem_pool_new (log_buf_t, 256);
        if (!ctx->logbuf_pool)
                return -1;

        INIT_LIST_HEAD (&pool->all_frames);
        LOCK_INIT (&pool->lock);
        ctx->pool = pool;

        pthread_mutex_init (&(ctx->lock), NULL);

        cmd_args = &ctx->cmd_args;

        INIT_LIST_HEAD (&cmd_args->xlator_options);

        lim.rlim_cur = RLIM_INFINITY;
        lim.rlim_max = RLIM_INFINITY;
        setrlimit (RLIMIT_CORE, &lim);

        return 0;
}
Beispiel #4
0
   General Public License, version 3 or any later version (LGPLv3 or
   later), or the GNU General Public License, version 2 (GPLv2), in all
   cases as published by the Free Software Foundation.
*/
#include "xlator.h"
#include "defaults.h"
#include "read-only-common.h"
#include "read-only-mem-types.h"
#include "read-only.h"

int32_t
mem_acct_init (xlator_t *this)
{
        int     ret = -1;

        ret = xlator_mem_acct_init (this, gf_read_only_mt_end + 1);
        if (ret)
                gf_log (this->name, GF_LOG_ERROR, "Memory accounting "
                        "initialization failed.");

        return ret;
}

static int32_t
worm_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int32_t op_ret,
               int32_t op_errno, fd_t *fd, dict_t *xdata)
{
        STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd, xdata);
        return 0;
}
Beispiel #5
0
static int
glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
{
    cmd_args_t    *cmd_args = NULL;
    struct rlimit  lim = {0, };
    call_pool_t   *pool = NULL;

    xlator_mem_acct_init (THIS, gfd_mt_end);

    ctx->process_uuid = generate_uuid ();
    if (!ctx->process_uuid)
        return -1;

    ctx->page_size  = 128 * GF_UNIT_KB;

    ctx->iobuf_pool = iobuf_pool_new (8 * GF_UNIT_MB, ctx->page_size);
    if (!ctx->iobuf_pool)
        return -1;

    ctx->event_pool = event_pool_new (DEFAULT_EVENT_POOL_SIZE);
    if (!ctx->event_pool)
        return -1;

    pool = GF_CALLOC (1, sizeof (call_pool_t),
                      gfd_mt_call_pool_t);
    if (!pool)
        return -1;

    /* frame_mem_pool size 112 * 16k */
    pool->frame_mem_pool = mem_pool_new (call_frame_t, 16384);

    if (!pool->frame_mem_pool)
        return -1;

    /* stack_mem_pool size 256 * 8k */
    pool->stack_mem_pool = mem_pool_new (call_stack_t, 8192);

    if (!pool->stack_mem_pool)
        return -1;

    ctx->stub_mem_pool = mem_pool_new (call_stub_t, 1024);
    if (!ctx->stub_mem_pool)
        return -1;

    INIT_LIST_HEAD (&pool->all_frames);
    LOCK_INIT (&pool->lock);
    ctx->pool = pool;

    pthread_mutex_init (&(ctx->lock), NULL);

    cmd_args = &ctx->cmd_args;

    /* parsing command line arguments */
    cmd_args->log_level = DEFAULT_LOG_LEVEL;
#ifdef GF_DARWIN_HOST_OS
    cmd_args->mac_compat = GF_OPTION_DEFERRED;
    /* On Darwin machines, O_APPEND is not handled,
     * which may corrupt the data
     */
    cmd_args->fuse_direct_io_mode = GF_OPTION_DISABLE;
#else
    cmd_args->mac_compat = GF_OPTION_DISABLE;
    cmd_args->fuse_direct_io_mode = GF_OPTION_DEFERRED;
#endif
    cmd_args->fuse_attribute_timeout = -1;
    cmd_args->fuse_entry_timeout = -1;

    INIT_LIST_HEAD (&cmd_args->xlator_options);

    lim.rlim_cur = RLIM_INFINITY;
    lim.rlim_max = RLIM_INFINITY;
    setrlimit (RLIMIT_CORE, &lim);

    return 0;
}