glusterfs  8.6
About: GlusterFS is a network/cluster filesystem. The storage server (or each in a cluster) runs glusterfsd and the clients use mount command or glusterfs client to mount the exported filesystem. Release series 8.x.
  Fossies Dox: glusterfs-8.6.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

glusterfsd.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/resource.h>
#include <sys/file.h>
#include <sys/wait.h>
#include <netdb.h>
#include <signal.h>
#include <libgen.h>
#include <dlfcn.h>
#include <sys/utsname.h>
#include <stdint.h>
#include <pthread.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <time.h>
#include <semaphore.h>
#include <errno.h>
#include <pwd.h>
#include <glusterfs/xlator.h>
#include <glusterfs/glusterfs.h>
#include <glusterfs/compat.h>
#include <glusterfs/logging.h>
#include "glusterfsd-messages.h"
#include <glusterfs/dict.h>
#include <glusterfs/list.h>
#include <glusterfs/timer.h>
#include "glusterfsd.h"
#include <glusterfs/revision.h>
#include <glusterfs/common-utils.h>
#include <glusterfs/gf-event.h>
#include <glusterfs/statedump.h>
#include <glusterfs/latency.h>
#include "glusterfsd-mem-types.h"
#include <glusterfs/syscall.h>
#include <glusterfs/call-stub.h>
#include <fnmatch.h>
#include "rpc-clnt.h"
#include <glusterfs/syncop.h>
#include <glusterfs/client_t.h>
#include "netgroups.h"
#include "exports.h"
#include <glusterfs/monitoring.h>
#include <glusterfs/daemon.h>
Include dependency graph for glusterfsd.c:

Go to the source code of this file.

Macros

#define DICT_SET_VAL(method, dict, key, val, msgid)
 

Functions

static error_t parse_opts (int32_t key, char *arg, struct argp_state *_state)
 
int glusterfs_pidfile_cleanup (glusterfs_ctx_t *ctx)
 
int glusterfs_volumes_init (glusterfs_ctx_t *ctx)
 
int glusterfs_mgmt_init (glusterfs_ctx_t *ctx)
 
int glusterfs_listener_init (glusterfs_ctx_t *ctx)
 
static int set_fuse_mount_options (glusterfs_ctx_t *ctx, dict_t *options)
 
int create_fuse_mount (glusterfs_ctx_t *ctx)
 
static FILE * get_volfp (glusterfs_ctx_t *ctx)
 
static int gf_remember_backup_volfile_server (char *arg)
 
static int gf_remember_xlator_option (char *arg)
 
static error_t parse_opts (int key, char *arg, struct argp_state *state)
 
bool should_call_fini (glusterfs_ctx_t *ctx, xlator_t *trav)
 
void cleanup_and_exit (int signum)
 
static void reincarnate (int signum)
 
void emancipate (glusterfs_ctx_t *ctx, int ret)
 
static uint8_t gf_get_process_mode (char *exec_name)
 
static int glusterfs_ctx_defaults_init (glusterfs_ctx_t *ctx)
 
static int logging_init (glusterfs_ctx_t *ctx, const char *progpath)
 
void gf_check_and_set_mem_acct (int argc, char *argv[])
 
int print_exports_file (const char *exports_file)
 
int print_netgroups_file (const char *netgroups_file)
 
int parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
 
int glusterfs_pidfile_setup (glusterfs_ctx_t *ctx)
 
int glusterfs_pidfile_update (glusterfs_ctx_t *ctx, pid_t pid)
 
void * glusterfs_sigwaiter (void *arg)
 
void glusterfsd_print_trace (int signum)
 
int glusterfs_signals_setup (glusterfs_ctx_t *ctx)
 
int daemonize (glusterfs_ctx_t *ctx)
 
int glusterfs_process_volfp (glusterfs_ctx_t *ctx, FILE *fp)
 
int main (int argc, char *argv[])
 

Variables

static char gf_doc [] = ""
 
static char argp_doc []
 
const char * argp_program_version
 
const char * argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"
 
static struct argp_option gf_options []
 
static struct argp argp = {gf_options, parse_opts, argp_doc, gf_doc}
 
glusterfs_ctx_tglusterfsd_ctx
 

Macro Definition Documentation

◆ DICT_SET_VAL

#define DICT_SET_VAL (   method,
  dict,
  key,
  val,
  msgid 
)
Value:
if (method(dict, key, val)) { \
gf_smsg("glusterfsd", GF_LOG_ERROR, 0, msgid, "key=%s", key); \
goto err; \
}
#define err(x...)
Definition: gcrawler.c:34
@ GF_LOG_ERROR
Definition: logging.h:73

Definition at line 302 of file glusterfsd.c.

Function Documentation

◆ cleanup_and_exit()

◆ create_fuse_mount()

◆ daemonize()

◆ emancipate()

◆ get_volfp()

static FILE * get_volfp ( glusterfs_ctx_t ctx)
static

◆ gf_check_and_set_mem_acct()

void gf_check_and_set_mem_acct ( int  argc,
char *  argv[] 
)

Definition at line 1779 of file glusterfsd.c.

References gf_global_mem_acct_enable_set().

Referenced by main().

◆ gf_get_process_mode()

static uint8_t gf_get_process_mode ( char *  exec_name)
static

Definition at line 1542 of file glusterfsd.c.

References GF_CLIENT_PROCESS, GF_FREE, GF_GLUSTERD_PROCESS, GF_SERVER_PROCESS, and gf_strdup().

Referenced by parse_cmdline().

◆ gf_remember_backup_volfile_server()

static int gf_remember_backup_volfile_server ( char *  arg)
static

◆ gf_remember_xlator_option()

◆ glusterfs_ctx_defaults_init()

static int glusterfs_ctx_defaults_init ( glusterfs_ctx_t ctx)
static

Definition at line 1564 of file glusterfsd.c.

References call_pool::all_frames, _glusterfs_ctx::cleanup_lock, _glusterfs_ctx::clienttable, _glusterfs_ctx::cmd_args, DEFAULT_EVENT_POOL_SIZE, DEFAULT_LOG_LEVEL, _glusterfs_ctx::dict_data_pool, _glusterfs_ctx::dict_pair_pool, _glusterfs_ctx::dict_pool, _glusterfs_ctx::event_pool, _glusterfs_ctx::fd_cond, _glusterfs_ctx::fd_lock, _cmd_args::fopen_keep_cache, call_pool::frame_mem_pool, _cmd_args::fuse_attribute_timeout, _cmd_args::fuse_direct_io_mode, _cmd_args::fuse_entry_timeout, _cmd_args::fuse_flush_handle_interrupt, generate_glusterfs_ctx_id(), GF_CALLOC, gf_clienttable_alloc(), gf_event_pool_new(), GF_FREE, GF_LOG_CRITICAL, GF_LOG_FLUSH_TIMEOUT_DEFAULT, GF_LOG_LRU_BUFSIZE_DEFAULT, gf_logformat_withmsgid, gf_logger_glusterlog, GF_MEMPOOL_COUNT_OF_DATA_PAIR_T, GF_MEMPOOL_COUNT_OF_DATA_T, GF_MEMPOOL_COUNT_OF_DICT_T, GF_MEMPOOL_COUNT_OF_LRU_BUF_T, GF_OPTION_DEFERRED, GF_OPTION_DISABLE, gf_smsg, GF_UNIT_KB, gfd_mt_call_pool_t, gfd_mt_end, glusterfsd_msg_13, glusterfsd_msg_14, glusterfsd_msg_34, INIT_LIST_HEAD, _glusterfs_ctx::iobuf_pool, iobuf_pool_new(), _glusterfs_ctx::janitor_fds, _cmd_args::kernel_writeback_cache, call_pool::lock, LOCK_INIT, _cmd_args::log_buf_size, _cmd_args::log_flush_timeout, _cmd_args::log_format, _cmd_args::log_level, _glusterfs_ctx::logbuf_pool, _cmd_args::logger, _cmd_args::mac_compat, _glusterfs_ctx::measure_latency, _cmd_args::mem_acct, _glusterfs_ctx::mem_acct_enable, mem_pool_destroy(), mem_pool_new, _glusterfs_ctx::notify_cond, _glusterfs_ctx::notify_lock, out, _glusterfs_ctx::page_size, _glusterfs_ctx::pool, _glusterfs_ctx::process_uuid, _glusterfs_ctx::pxl_count, call_pool::stack_mem_pool, STARTING_EVENT_THREADS, _glusterfs_ctx::stub_mem_pool, THIS, _cmd_args::volfile_servers, xlator_mem_acct_init(), and _cmd_args::xlator_options.

Referenced by main().

◆ glusterfs_listener_init()

◆ glusterfs_mgmt_init()

◆ glusterfs_pidfile_cleanup()

int glusterfs_pidfile_cleanup ( glusterfs_ctx_t ctx)

◆ glusterfs_pidfile_setup()

int glusterfs_pidfile_setup ( glusterfs_ctx_t ctx)

◆ glusterfs_pidfile_update()

int glusterfs_pidfile_update ( glusterfs_ctx_t ctx,
pid_t  pid 
)

◆ glusterfs_process_volfp()

◆ glusterfs_signals_setup()

◆ glusterfs_sigwaiter()

void * glusterfs_sigwaiter ( void *  arg)

◆ glusterfs_volumes_init()

◆ glusterfsd_print_trace()

void glusterfsd_print_trace ( int  signum)

Definition at line 2275 of file glusterfsd.c.

References gf_print_trace(), and glusterfsd_ctx.

Referenced by glusterfs_signals_setup().

◆ logging_init()

◆ main()

◆ parse_cmdline()

◆ parse_opts() [1/2]

static error_t parse_opts ( int  key,
char *  arg,
struct argp_state *  state 
)
static

Definition at line 764 of file glusterfsd.c.

References _gf_false, _gf_true, _cmd_args::acl, ARGP_ACL_KEY, ARGP_ATTR_TIMES_GRANULARITY_KEY, ARGP_ATTRIBUTE_TIMEOUT_KEY, ARGP_AUX_GFID_MOUNT_KEY, ARGP_BRICK_MUX_KEY, ARGP_BRICK_NAME_KEY, ARGP_BRICK_PORT_KEY, ARGP_CAPABILITY_KEY, ARGP_CLIENT_PID_KEY, ARGP_DEBUG_KEY, ARGP_DIRECT_IO_MODE_KEY, ARGP_DUMP_FUSE_KEY, ARGP_ENTRY_TIMEOUT_KEY, ARGP_FOPEN_KEEP_CACHE_KEY, ARGP_FUSE_AUTO_INVAL_KEY, ARGP_FUSE_BACKGROUND_QLEN_KEY, ARGP_FUSE_CONGESTION_THRESHOLD_KEY, ARGP_FUSE_DEV_EPERM_RATELIMIT_NS_KEY, ARGP_FUSE_EVENT_HISTORY_KEY, ARGP_FUSE_FLUSH_HANDLE_INTERRUPT_KEY, ARGP_FUSE_INVALIDATE_LIMIT_KEY, ARGP_FUSE_LRU_LIMIT_KEY, ARGP_FUSE_MOUNTOPTS_KEY, ARGP_FUSE_NO_ROOT_SQUASH_KEY, ARGP_FUSE_USE_READDIRP_KEY, ARGP_GID_TIMEOUT_KEY, ARGP_GLOBAL_THREADING_KEY, ARGP_GLOBAL_TIMER_WHEEL, ARGP_INODE32_KEY, ARGP_KERNEL_WRITEBACK_CACHE_KEY, ARGP_LOCALTIME_LOGGING_KEY, ARGP_LOG_BUF_SIZE, ARGP_LOG_FILE_KEY, ARGP_LOG_FLUSH_TIMEOUT, ARGP_LOG_FORMAT, ARGP_LOG_LEVEL_CRITICAL_OPTION, ARGP_LOG_LEVEL_DEBUG_OPTION, ARGP_LOG_LEVEL_ERROR_OPTION, ARGP_LOG_LEVEL_INFO_OPTION, ARGP_LOG_LEVEL_KEY, ARGP_LOG_LEVEL_NONE_OPTION, ARGP_LOG_LEVEL_TRACE_OPTION, ARGP_LOG_LEVEL_WARNING_OPTION, ARGP_LOGGER, ARGP_MAC_COMPAT_KEY, ARGP_MEM_ACCOUNTING_KEY, ARGP_NEGATIVE_TIMEOUT_KEY, ARGP_NO_DAEMON_KEY, ARGP_PID_FILE_KEY, ARGP_PRINT_EXPORTS, ARGP_PRINT_LIBEXECDIR_KEY, ARGP_PRINT_LOGDIR_KEY, ARGP_PRINT_NETGROUPS, ARGP_PRINT_STATEDUMPDIR_KEY, ARGP_PRINT_XLATORDIR_KEY, ARGP_PROCESS_NAME_KEY, ARGP_READ_ONLY_KEY, ARGP_READER_THREAD_COUNT_KEY, ARGP_RESOLVE_GIDS_KEY, ARGP_RUN_ID_KEY, ARGP_SECURE_MGMT_KEY, ARGP_SELINUX_KEY, ARGP_SOCK_FILE_KEY, ARGP_SUBDIR_MOUNT_KEY, ARGP_THIN_CLIENT_KEY, ARGP_USER_MAP_ROOT_KEY, ARGP_VOLFILE_CHECK_KEY, ARGP_VOLFILE_ID_KEY, ARGP_VOLFILE_MAX_FETCH_ATTEMPTS, ARGP_VOLFILE_SERVER_KEY, ARGP_VOLFILE_SERVER_PORT_KEY, ARGP_VOLFILE_SERVER_TRANSPORT_KEY, ARGP_VOLUME_FILE_KEY, ARGP_VOLUME_NAME_KEY, ARGP_WORM_KEY, ARGP_XLATOR_OPTION_KEY, _cmd_args::attr_times_granularity, _cmd_args::aux_gfid_mount, _cmd_args::background_qlen, _cmd_args::brick_mux, _cmd_args::brick_name, _cmd_args::brick_port, _cmd_args::brick_port2, _cmd_args::capability, _cmd_args::client_pid, _cmd_args::client_pid_set, _cmd_args::congestion_threshold, _cmd_args::debug_mode, _cmd_args::dump_fuse, ENABLE_DEBUG_MODE, _cmd_args::enable_ino32, ENABLE_NO_DAEMON_MODE, _cmd_args::event_history, _cmd_args::fopen_keep_cache, _cmd_args::fuse_attribute_timeout, _cmd_args::fuse_auto_inval, _cmd_args::fuse_dev_eperm_ratelimit_ns, _cmd_args::fuse_direct_io_mode, _cmd_args::fuse_entry_timeout, _cmd_args::fuse_flush_handle_interrupt, _cmd_args::fuse_mountopts, _cmd_args::fuse_negative_timeout, gf_asprintf(), gf_boolean_t, GF_FREE, GF_LOG_CRITICAL, GF_LOG_DEBUG, GF_LOG_ERROR, GF_LOG_FLUSH_TIMEOUT_MAX, GF_LOG_FLUSH_TIMEOUT_MAX_STR, GF_LOG_FLUSH_TIMEOUT_MIN, GF_LOG_FLUSH_TIMEOUT_MIN_STR, GF_LOG_FORMAT_NO_MSG_ID, GF_LOG_FORMAT_WITH_MSG_ID, GF_LOG_INFO, GF_LOG_LRU_BUFSIZE_MAX, GF_LOG_LRU_BUFSIZE_MAX_STR, GF_LOG_LRU_BUFSIZE_MIN_STR, GF_LOG_NONE, GF_LOG_TRACE, GF_LOG_WARNING, gf_logformat_traditional, gf_logformat_withmsgid, GF_LOGGER_GLUSTER_LOG, gf_logger_glusterlog, GF_LOGGER_SYSLOG, gf_logger_syslog, gf_remember_backup_volfile_server(), gf_remember_xlator_option(), gf_strdup(), gf_string2boolean(), gf_string2double(), gf_string2int(), gf_string2int32(), gf_string2uint32(), gf_string2uint_base10(), _cmd_args::gid_timeout, _cmd_args::gid_timeout_set, _cmd_args::global_threading, _cmd_args::global_timer_wheel, _cmd_args::invalidate_limit, _cmd_args::kernel_writeback_cache, _cmd_args::localtime_logging, _cmd_args::log_buf_size, _cmd_args::log_file, _cmd_args::log_flush_timeout, _cmd_args::log_format, _cmd_args::log_level, _cmd_args::logger, _cmd_args::lru_limit, _cmd_args::mac_compat, _cmd_args::max_connect_attempts, _cmd_args::mount_point, _cmd_args::no_daemon_mode, _cmd_args::no_root_squash, _cmd_args::pid_file, _cmd_args::print_exports, _cmd_args::print_libexecdir, _cmd_args::print_logdir, _cmd_args::print_netgroups, _cmd_args::print_statedumpdir, _cmd_args::print_xlatordir, _cmd_args::process_name, _cmd_args::read_only, _cmd_args::reader_thread_count, _cmd_args::resolve_gids, _cmd_args::run_id, _cmd_args::secure_mgmt, _cmd_args::selinux, _cmd_args::sock_file, _cmd_args::subdir_mount, _cmd_args::thin_client, _cmd_args::uid_map_root, _cmd_args::use_readdirp, _cmd_args::volfile, _cmd_args::volfile_check, _cmd_args::volfile_id, _cmd_args::volfile_server_port, _cmd_args::volfile_server_transport, _cmd_args::volume_name, and _cmd_args::worm.

◆ parse_opts() [2/2]

static error_t parse_opts ( int32_t  key,
char *  arg,
struct argp_state *  _state 
)
static

◆ print_exports_file()

int print_exports_file ( const char *  exports_file)

print_exports_file - Print out & verify the syntax of the exports file specified in the parameter.

@exports_file : Path of the exports file to print & verify

Returns
: success: 0 when successfully parsed failure: 1 when failed to parse one or more lines -1 when other critical errors (dlopen () etc) Critical errors are treated differently than parse errors. Critical errors terminate the program immediately here and print out different error messages. Hence there are different return values.

Definition at line 1806 of file glusterfsd.c.

References exp_file_deinit(), exp_file_parse(), exp_file_print(), gf_asprintf(), GF_FREE, gf_log, GF_LOG_CRITICAL, and out.

Referenced by main().

◆ print_netgroups_file()

int print_netgroups_file ( const char *  netgroups_file)

print_netgroups_file - Print out & verify the syntax of the netgroups file specified in the parameter.

@netgroups_file : Path of the netgroups file to print & verify

Returns
: success: 0 when successfully parsed failure: 1 when failed to parse one more more lines -1 when other critical errors (dlopen () etc)

We have multiple returns here because for critical errors, we abort operations immediately and exit. For example, if we can't load the NFS server library, then we have a real bad problem so we don't continue. Or if we cannot allocate anymore memory, we don't want to continue. Also, we want to print out a different error messages based on the ret value.

Definition at line 1902 of file glusterfsd.c.

References gf_asprintf(), GF_FREE, gf_log, GF_LOG_CRITICAL, ng_file_deinit(), ng_file_parse(), ng_file_print(), and out.

Referenced by main().

◆ reincarnate()

◆ set_fuse_mount_options()

static int set_fuse_mount_options ( glusterfs_ctx_t ctx,
dict_t options 
)
static

Definition at line 309 of file glusterfsd.c.

References _cmd_args::acl, _cmd_args::attr_times_granularity, _cmd_args::aux_gfid_mount, _cmd_args::background_qlen, _cmd_args::capability, _cmd_args::client_pid, _cmd_args::client_pid_set, _glusterfs_ctx::cmd_args, _cmd_args::congestion_threshold, dict_set_double(), dict_set_dynstr_sizen, dict_set_int32_sizen, dict_set_static_ptr(), dict_set_str(), dict_set_uint32(), DICT_SET_VAL, _cmd_args::dump_fuse, _cmd_args::enable_ino32, err, _cmd_args::event_history, _cmd_args::fopen_keep_cache, _cmd_args::fuse_attribute_timeout, _cmd_args::fuse_auto_inval, _cmd_args::fuse_dev_eperm_ratelimit_ns, _cmd_args::fuse_direct_io_mode, _cmd_args::fuse_entry_timeout, _cmd_args::fuse_flush_handle_interrupt, _cmd_args::fuse_negative_timeout, gf_asprintf(), GF_LOG_ERROR, gf_msg_debug, GF_OPTION_DISABLE, GF_OPTION_ENABLE, gf_smsg, gf_strdup(), _cmd_args::gid_timeout, _cmd_args::gid_timeout_set, _cmd_args::global_threading, glusterfsd_msg_1, glusterfsd_msg_2, glusterfsd_msg_3, _cmd_args::invalidate_limit, _cmd_args::kernel_writeback_cache, _cmd_args::lru_limit, _cmd_args::mount_point, _cmd_args::no_daemon_mode, _cmd_args::no_root_squash, options, _cmd_args::read_only, _cmd_args::reader_thread_count, _cmd_args::resolve_gids, _cmd_args::selinux, _cmd_args::thin_client, _cmd_args::uid_map_root, _cmd_args::use_readdirp, _cmd_args::volfile_check, ZR_ATTR_TIMEOUT_OPT, ZR_DIRECT_IO_OPT, ZR_DUMP_FUSE, ZR_ENTRY_TIMEOUT_OPT, ZR_MOUNTPOINT_OPT, ZR_NEGATIVE_TIMEOUT_OPT, and ZR_STRICT_VOLFILE_CHECK.

Referenced by create_fuse_mount().

◆ should_call_fini()

bool should_call_fini ( glusterfs_ctx_t ctx,
xlator_t trav 
)

Variable Documentation

◆ argp

struct argp argp = {gf_options, parse_opts, argp_doc, gf_doc}
static

Definition at line 291 of file glusterfsd.c.

Referenced by parse_cmdline().

◆ argp_doc

char argp_doc[]
static
Initial value:
=
"--volfile-server=SERVER [MOUNT-POINT]\n"
"--volfile=VOLFILE [MOUNT-POINT]"

Definition at line 85 of file glusterfsd.c.

◆ argp_program_bug_address

const char* argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"

Definition at line 99 of file glusterfsd.c.

◆ argp_program_version

const char* argp_program_version
Initial value:
=
"" PACKAGE_NAME " " PACKAGE_VERSION
"\nRepository revision: " "git://git.gluster.org/glusterfs.git"
"\n"
"Copyright (c) 2006-2016 Red Hat, Inc. "
"<https://www.gluster.org/>\n"
"GlusterFS comes with ABSOLUTELY NO WARRANTY.\n"
"It is licensed to you under your choice of the GNU Lesser\n"
"General Public License, version 3 or any later version (LGPLv3\n"
"or later), or the GNU General Public License, version 2 (GPLv2),\n"
"in all cases as published by the Free Software Foundation."

Definition at line 88 of file glusterfsd.c.

◆ gf_doc

char gf_doc[] = ""
static

Definition at line 84 of file glusterfsd.c.

◆ gf_options

struct argp_option gf_options[]
static

Definition at line 104 of file glusterfsd.c.

◆ glusterfsd_ctx