diff options
author | David Teigland <teigland@redhat.com> | 2008-08-18 12:43:30 -0400 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2008-08-28 12:49:43 -0400 |
commit | dc68c7ed362a00a48290252573a8eb9f74463c3a (patch) | |
tree | 99b8b64ea08d4990373d09e01b7bac2566ad3879 /fs/dlm/user.c | |
parent | 0f8e0d9a317406612700426fad3efab0b7bbc467 (diff) |
dlm: detect available userspace daemon
If dlm_controld (the userspace daemon that controls the setup and
recovery of the dlm) fails, the kernel should shut down the lockspaces
in the kernel rather than leaving them running. This is detected by
having dlm_controld hold a misc device open while running, and if
the kernel detects a close while the daemon is still needed, it stops
the lockspaces in the kernel.
Knowing that the userspace daemon isn't running also allows the
lockspace create/remove routines to avoid waiting on the daemon
for join/leave operations.
Signed-off-by: David Teigland <teigland@redhat.com>
Diffstat (limited to 'fs/dlm/user.c')
-rw-r--r-- | fs/dlm/user.c | 61 |
1 files changed, 60 insertions, 1 deletions
diff --git a/fs/dlm/user.c b/fs/dlm/user.c index 6542110c0da4..81627b502a56 100644 --- a/fs/dlm/user.c +++ b/fs/dlm/user.c | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | static const char name_prefix[] = "dlm"; | 28 | static const char name_prefix[] = "dlm"; |
29 | static const struct file_operations device_fops; | 29 | static const struct file_operations device_fops; |
30 | static atomic_t dlm_monitor_opened; | ||
31 | static int dlm_monitor_unused = 1; | ||
30 | 32 | ||
31 | #ifdef CONFIG_COMPAT | 33 | #ifdef CONFIG_COMPAT |
32 | 34 | ||
@@ -890,6 +892,26 @@ static unsigned int device_poll(struct file *file, poll_table *wait) | |||
890 | return 0; | 892 | return 0; |
891 | } | 893 | } |
892 | 894 | ||
895 | int dlm_user_daemon_available(void) | ||
896 | { | ||
897 | /* dlm_controld hasn't started (or, has started, but not | ||
898 | properly populated configfs) */ | ||
899 | |||
900 | if (!dlm_our_nodeid()) | ||
901 | return 0; | ||
902 | |||
903 | /* This is to deal with versions of dlm_controld that don't | ||
904 | know about the monitor device. We assume that if the | ||
905 | dlm_controld was started (above), but the monitor device | ||
906 | was never opened, that it's an old version. dlm_controld | ||
907 | should open the monitor device before populating configfs. */ | ||
908 | |||
909 | if (dlm_monitor_unused) | ||
910 | return 1; | ||
911 | |||
912 | return atomic_read(&dlm_monitor_opened) ? 1 : 0; | ||
913 | } | ||
914 | |||
893 | static int ctl_device_open(struct inode *inode, struct file *file) | 915 | static int ctl_device_open(struct inode *inode, struct file *file) |
894 | { | 916 | { |
895 | cycle_kernel_lock(); | 917 | cycle_kernel_lock(); |
@@ -902,6 +924,20 @@ static int ctl_device_close(struct inode *inode, struct file *file) | |||
902 | return 0; | 924 | return 0; |
903 | } | 925 | } |
904 | 926 | ||
927 | static int monitor_device_open(struct inode *inode, struct file *file) | ||
928 | { | ||
929 | atomic_inc(&dlm_monitor_opened); | ||
930 | dlm_monitor_unused = 0; | ||
931 | return 0; | ||
932 | } | ||
933 | |||
934 | static int monitor_device_close(struct inode *inode, struct file *file) | ||
935 | { | ||
936 | if (atomic_dec_and_test(&dlm_monitor_opened)) | ||
937 | dlm_stop_lockspaces(); | ||
938 | return 0; | ||
939 | } | ||
940 | |||
905 | static const struct file_operations device_fops = { | 941 | static const struct file_operations device_fops = { |
906 | .open = device_open, | 942 | .open = device_open, |
907 | .release = device_close, | 943 | .release = device_close, |
@@ -925,19 +961,42 @@ static struct miscdevice ctl_device = { | |||
925 | .minor = MISC_DYNAMIC_MINOR, | 961 | .minor = MISC_DYNAMIC_MINOR, |
926 | }; | 962 | }; |
927 | 963 | ||
964 | static const struct file_operations monitor_device_fops = { | ||
965 | .open = monitor_device_open, | ||
966 | .release = monitor_device_close, | ||
967 | .owner = THIS_MODULE, | ||
968 | }; | ||
969 | |||
970 | static struct miscdevice monitor_device = { | ||
971 | .name = "dlm-monitor", | ||
972 | .fops = &monitor_device_fops, | ||
973 | .minor = MISC_DYNAMIC_MINOR, | ||
974 | }; | ||
975 | |||
928 | int __init dlm_user_init(void) | 976 | int __init dlm_user_init(void) |
929 | { | 977 | { |
930 | int error; | 978 | int error; |
931 | 979 | ||
980 | atomic_set(&dlm_monitor_opened, 0); | ||
981 | |||
932 | error = misc_register(&ctl_device); | 982 | error = misc_register(&ctl_device); |
933 | if (error) | 983 | if (error) { |
934 | log_print("misc_register failed for control device"); | 984 | log_print("misc_register failed for control device"); |
985 | goto out; | ||
986 | } | ||
935 | 987 | ||
988 | error = misc_register(&monitor_device); | ||
989 | if (error) { | ||
990 | log_print("misc_register failed for monitor device"); | ||
991 | misc_deregister(&ctl_device); | ||
992 | } | ||
993 | out: | ||
936 | return error; | 994 | return error; |
937 | } | 995 | } |
938 | 996 | ||
939 | void dlm_user_exit(void) | 997 | void dlm_user_exit(void) |
940 | { | 998 | { |
941 | misc_deregister(&ctl_device); | 999 | misc_deregister(&ctl_device); |
1000 | misc_deregister(&monitor_device); | ||
942 | } | 1001 | } |
943 | 1002 | ||