diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-11-29 11:40:46 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-12-03 09:59:03 -0500 |
commit | 6c1e82a4b74ad0c8b45c833a4409f153199d9be4 (patch) | |
tree | 10734030e4b308f16680de6f54db3af76ecca8b3 /fs/nfsd/fault_inject.c | |
parent | d7cc431edd0a6c69a88b5ff1e304af50bfb2270e (diff) |
NFSD: Forget state for a specific client
Write the client's ip address to any state file and all appropriate
state for that client will be forgotten.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/fault_inject.c')
-rw-r--r-- | fs/nfsd/fault_inject.c | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index 19f9094bbb07..96ffdf55dcec 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c | |||
@@ -8,9 +8,12 @@ | |||
8 | #include <linux/fs.h> | 8 | #include <linux/fs.h> |
9 | #include <linux/debugfs.h> | 9 | #include <linux/debugfs.h> |
10 | #include <linux/module.h> | 10 | #include <linux/module.h> |
11 | #include <linux/nsproxy.h> | ||
12 | #include <linux/sunrpc/clnt.h> | ||
11 | #include <asm/uaccess.h> | 13 | #include <asm/uaccess.h> |
12 | 14 | ||
13 | #include "state.h" | 15 | #include "state.h" |
16 | #include "netns.h" | ||
14 | 17 | ||
15 | struct nfsd_fault_inject_op { | 18 | struct nfsd_fault_inject_op { |
16 | char *file; | 19 | char *file; |
@@ -64,6 +67,24 @@ static void nfsd_inject_set(struct nfsd_fault_inject_op *op, u64 val) | |||
64 | printk(KERN_INFO "NFSD: %s: found %llu", op->file, count); | 67 | printk(KERN_INFO "NFSD: %s: found %llu", op->file, count); |
65 | } | 68 | } |
66 | 69 | ||
70 | static void nfsd_inject_set_client(struct nfsd_fault_inject_op *op, | ||
71 | struct sockaddr_storage *addr, | ||
72 | size_t addr_size) | ||
73 | { | ||
74 | char buf[INET6_ADDRSTRLEN]; | ||
75 | struct nfs4_client *clp; | ||
76 | u64 count; | ||
77 | |||
78 | nfs4_lock_state(); | ||
79 | clp = nfsd_find_client(addr, addr_size); | ||
80 | if (clp) { | ||
81 | count = op->forget(clp, 0); | ||
82 | rpc_ntop((struct sockaddr *)&clp->cl_addr, buf, 129); | ||
83 | printk(KERN_INFO "NFSD [%s]: Client %s had %llu state object(s)\n", op->file, buf, count); | ||
84 | } | ||
85 | nfs4_unlock_state(); | ||
86 | } | ||
87 | |||
67 | static void nfsd_inject_get(struct nfsd_fault_inject_op *op, u64 *val) | 88 | static void nfsd_inject_get(struct nfsd_fault_inject_op *op, u64 *val) |
68 | { | 89 | { |
69 | nfs4_lock_state(); | 90 | nfs4_lock_state(); |
@@ -100,15 +121,23 @@ static ssize_t fault_inject_read(struct file *file, char __user *buf, | |||
100 | static ssize_t fault_inject_write(struct file *file, const char __user *buf, | 121 | static ssize_t fault_inject_write(struct file *file, const char __user *buf, |
101 | size_t len, loff_t *ppos) | 122 | size_t len, loff_t *ppos) |
102 | { | 123 | { |
103 | char write_buf[24]; | 124 | char write_buf[INET6_ADDRSTRLEN]; |
104 | size_t size = min(sizeof(write_buf), len) - 1; | 125 | size_t size = min(sizeof(write_buf), len) - 1; |
126 | struct net *net = current->nsproxy->net_ns; | ||
127 | struct sockaddr_storage sa; | ||
105 | u64 val; | 128 | u64 val; |
106 | 129 | ||
107 | if (copy_from_user(write_buf, buf, size)) | 130 | if (copy_from_user(write_buf, buf, size)) |
108 | return -EFAULT; | 131 | return -EFAULT; |
109 | 132 | write_buf[size] = '\0'; | |
110 | val = simple_strtoll(write_buf, NULL, 0); | 133 | |
111 | nfsd_inject_set(file->f_dentry->d_inode->i_private, val); | 134 | size = rpc_pton(net, write_buf, size, (struct sockaddr *)&sa, sizeof(sa)); |
135 | if (size > 0) | ||
136 | nfsd_inject_set_client(file->f_dentry->d_inode->i_private, &sa, size); | ||
137 | else { | ||
138 | val = simple_strtoll(write_buf, NULL, 0); | ||
139 | nfsd_inject_set(file->f_dentry->d_inode->i_private, val); | ||
140 | } | ||
112 | return len; /* on success, claim we got the whole input */ | 141 | return len; /* on success, claim we got the whole input */ |
113 | } | 142 | } |
114 | 143 | ||