From cc2fd83accfd6c9389dd8adc53ec58ab5b083f82 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Oct 01 2012 16:23:14 +0000 Subject: sanlock: change log level for startup and io timeouts make daemon startup and io timeout messages a warning instead of an error, so they are written to sanlock.log, not /var/log/messages (which should be for real errors). Signed-off-by: David Teigland --- diff --git a/src/diskio.c b/src/diskio.c index f187ea4..7647094 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -348,7 +348,7 @@ static struct aicb *find_callback_slot(struct task *task, int ioto) struct aicb *ev_aicb = container_of(ev_iocb, struct aicb, iocb); int op = ev_iocb ? ev_iocb->aio_lio_opcode : -1; - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld old free", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld old free", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2); ev_aicb->used = 0; free(ev_aicb->buf); @@ -429,20 +429,20 @@ static int do_linux_aio(int fd, uint64_t offset, char *buf, int len, ev_aicb->used = 0; if (ev_iocb != iocb) { - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld other free", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld other free", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2); free(ev_aicb->buf); ev_aicb->buf = NULL; goto retry; } if ((int)event.res < 0) { - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match res", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match res", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2); rv = event.res; goto out; } if (event.res != len) { - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2, len); rv = -EMSGSIZE; goto out; @@ -466,7 +466,7 @@ static int do_linux_aio(int fd, uint64_t offset, char *buf, int len, task->to_count++; - log_taske(task, "aio timeout %d %p:%p:%p ioto %d to_count %d", + log_taskw(task, "aio timeout %d %p:%p:%p ioto %d to_count %d", cmd, aicb, iocb, buf, ioto, task->to_count); rv = io_cancel(task->aio_ctx, iocb, &event); @@ -802,26 +802,26 @@ int read_iobuf_reap(int fd, uint64_t offset, char *iobuf, int iobuf_len, ev_aicb->used = 0; if (ev_iocb != iocb) { - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld other free r", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld other free r", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2); free(ev_aicb->buf); ev_aicb->buf = NULL; goto retry; } if ((int)event.res < 0) { - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match res r", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match res r", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2); rv = event.res; goto out; } if (event.res != iobuf_len) { - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d r", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match len %d r", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2, iobuf_len); rv = -EMSGSIZE; goto out; } - log_taske(task, "aio collect %d %p:%p:%p result %ld:%ld match reap", + log_taskw(task, "aio collect %d %p:%p:%p result %ld:%ld match reap", op, ev_aicb, ev_iocb, ev_aicb->buf, event.res, event.res2); rv = 0; diff --git a/src/log.h b/src/log.h index 2421597..db6d275 100644 --- a/src/log.h +++ b/src/log.h @@ -9,6 +9,21 @@ #ifndef __LOG_H__ #define __LOG_H__ +/* + * Log levels are used mainly to indicate where the message + * should be recorded: + * + * log_error() write to /var/log/messages and /var/log/sanlock.log + * log_level(WARNING) write to /var/log/sanlock.log + * log_debug() write to incore buffer, not to file + * + * Anything in /var/log/messages should not happen and should be reported. + * So anything we want to visible and reported should be LOG_ERR. + * + * If we want to log something to assist in debugging, but not be reported, + * it should be LOG_WARNING (goes only to sanlock.log) + */ + void log_level(uint32_t space_id, uint32_t token_id, char *name_in, int level, const char *fmt, ...) __attribute__((format(printf, 5, 6))); @@ -27,6 +42,7 @@ void copy_log_dump(char *buf, int *len); #define log_errst(space, token, fmt, args...) log_level(space->space_id, token->token_id, NULL, LOG_ERR, fmt, ##args) #define log_taske(task, fmt, args...) log_level(0, 0, task->name, LOG_ERR, fmt, ##args) +#define log_taskw(task, fmt, args...) log_level(0, 0, task->name, LOG_WARNING, fmt, ##args) #define log_taskd(task, fmt, args...) log_level(0, 0, task->name, LOG_DEBUG, fmt, ##args) /* use log_tool for tool actions (non-daemon), and for daemon until diff --git a/src/main.c b/src/main.c index eea6bb3..46aa5ef 100644 --- a/src/main.c +++ b/src/main.c @@ -1625,9 +1625,8 @@ static int do_daemon(void) setup_groups(); - log_error("sanlock daemon started %s host %s time %llu", - RELEASE_VERSION, our_host_name_global, - (unsigned long long)time(NULL)); + log_level(0, 0, NULL, LOG_WARNING, "sanlock daemon started %s host %s", + RELEASE_VERSION, our_host_name_global); setup_priority();