diff options
author | Wendy Cheng <wcheng@redhat.com> | 2008-01-17 11:10:12 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2008-04-25 13:00:11 -0400 |
commit | 17efa372cfe4d189705edf6cd4fbe283827a5dc7 (patch) | |
tree | dcf10b96b079fff6edebbf451a32608ce6032663 /fs/nfsd | |
parent | 4373ea84c84d8a96e99d3da99e813d3e36d1bd11 (diff) |
lockd: unlock lockd locks held for a certain filesystem
Add /proc/fs/nfsd/unlock_filesystem, which allows e.g.:
shell> echo /mnt/sfs1 > /proc/fs/nfsd/unlock_filesystem
so that a filesystem can be unmounted before allowing a peer nfsd to
take over nfs service for the filesystem.
Signed-off-by: S. Wendy Cheng <wcheng@redhat.com>
Cc: Lon Hohberger <lhh@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
fs/lockd/svcsubs.c | 66 +++++++++++++++++++++++++++++++++++++++-----
fs/nfsd/nfsctl.c | 65 +++++++++++++++++++++++++++++++++++++++++++
include/linux/lockd/lockd.h | 7 ++++
3 files changed, 131 insertions(+), 7 deletions(-)
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfsctl.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 7706f6c9ab8a..42f3820ee8f5 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -56,6 +56,7 @@ enum { | |||
56 | NFSD_List, | 56 | NFSD_List, |
57 | NFSD_Fh, | 57 | NFSD_Fh, |
58 | NFSD_FO_UnlockIP, | 58 | NFSD_FO_UnlockIP, |
59 | NFSD_FO_UnlockFS, | ||
59 | NFSD_Threads, | 60 | NFSD_Threads, |
60 | NFSD_Pool_Threads, | 61 | NFSD_Pool_Threads, |
61 | NFSD_Versions, | 62 | NFSD_Versions, |
@@ -93,6 +94,7 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); | |||
93 | #endif | 94 | #endif |
94 | 95 | ||
95 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); | 96 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size); |
97 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size); | ||
96 | 98 | ||
97 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { | 99 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
98 | [NFSD_Svc] = write_svc, | 100 | [NFSD_Svc] = write_svc, |
@@ -104,6 +106,7 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { | |||
104 | [NFSD_Getfs] = write_getfs, | 106 | [NFSD_Getfs] = write_getfs, |
105 | [NFSD_Fh] = write_filehandle, | 107 | [NFSD_Fh] = write_filehandle, |
106 | [NFSD_FO_UnlockIP] = failover_unlock_ip, | 108 | [NFSD_FO_UnlockIP] = failover_unlock_ip, |
109 | [NFSD_FO_UnlockFS] = failover_unlock_fs, | ||
107 | [NFSD_Threads] = write_threads, | 110 | [NFSD_Threads] = write_threads, |
108 | [NFSD_Pool_Threads] = write_pool_threads, | 111 | [NFSD_Pool_Threads] = write_pool_threads, |
109 | [NFSD_Versions] = write_versions, | 112 | [NFSD_Versions] = write_versions, |
@@ -329,6 +332,33 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | |||
329 | return nlmsvc_unlock_all_by_ip(server_ip); | 332 | return nlmsvc_unlock_all_by_ip(server_ip); |
330 | } | 333 | } |
331 | 334 | ||
335 | static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) | ||
336 | { | ||
337 | struct nameidata nd; | ||
338 | char *fo_path; | ||
339 | int error; | ||
340 | |||
341 | /* sanity check */ | ||
342 | if (size == 0) | ||
343 | return -EINVAL; | ||
344 | |||
345 | if (buf[size-1] != '\n') | ||
346 | return -EINVAL; | ||
347 | |||
348 | fo_path = buf; | ||
349 | if (qword_get(&buf, fo_path, size) < 0) | ||
350 | return -EINVAL; | ||
351 | |||
352 | error = path_lookup(fo_path, 0, &nd); | ||
353 | if (error) | ||
354 | return error; | ||
355 | |||
356 | error = nlmsvc_unlock_all_by_sb(nd.path.mnt->mnt_sb); | ||
357 | |||
358 | path_put(&nd.path); | ||
359 | return error; | ||
360 | } | ||
361 | |||
332 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size) | 362 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size) |
333 | { | 363 | { |
334 | /* request is: | 364 | /* request is: |
@@ -733,6 +763,8 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | |||
733 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, | 763 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
734 | [NFSD_FO_UnlockIP] = {"unlock_ip", | 764 | [NFSD_FO_UnlockIP] = {"unlock_ip", |
735 | &transaction_ops, S_IWUSR|S_IRUSR}, | 765 | &transaction_ops, S_IWUSR|S_IRUSR}, |
766 | [NFSD_FO_UnlockFS] = {"unlock_filesystem", | ||
767 | &transaction_ops, S_IWUSR|S_IRUSR}, | ||
736 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, | 768 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, |
737 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, | 769 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
738 | [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, | 770 | [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, |