diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2010-03-01 19:32:36 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2010-03-06 15:02:03 -0500 |
commit | f013574014816c7a557b3c52233f3620463f0b9b (patch) | |
tree | d02032686b7e0580e6eb515c23dd1d245d1fda4a /fs/nfsd | |
parent | f958a1320ff7a1e0e861d3c90de6da12a88839dc (diff) |
nfsd4: reshuffle lease-setting code to allow reuse
We'll soon allow setting the grace period, so we'll want to share this
code.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfsctl.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 6738e9d8a83d..9c73caccffff 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -1203,26 +1203,36 @@ static ssize_t write_maxblksize(struct file *file, char *buf, size_t size) | |||
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | #ifdef CONFIG_NFSD_V4 | 1205 | #ifdef CONFIG_NFSD_V4 |
1206 | static ssize_t __write_leasetime(struct file *file, char *buf, size_t size) | 1206 | static ssize_t __nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) |
1207 | { | 1207 | { |
1208 | /* if size > 10 seconds, call | 1208 | /* if size > 10 seconds, call |
1209 | * nfs4_reset_lease() then write out the new lease (seconds) as reply | 1209 | * nfs4_reset_lease() then write out the new lease (seconds) as reply |
1210 | */ | 1210 | */ |
1211 | char *mesg = buf; | 1211 | char *mesg = buf; |
1212 | int rv, lease; | 1212 | int rv, i; |
1213 | 1213 | ||
1214 | if (size > 0) { | 1214 | if (size > 0) { |
1215 | if (nfsd_serv) | 1215 | if (nfsd_serv) |
1216 | return -EBUSY; | 1216 | return -EBUSY; |
1217 | rv = get_int(&mesg, &lease); | 1217 | rv = get_int(&mesg, &i); |
1218 | if (rv) | 1218 | if (rv) |
1219 | return rv; | 1219 | return rv; |
1220 | if (lease < 10 || lease > 3600) | 1220 | if (i < 10 || i > 3600) |
1221 | return -EINVAL; | 1221 | return -EINVAL; |
1222 | nfsd4_lease = lease; | 1222 | *time = i; |
1223 | } | 1223 | } |
1224 | 1224 | ||
1225 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", nfsd4_lease); | 1225 | return scnprintf(buf, SIMPLE_TRANSACTION_LIMIT, "%ld\n", *time); |
1226 | } | ||
1227 | |||
1228 | static ssize_t nfsd4_write_time(struct file *file, char *buf, size_t size, time_t *time) | ||
1229 | { | ||
1230 | ssize_t rv; | ||
1231 | |||
1232 | mutex_lock(&nfsd_mutex); | ||
1233 | rv = __nfsd4_write_time(file, buf, size, time); | ||
1234 | mutex_unlock(&nfsd_mutex); | ||
1235 | return rv; | ||
1226 | } | 1236 | } |
1227 | 1237 | ||
1228 | /** | 1238 | /** |
@@ -1248,12 +1258,7 @@ static ssize_t __write_leasetime(struct file *file, char *buf, size_t size) | |||
1248 | */ | 1258 | */ |
1249 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) | 1259 | static ssize_t write_leasetime(struct file *file, char *buf, size_t size) |
1250 | { | 1260 | { |
1251 | ssize_t rv; | 1261 | return nfsd4_write_time(file, buf, size, &nfsd4_lease); |
1252 | |||
1253 | mutex_lock(&nfsd_mutex); | ||
1254 | rv = __write_leasetime(file, buf, size); | ||
1255 | mutex_unlock(&nfsd_mutex); | ||
1256 | return rv; | ||
1257 | } | 1262 | } |
1258 | 1263 | ||
1259 | extern char *nfs4_recoverydir(void); | 1264 | extern char *nfs4_recoverydir(void); |