* [PATCH v2] watchdog: new option to skip ping in close
@ 2012-08-07 18:27 David Teigland
2012-08-07 18:57 ` Hans de Goede
0 siblings, 1 reply; 2+ messages in thread
From: David Teigland @ 2012-08-07 18:27 UTC (permalink / raw)
To: linux-watchdog
If a daemon has /dev/watchdog open, and exits (say by crashing or
sigkill), watchdog_release() generates a new watchdog_ping(), extending
the life of the machine. However, the daemon may require control over
whether or not the watchdog is pinged, and the ping generated by close
compromises this control.
Signed-off-by: David Teigland <teigland@redhat.com>
---
drivers/watchdog/watchdog_dev.c | 7 ++++++-
include/linux/watchdog.h | 2 ++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
index ef8edec..47ae7fe 100644
--- a/drivers/watchdog/watchdog_dev.c
+++ b/drivers/watchdog/watchdog_dev.c
@@ -394,6 +394,9 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
if (err)
return err;
return put_user(val, p);
+ case WDIOC_NOCLOSEPING:
+ set_bit(WDOG_NO_CLOSE_PING, &wdd->status);
+ return 0;
default:
return -ENOTTY;
}
@@ -480,7 +483,9 @@ static int watchdog_release(struct inode *inode, struct file *file)
if (!test_bit(WDOG_UNREGISTERED, &wdd->status))
dev_crit(wdd->dev, "watchdog did not stop!\n");
mutex_unlock(&wdd->lock);
- watchdog_ping(wdd);
+
+ if (!test_bit(WDOG_NO_CLOSE_PING, &wdd->status))
+ watchdog_ping(wdd);
}
/* Allow the owner module to be unloaded again */
diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
index da70f0f..4fa10ff 100644
--- a/include/linux/watchdog.h
+++ b/include/linux/watchdog.h
@@ -31,6 +31,7 @@ struct watchdog_info {
#define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int)
#define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int)
#define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int)
+#define WDIOC_NOCLOSEPING _IOR(WATCHDOG_IOCTL_BASE, 11, int)
#define WDIOF_UNKNOWN -1 /* Unknown flag error */
#define WDIOS_UNKNOWN -1 /* Unknown status error */
@@ -140,6 +141,7 @@ struct watchdog_device {
#define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
#define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
#define WDOG_UNREGISTERED 4 /* Has the device been unregistered */
+#define WDOG_NO_CLOSE_PING 5 /* Do not ping in watchdog_release() */
};
#ifdef CONFIG_WATCHDOG_NOWAYOUT
--
1.7.10.1.362.g242cab3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] watchdog: new option to skip ping in close
2012-08-07 18:27 [PATCH v2] watchdog: new option to skip ping in close David Teigland
@ 2012-08-07 18:57 ` Hans de Goede
0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2012-08-07 18:57 UTC (permalink / raw)
To: David Teigland; +Cc: linux-watchdog
Hi,
Code wise this version gets an ACK from me, API wise I'm not sure, so
lets see what Wim Van Sebroeck (the watchdog subsys maintainer) has to
say on this patch.
Regards,
Hans
On 08/07/2012 08:27 PM, David Teigland wrote:
> If a daemon has /dev/watchdog open, and exits (say by crashing or
> sigkill), watchdog_release() generates a new watchdog_ping(), extending
> the life of the machine. However, the daemon may require control over
> whether or not the watchdog is pinged, and the ping generated by close
> compromises this control.
>
> Signed-off-by: David Teigland <teigland@redhat.com>
> ---
> drivers/watchdog/watchdog_dev.c | 7 ++++++-
> include/linux/watchdog.h | 2 ++
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c
> index ef8edec..47ae7fe 100644
> --- a/drivers/watchdog/watchdog_dev.c
> +++ b/drivers/watchdog/watchdog_dev.c
> @@ -394,6 +394,9 @@ static long watchdog_ioctl(struct file *file, unsigned int cmd,
> if (err)
> return err;
> return put_user(val, p);
> + case WDIOC_NOCLOSEPING:
> + set_bit(WDOG_NO_CLOSE_PING, &wdd->status);
> + return 0;
> default:
> return -ENOTTY;
> }
> @@ -480,7 +483,9 @@ static int watchdog_release(struct inode *inode, struct file *file)
> if (!test_bit(WDOG_UNREGISTERED, &wdd->status))
> dev_crit(wdd->dev, "watchdog did not stop!\n");
> mutex_unlock(&wdd->lock);
> - watchdog_ping(wdd);
> +
> + if (!test_bit(WDOG_NO_CLOSE_PING, &wdd->status))
> + watchdog_ping(wdd);
> }
>
> /* Allow the owner module to be unloaded again */
> diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h
> index da70f0f..4fa10ff 100644
> --- a/include/linux/watchdog.h
> +++ b/include/linux/watchdog.h
> @@ -31,6 +31,7 @@ struct watchdog_info {
> #define WDIOC_SETPRETIMEOUT _IOWR(WATCHDOG_IOCTL_BASE, 8, int)
> #define WDIOC_GETPRETIMEOUT _IOR(WATCHDOG_IOCTL_BASE, 9, int)
> #define WDIOC_GETTIMELEFT _IOR(WATCHDOG_IOCTL_BASE, 10, int)
> +#define WDIOC_NOCLOSEPING _IOR(WATCHDOG_IOCTL_BASE, 11, int)
>
> #define WDIOF_UNKNOWN -1 /* Unknown flag error */
> #define WDIOS_UNKNOWN -1 /* Unknown status error */
> @@ -140,6 +141,7 @@ struct watchdog_device {
> #define WDOG_ALLOW_RELEASE 2 /* Did we receive the magic char ? */
> #define WDOG_NO_WAY_OUT 3 /* Is 'nowayout' feature set ? */
> #define WDOG_UNREGISTERED 4 /* Has the device been unregistered */
> +#define WDOG_NO_CLOSE_PING 5 /* Do not ping in watchdog_release() */
> };
>
> #ifdef CONFIG_WATCHDOG_NOWAYOUT
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-08-07 18:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-07 18:27 [PATCH v2] watchdog: new option to skip ping in close David Teigland
2012-08-07 18:57 ` Hans de Goede
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).