Compare commits
No commits in common. "acd156d197cd9593a0e27b185d1fa4fff2ad98a1" and "819a555bc5cccd6b4e8b53b7b5036744a94142a7" have entirely different histories.
acd156d197
...
819a555bc5
|
@ -971,12 +971,6 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
|
||||||
assert(a);
|
assert(a);
|
||||||
assert(fd == a->pipe_fd);
|
assert(fd == a->pipe_fd);
|
||||||
|
|
||||||
if (events & (EPOLLHUP|EPOLLERR)) {
|
|
||||||
log_unit_error(UNIT(a), "Got hangup/error on autofs pipe from kernel. Likely our automount point has been unmounted by someone or something else?");
|
|
||||||
automount_enter_dead(a, AUTOMOUNT_FAILURE_UNMOUNTED);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (events != EPOLLIN) {
|
if (events != EPOLLIN) {
|
||||||
log_unit_error(UNIT(a), "Got invalid poll event %"PRIu32" on pipe (fd=%d)", events, fd);
|
log_unit_error(UNIT(a), "Got invalid poll event %"PRIu32" on pipe (fd=%d)", events, fd);
|
||||||
goto fail;
|
goto fail;
|
||||||
|
@ -1076,7 +1070,6 @@ static const char* const automount_result_table[_AUTOMOUNT_RESULT_MAX] = {
|
||||||
[AUTOMOUNT_FAILURE_RESOURCES] = "resources",
|
[AUTOMOUNT_FAILURE_RESOURCES] = "resources",
|
||||||
[AUTOMOUNT_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
|
[AUTOMOUNT_FAILURE_START_LIMIT_HIT] = "start-limit-hit",
|
||||||
[AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT] = "mount-start-limit-hit",
|
[AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT] = "mount-start-limit-hit",
|
||||||
[AUTOMOUNT_FAILURE_UNMOUNTED] = "unmounted",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
DEFINE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
|
DEFINE_STRING_TABLE_LOOKUP(automount_result, AutomountResult);
|
||||||
|
|
|
@ -8,7 +8,6 @@ typedef struct Automount Automount;
|
||||||
typedef enum AutomountResult {
|
typedef enum AutomountResult {
|
||||||
AUTOMOUNT_SUCCESS,
|
AUTOMOUNT_SUCCESS,
|
||||||
AUTOMOUNT_FAILURE_RESOURCES,
|
AUTOMOUNT_FAILURE_RESOURCES,
|
||||||
AUTOMOUNT_FAILURE_UNMOUNTED,
|
|
||||||
AUTOMOUNT_FAILURE_START_LIMIT_HIT,
|
AUTOMOUNT_FAILURE_START_LIMIT_HIT,
|
||||||
AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT,
|
AUTOMOUNT_FAILURE_MOUNT_START_LIMIT_HIT,
|
||||||
_AUTOMOUNT_RESULT_MAX,
|
_AUTOMOUNT_RESULT_MAX,
|
||||||
|
|
|
@ -2938,7 +2938,7 @@ int manager_loop(Manager *m) {
|
||||||
|
|
||||||
watchdog_usec = manager_get_watchdog(m, WATCHDOG_RUNTIME);
|
watchdog_usec = manager_get_watchdog(m, WATCHDOG_RUNTIME);
|
||||||
if (timestamp_is_set(watchdog_usec))
|
if (timestamp_is_set(watchdog_usec))
|
||||||
(void) watchdog_ping();
|
watchdog_ping();
|
||||||
|
|
||||||
if (!ratelimit_below(&rl)) {
|
if (!ratelimit_below(&rl)) {
|
||||||
/* Yay, something is going seriously wrong, pause a little */
|
/* Yay, something is going seriously wrong, pause a little */
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <linux/watchdog.h>
|
#include <linux/watchdog.h>
|
||||||
|
|
||||||
#include "errno-util.h"
|
|
||||||
#include "fd-util.h"
|
#include "fd-util.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "string-util.h"
|
#include "string-util.h"
|
||||||
|
@ -20,40 +19,44 @@ static usec_t watchdog_timeout = USEC_INFINITY;
|
||||||
static usec_t watchdog_last_ping = USEC_INFINITY;
|
static usec_t watchdog_last_ping = USEC_INFINITY;
|
||||||
|
|
||||||
static int update_timeout(void) {
|
static int update_timeout(void) {
|
||||||
|
int r;
|
||||||
|
|
||||||
if (watchdog_fd < 0)
|
if (watchdog_fd < 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (watchdog_timeout == USEC_INFINITY)
|
if (watchdog_timeout == USEC_INFINITY)
|
||||||
return 0;
|
return 0;
|
||||||
|
else if (watchdog_timeout == 0) {
|
||||||
if (watchdog_timeout == 0) {
|
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
flags = WDIOS_DISABLECARD;
|
flags = WDIOS_DISABLECARD;
|
||||||
if (ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags) < 0)
|
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
|
||||||
|
if (r < 0)
|
||||||
return log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
|
return log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
|
||||||
} else {
|
} else {
|
||||||
char buf[FORMAT_TIMESPAN_MAX];
|
|
||||||
int sec, flags;
|
int sec, flags;
|
||||||
usec_t t;
|
char buf[FORMAT_TIMESPAN_MAX];
|
||||||
|
|
||||||
t = DIV_ROUND_UP(watchdog_timeout, USEC_PER_SEC);
|
sec = (int) DIV_ROUND_UP(watchdog_timeout, USEC_PER_SEC);
|
||||||
sec = (int) t >= INT_MAX ? INT_MAX : t; /* Saturate */
|
r = ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec);
|
||||||
if (ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec) < 0)
|
if (r < 0)
|
||||||
return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
|
return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
|
||||||
|
|
||||||
watchdog_timeout = (usec_t) sec * USEC_PER_SEC;
|
watchdog_timeout = (usec_t) sec * USEC_PER_SEC;
|
||||||
log_info("Set hardware watchdog to %s.", format_timespan(buf, sizeof(buf), watchdog_timeout, 0));
|
log_info("Set hardware watchdog to %s.", format_timespan(buf, sizeof(buf), watchdog_timeout, 0));
|
||||||
|
|
||||||
flags = WDIOS_ENABLECARD;
|
flags = WDIOS_ENABLECARD;
|
||||||
if (ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags) < 0) {
|
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
|
||||||
|
if (r < 0) {
|
||||||
/* ENOTTY means the watchdog is always enabled so we're fine */
|
/* ENOTTY means the watchdog is always enabled so we're fine */
|
||||||
log_full(ERRNO_IS_NOT_SUPPORTED(errno) ? LOG_DEBUG : LOG_WARNING,
|
log_full(errno == ENOTTY ? LOG_DEBUG : LOG_WARNING,
|
||||||
"Failed to enable hardware watchdog: %m");
|
"Failed to enable hardware watchdog: %m");
|
||||||
if (!ERRNO_IS_NOT_SUPPORTED(errno))
|
if (errno != ENOTTY)
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0) < 0)
|
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
|
||||||
|
if (r < 0)
|
||||||
return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
|
return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
|
||||||
|
|
||||||
watchdog_last_ping = now(clock_boottime_or_monotonic());
|
watchdog_last_ping = now(clock_boottime_or_monotonic());
|
||||||
|
@ -64,23 +67,19 @@ static int update_timeout(void) {
|
||||||
|
|
||||||
static int open_watchdog(void) {
|
static int open_watchdog(void) {
|
||||||
struct watchdog_info ident;
|
struct watchdog_info ident;
|
||||||
const char *fn;
|
|
||||||
|
|
||||||
if (watchdog_fd >= 0)
|
if (watchdog_fd >= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fn = watchdog_device ?: "/dev/watchdog";
|
watchdog_fd = open(watchdog_device ?: "/dev/watchdog",
|
||||||
watchdog_fd = open(fn, O_WRONLY|O_CLOEXEC);
|
O_WRONLY|O_CLOEXEC);
|
||||||
if (watchdog_fd < 0)
|
if (watchdog_fd < 0)
|
||||||
return log_debug_errno(errno, "Failed to open watchdog device %s: %m", fn);
|
return -errno;
|
||||||
|
|
||||||
if (ioctl(watchdog_fd, WDIOC_GETSUPPORT, &ident) < 0)
|
if (ioctl(watchdog_fd, WDIOC_GETSUPPORT, &ident) >= 0)
|
||||||
log_debug_errno(errno, "Hardware watchdog %s does not support WDIOC_GETSUPPORT ioctl: %m", fn);
|
log_info("Hardware watchdog '%s', version %x",
|
||||||
else
|
|
||||||
log_info("Using hardware watchdog '%s', version %x, device %s",
|
|
||||||
ident.identity,
|
ident.identity,
|
||||||
ident.firmware_version,
|
ident.firmware_version);
|
||||||
fn);
|
|
||||||
|
|
||||||
return update_timeout();
|
return update_timeout();
|
||||||
}
|
}
|
||||||
|
@ -103,8 +102,8 @@ int watchdog_set_timeout(usec_t *usec) {
|
||||||
|
|
||||||
watchdog_timeout = *usec;
|
watchdog_timeout = *usec;
|
||||||
|
|
||||||
/* If we didn't open the watchdog yet and didn't get any explicit timeout value set, don't do
|
/* If we didn't open the watchdog yet and didn't get any
|
||||||
* anything */
|
* explicit timeout value set, don't do anything */
|
||||||
if (watchdog_fd < 0 && watchdog_timeout == USEC_INFINITY)
|
if (watchdog_fd < 0 && watchdog_timeout == USEC_INFINITY)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -114,11 +113,13 @@ int watchdog_set_timeout(usec_t *usec) {
|
||||||
r = update_timeout();
|
r = update_timeout();
|
||||||
|
|
||||||
*usec = watchdog_timeout;
|
*usec = watchdog_timeout;
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
usec_t watchdog_runtime_wait(void) {
|
usec_t watchdog_runtime_wait(void) {
|
||||||
usec_t rtwait, ntime;
|
usec_t rtwait;
|
||||||
|
usec_t ntime;
|
||||||
|
|
||||||
if (!timestamp_is_set(watchdog_timeout))
|
if (!timestamp_is_set(watchdog_timeout))
|
||||||
return USEC_INFINITY;
|
return USEC_INFINITY;
|
||||||
|
@ -154,14 +155,18 @@ int watchdog_ping(void) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0) < 0)
|
r = ioctl(watchdog_fd, WDIOC_KEEPALIVE, 0);
|
||||||
|
if (r < 0)
|
||||||
return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
|
return log_warning_errno(errno, "Failed to ping hardware watchdog: %m");
|
||||||
|
|
||||||
watchdog_last_ping = ntime;
|
watchdog_last_ping = ntime;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void watchdog_close(bool disarm) {
|
void watchdog_close(bool disarm) {
|
||||||
|
int r;
|
||||||
|
|
||||||
if (watchdog_fd < 0)
|
if (watchdog_fd < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -170,7 +175,8 @@ void watchdog_close(bool disarm) {
|
||||||
|
|
||||||
/* Explicitly disarm it */
|
/* Explicitly disarm it */
|
||||||
flags = WDIOS_DISABLECARD;
|
flags = WDIOS_DISABLECARD;
|
||||||
if (ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags) < 0)
|
r = ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags);
|
||||||
|
if (r < 0)
|
||||||
log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
|
log_warning_errno(errno, "Failed to disable hardware watchdog: %m");
|
||||||
|
|
||||||
/* To be sure, use magic close logic, too */
|
/* To be sure, use magic close logic, too */
|
||||||
|
|
Loading…
Reference in New Issue