Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robinhood Sync Acceleration for PanFS #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ CFLAGS="$CFLAGS $GLIB2_CFLAGS $GTHREAD2_CFLAGS"
LDFLAGS="$LDFLAGS $GLIB2_LIBS $GTHREAD2_LIBS"

# debug flags

AX_ENABLE_FLAG([debug-db], [enables debug traces for database operations], [-D_DEBUG_DB])
AX_ENABLE_FLAG([debug-parsing], [enables debug traces for configuration file parsing], [-D_DEBUG_PARSING])
AM_CONDITIONAL(DEBUG_PARSING, test "x$enable_debug_parsing" == "xyes" )
Expand Down Expand Up @@ -147,17 +148,31 @@ build_lustre="OFF"
build_backup="OFF"
build_lhsm="OFF"
build_shook="OFF"
build_panfs="OFF"

AC_ARG_ENABLE([lustre], AS_HELP_STRING([--disable-lustre],
[Disable all lustre specific features]),
[support_lustre="$enableval"],[support_lustre="yes"])
AC_ARG_ENABLE([shook], AS_HELP_STRING([--disable-shook],
[Disable build of shook specific modules]),
[support_shook="$enableval"],[support_shook="yes"])
AC_ARG_ENABLE([panfs], AS_HELP_STRING([--enable-panfs],
[enable PanFS-specific features]),
[support_panfs="yes"],[support_panfs="no"])

# default input option is --scan
INPUT_OPT="--scan"

# Panasas File System
if test "x$support_panfs" = "xyes" ; then
AC_DEFINE(_PANFS, 1, [panfs is available])
AM_CONDITIONAL( PANFS, test "x$support_panfs" = "xyes" )
AC_SUBST(PANFS)
build_panfs="ON"
else
AM_CONDITIONAL(PANFS, test 0 = 1 )
fi

# shook requires Lustre + FID support + shook library
# hsm_lite requires Lustre + FID support
# lustre_hsm requires Lustre >= 2.5
Expand Down Expand Up @@ -490,6 +505,7 @@ AC_SUBST(ac_configure_args)
AC_OUTPUT

AC_MSG_NOTICE([Summary:])
AC_MSG_NOTICE([PanFS support is $build_panfs])
AC_MSG_NOTICE([Lustre support is $build_lustre])
AC_MSG_NOTICE([Backup support is $build_backup])
AC_MSG_NOTICE([Lustre/HSM support is $build_lhsm])
Expand Down
6 changes: 5 additions & 1 deletion src/cfg_parsing/rbh_cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "policy_rules.h"
#include "policy_run.h"
#include "status_manager.h"
#include "panfs_config.h"

char config_file[RBH_PATH_MAX] = "";

Expand All @@ -43,6 +44,9 @@ struct mod_cfgs {
{&global_cfg_hdlr, MODULE_MASK_ALWAYS},
{&log_cfg_hdlr, MODULE_MASK_ALWAYS},
{&updt_params_hdlr, MODULE_MASK_ALWAYS},
#ifdef _PANFS
{&panfs_cfg_hdlr, MODULE_MASK_ALWAYS},
#endif
{&lmgr_cfg_hdlr, MODULE_MASK_ALWAYS},
{&entry_proc_cfg_hdlr, MODULE_MASK_ENTRY_PROCESSOR},
{&fs_scan_cfg_hdlr, MODULE_MASK_FS_SCAN},
Expand Down Expand Up @@ -144,7 +148,7 @@ static int rbh_cfg_read_set(int module_mask, char *file_path, char *err_msg_out,
/* just free the top level handler */
free(cfg);
}

config_free:
/* free config file resources */
rh_config_Free(syntax_tree);
Expand Down
3 changes: 3 additions & 0 deletions src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ noinst_LTLIBRARIES=libcommontools.la
if LUSTRE
FS_SRC=lustre_tools.c
endif
if PANFS
FS_SRC=panfs_config.c
endif
if MNTENTCOMPAT
COMPAT_SRC=mntent_compat.c mntent_compat.h
endif
Expand Down
179 changes: 179 additions & 0 deletions src/common/panfs_config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil; -*-
* vim:expandtab:shiftwidth=4:tabstop=4:
*/
/*
* Copyright (C) 2008, 2009 CEA/DAM
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the CeCILL License.
*
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license (http://www.cecill.info) and that you
* accept its terms.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include "panfs_config.h"
#include "rbh_cfg_helpers.h"
#include "rbh_misc.h"
#include "rbh_logs.h"
#include <errno.h>

#define PANFS_CONFIG_BLOCK "Panasas"

/* exported variable available to all modules */
panfs_config_t panfs_config;

static void panfs_cfg_set_default(void *module_config)
{
panfs_config_t *conf = (panfs_config_t *)module_config;
rh_strncpy(conf->snap_delta_path, "", RBH_PATH_MAX);
rh_strncpy(conf->snap_delta_results_path, "", RBH_PATH_MAX);
rh_strncpy(conf->volume, "", FILENAME_MAX);
conf->update_interval = 600;//10 min
}

static void panfs_cfg_write_default(FILE *output)
{
print_begin_block(output, 0, PANFS_CONFIG_BLOCK, NULL);
print_line(output, 1, "snap_delta_path : PATH");
print_line(output, 1, "snap_delta_results_path : PATH");
print_line(output, 1, "volume : volumeName");
print_line(output, 1, "# Interval for updating database");
print_line(output, 1, "update_interval = 10min ;");
fprintf(output, "\n");
print_end_block(output, 0);
}

static int panfs_cfg_read(config_file_t config, void *module_config,
char *msg_out)
{
panfs_config_t *conf = (panfs_config_t *)module_config;
config_item_t panfs_block;
int rc;

static const char * const allowed_params[] = {
"snap_delta_path", "snap_delta_results_path", "volume", "update_interval", NULL
};
const cfg_param_t cfg_params[] = {
{"snap_delta_path", PT_STRING, PFLG_MANDATORY |
PFLG_REMOVE_FINAL_SLASH | PFLG_NO_WILDCARDS, conf->snap_delta_path,
sizeof(conf->snap_delta_path)}
,
{"snap_delta_results_path", PT_STRING, PFLG_MANDATORY |
PFLG_REMOVE_FINAL_SLASH | PFLG_NO_WILDCARDS, conf->snap_delta_results_path,
sizeof(conf->snap_delta_results_path)}
,
{"volume", PT_STRING,
PFLG_MANDATORY |
PFLG_NO_WILDCARDS, conf->volume, sizeof(conf->volume)}
,
{"update_interval", PT_DURATION, PFLG_POSITIVE | PFLG_NOT_NULL,
&conf->update_interval, 0}
,

END_OF_PARAMS
};

/* get PANASAS block */
rc = get_cfg_block(config, PANFS_CONFIG_BLOCK, &panfs_block, msg_out);
if (rc)
return rc;

/* retrieve std parameters */
rc = read_scalar_params(panfs_block, PANFS_CONFIG_BLOCK, cfg_params,
msg_out);
if (rc)
return rc;

/* check unknown parameters */
CheckUnknownParameters(panfs_block, PANFS_CONFIG_BLOCK, allowed_params);

return 0;
}

static int panfs_cfg_set(void *module_config, bool reload)
{
panfs_config_t *conf = (panfs_config_t *) module_config;

if (!reload) {
/* copy the whole structure content */
panfs_config = *conf;
return 0;
}

if (strcmp(conf->snap_delta_path, panfs_config.snap_delta_path)){
DisplayLog(LVL_MAJOR, "PanasasConfig",
PANFS_CONFIG_BLOCK
"::Path to pan_snap_delta updated");
strcpy(panfs_config.snap_delta_path,conf->snap_delta_path);

}
if (strcmp(conf->snap_delta_results_path, panfs_config.snap_delta_results_path)){
DisplayLog(LVL_MAJOR, "PanasasConfig",
PANFS_CONFIG_BLOCK
"::Path to pan_snap_delta results updated");
strcpy(panfs_config.snap_delta_results_path,conf->snap_delta_results_path);

}
if (strcmp(conf->volume, panfs_config.volume)){
DisplayLog(LVL_MAJOR, "PanasasConfig",
PANFS_CONFIG_BLOCK
"::Volume's name changed in config file, but cannot be modified dynamically. If you need to change it, drop the database and run it one more time.");
exit(1);
}
if (panfs_config.update_interval != conf->update_interval) {
DisplayLog(LVL_MAJOR, "PanasasConfig",
PANFS_CONFIG_BLOCK "::update_interval modified: "
"'%" PRI_TT "'->'%" PRI_TT "'",
panfs_config.update_interval, conf->update_interval);
panfs_config.update_interval = conf->update_interval;
}
return 0;
}

static void panfs_cfg_write_template(FILE *output)
{
print_begin_block(output, 0, PANFS_CONFIG_BLOCK, NULL);
print_line(output, 1,
"# Path to pan_snap_delta binary");
print_line(output, 1, "snap_delta_path = \"/panfs/\" ;");
fprintf(output, "\n");
print_line(output, 1,
"# Path to pan_snap_delta results");
print_line(output, 1, "snap_delta_results_path = \"/tmp/\" ;");
fprintf(output, "\n");
print_line(output, 1, "# Name of the volume");
print_line(output, 1, "volume = home;");
fprintf(output, "\n");
print_line(output, 1,
"# Time between checks to see if there are newer snapshots to process");

print_line(output, 1, " update_interval=10m;");
print_end_block(output, 0);
}

static void *panfs_cfg_new(void)
{
return calloc(1, sizeof(panfs_config_t));
}

static void panfs_cfg_free(void *cfg)
{
if (cfg != NULL)
free(cfg);
}

/** structure with config handling functions */
mod_cfg_funcs_t panfs_cfg_hdlr = {
.module_name = "panasas",
.new = panfs_cfg_new,
.free = panfs_cfg_free,
.set_default = panfs_cfg_set_default,
.read = panfs_cfg_read,
.set_config = panfs_cfg_set,
.write_default = panfs_cfg_write_default,
.write_template = panfs_cfg_write_template
};
46 changes: 43 additions & 3 deletions src/common/rbh_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
#include <ctype.h>
#include <string.h>

#ifdef _PANFS
#include <sys/utsname.h>
#include <linux/types.h>
#include <linux/unistd.h>
#include <sys/time.h> /* for gettimeofday */
#include <syscall.h>
#include <sys/xattr.h>
#endif

#ifndef HAVE_GETMNTENT_R
#include "mntent_compat.h"
#else
Expand Down Expand Up @@ -2174,11 +2183,42 @@ int path2id(const char *path, entry_id_t *id, const struct stat *st)
path, strerror(-rc));
return rc;
}
#ifdef _PANFS
st = &stn;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer you include this large piece of code in a subfonction.

ssize_t vallentmp;
char *valtmp;
char *key;
vallentmp = lgetxattr(path, "system.panfs.obj_id", NULL, 0);
if (vallentmp == -1){
DisplayLog(LVL_CRIT, "StatGetxattrErr","Fatal Error. lgetxattr doesn't return any size for path %s. Error number = %d.\n",path,errno);
exit(1);
}
else if (vallentmp > 0) {
valtmp = malloc(vallentmp + 1);
if(valtmp!=NULL){
vallentmp = lgetxattr(path, "system.panfs.obj_id", valtmp, vallentmp);
valtmp[vallentmp] = 0;
key=strchr(valtmp, 'U')+1;
free(valtmp);
id->inode =strtoull(key,&key,16);
id->fs_key = get_fskey();
}
else{
DisplayLog(LVL_CRIT, "StatGetxattrErr","Fatal Error. Out of space.\n");
exit(1);
}
}
else if (vallentmp == 0){
DisplayLog(LVL_MAJOR, "StatgetxattrErr","Fatal Error. No value for size of lgetxattr.");
exit(1);
}
#endif
}
else{
/* build id from dev/inode */
id->inode = st->st_ino;
id->fs_key = get_fskey();
}
/* build id from dev/inode */
id->inode = st->st_ino;
id->fs_key = get_fskey();
#endif
return 0;
}
Expand Down
Loading