diff options
author | Marc Eshel <eshel@almaden.ibm.com> | 2007-07-17 07:04:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-17 13:23:07 -0400 |
commit | 9a8db97e7756119689c93c431e8b8324080f5625 (patch) | |
tree | 2e0ac28664b02c7e1c7a111c6e60ac059fd92ad8 /fs | |
parent | 12127498c8f5e479df15ee374a0932f5659df49e (diff) |
knfsd: lockd: nfsd4: use same grace period for lockd and nfsd4
Both lockd and (in the nfsv4 case) nfsd enforce a "grace period" after reboot,
during which clients may reclaim locks from the previous server instance, but
may not acquire new locks.
Currently the lockd and nfsd enforce grace periods of different lengths. This
may cause problems when we reboot a server with both v2/v3 and v4 clients.
For example, if the lockd grace period is shorter (as is likely the case),
then a v3 client might acquire a new lock that conflicts with a lock already
held (but not yet reclaimed) by a v4 client.
This patch calculates a lease time that lockd and nfsd can both use.
Signed-off-by: Marc Eshel <eshel@almaden.ibm.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/lockd/svc.c | 27 | ||||
-rw-r--r-- | fs/nfsd/lockd.c | 1 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 16 |
3 files changed, 33 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 |