diff options
Diffstat (limited to 'fs/nfsd/nfsctl.c')
| -rw-r--r-- | fs/nfsd/nfsctl.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 613bcb8171a5..42f3820ee8f5 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include <linux/seq_file.h> | 22 | #include <linux/seq_file.h> |
| 23 | #include <linux/pagemap.h> | 23 | #include <linux/pagemap.h> |
| 24 | #include <linux/init.h> | 24 | #include <linux/init.h> |
| 25 | #include <linux/inet.h> | ||
| 25 | #include <linux/string.h> | 26 | #include <linux/string.h> |
| 26 | #include <linux/smp_lock.h> | 27 | #include <linux/smp_lock.h> |
| 27 | #include <linux/ctype.h> | 28 | #include <linux/ctype.h> |
| @@ -35,6 +36,7 @@ | |||
| 35 | #include <linux/nfsd/cache.h> | 36 | #include <linux/nfsd/cache.h> |
| 36 | #include <linux/nfsd/xdr.h> | 37 | #include <linux/nfsd/xdr.h> |
| 37 | #include <linux/nfsd/syscall.h> | 38 | #include <linux/nfsd/syscall.h> |
| 39 | #include <linux/lockd/lockd.h> | ||
| 38 | 40 | ||
| 39 | #include <asm/uaccess.h> | 41 | #include <asm/uaccess.h> |
| 40 | #include <net/ipv6.h> | 42 | #include <net/ipv6.h> |
| @@ -53,6 +55,8 @@ enum { | |||
| 53 | NFSD_Getfs, | 55 | NFSD_Getfs, |
| 54 | NFSD_List, | 56 | NFSD_List, |
| 55 | NFSD_Fh, | 57 | NFSD_Fh, |
| 58 | NFSD_FO_UnlockIP, | ||
| 59 | NFSD_FO_UnlockFS, | ||
| 56 | NFSD_Threads, | 60 | NFSD_Threads, |
| 57 | NFSD_Pool_Threads, | 61 | NFSD_Pool_Threads, |
| 58 | NFSD_Versions, | 62 | NFSD_Versions, |
| @@ -89,6 +93,9 @@ static ssize_t write_leasetime(struct file *file, char *buf, size_t size); | |||
| 89 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); | 93 | static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); |
| 90 | #endif | 94 | #endif |
| 91 | 95 | ||
| 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); | ||
| 98 | |||
| 92 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { | 99 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
| 93 | [NFSD_Svc] = write_svc, | 100 | [NFSD_Svc] = write_svc, |
| 94 | [NFSD_Add] = write_add, | 101 | [NFSD_Add] = write_add, |
| @@ -98,6 +105,8 @@ static ssize_t (*write_op[])(struct file *, char *, size_t) = { | |||
| 98 | [NFSD_Getfd] = write_getfd, | 105 | [NFSD_Getfd] = write_getfd, |
| 99 | [NFSD_Getfs] = write_getfs, | 106 | [NFSD_Getfs] = write_getfs, |
| 100 | [NFSD_Fh] = write_filehandle, | 107 | [NFSD_Fh] = write_filehandle, |
| 108 | [NFSD_FO_UnlockIP] = failover_unlock_ip, | ||
| 109 | [NFSD_FO_UnlockFS] = failover_unlock_fs, | ||
| 101 | [NFSD_Threads] = write_threads, | 110 | [NFSD_Threads] = write_threads, |
| 102 | [NFSD_Pool_Threads] = write_pool_threads, | 111 | [NFSD_Pool_Threads] = write_pool_threads, |
| 103 | [NFSD_Versions] = write_versions, | 112 | [NFSD_Versions] = write_versions, |
| @@ -298,6 +307,58 @@ static ssize_t write_getfd(struct file *file, char *buf, size_t size) | |||
| 298 | return err; | 307 | return err; |
| 299 | } | 308 | } |
| 300 | 309 | ||
| 310 | static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size) | ||
| 311 | { | ||
| 312 | __be32 server_ip; | ||
| 313 | char *fo_path, c; | ||
| 314 | int b1, b2, b3, b4; | ||
| 315 | |||
| 316 | /* sanity check */ | ||
| 317 | if (size == 0) | ||
| 318 | return -EINVAL; | ||
| 319 | |||
| 320 | if (buf[size-1] != '\n') | ||
| 321 | return -EINVAL; | ||
| 322 | |||
| 323 | fo_path = buf; | ||
| 324 | if (qword_get(&buf, fo_path, size) < 0) | ||
| 325 | return -EINVAL; | ||
| 326 | |||
| 327 | /* get ipv4 address */ | ||
| 328 | if (sscanf(fo_path, "%u.%u.%u.%u%c", &b1, &b2, &b3, &b4, &c) != 4) | ||
| 329 | return -EINVAL; | ||
| 330 | server_ip = htonl((((((b1<<8)|b2)<<8)|b3)<<8)|b4); | ||
| 331 | |||
| 332 | return nlmsvc_unlock_all_by_ip(server_ip); | ||
| 333 | } | ||
| 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 | |||
| 301 | 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) |
| 302 | { | 363 | { |
| 303 | /* request is: | 364 | /* request is: |
| @@ -700,6 +761,10 @@ static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | |||
| 700 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, | 761 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 701 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, | 762 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 702 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, | 763 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
| 764 | [NFSD_FO_UnlockIP] = {"unlock_ip", | ||
| 765 | &transaction_ops, S_IWUSR|S_IRUSR}, | ||
| 766 | [NFSD_FO_UnlockFS] = {"unlock_filesystem", | ||
| 767 | &transaction_ops, S_IWUSR|S_IRUSR}, | ||
| 703 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, | 768 | [NFSD_Fh] = {"filehandle", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 704 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, | 769 | [NFSD_Threads] = {"threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
| 705 | [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, | 770 | [NFSD_Pool_Threads] = {"pool_threads", &transaction_ops, S_IWUSR|S_IRUSR}, |
