redmine

Added untested BSM prefetcher support

... ... @@ -154,6 +154,7 @@ enum notifyengine_enum {
NE_INOTIFY,
NE_KQUEUE,
NE_BSM,
NE_BSM_PREFETCH,
NE_DTRACEPIPE,
};
typedef enum notifyengine_enum notifyengine_t;
... ...
... ... @@ -199,3 +199,5 @@ filesz:1M\n\
// In nanoseconds
#define OUTPUT_LOCK_TIMEOUT (100*1000*1000)
#define WAITPID_TIMED_GRANULARITY (30*1000*1000)
#define BSM_QUEUE_LENGTH_MAX (1024*1024)
... ...
... ... @@ -118,6 +118,7 @@ enum flags_enum {
SHM_MPROTECT = 42|OPTION_LONGOPTONLY,
MODSIGN = 43|OPTION_LONGOPTONLY,
CANCEL_SYSCALLS = 44|OPTION_LONGOPTONLY,
EXITONSYNCSKIP = 45|OPTION_LONGOPTONLY,
};
typedef enum flags_enum flags_t;
... ...
... ... @@ -51,6 +51,7 @@ extern void _info(const char *const function_name, const char *fmt, ...);
# define error_or_debug(debug_level, ...) ((debug_level)<0 ? _error(__FUNCTION__, __VA_ARGS__) : (void)0)
#endif
#define critical_or_warning(cond, ...) ((cond) ? _critical : _warning)(__FUNCTION__, __VA_ARGS__)
extern void error_init(void *_outputmethod, int *_quiet, int *_verbose, int *_debug);
... ...
... ... @@ -113,6 +113,7 @@ static const struct option long_options[] =
{"threading", required_argument, NULL, THREADING},
{"retries", optional_argument, NULL, RETRIES},
{"ignore-failures", optional_argument, NULL, IGNOREFAILURES},
{"exit-on-sync-skipping",optional_argument, NULL, EXITONSYNCSKIP},
{"output", required_argument, NULL, OUTPUT_METHOD},
{"one-file-system", optional_argument, NULL, ONEFILESYSTEM},
{"exclude-mount-points",optional_argument, NULL, EXCLUDEMOUNTPOINTS},
... ... @@ -315,6 +316,7 @@ static char *const notify_engines[] = {
[NE_KQUEUE] = "kqueue",
[NE_FANOTIFY] = "fanotify",
[NE_BSM] = "bsm",
[NE_BSM_PREFETCH] = "bsm_prefetch",
[NE_DTRACEPIPE] = "dtracepipe",
NULL
};
... ... @@ -1359,6 +1361,7 @@ int parse_parameter(ctx_t *ctx_p, uint16_t param_id, char *arg, paramsource_t pa
#endif
#ifdef BSM_SUPPORT
case NE_BSM:
case NE_BSM_PREFETCH:
#endif
#ifdef DTRACEPIPE_SUPPORT
case NE_DTRACEPIPE:
... ... @@ -1999,6 +2002,7 @@ int ctx_check(ctx_t *ctx_p) {
#endif
#ifdef BSM_SUPPORT
case NE_BSM:
case NE_BSM_PREFETCH:
#endif
#ifdef DTRACEPIPE_SUPPORT
case NE_DTRACEPIPE:
... ...
... ... @@ -1039,6 +1039,7 @@ CPU/HDD expensive way.
FreeBSD users: notify me about found bugs or performance issues, please. And
before the bugfix you can switch to "inotify" through libinotify or to "bsm".
.RE
.IR bsm
.RS
... ... @@ -1057,6 +1058,23 @@ will just parse the log via
Reliable, but hacky way. It requires global audit reconfiguration that
may hopple audit analysis.
.B Warning!
FreeBSD has a limit for queued events. In default FreeBSD kernel it's only
1024 events. So choose
.B one
of:
.RS
\- To patch the kernel to increase the limit.
.br
\- Don't use
.B clsync
on systems with too many file events.
.br
\- Use
.I bsm_prefetch
mode.
.RE
.B Not well tested. Use with caution!
Also file /etc/security/audit_control will be overwritten with:
.RS
... ... @@ -1076,6 +1094,16 @@ policy:cnt
.br
filesz:1M
.RE
unless it's already starts with "#clsync\\n" ("\\n" is a new line character).
.RE
.I bsm_prefetch
.RS
The same as
.I bsm
but all BSM events will be prefetched by an additional thread to prevent BSM
queue overflow. This may utilize a lot of memory on systems with a high FS
events frequency.
.RE
.RE
... ...
This diff is collapsed. Click to expand it.
... ... @@ -18,8 +18,8 @@
*/
extern int bsm_init(ctx_t *ctx_p);
extern int bsm_wait(struct ctx *ctx_p, struct indexes *indexes_p, struct timeval *tv_p);
extern int bsm_handle(struct ctx *ctx_p, struct indexes *indexes_p);
extern int (*bsm_wait)(struct ctx *ctx_p, struct indexes *indexes_p, struct timeval *timeout_p);
extern int (*bsm_handle)(struct ctx *ctx_p, struct indexes *indexes_p);
extern int bsm_add_watch_dir(struct ctx *ctx_p, struct indexes *indexes_p, const char *const accpath);
extern int bsm_deinit(ctx_t *ctx_p);
... ...
... ... @@ -1594,6 +1594,7 @@ int __privileged_fork_execvp(const char *file, char *const argv[])
return pid;
}
#ifdef CAPABILITIES_SUPPORT
#define pthread_mutex_init_smart(mutex_p) _pthread_mutex_init_smart(ctx_p->flags[SPLITTING]==SM_PROCESS, mutex_p)
static inline int _pthread_mutex_init_smart(int isshared, pthread_mutex_t **mutex_p) {
int rc;
... ... @@ -1661,7 +1662,7 @@ static inline int _pthread_cond_destroy_smart(int isshared, pthread_cond_t *cond
return 0;
}
#endif
int privileged_init(ctx_t *ctx_p)
{
... ...
... ... @@ -132,6 +132,7 @@ static inline void evinfo_merge(ctx_t *ctx_p, eventinfo_t *evinfo_dst, eventinfo
#ifdef BSM_SUPPORT
switch(ctx_p->flags[MONITOR]) {
case NE_BSM:
case NE_BSM_PREFETCH:
evinfo_dst->evmask = evinfo_src->evmask;
break;
}
... ... @@ -860,7 +861,7 @@ static inline int so_call_rsync(ctx_t *ctx_p, indexes_t *indexes_p, const char *
// === SYNC_EXEC() === {
#define SYNC_EXEC(...) (SHOULD_THREAD(ctx_p) ? sync_exec_thread : sync_exec )(__VA_ARGS__)
//#define SYNC_EXEC(...) (SHOULD_THREAD(ctx_p) ? sync_exec_thread : sync_exec )(__VA_ARGS__)
#define SYNC_EXEC_ARGV(...) (SHOULD_THREAD(ctx_p) ? sync_exec_argv_thread : sync_exec_argv)(__VA_ARGS__)
#define debug_argv_dump(level, argv)\
... ... @@ -1054,6 +1055,7 @@ int sync_exec_argv(ctx_t *ctx_p, indexes_t *indexes_p, thread_callbackfunct_t ca
return ret;
}
/*
static inline int sync_exec(ctx_t *ctx_p, indexes_t *indexes_p, thread_callbackfunct_t callback, thread_callbackfunct_arg_t *callback_arg_p, ...) {
int rc;
debug(2, "");
... ... @@ -1067,6 +1069,7 @@ static inline int sync_exec(ctx_t *ctx_p, indexes_t *indexes_p, thread_callbackf
free(argv);
return rc;
}
*/
int __sync_exec_thread(threadinfo_t *threadinfo_p) {
char **argv = threadinfo_p->argv;
... ... @@ -1139,6 +1142,7 @@ static inline int sync_exec_argv_thread(ctx_t *ctx_p, indexes_t *indexes_p, thre
return 0;
}
/*
static inline int sync_exec_thread(ctx_t *ctx_p, indexes_t *indexes_p, thread_callbackfunct_t callback, thread_callbackfunct_arg_t *callback_arg_p, ...) {
debug(2, "");
... ... @@ -1149,6 +1153,7 @@ static inline int sync_exec_thread(ctx_t *ctx_p, indexes_t *indexes_p, thread_ca
return sync_exec_argv_thread(ctx_p, indexes_p, callback, callback_arg_p, argv);
}
*/
// } === SYNC_EXEC() ===
... ... @@ -1210,6 +1215,7 @@ static inline void evinfo_initialevmask(ctx_t *ctx_p, eventinfo_t *evinfo_p, int
#endif
#ifdef BSM_SUPPORT
case NE_BSM:
case NE_BSM_PREFETCH:
evinfo_p->evmask = (isdir ? AUE_MKDIR : AUE_OPEN_RWC);
break;
#endif
... ... @@ -1821,7 +1827,8 @@ int sync_notify_init(ctx_t *ctx_p) {
}
#endif
#ifdef BSM_SUPPORT
case NE_BSM: {
case NE_BSM:
case NE_BSM_PREFETCH: {
int bsm_d = bsm_init(ctx_p);
if(bsm_d == -1) {
error("cannot bsm_init(ctx_p).");
... ... @@ -2067,6 +2074,7 @@ int sync_prequeue_loadmark
#endif
#ifdef BSM_SUPPORT
case NE_BSM:
case NE_BSM_PREFETCH:
evinfo->evmask = event_mask;
break;
#endif
... ... @@ -3773,6 +3781,7 @@ int sync_run(ctx_t *ctx_p) {
#endif
#ifdef BSM_SUPPORT
case NE_BSM:
case NE_BSM_PREFETCH:
ctx_p->notifyenginefunct.add_watch_dir = bsm_add_watch_dir;
ctx_p->notifyenginefunct.wait = bsm_wait;
ctx_p->notifyenginefunct.handle = bsm_handle;
... ... @@ -3864,6 +3873,7 @@ int sync_run(ctx_t *ctx_p) {
#endif
#ifdef BSM_SUPPORT
case NE_BSM:
case NE_BSM_PREFETCH:
bsm_deinit(ctx_p);
break;
#endif
... ...