|
10 | 10 | #include <linux/ctype.h> |
11 | 11 | #include <linux/fs_context.h> |
12 | 12 |
|
| 13 | +#include <linux/sunrpc/cache.h> |
13 | 14 | #include <linux/sunrpc/svcsock.h> |
14 | 15 | #include <linux/lockd/bind.h> |
15 | 16 | #include <linux/sunrpc/addr.h> |
@@ -2212,6 +2213,41 @@ int nfsd_nl_pool_mode_get_doit(struct sk_buff *skb, struct genl_info *info) |
2212 | 2213 | return err; |
2213 | 2214 | } |
2214 | 2215 |
|
| 2216 | +/** |
| 2217 | + * nfsd_nl_cache_flush_doit - flush nfsd caches via netlink |
| 2218 | + * @skb: reply buffer |
| 2219 | + * @info: netlink metadata and command arguments |
| 2220 | + * |
| 2221 | + * Flush the svc_export and/or expkey caches. If NFSD_A_CACHE_FLUSH_MASK |
| 2222 | + * is provided, only flush the caches indicated by the bitmask (bit 0 = |
| 2223 | + * svc_export, bit 1 = expkey). If omitted, flush both. |
| 2224 | + * |
| 2225 | + * Return 0 on success or a negative errno. |
| 2226 | + */ |
| 2227 | +int nfsd_nl_cache_flush_doit(struct sk_buff *skb, struct genl_info *info) |
| 2228 | +{ |
| 2229 | + struct net *net = genl_info_net(info); |
| 2230 | + struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
| 2231 | + u32 mask = ~0U; |
| 2232 | + |
| 2233 | + if (info->attrs[NFSD_A_CACHE_FLUSH_MASK]) |
| 2234 | + mask = nla_get_u32(info->attrs[NFSD_A_CACHE_FLUSH_MASK]); |
| 2235 | + |
| 2236 | + mutex_lock(&nfsd_mutex); |
| 2237 | + |
| 2238 | + if ((mask & NFSD_CACHE_TYPE_SVC_EXPORT) && |
| 2239 | + nn->svc_export_cache) |
| 2240 | + cache_purge(nn->svc_export_cache); |
| 2241 | + |
| 2242 | + if ((mask & NFSD_CACHE_TYPE_EXPKEY) && |
| 2243 | + nn->svc_expkey_cache) |
| 2244 | + cache_purge(nn->svc_expkey_cache); |
| 2245 | + |
| 2246 | + mutex_unlock(&nfsd_mutex); |
| 2247 | + |
| 2248 | + return 0; |
| 2249 | +} |
| 2250 | + |
2215 | 2251 | int nfsd_cache_notify(struct cache_detail *cd, struct cache_head *h, u32 cache_type) |
2216 | 2252 | { |
2217 | 2253 | struct genlmsghdr *hdr; |
|
0 commit comments