|
14 | 14 | #include <linux/nfs.h> |
15 | 15 | #include <linux/nfs_common.h> |
16 | 16 | #include <linux/nfslocalio.h> |
| 17 | +#include <linux/nfs_fs.h> |
| 18 | +#include <linux/nfs_xdr.h> |
17 | 19 | #include <linux/string.h> |
18 | 20 |
|
19 | 21 | #include "nfsd.h" |
20 | 22 | #include "vfs.h" |
21 | 23 | #include "netns.h" |
22 | 24 | #include "filecache.h" |
| 25 | +#include "cache.h" |
23 | 26 |
|
24 | 27 | static const struct nfsd_localio_operations nfsd_localio_ops = { |
25 | 28 | .nfsd_serv_try_get = nfsd_serv_try_get, |
@@ -90,3 +93,77 @@ nfsd_open_local_fh(struct net *net, struct auth_domain *dom, |
90 | 93 | return localio; |
91 | 94 | } |
92 | 95 | EXPORT_SYMBOL_GPL(nfsd_open_local_fh); |
| 96 | + |
| 97 | +/* |
| 98 | + * UUID_IS_LOCAL XDR functions |
| 99 | + */ |
| 100 | + |
| 101 | +static __be32 localio_proc_null(struct svc_rqst *rqstp) |
| 102 | +{ |
| 103 | + return rpc_success; |
| 104 | +} |
| 105 | + |
| 106 | +struct localio_uuidarg { |
| 107 | + uuid_t uuid; |
| 108 | +}; |
| 109 | + |
| 110 | +static __be32 localio_proc_uuid_is_local(struct svc_rqst *rqstp) |
| 111 | +{ |
| 112 | + struct localio_uuidarg *argp = rqstp->rq_argp; |
| 113 | + struct net *net = SVC_NET(rqstp); |
| 114 | + struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
| 115 | + |
| 116 | + nfs_uuid_is_local(&argp->uuid, &nn->local_clients, |
| 117 | + net, rqstp->rq_client, THIS_MODULE); |
| 118 | + |
| 119 | + return rpc_success; |
| 120 | +} |
| 121 | + |
| 122 | +static bool localio_decode_uuidarg(struct svc_rqst *rqstp, |
| 123 | + struct xdr_stream *xdr) |
| 124 | +{ |
| 125 | + struct localio_uuidarg *argp = rqstp->rq_argp; |
| 126 | + u8 uuid[UUID_SIZE]; |
| 127 | + |
| 128 | + if (decode_opaque_fixed(xdr, uuid, UUID_SIZE)) |
| 129 | + return false; |
| 130 | + import_uuid(&argp->uuid, uuid); |
| 131 | + |
| 132 | + return true; |
| 133 | +} |
| 134 | + |
| 135 | +static const struct svc_procedure localio_procedures1[] = { |
| 136 | + [LOCALIOPROC_NULL] = { |
| 137 | + .pc_func = localio_proc_null, |
| 138 | + .pc_decode = nfssvc_decode_voidarg, |
| 139 | + .pc_encode = nfssvc_encode_voidres, |
| 140 | + .pc_argsize = sizeof(struct nfsd_voidargs), |
| 141 | + .pc_ressize = sizeof(struct nfsd_voidres), |
| 142 | + .pc_cachetype = RC_NOCACHE, |
| 143 | + .pc_xdrressize = 0, |
| 144 | + .pc_name = "NULL", |
| 145 | + }, |
| 146 | + [LOCALIOPROC_UUID_IS_LOCAL] = { |
| 147 | + .pc_func = localio_proc_uuid_is_local, |
| 148 | + .pc_decode = localio_decode_uuidarg, |
| 149 | + .pc_encode = nfssvc_encode_voidres, |
| 150 | + .pc_argsize = sizeof(struct localio_uuidarg), |
| 151 | + .pc_argzero = sizeof(struct localio_uuidarg), |
| 152 | + .pc_ressize = sizeof(struct nfsd_voidres), |
| 153 | + .pc_cachetype = RC_NOCACHE, |
| 154 | + .pc_name = "UUID_IS_LOCAL", |
| 155 | + }, |
| 156 | +}; |
| 157 | + |
| 158 | +#define LOCALIO_NR_PROCEDURES ARRAY_SIZE(localio_procedures1) |
| 159 | +static DEFINE_PER_CPU_ALIGNED(unsigned long, |
| 160 | + localio_count[LOCALIO_NR_PROCEDURES]); |
| 161 | +const struct svc_version localio_version1 = { |
| 162 | + .vs_vers = 1, |
| 163 | + .vs_nproc = LOCALIO_NR_PROCEDURES, |
| 164 | + .vs_proc = localio_procedures1, |
| 165 | + .vs_dispatch = nfsd_dispatch, |
| 166 | + .vs_count = localio_count, |
| 167 | + .vs_xdrsize = XDR_QUADLEN(UUID_SIZE), |
| 168 | + .vs_hidden = true, |
| 169 | +}; |
0 commit comments