diff options
-rw-r--r-- | fs/lockd/svc.c | 27 | ||||
-rw-r--r-- | fs/nfsd/lockd.c | 1 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 16 | ||||
-rw-r--r-- | include/linux/lockd/bind.h | 9 |
4 files changed, 42 insertions, 11 deletions
diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c index 9fcdef50aad6..82e2192a0d5c 100644 --- a/fs/lockd/svc.c +++ b/fs/lockd/svc.c | |||
@@ -76,18 +76,31 @@ static const int nlm_port_min = 0, nlm_port_max = 65535; | |||
76 | 76 | ||
77 | static struct ctl_table_header * nlm_sysctl_table; | 77 | static struct ctl_table_header * nlm_sysctl_table; |
78 | 78 | ||
79 | static unsigned long set_grace_period(void) | 79 | static unsigned long get_lockd_grace_period(void) |
80 | { | 80 | { |
81 | unsigned long grace_period; | ||
82 | |||
83 | /* Note: nlm_timeout should always be nonzero */ | 81 | /* Note: nlm_timeout should always be nonzero */ |
84 | if (nlm_grace_period) | 82 | if (nlm_grace_period) |
85 | grace_period = ((nlm_grace_period + nlm_timeout - 1) | 83 | return roundup(nlm_grace_period, nlm_timeout) * HZ; |
86 | / nlm_timeout) * nlm_timeout * HZ; | ||
87 | else | 84 | else |
88 | grace_period = nlm_timeout * 5 * HZ; | 85 | return nlm_timeout * 5 * HZ; |
86 | } | ||
87 | |||
88 | unsigned long get_nfs_grace_period(void) | ||
89 | { | ||
90 | unsigned long lockdgrace = get_lockd_grace_period(); | ||
91 | unsigned long nfsdgrace = 0; | ||
92 | |||
93 | if (nlmsvc_ops) | ||
94 | nfsdgrace = nlmsvc_ops->get_grace_period(); | ||
95 | |||
96 | return max(lockdgrace, nfsdgrace); | ||
97 | } | ||
98 | EXPORT_SYMBOL(get_nfs_grace_period); | ||
99 | |||
100 | static unsigned long set_grace_period(void) | ||
101 | { | ||
89 | nlmsvc_grace_period = 1; | 102 | nlmsvc_grace_period = 1; |
90 | return grace_period + jiffies; | 103 | return get_nfs_grace_period() + jiffies; |
91 | } | 104 | } |
92 | 105 | ||
93 | static inline void clear_grace_period(void) | 106 | static inline void clear_grace_period(void) |
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c index 221acd1f11f6..9e4a568a5013 100644 --- a/fs/nfsd/lockd.c +++ b/fs/nfsd/lockd.c | |||
@@ -65,6 +65,7 @@ nlm_fclose(struct file *filp) | |||
65 | static struct nlmsvc_binding nfsd_nlm_ops = { | 65 | static struct nlmsvc_binding nfsd_nlm_ops = { |
66 | .fopen = nlm_fopen, /* open file for locking */ | 66 | .fopen = nlm_fopen, /* open file for locking */ |
67 | .fclose = nlm_fclose, /* close file */ | 67 | .fclose = nlm_fclose, /* close file */ |
68 | .get_grace_period = get_nfs4_grace_period, | ||
68 | }; | 69 | }; |
69 | 70 | ||
70 | void | 71 | void |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 8c52913d7cb6..9cc31eaf3857 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -51,6 +51,7 @@ | |||
51 | #include <linux/namei.h> | 51 | #include <linux/namei.h> |
52 | #include <linux/mutex.h> | 52 | #include <linux/mutex.h> |
53 | #include <linux/lockd/bind.h> | 53 | #include <linux/lockd/bind.h> |
54 | #include <linux/module.h> | ||
54 | 55 | ||
55 | #define NFSDDBG_FACILITY NFSDDBG_PROC | 56 | #define NFSDDBG_FACILITY NFSDDBG_PROC |
56 | 57 | ||
@@ -3190,20 +3191,27 @@ nfsd4_load_reboot_recovery_data(void) | |||
3190 | printk("NFSD: Failure reading reboot recovery data\n"); | 3191 | printk("NFSD: Failure reading reboot recovery data\n"); |
3191 | } | 3192 | } |
3192 | 3193 | ||
3194 | unsigned long | ||
3195 | get_nfs4_grace_period(void) | ||
3196 | { | ||
3197 | return max(user_lease_time, lease_time) * HZ; | ||
3198 | } | ||
3199 | |||
3193 | /* initialization to perform when the nfsd service is started: */ | 3200 | /* initialization to perform when the nfsd service is started: */ |
3194 | 3201 | ||
3195 | static void | 3202 | static void |
3196 | __nfs4_state_start(void) | 3203 | __nfs4_state_start(void) |
3197 | { | 3204 | { |
3198 | time_t grace_time; | 3205 | unsigned long grace_time; |
3199 | 3206 | ||
3200 | boot_time = get_seconds(); | 3207 | boot_time = get_seconds(); |
3201 | grace_time = max(user_lease_time, lease_time); | 3208 | grace_time = get_nfs_grace_period(); |
3202 | lease_time = user_lease_time; | 3209 | lease_time = user_lease_time; |
3203 | in_grace = 1; | 3210 | in_grace = 1; |
3204 | printk("NFSD: starting %ld-second grace period\n", grace_time); | 3211 | printk(KERN_INFO "NFSD: starting %ld-second grace period\n", |
3212 | grace_time/HZ); | ||
3205 | laundry_wq = create_singlethread_workqueue("nfsd4"); | 3213 | laundry_wq = create_singlethread_workqueue("nfsd4"); |
3206 | queue_delayed_work(laundry_wq, &laundromat_work, grace_time*HZ); | 3214 | queue_delayed_work(laundry_wq, &laundromat_work, grace_time); |
3207 | } | 3215 | } |
3208 | 3216 | ||
3209 | int | 3217 | int |
diff --git a/include/linux/lockd/bind.h b/include/linux/lockd/bind.h index 246de1d84a26..6f1637c61e10 100644 --- a/include/linux/lockd/bind.h +++ b/include/linux/lockd/bind.h | |||
@@ -27,6 +27,7 @@ struct nlmsvc_binding { | |||
27 | struct nfs_fh *, | 27 | struct nfs_fh *, |
28 | struct file **); | 28 | struct file **); |
29 | void (*fclose)(struct file *); | 29 | void (*fclose)(struct file *); |
30 | unsigned long (*get_grace_period)(void); | ||
30 | }; | 31 | }; |
31 | 32 | ||
32 | extern struct nlmsvc_binding * nlmsvc_ops; | 33 | extern struct nlmsvc_binding * nlmsvc_ops; |
@@ -38,4 +39,12 @@ extern int nlmclnt_proc(struct inode *, int, struct file_lock *); | |||
38 | extern int lockd_up(int proto); | 39 | extern int lockd_up(int proto); |
39 | extern void lockd_down(void); | 40 | extern void lockd_down(void); |
40 | 41 | ||
42 | unsigned long get_nfs_grace_period(void); | ||
43 | |||
44 | #ifdef CONFIG_NFSD_V4 | ||
45 | unsigned long get_nfs4_grace_period(void); | ||
46 | #else | ||
47 | static inline unsigned long get_nfs4_grace_period(void) {return 0;} | ||
48 | #endif | ||
49 | |||
41 | #endif /* LINUX_LOCKD_BIND_H */ | 50 | #endif /* LINUX_LOCKD_BIND_H */ |